Microcontroller › 8051 › Communication between r303 with 8051
- This topic has 12 replies, 5 voices, and was last updated 9 years, 6 months ago by Shailesh Kukna.
-
AuthorPosts
-
April 9, 2014 at 4:12 pm #3030DronaParticipant
Hi Guys,
How do i connect r303 with 89v51rd2. And how can i code 8051(89v51rd2) so that they can scan the image.
Will i be able to connect TX of r303 directily to P3.1 port and communicate the commands of scan and receive to r303(bio-metric sensor)
This is the Code To read finger print(but its not scanning can anyone suggest me the fault)
#incude<reg51.h>sfr ldata=0x90;sbit rs=P2^3;sbit rw=P2^4;sbit en=P2^5;sbit busy=P1^7;char uart_data;//This Function is to add delay into programvoid delay(unsigned int value){unsigned int i,j;for(i=0;i<value;i++)for(j=0;j<1275;j++) ;}//This funciton is to check if the lcd is ready to take commandsvoid lcd_ready(){busy=1;rs=0;rw=1;while (busy==1){en=0;delay(1);en=1;}return;}//This id to print a byte onto screenvoid lcd_data (unsigned char value){lcd_ready();ldata=value;rs=1;rw=0;en=1;delay(1);en=0;return;}unsigned char asc1,asc2;//This is to convert the decimal to ASCIIvoid conv(unsigned char adc1){unsigned char d1,d2;d1=adc1%10;d2=adc1/10;asc1=d1 | 0x30;asc2=d2 | 0x30;}//This is to print the ascii value onto screenvoid finger_data(unsigned char i){if(RI==1){RI=0;uart_data=SBUF;SBUF=uart_data;conv(uart_data);lcd_data(asc2);lcd_data(asc1);}else RI=0;}//This is to send a bytes of data to sensorvoid UART_SendByte(unsigned char GenImg[],unsigned char dt){int i;for(i=0;i<dt;i++){TI=0;SBUF = GenImg;while(TI==0);TI=0;}}//This is to get the conformation code from the sensorunsigned char UART_GetByte(){int i;for(i=0;i<10;i++){RI=0;while(RI==0);RI=0;}return SBUF;}//This is to send commands to lcdvoid lcdcmd (unsigned char value){lcd_ready();ldata=value;rs=0;rw=0;en=1;delay(1);en=0;return;}//This Function initializes UART Codevoid UART_Init(){SCON = 0x50; /* uart in mode 1 (8 bit), REN=1 */TMOD = TMOD | 0x20 ; /* Timer 1 in mode 2 */TH1 = 0xFD; /* 9600 Bds at 11.059MHz */TL1 = 0xFD; /* 9600 Bds at 11.059MHz */ES = 1; /* Enable serial interrupt */EA = 1; /* Enable global interrupt */TR1 = 1; /* Timer 1 run */}void lcd_display(char d[]){int i;for(i=0;i<strlen(d);i++)lcd_data(d);}//This Function is to read finger from sensorvoid read_fin(){unsigned char GenImg[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x03,0x01,0x00,0x05};unsigned char Ack,val;l1:lcdcmd(0x01);lcdcmd(0x86);lcd_display(“Welcome”);delay(500);lcdcmd(0x01);lcdcmd(0x86);lcd_display(“Place Finger”);delay(500);UART_Init();UART_SendByte(GenImg,12);Ack=UART_GetByte();finger_data(val);delay(1500);lcdcmd(0x01);lcdcmd(0x86);if(Ack==0x00) lcd_display(“Finger Success”);else{lcd_display(“Error or Fault occured”);goto l1;}}April 10, 2014 at 3:23 am #11509SHAH DISHANT H.ParticipantHi,
first check with LCD…
Is it working fine??
Why you are using busy flag method ? before using busy flag, you have not put RW=1…!!
Go for simple method for LCD..!!
All the best…!!
April 11, 2014 at 11:53 am #11531DronaParticipantThanks Shah Dishant h.
But,I tried deleted all lcd commands and tried to send adding vrypwd(verify password) code at beggining of the program but the module did not work.
I actually connected TX And RX of R303 to TTL 232 and then Connected 2,3,5 of serial to 3,2,5 of 8051 module but it seems that it didn’t work out. Can u help me out with that.
April 14, 2014 at 11:41 am #11551SHAH DISHANT H.ParticipantHi,
In your system, you have 2 modules…
1. LCD
2. Serial Communication
First try to program it individually and then combine it…!!
April 16, 2014 at 1:07 pm #11565DronaParticipantHey I am Trying To code for Searching.
But what is the startPage and End Page.
And how to calculate the Check Sum For That its should be 2 byte. so how to calculate a two byte check sum.
April 18, 2014 at 4:15 pm #11589DronaParticipant#include<reg51.h>
#include<string.h>unsigned char Ack[28];
unsigned char TemplateNum[2];//It is Two Bytes of data
unsigned char statReg,sysIDcode,FingLibSize,securityLvl,DeviceAddr[2],DataPckSize,baudRate;
void rx(unsigned int num)
{
i=0;
while(RI && i<num)
{
Ack[i++]=SBUF;
RI=0;
}
Ack=’