Thứ Sáu, 14 tháng 12, 2018

Fingerprint Detection using Microcontroller

REQUIREMENTS:
  1. AtMega 16 Microcontroller (development board)
  2. Fingerprint scanner module (R305)
  3. 16X2 Alphanumeric LCD (for user display)
DESCRIPTION:
In today’s secure world biometric safety is on the top. Unlike other techniques which make use of passwords and numbers, that are needed to be remembered, biometric techniques make use of human body parts like fingerprints or even iris of your eyes and as we know that these things are unique to all thus it makes biometric systems the most effective over others. In this project I have interfaced a very popular fingerprint scanner R305 with AtMega 16 microcontroller. This module communicates over UART protocol with microcontroller i.e. it makes use of Rx and Tx pin of microcontroller to interact with it.
Now talking about this module, it comes preloaded with scanner as well as detection section and we are left with 4 pins for connections. These 4 pins are: VCC, GND, Rx and Tx. It works over 3.3 to 5V supply and its Rx and Tx pin is connected to Tx and Rx pin of the microcontroller respectively. The mode is semi duplex asynchronism serial communication and the default baud rate is 57600bps but it can be changed between 9600~115200bps.
At power on, it takes about half a second for initialization, during this period the module can’t accept commands. The system sets aside a 512-bytes memory (16 pages X 32 bytes) for user’s notepad, where data requiring power-off protection can be stored. There is an image buffer and two 512-byte-character-file buffers within the RAM space of the module. This buffer serves for image storage and the image format is 256*288 pixels.  Two character file buffers can be used to store both character file and template file. System sets aside a certain space within Flash for fingerprint template storage, that’s fingerprint library. It is non volatile in nature. This module also serves the purpose for providing any 32 bit random number.
When communicating, the transferring and receiving of command/data/result are all wrapped in data package format.
 Fig. 1 Image showing format of Data Packet for communicating Commands, Result or Data from R305 Fingerprint Module

ADDER: Default value is 0xFFFFFFFF, which can be modified by command. High byte transferred first and at wrong adder value, module will reject to transfer.HEADER: Fixed value of 0xEF01
PACKAGE IDENTIFIER: Its size is one byte. 01H for command packet and 07H for acknowledge packet.
PACKAGE LENGTH: Refers to the length of package content (command packets and data packets) plus the length of Checksum ( 2 bytes). Unit is byte. Max length is 256 bytes.
PACKAGE CONTENTS: It can be commands, data and command’s parameters, acknowledge result, etc. (fingerprint character value, templates are all deemed as data)
CHECKSUM: The arithmetic sum of package identifier, package length and all packages contends. Overflowing bits are omitted. High byte is transferred first.
Let me clear this concept with an example:-
To change the Modules Address, a command package like this is needed to be sent to it:
Fig. 2: Image showing format of Data Packet used for sending command to change address of R305 Fingerprint Module
If change becomes successful this type of acknowledge package will be received by it:
Fig. 3: Image showing format of Data Packet received on success of change in address of R305 Fingerprint Module
*If there will be any error while doing this task, this CODE will change to 0x01.

If change becomes successful this type of acknowledge package will be received by it:
Coming back to this project I have made use of only few functions out of several. These are:
  1. Collecting finger image
  2. Generating character file from that image
  3. Generating template for this character file
  4. Storing template in Flash library
  5. Deleting template from Flash library
  6. Searching finger library
