EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
You are here: Home / Topics / Communication between r303 with 8051

Communication between r303 with 8051

|

Microcontroller › 8051 › Communication between r303 with 8051

  • This topic has 12 replies, 5 voices, and was last updated 7 years, 5 months ago by Shailesh Kukna.
Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • April 9, 2014 at 4:12 pm #3030
    Drona
    Participant

    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 program
    void 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 commands
    void 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 screen
    void 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 ASCII
    void 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 screen
    void 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 sensor
    void 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 sensor
    unsigned 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 lcd
    void lcdcmd (unsigned char value)
    {
    lcd_ready();
    ldata=value;
    rs=0;
    rw=0;
    en=1;
    delay(1);
    en=0;
    return;
    }
     
    //This Function initializes UART Code
    void 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 sensor
    void 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 #11509
    SHAH DISHANT H.
    Participant

    Hi,

     

    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 #11531
    Drona
    Participant

    Thanks 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 #11551
    SHAH DISHANT H.
    Participant

    Hi,

     

    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 #11565
    Drona
    Participant

    Hey 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.o.O so how to calculate a two byte check sum.

     

    April 18, 2014 at 4:15 pm #11589
    Drona
    Participant

    #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=’’;
    }
    void tx1(unsigned char y)
    {
      SBUF=y;
      while(TI==0);
      TI=0;
    }
    void delay(unsigned int x)
    {
      unsigned int i,j;
      for(i=0;i<x;i++)
      for(j=0;j<1000;j++);
    }

    void scan_fin()
    {
     unsigned char i,j;
     unsigned char VryPwd[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x07,0x13,0xFF,0xFF,0xFF,0xFF,0x04,0x17};
     unsigned char ReadSysPara[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x03,0x0F,0x00,0x13};
     unsigned char ReadTemplateNum[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x03,0x1D,0x00,0x21};
     unsigned char GenImg[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x03,0x01,0x00,0x05};
     unsigned char Img2T[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x04,0x02,0x01,0x08};
     unsigned char search[17]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x08,0x04};
     
     unsigned char MatchScore[2],pageID[2];
     
     //This is to verify the password of Bio-Metric
     do
     {
      for(i=0;k<strlen(VryPwd);i++)
       tx1(VryPwd);
      delay(1000);
      rx(16);
     }while(Ack[9]!=0x00);
     //This is to retice the system parameters of Bio-Metric
     do
     {
      for(i=0;i<strlen(ReadSysPara);i++)
       tx1(ReadSysPara
    );
      delay(1000);
      rx(28);
     }while(Ack[9]!=0x00);
     statReg=Ack[10];
     sysIDcode=Ack[11];
     FingLibSize=Ack[12];
     securityLvl=Ack[13];
     DeviceAddr[0]=Ack[14];
     DeviceAddr[1]=Ack[15];
     DataPckSize=Ack[16];
     baudRate=Ack[17];
     //This is to retrive the Template Number from Bio-Metric
     do
     {
      for (int i = 0; i < strlen(Syspara); ++i)
       tx1(ReadTemplateNum);
      delay(1000);
      rx1(14);
     }while(Ack[9]!=0x00);
     TemplateNum[0]=Ack[10];
     TemplateNum[1]=Ack[11];
     //This is to Scan Finger and Place it in imageBuffer
     do
     {
      for (int i = 0; i < strlen(GenImg); ++i)
       tx1(GenImg
    );
      delay(1500);
      rx1(12);
     }while(Ack[9]!=0x00);
     //This is to Convert the Image in ImageBuffer to charBuffer
     do
     {
      for (int i = 0; i < strlen(Img2Tz); ++i)
       tx1(Img2Tz
    );
      delay(1000);
      rx(12);
     }while(Ack[9]!=0x00);
     //This is to compare the CharBuffer and The Values stored
     search[10]=0x01;     //This is for BufferID
     search[11]=0x00;     //This is for StartPage Byte 1
     search[12]=0x00;     //This is for StartPage Byte 2
     search[13]=TemplateNum[0];   //This is for Pagenumber byte 1
     search[14]=TemplateNum[1];   //This is for PageNumber byte 2
     

     //This below Two Bytes are for Check Sum
     search[15]=
     search[16]=
     

     

     do
     {
      for (int i = 0; i < strlen(search); ++i)
       tx1(search);
      delay(1000);
      rx(16);
     } while (Ack[9]!=0x00);
     pageID[0]=Ack[10];
     pageID[1]=Ack[11];
     MatchScore[0]=Ack[12];
     MatchScore[1]=Ack[13];
    //Note is Page ID Same as Template ID
    } 
    void main()
    {
     void scan_fin();
    }

     

    any one tell me how to calculate 2 byte check sum of hexa value….

     

    Is there any fault in this program….
    i am not getting the output…. Except the check sum part…
     

    April 30, 2014 at 3:53 pm #11659
    praveenkumar.v
    Participant

    Hi friend

      Can you explain for what sort of application u are working with fingerprint.

     

    The first thing you have to check whether his parameters such storing,searching of the finger image are fine.

    For that you can use SFG demo software where u can load and install it in ur pc,and then u have to connect ur finger print module to the pc with the help of max232 and RS232 to USB converter but in our case we have programmer that is having max232 and we have usb connector to connect with pc,from that first u check ur module working well and then go for coding with the controller.

    May 1, 2014 at 2:19 am #11660
    Drona
    Participant

    Hi

     

    thanks for you reply,

     

    1)The sfg module is working with pc.i.e, when i connect it to pc i am able to add,search,all operations are working.

    But when i interface it with 8051(p89v51rd2) the commands i send dont work.

     

    2)I am interfacing bio-metric with 8051 and sending the ID i receive from sensor to a receiver module

    and using that id i am giving the attendance…

    May 1, 2014 at 7:20 am #11662
    praveenkumar.v
    Participant

    Hi friend

       

          Try to use serial interrupt for recieving the acknowledgement.

          For that u have to initialize as ES=1 in ur UART function.

          And provide 3Sec delay for recieving acknowledgement.

        

          And then we are also facing problems on working with search command while google it we find that data sheet itself having some error in that they said that higher and lower byte for the search commands are interchanged and then by trail and error method the search command executed succesfully.

     

     

       The arguments for the search command is

    unsigned char search_template[] =    

                                          {0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x08,0x04,0x01,0x00,0x00,0x01,0x00,0x00,0x0f}

     

                                                                       0X01

                                                            0X00  0X08

                                                                       0X04

                                                                       0X01

                                                            0X00  0X00

                                                            0X00  0X01

                                                           

               check sum                            0X00  0X0f

     

            while passing the arguments to the module higher byte and lower byte should be iterchanged and for check sum calculation the lower byte will be added to its respective lower byte.

     

     

             i hope this might help you. 

    May 1, 2014 at 2:33 pm #11663
    Drona
    Participant

    yes thanks for the help,

    please can u explain me how you took the start and end address in the search array(i.e, 11th to 17th positions of array)
    actually i didn’t understand that part in the manual…

    May 1, 2014 at 5:38 pm #11664
    praveenkumar.v
    Participant

    Hi friend

        

         Buf id refers to 1 or 2 it depends on us where we generate the character file for the finger image.

        

         Start page refers to the starting id where id starts from 0 hence it should be given as 0x00 0x00.

     

          Page num refers to the starting page normally starts from 1. And single page consist of four template and there are 16 pages totally available.

     

         But i’m not sure the definition for start page and the page num are correct it’s our assumption while working with our project and the search command provides the acknowledgement and returns the matched id.

     

     

     

    February 20, 2015 at 6:20 pm #12630
    manikandan
    Participant

    I'm also do my project by fingerprint access. i read your post i got some imformation and understand little bit how the module work but i have confusion in command such

    unsigned char VryPwd[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x07,0x13,0xFF,0xFF,0xFF,0xFF,0x04,0x17};

    can you explain me each charector 

    March 8, 2015 at 6:30 am #12677
    Shailesh Kukna
    Participant

    R303a is working with its own protocol.

    You have to read datasheet for that carefully.

    When communicate with 8051, the controller has to send a command packet to the R303a fingerprint module.

    After receiving command from the controller, the module send acknowledge command to the controller.

    VryPwd[] is a command sent by controller to the module.

    First two bytes are header, next four are address, next one is for package identifier, next two are for package length, next one is for instruction code, next for are for password of module, and last two are checksum.

    Again I say that read the datasheet carefully. 

  • Author
    Posts
Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Charging shutdown circuit question. August 7, 2022
  • \Dim light short circuit tester August 7, 2022
  • Right channel distortion on vintage fisher rs-2010 August 7, 2022
  • Pedestal fan August 7, 2022
  • Automatic bartender machine audio decoration August 7, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools