Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] R305 Fingerprint Sensor Reading issue

Status
Not open for further replies.

arunbharathi.arasu

Full Member level 2
Joined
Feb 28, 2013
Messages
134
Helped
7
Reputation
14
Reaction score
6
Trophy points
1,298
Location
Chennai, Tamil Nadu, India
Activity points
2,151
Dear Friends,

I'm using R305 Fingerprint sensor for my project.
I don't know how to get data from fingerprint sensor.

I wrote simple code for R305, which is given below.
I used Hi-Tech C compiler.


Code:
#include<htc.h>
#include<stdio.h>
#include <string.h>
#include"uart.h"
#include"gsm.h"


unsigned char Arraydata[160],count=0;
void port_init()
{
    TRISD1=0;       // IGNITION CNAGE TO OFF/ON
    TRISD2=1;       // IGNITION STATUS CHECK 
    TRISD3=1;       // AC STATUS CHECK
    
}
void delay(unsigned int de)
{
    unsigned int maxde,minde;
    for(maxde=0;maxde<de;maxde++)
        for(minde=0;minde<453;minde++);
}


void interrupt uart_ISR(void)
{
    if(RCIF == 1)
    {
        IG_CHANGE=1;
        Rx_data=RCREG;
        RCIF=0;
            if(Rx_data!= '\r')
           {
             Arraydata[count]= Rx_data; 
             count++;
           }
           else
           {
            Arraydata[count]='\0';
           }
            trans_string(Arraydata);
        }     
}
void port1_init()
{
    TRISC6=0;
    TRISC7=1;
}
void transmitter_data(unsigned char dat)
{
    while(!TRMT);
    TXREG=dat;
}
void trans_string(unsigned char *str)
{
    while(*str!='\0')
    {
      transmitter_data(*str);
      str++;
      delay(20);
    }
}




void UART_init()
{
    TXEN    =   1;  //  transmission side enable
    SYNC    =   0;  //  enable asynchronous bit
    BRGH    =   1;  //  enable high baud rate generator
    TRMT    =   0;  //  make transmit shift register are full
    TX9D    =   0;  //  disable 9bit transmission


    SPEN    =   1;  //  enable serial port in receiver side
    CREN    =   1;  //  enable continuous reception
    ADDEN   =   0;  //  disable address decets bit
    FERR    =   0;  //  set no framing error bit
    OERR    =   0;  //  set no overrun bit
    RX9D    =   0;  //  disble 9bit reception


    SPBRG   =   129;//  load SPBRG value for 9600 baud rate for 20 mhz
    GIE     =   1;
 
    IPEN   = 1;
    GIEH  = 1;
    GIEL  = 1;
    PEIE    =   1;
    RCIE    =   1;
    RCIP  = 1;
  
}

void main()
{
    port_init();
    port1_init();
    UART_init();
   while(1)
   {
     
       trans_string("0xEF\r");
       delay(100);
       trans_string("0x01\r");
       delay(100);
       trans_string("0xFF\r");
       delay(100);
       trans_string("0xFF\r");
       delay(100);
       trans_string("0xFF\r");
       delay(100);
       trans_string("0xFF\r");
       delay(100);
       trans_string("0xFF\r");
       delay(100);
       trans_string("0x01\r");
       delay(100);
      trans_string("0x00\r");
       delay(100);
       trans_string("0x03\r");
       delay(100);
       trans_string("0x01\r");
       delay(100);
       trans_string("0x00\r");
       delay(100);
       trans_string("0x05\r");
       delay(10000);
   }
}
 
Last edited by a moderator:

Which MCU you are going to use? if it is PIC18F4520 then here is code for you
Code:
#include <htc.h>
#include <stdio.h>
#include "Includes.h"

//------------------------------------------------------------FUSE CONFIGURATION ----------------------------------------

__CONFIG(1, HSPLL);
__CONFIG(2, BORDIS & PWRTDIS & WDTDIS & PBADDIS);
__CONFIG(3, CCP2RC1 & MCLREN);
__CONFIG(4, DEBUGEN & LVPDIS & STVREN);
__CONFIG(5, UNPROTECT);


//------------------------------------------------------------FUNCTION DECLARATION FREQUENCY ----------------------------------------


void interrupt ISR(void);
void PORTs_init(void);



//------------------------------------------------------------XTAL FREQUENCY ----------------------------------------

#define _XTAL_FREQ  32000000  //this is 4x8Mhz because of the PLL Enable

  
//------------------------------------------------------------GLOBAL VARIABLE DECLARATION----------------------------------------

char Reply[20]="\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
int Finger_Detect;
char temp;
char a[5]="\0\0\0\0\0";
char buf[10]="";




void PORTs_init(void) 
{
		  TRISC  =0x81;		
    	  PORTC  =0x7E;
	

}

//------------------------------------------------------------BIO-INPUT RELATED FUNCTION----------------------------------------

unsigned int Finger_PROESS()
{
		for(int i=1;i<=12;i++){      //this loop to fill the buffer with null values precaution
		Reply[i]=33;                    
		}
check:

		FingerDetectR305();
		for(int i=1;i<=12;i++){
		Reply[i]=ReceiveByteSerially();
		}
		switch(Reply[10]){
		case 0x00:
		for(int i=1;i<=12;i++){
		Reply[i]=33;
		}
		break;
		default:
		for(int i=1;i<=12;i++){
		Reply[i]=33;
		}
		goto check;
		break;
		}
		FingerStore1R305();
		for(int i=1;i<=12;i++){
		Reply[i]=ReceiveByteSerially();
		}
		switch(Reply[10]){
		case 0x00:
	
		break;
		default:
		for(int i=1;i<=12;i++){
		Reply[i]=ReceiveByteSerially();
		}
		goto check;
		break;
		}
		SearchLibR305();
		for(int i=1;i<=12;i++){
		Reply[i]=ReceiveByteSerially();
		}
		switch(Reply[10]){
		case 0x00:	
	switch(Reply[12]){
		case 0x00:
		for(int i=1;i<=12;i++){
		Reply[i]=33;
		}	
		return 1;		
		break;
		case 0x01:
		for(int i=1;i<=12;i++){
		Reply[i]=33;
		}	
		return 2;	
		break;
		case 0x02:
		for(int i=1;i<=12;i++){
		Reply[i]=3;
		}	
		return 3;	
		break;
		break;
		default:
		for(int i=1;i<=12;i++){
		Reply[i]=3;
		}
		return 9;
		goto check;	
		break;
		}
}
}






//------------------------------------------------------------MAIN PROGRAM RELATED FUNCTION----------------------------------------


main(void)
{
		unsigned int USER_DETECT;
		PORTs_init();
		InitUART();
		while(1)
		{
		USER_DETECT=Finger_PROESS();  //this return the ID of the matched user  
		for(int i=1;i<=12;i++){
		Reply[i]=0;
		}
		switch(USER_DETECT){
		case 1:
		break;
		case 2:
		break;
		case 3:
		break;
		default:	

		break;
        }
    }
}
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top