When enrolling, user needs to enter the finger two times. The system will process the two time finger images, generate a template of the finger based on processing results and store the template. When matching, user enters the finger through optical sensor and system will generate a template of the finger and compare it with templates of the finger library. For 1:1 matching, system will compare the live finger with specific template designated in the Module; for 1:N matching, or searching, system will search the whole finger library for the matching finger. In both circumstances, system will return the matching result, success or failure.
Here N is the maximum number of templates flash library can store. Mine has 1000.
I would recommend going through its datasheet and understanding how to communicate with it and see what all functions it can perform. I have attached the PDF file of the same in this folder itself.
In this project you will see that on powering up the microcontroller the fingerprint module will take certain time to initialize itself, thus I have given it plenty of delay time to do so. Also the status will be shown on a 16X2 LCD and some LEDS as well.
LCD is connected to PORTB and will work under 4 bit mode. LEDs are connected with PORTC.
Fig. 4: Prototype of AVR ATMega16 and R305 Module based Fingerprint Scanner
Fig. 5: Typical Image of R305 Fingerprint Module
Fig. 6: Image showing pin connections of R305 Fingerprint Module
Header files used in my coding part have been attached inside this folder itself.
APPLICATIONS:
  1. Can be used in biometric attendance systems
  2. Can be used for security purposes where high level security is desired
Circuit:
Circuit Diagram of AVR ATMega16 and R305 Module based Fingerprint Scanner
Code:
#include<avr/io.h>
#include<util/delay.h>
#include<uart.h>
#include<lcd.h>

void read_finger_1()          //for char_buffer1
{
      int i=0;
      char k=1,ch=1;

      sendchar_uart(239);
      sendchar_uart(1);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(1);
      sendchar_uart(0);
      sendchar_uart(3);
      sendchar_uart(1);
      sendchar_uart(0);
      sendchar_uart(5);

      for(i=0;i<10;i++)
      {
            k=getchar_uart();
            if(i==9)
            {
                  ch=k;
                  k=getchar_uart();
                  k=getchar_uart();
                  if(ch==0x00)
                  {
                        PORTC|=(1<<0);
                        k=1;
                        sendchar_uart(239);
                        sendchar_uart(1);
                        sendchar_uart(255);
                        sendchar_uart(255);
                        sendchar_uart(255);
                        sendchar_uart(255);
                        sendchar_uart(1);
                        sendchar_uart(0);
                        sendchar_uart(4);
                        sendchar_uart(2);
                        sendchar_uart(1);
                        sendchar_uart(0);
                        sendchar_uart(8);
                        i=0;
                        for(i=0;i<10;i++)
                        {
                              k=getchar_uart();
                              if(i==9)
                              {
                                    ch=k;
                                    k=getchar_uart();
                                    k=getchar_uart();
                                    if(ch==0x00)
                                    {
                                          PORTC|=(1<<1);
                                    }
                              }
                        }
                  }
            }
      }
}

void read_finger_2()          //for char_buffer2
{
      int i=0;
      char k=1,ch=1;

      sendchar_uart(239);
      sendchar_uart(1);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(1);
      sendchar_uart(0);
      sendchar_uart(3);
      sendchar_uart(1);
      sendchar_uart(0);
      sendchar_uart(5);

      for(i=0;i<10;i++)
      {
            k=getchar_uart();
            if(i==9)
            {
                  ch=k;
                  k=getchar_uart();
                  k=getchar_uart();
                  if(ch==0x00)
                  {
                        PORTC|=(1<<2);
                        k=1;
                        sendchar_uart(239);
                        sendchar_uart(1);
                        sendchar_uart(255);
                        sendchar_uart(255);
                        sendchar_uart(255);
                        sendchar_uart(255);
                        sendchar_uart(1);
                        sendchar_uart(0);
                        sendchar_uart(4);
                        sendchar_uart(2);
                        sendchar_uart(2);
                        sendchar_uart(0);
                        sendchar_uart(9);
                        i=0;
                        for(i=0;i<10;i++)
                        {
                              k=getchar_uart();
                              if(i==9)
                              {
                                    ch=k;
                                    k=getchar_uart();
                                    k=getchar_uart();
                                    if(ch==0x00)
                                    {
                                          PORTC|=(1<<3);
                                    }
                              }
                        }
                  }
            }
      }
}

void make_template()
{
      int i=0;
      char k=1,ch=1;

      k=1;
      sendchar_uart(239);
      sendchar_uart(1);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(1);
      sendchar_uart(0);
      sendchar_uart(3);
      sendchar_uart(5);
      sendchar_uart(0);
      sendchar_uart(9);

      for(i=0;i<10;i++)
      {
            k=getchar_uart();
            if(i==9)
            {
                  ch=k;
                  k=getchar_uart();
                  k=getchar_uart();
                  if(ch==0x00)
                        PORTC|=(1<<4);
            }
      }

}

void check_finger()
{
int i=0;
char k=1,ch=1;

sendchar_uart(239);
sendchar_uart(1);
sendchar_uart(255);
sendchar_uart(255);
sendchar_uart(255);
sendchar_uart(255);
sendchar_uart(1);
sendchar_uart(0);
sendchar_uart(8);
sendchar_uart(4);
sendchar_uart(1);
sendchar_uart(0);
sendchar_uart(0);
sendchar_uart(0);
sendchar_uart(10);
sendchar_uart(0);
sendchar_uart(24);

for(i=0;i<10;i++)
      {
            k=getchar_uart();
            if(i==9)
            {
                  ch=k;
                  k=getchar_uart();
                  k=getchar_uart();
                  k=getchar_uart();
                  k=getchar_uart();
                  k=getchar_uart();
                  k=getchar_uart();
                  LCDclr();
                  if(ch==0x00)
                        {
                              PORTC|=(1<<5);
                              LCDdisplay("FINGER FOUND");
                        }
                  else
                        LCDdisplay("FINGER NOT FOUND");
            }
      }
}

void store(int ID)
{
      int i=0,sum=14+ID;
      char k=1,ch=1;

      sendchar_uart(239);
      sendchar_uart(1);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(1);
      sendchar_uart(0);
      sendchar_uart(6);
      sendchar_uart(6);
      sendchar_uart(1);
      sendchar_uart(0);
      sendchar_uart(ID);
      sendchar_uart(0);//C
      sendchar_uart(sum);//C

      for(i=0;i<10;i++)
            {
                  k=getchar_uart();
                  if(i==9)
                  {
                        ch=k;
                        k=getchar_uart();
                        k=getchar_uart();
                        if(ch==0x00)
                              PORTC|=(1<<6);
                  }
            }
}

void empty()
{
      int i=0;
      char k=1,ch=1;

      sendchar_uart(239);
      sendchar_uart(1);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(255);
      sendchar_uart(1);
      sendchar_uart(0);
      sendchar_uart(3);
      sendchar_uart(13);
      sendchar_uart(0);
      sendchar_uart(17);

      for(i=0;i<10;i++)
            {
                  k=getchar_uart();
                  if(i==9)
                  {
                        ch=k;
                        k=getchar_uart();
                        k=getchar_uart();
                        if(ch==0x00)
                              PORTC|=(1<<7);
                  }
            }
}

void main()
{
      DDRC=0xff;
      PORTC=0;

      enable_uart(9600);
      LCDinit();
      LCDclr();
      _delay_ms(5000);  //plenty of delay for modules initialization
      LCDdisplay("Scanning.....");
      read_finger_1();  //scans and stores in char_buffer1
      read_finger_2();  //scans and stores in char_buffer2
      make_template();  //makes the template with info in char_buffer1 & char_buffer2 and stores it in char_buffer1
      check_finger();         //checks for the finger authentication
//    store(0);               //stores the scanned value to the given parametric location in flash library
//    empty();                //empties the flash library
}

Không có nhận xét nào:

Đăng nhận xét

Bài đăng mới nhất

Hướng dẫn sử dụng Cân điện tử Fujihatsu FTC-01

Hướng dẫn sử dụng Cân điện tử Fujihatsu FTC-01 # candientu ,  # fujihatsu ,  # candientufujihatsu  #candientu,  # candientufujhatsu , #fuji...

Bài đăng phổ biến