+ All Categories
Home > Documents > Bank Security System using RFID reader

Bank Security System using RFID reader

Date post: 09-Nov-2015
Category:
Upload: jithinjithu250
View: 22 times
Download: 0 times
Share this document with a friend
Description:
undergraduate project
Popular Tags:
110
Bank Security System Project Report 2014- 2015 INTRODUCTION In today's modern world, security plays an important role. Every person has precious accessories like gold, jewelry or cash. It is not enough to have these accessories, but security of this is very important, for this purpose we keep them in bank lockers. Still we often hear or read in news paper that some fake person has access the locker of another person and have stolen money. In order to overcome this type of frauds, authentification of the person who wants to use the locker is very important,. In this project; we are designing advance security systems for banking which will ensure the guanine access of the locker overcoming all the misuses. For this we are using microcontroller, RFID reader, Finger print module, and LCD. The RFID reader reads the details of the RFID passport .The RFID acts as a medium to retrieve data from server .The output of RFID reader is serially communicated to PIC and sends the data wirelessly with the help of ZigBee transceiver. On the other side the other ZigBee receiver receives the details and sends to the server. Here, the server compares with the data already there. If it matches, the fingerprint module will be activated. The person is allowed to press on that module. If the data matches with fingerprint library, then the person is allowed, less he would be termed as a criminal by giving an alarm/buzzing signal. The PIC displays the details through the LCD connected at the port . Dept. Of Electronics 1 CAS Vattamkulam
Transcript

Bank Security System Project Report 2014-2015INTRODUCTION

In today's modern world, security plays an important role. Every person has precious accessories like gold, jewelry or cash. It is not enough to have these accessories, but security of this is very important, for this purpose we keep them in bank lockers. Still we often hear or read in news paper that some fake person has access the locker of another person and have stolen money.In order to overcome this type of frauds, authentification of the person who wants to use the locker is very important,. In this project; we are designing advance security systems for banking which will ensure the guanine access of the locker overcoming all the misuses. For this we are using microcontroller, RFID reader, Finger print module, and LCD. The RFID reader reads the details of the RFID passport .The RFID acts as a medium to retrieve data from server .The output of RFID reader is serially communicated to PIC and sends the data wirelessly with the help of ZigBee transceiver. On the other side the other ZigBee receiver receives the details and sends to the server. Here, the server compares with the data already there. If it matches, the fingerprint module will be activated. The person is allowed to press on that module. If the data matches with fingerprint library, then the person is allowed, less he would be termed as a criminal by giving an alarm/buzzing signal. The PIC displays the details through the LCD connected at the port .

CASE STUDYNEED FOR BANK SECURITY SYSTEMThere is a saying that NECESSITIES IS THE MOTHER OF ALL INVENTIONS. Which in a more advanced version would read APPLICATION DRIVES THE TECHNOLOGY? Going by those lines, we would like to highlight some areas of work where our project has some potential use. Our project is basically concerned with banking locker systems. It is about taking all the security parameters and compare it with what is in the database and react accordingly. These applications are possible due to some of the advantages of our work. The are as follows: 1. User friendly 2. Applications at major banks 3. Software in embedded C 4. Easy interfacing with PC . We decided to do a project on smart bank locker access system in the seventh semester. The idea came to us while searching for topics on which to do project work. We always wanted to put theory that we studied into practice. Our inspiration in this direction was our subject embedded system in which we studied the principles governing real time application.In this first couple of months we spent searching topics for project work, we came across numerous instances of the rapid advancements made in the field of bank security system as described in various journals and magazines as well as over the internet.

Existing Methods of using bank locker

Use of keysMost of the banks in India gives key to the bank locker for the accessing of locker. Usually there are two keys of the bank locker one belongs to locker holder and other is given to the manager of the bank.

Drawbacks of using key as a security for accessing locker There are number of drawbacks of using key as a security for accessing locker like 1. The key can be lost and the locker holder suffer the different headache of getting new key as well as he cant use the locker in mean time. 2. The key can be stolen or duplicate key can be easily made and unauthorized person can access the locker. While searching on the various methods used for the security application, we have come across number of advance technique of security, these security methods really temptated us and we are inspired to use the best among them, combination of three. The methods we have chosen for our project, they are widely used in many vital areas where security requirement is very severe as well as these methods assures 100% security.

HARDWARE STUDY BLOCK DIAGRAM

BLOCK DIAGRAM DESCRIPTIONPOWER SUPPLYThe power supply section is the important for any electronics circuits. To derive the power supply, the 230V, 50Hz AC mains is stepped down by transformer X1 to deliver a secondary output of 12V, 500 mA. The transformer output is rectified by a full-wave rectifier comprising diodes D1 through D4, filtered by capacitor C1 and regulated by ICs 7812 (IC2) and 7805 (IC3). Capacitor C2 bypasses the ripples present in the regulated supply. LED1 acts as the power indicator and R1 limits the current through LED1.The power supply section is shown in the fig

MICRO CONTROLLERThe microcontroller PIC 18F24J50 is used in this project. It is the brain of the project and it controls the entire working of this project.

LCDLCD unit is used to display the details about the person and the key number.

SERIAL PORT (RS 232std)An asynchronous used to enable serial communication and capable of transmitting a bit at a time.

BUZZERIt is used to produce beep sound.

MAX232The serial interface used here is the MAX 232. Max 232 converts RS232 voltage levels to TTL voltage levels and TTL voltage to RS232. It provides 2-channel RS232C ports and 2- channel TTL ports. Since RS232 is not compatible with todays microprocessors and microcontrollers we need a line driver to convert the RS232Ss signals to TTL voltage levels that will be acceptable to the todays microprocessor pins. One example of such a converter is MAX232 from Maxim Corporation.

INTRODUCTION TO EMBEDDED SYSTEMAn embedded system is a special-purpose computer system designed to perform a dedicated function. Unlike a general-purpose computer, such as a personal computer, an embedded system performs one or a few pre-defined tasks, usually with very specific requirements, and often includes task-specific hardware and mechanical parts not usually found in a general-purpose computer. Since the system is dedicated to specific tasks, design engineers can optimize it, reducing the size and cost of the product. Embedded systems are often mass-produced, benefiting from economies of scale. Physically embedded systems range from portable devices such as digital watches and MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems controlling nuclear power plants. In terms of complexity embedded systems run from simple, with a single microcontroller chip, to very complex with multiple units, peripherals and networks mounted inside a large chassis or enclosure.Mobile phones or handheld computers share some elements with embedded systems, such as the operating systems and microprocessors which power them, but are not truly embedded systems themselves because they tend to be more general purpose, allowing different applications to be loaded and peripherals to be connected.a) OVERVIEWEmbedded systems run the computing devices hidden inside a vast array of everyday products and appliances such as cell phones, toys, handheld PDAs, cameras, and microwave ovens. Cars are full of them, as are airplanes, satellites, and advanced military and medical equipments. As applications grow increasingly complex, so do the complexities of the embedded computing devices. The goal of this course is to develop a comprehensive understanding of the technologies behind the embedded systems design. The students develop an appreciation of the existing capabilities and limitations of various steps in overall design methodology - modeling/specification, exploration, partitioning, synthesis (hardware/software/interface), and validation/verification of embedded systems

b) CHARACTERISTICS OF EMBEDDED SYSTEM Embedded systems are designed to do some specific task, rather than be a general-purpose computer for multiple tasks. Some also have real-time Performance constraints that must be met, for reason such as safety and usability; others may have low or no performance requirements, allowing the system hardware to be simplified to reduce costs. Embedded systems are not always separate devices. Most often they are physically built-in to the devices they control The software written for embedded systems is often called firmware, and is stored in read-only memory or Flash memory chips rather than a disk drive. It often runs with limited computer hardware resources: small or no keyboard, screen, and little memory.

c) ADVANTAGES OF EMBEDDED SYSTEM Higher performance: The integration of various ICs shortens the traveling route and time of data to be transmitted resulting in higher performance. Lower power consumption: The integration of various ICs eliminates buffers and other interface circuits. As the number of components is reduced, less power will be consumed. Slimmer and more compact: Housed in a single separate package, the chip is smaller in size and therefore occupies less space on the PCB. Hence products using embedded system are slimmer and more compact. Reduced design and development system: The system on a chip provides all functionality required by the system. System designers need not worry about the basic function of the system-right from the beginning of the design phase, they can focus on the development features. As a result, the time spends on research and development is reduced and this in turn reduces the time to market of their products. Lower system costs: In the past, several chips in separate packages were required to configure a system. Now, just one system on-chip can replace all of these, dramatically reducing the packaging cost.MICROCONTROLLERS VERSUS MICROPROCESSORS The microprocessor is a clock driven semiconductor device consisting of electronic logic circuits. By microprocessor is meant the general purpose microprocessors such as Intels x86 family. These microprocessors contain no RAM, no ROM, and no I/O ports on the chip itself. The microprocessors is capable of performing various computing functions And making decisions to change the sequence of program execution. The microprocessor is in many ways similar to CPU but includes all the logic circuitry including the control unit, on one chip. The microprocessor is divided mainly into three segments they are Arithmetic Logic Unit (ALU), Register Array and Control Unit. Arithmetic Logic Unit This is the area of the microprocessor where various computing functions are performed on data. The ALU performs such arithmetic operations as additions and subtractions, and such logic functions as AND, OR, and exclusive OR. Register Array This area of microprocessors consists of various registers .These registers are primarily used to store data temporarily during the execution of a program and are accessible to the user through instructions. Control unit The control unit provides the necessary timing and control signals to all the operations in the microcomputer. It controls the flow of data between the microprocessor and memory and peripherals. A microcontroller has a CPU in addition to a fixed amount of RAM, ROM I/O ports and a timer all on a single chip. The fixed amount of on chip ROM, RAM and number of I/O ports in microcontrollers make them ideal for many applications in which cost and space are critical.

Criteria for choosing a microcontroller:1. The first and foremost criteria are that it must meet the task at hand efficiently and cost effectively. In analyzing the need for microcontroller-based project, first see whether an 8-bit, 16-bit or 32-bit microcontroller can best handle the computing the needs of the task most effectively. Other considerations are: Speed. Packaging. Power consumptions. The amount of RAM and ROM on chip. The number of I/O pins and timer on the chip. Cost per unit 2. The second criteria in choosing a microcontroller are how easy it is to develop product around it.3. The third criterion is its ready availability in needed quantities both now and in future

PIC 18F24J50

Low-Power, High-Speed CMOS Flash Technology C Compiler Optimized Architecture for Re-Entrant Code Priority Levels for Interrupts Self-Programmable under Software Control 8 x 8 Single-Cycle Hardware Multiplier Extended Watchdog Timer (WDT): - Programmable period from 4 ms to 131s Single-Supply In-Circuit Serial Programming (ICSP) via two pins In-Circuit Debug (ICD) w/Three Breakpoints via 2 Pins Operating Voltage Range of 2.0V to 3.6V On-Chip 2.5V Regulator Flash Program Memory of 10,000 Erase/Write Cycles Minimum and 20-Year Data Retention

PIC18F24J 50 CHIP DIAGRAM

ACCUMULATORAcc is the Accumulator register. The mnemonics for Accumulator specific instructions, however, refer to the accumulator simply as A.B REGISTERThe B register is used during multiply and divide operations. For other instructions it can be treated as another scratch pad register.STACK POINTERThe stack pointer register is 8 bits wide. It is incremented before data is stored during PUSH and CALL executions.DATA POINTER The Data pointer (DTPR) consists of a high byte and a low byte. Its functions are to hold a 16-bit address. It may be manipulated as 16-bit register or as two independent 8-bit registers.SERIAL DATA BUFFERThe serial data buffer is actually two separate registers, a transmit buffer and a receive buffer register. When data is moved to serial data buffer, it goes to the transmit buffer, where it is held for serial transmission. When data is moved from serial data buffer, it comes from the receive bufferTIMER REGISTERSRegister pairs (THO, TLO), (THI, TLI) and (TH2, TL2) are the 16-bit counter register for timer/counter 0,1 and 2 respectively.CONTROL REGISTERSSpecial function registers IP, IF, TMOD, TCON, T2CON, T2 MOD, SCON and PCON contain control and status bits for the interrupt system, the timer/counters and the serial port.

MCLR :- The Master Clear pin is an optional external reset that is activated by pulling the pin low. TheMCLRpin can be setup as an standard digital input pin or be enabled as an external reset pin. This is controlled by a configuration setting. VCC:- Digital supply voltage. GND :-Ground. Port A (RA7..RA0) :-Port A serves as the analog inputs to the A/D Converter. Port A also serves as an 8-bit bi-directional I/O port, if the A/D Converter is not used. Port pins can provide internal pull-up resistors (selected for each bit). The Port A output buffers have symmetrical drive characteristics with both high sink and source capability. When pins RA0 to RA7 are used as inputs and are externally pulled low, they will source current if the internal pull-up resistors are activated. The Port A pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port B (RB7..RB0) :-Port B is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port B output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port B pins that are externally pulled low will source current if the pull-up resistors are activated. The Port B pins are tri-stated when a reset condition becomes active, even if the clock is not running. Port C (RC7..RC0) :-Port C is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port C output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port C pins that are externally pulled low will source current if the pull-up resistors are activated. The Port C pins are tri-stated when a reset condition becomes active, even if the clock is not running.RSTReset input a high on-this pin for two-machine cycles while the oscillator is running resets the device.

ALE/PROGAddress latch enable output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input during flash programming. In normal operations ALE is emitted at a constant rate of 1/16 the oscillator frequency, and may be used for external timing or clocking purposes.PSENProgram store enable is the read strobe to external program memory, when the microcontroller is executing code from external program memory locations. EA should be strapped to vie for internal program executions.This pin also receives the 12 VOH programming enable voltage (Vpp) during flash programming for parts that require 12 volt Vpp.

CRYSTAL OSCILLATOR

XTAL 1: Input to the inverting oscillator amplifier and input to the Internal clock operating circuit. XTAL 2: Output from the inverting oscillator amplifier XTAL 1 and XTAL 2 are the input and output, respectively of an inverting amplifier, which can be configured for use as an on-chip oscillator, as shown in figure (1). Either a quartz crystal or ceramic resonator may be used. They are no requirements on the duly cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide by two flip flop, but minimum and maximum voltage, high and low time specifications must be observed.

LM7805 Voltage Regulator These are monolithic integrated circuits designed as fixed voltage regulators for a wide variety of applications including local, on card regulation. These regulators employ internal current limiting, thermal solution and safe area compensation. They can also be used with external components to obtain adjustable voltages and current. Its features are, Output Current up to 1A Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24 Thermal Overload Protection Short Circuit Protection Output Transistor Safe Operating Area Protection

MAX232

TheMAX232is an IC, first created in 1987 byMaxim Integrated Products, that converts signals from anRS-232serial port to signals suitable for use inTTL compatible digital logic circuits. The MAX232 is a dual driver/receiver and typically converts the RX, TX, CTS and RTS signals.The drivers provide RS-232 voltage level outputs (approx. 7.5V) from a single +5V supply via on-chipcharge pumpsand external capacitors. This makes it useful for implementing RS-232 in devices that otherwise do not need any voltages outside the 0V to +5V range, aspower supplydesign does not need to be made more complicated just for driving the RS-232 in this case.The receivers reduce RS-232 inputs (which may be as high as 25V), to standard 5VTTLlevels. These receivers have a typical threshold of 1.3V, and a typicalhysteresisof 0.5V.

Pin out diagram

LCD

LCD PIN DESCRIPTION

RFID Module and RFID TagRFID stands for Radio frequency identification. It is an automatic identification technology where digital data encoded in an RFID tag is read by the RFID reader. An RFID system consists of a reader device and a tag (transponder). A tag has a unique serial number which is identified by the reader. In this project, RFID has been interfaced with microcontroller to provide secured access. The relevant messages are also displayed on a 16x2 LCD.RFID Reader Module, are also called as interrogators. They convert radio waves returned from the RFID tag into a form that can be passed on to Controllers, which can make use of it. RFID tags and readers have to be tuned to the same frequency in order to communicate. RFID systems use many different frequencies. The tag contains an antenna connected to a small microchip. The reader functions similarly to a barcode scanner; however, while a barcode scanner uses a laser beam to scan the barcode, an RFID scanner uses electromagnetic waves. To transmit these waves, the reader uses an antenna that transmits a signal, communicating with the tags antenna. The tags antenna receives data from the reader and transmits its particular chip information to the reader. The data on the chip is usually stored in one of two types of memory. The most common is ReadOnly Memory (ROM) as its name suggests, read-only memory cannot be altered once programmed onto the chip during the manufacturing process. The second type of memory is Read/Write Memory; though it is also programmed during the manufacturing process, it can later be altered by certain devices.

Fingerprint Identification Module

Fingerprint processing includes two parts: fingerprint enrollment and fingerprint matching (the matching can be 1:1 or 1:N). 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 specifc 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.

Main Parameters of FP module:-

IC 4066The 4066 contains 4 analogue bilateral switches, each with an active-high enable input (A) and two input/outputs (X and Y). When the enable input is set high, the X and Y terminals are connected by a low impedance; this is theoncondition. When the enable is low, there is a high impedance path between X and Y, and the switch isoff.The 4066 is pin-compatible with the4016, but has a significantly loweronimpedance and more constantonresistance over the full range of input voltage. Therefore, the 4066 is preferable to the 4016 in most cases.

CIRCUIT DIAGRAM

SOFTWARE STUDYEMBEDDED CAn embedded hardware device, depending on its size and capabilities, can have an operating systemsuch as embedded Linuxwith limited or minimal functionality compared to a desktop version. For very small embedded devices, an OS might be entirely absent: it is not possible to write programs, compile, and run and debug the code in such small devices. In such a situation, it is necessary to use cross compilers (or assemblers), which compile programs written in a high-level language on a host system (typically a PC) and generate code for a target system (for example, an embedded device). If we write assembly programs and use an assembler running on a host to generate code for a target device, it is a cross assembler. So, we can write programs on our PC generate code for the embedded device and run it there. This solves the problem of creating executable code for embedded systems, but testing, debugging or tracing embedded programs are difficult.

Languages for programming embedded devices C is the language of choice for most of the programming done for embedded systems. It might appear that assembly language is intuitively the most obvious choice, since embedded programming is all about programming hardware devices such as microcontrollers. It is true that micro-controllers were initially programmed mostly in assembly language as with other embedded devices. It is not that difficult to write an assembly program since the assembly language produces the tightest code, making it possible to squeeze every possible byte of memory usage. However, the problem is that it becomes difficult to use for any reasonably-sized program, and even a slightly complicated device. The difficulties are in getting assembly programs to work correctly; and understanding, debugging, testing and, most importantly, maintaining them in the long run.

Also, high quality C compilers can often generate code that is comparable to the speed of programs written in assembly. So, the benefits of using assembly for efficiency are negligible compared to the ease with which programmers can write C code. However, if performance is the key to make or break a device, then it is hard to beat assembly. For example, DSP (digital signal processing) devices are mostly programmed in assembly even today, because performance is the most important requirement in these devices. Languages such as C++ have features that are often bulky, inefficient or inappropriate for use in resource constrained environments such as embedded devices. In particular, virtual functions and exception handling are two language features that are not efficient in terms of space and speed in embedded systems. Sometimes, C++ programming is used as Safe C, where only a small subset of C++ features is included. However, for convenience, most embedded projects pragmatically use C itself. Languages with managed runtimes, such as Java, are mostly heavyweight. Running Java programs requires a Java Virtual Machine, which can take up a lot of resources.Though Java is popular in high-end mobile phones because of the portability it provides and for browsing the Web, it is rarely suitable for use in small embedded devices. There are numerous special purposes or proprietary languages meant to be used in embedded systems such as B# and Dynamic C. Others, like Forth, are also well suited for the purpose. However, C is widely used and familiar to programmers worldwide, and its tools are easily available.

CHARACTERESTICS OF EMBEDDED CLike most imperative languages in the ALGOL tradition, C has facilities for structured programming and allows lexical variable scope and recursion, while a static type system prevents many unintended operations. In C, all executable Code is contained within functions. Function parameters are always passed by value. Pass-by-reference is achieved in C by explicitly passing pointer values.Heterogeneous aggregate data types (struct) allow related data elements to be combined and manipulated as a unit. C program source text is free-format, using the semicolon as a statement terminator (not a delimiter). C also exhibits the following more specific characteristics: Lack of nested function definitions Variables may be hidden in nested blocks Partially weak typing; for instance, characters can be used as integers Low-level access to computer memory by converting machine addresses to typed pointers Function and data pointers supporting ad hoc run-time polymorphism Array indexing as a secondary notion, defined in terms of pointer arithmetic A preprocessor for macro definition, source code file inclusion, and conditional compilation Complex functionality such as I/O, string manipulation, and mathematical functions consistently delegated to library routines A relatively small set of reserved keywords A lexical structure that resembles B more than ALGOL, for example { ... } rather than ALGOL's begin ... end the equal-sign is for assignment (copying), much like Fortran two consecutive equal-signs are to test for equality (compare to .EQ. in Fortran or the equal-sign in BASIC) && and || in place of ALGOL's and or (these are semantically distinct from the bit-wise operators & and | because they will never evaluate the right operand if the result can be determined from the left alone (short-circuit evaluation)).

FLOW CHART

EMBEDDED C PROGRAM#include#include#include"lcd5.c"#define SWITCH1_FINGER RA3#define SWITCH2_RFID RA2#define buzzer RA5#define red_led RC0#define green_led RC1#define _XTAL_FREQ 10000000#define ack 0x07void request(void);void initialize(void);void server_init(void);bit checksum_calculation(unsigned char *fp,unsigned char);void send_serial2(unsigned char *serial2,unsigned char);void send_serial1(unsigned char *serial1,unsigned char);void split(unsigned char *fp3,unsigned char);void initialvalues(void);//******************************************************************************************************** unsigned int t_num; unsigned char search[]={0xEF,0x1,0xFF,0xFF,0xFF,0xFF,0x1,0x0,0x3,0x1,0x0,0x5}; unsigned char charfile[]={0xEF,0x1,0xFF,0xFF,0xFF,0xFF,0x1,0x0,0x4,0x2,0x1,0x0,0x8}; unsigned char compare[]={0xEF,0x1,0xFF,0xFF,0xFF,0xFF,0x1,0x0,0x8,0x1B,0x1,0x0,0x0,0x1,0x0x1,0x0,0x27}; unsigned char tempreq[]={0xEF,0x1,0xFF,0xFF,0xFF,0xFF,0x1,0x0,0x4,0x9,0x1,0x0,0xF}unsigned char nofinger[]={0xEF,0x1,0xFF,0xFF,0xFF,0xFA,0x07,0x00,0x03,0x02,0x00,0x0C}; unsigned char resend[]={0xEF,0x1,0xFF,0xFF,0xFF,0xFA,0x07,0x00,0x03,0x04,0x00,0x0E}; unsigned char ok[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFA,0x07,0x00,0x03,0x00,0x00,0x0A}; unsigned char templocation[]={0xEF,0x1,0xFF,0xFF,0xFF,0xFF,0x1,0x0,0x6,0x6,0x1}; unsigned char deletefull[]={0xEF,0x01,0xFF,0xFF,0xFF,0xFF,0x1,0x0,0x03,0x0D,0x00,0x11}; unsigned char deletebylocation[]={0xEF,0x1,0xFF,0xFF,0xFF,0xFF,0x01,0x00,0x07,0x0C}; enum statetype {idle,srch,chrf,cmpr,match,mmatch,tmpreq,over,downloadcmplte,deleteall,deletelocation}state;//***********************************************************************************************************#define U1RRC7//UART 1 Receive pin#define U1TRC6 //UART 1 Transmit pin#define U2R RPINR1 //UART 2 Receive pin#define U2T RPOR0 //UART 2 Transmit pin;

#define U2T_REG 5 #define U2R_PIN 1#define EINT0 RB0 //Interrupt 0 RB0#define EINT1 RPINR1 //Interrupt 1 RP11#define EINT1_PIN 11 //Interrupt 1 RP11#define EINT2 RPINR2 //Interrupt 2 RP12#define EINT2_PIN 12 //Interrupt 2 RP12#define EINT3 RPINR3 //Interrupt 3 RP13#define EINT3_PIN 13 //Interrupt 3 RP13//*************************************************unsigned int t_num;unsigned char t_var = 255, t_cnt = 0, i=0, j=0,s=0;unsigned char rcv_Buffer[50];unsigned char rcv_server[50];unsigned char name[20],tot[10],prize[10];unsigned char rcv_Buffer_pos1 = 0;unsigned char rcv_Buffer_pos2 = 0;unsigned char rcvd_RfidTag_f = 0;unsigned char rcvd_ServerData_f = 0;unsigned char clr_lcd_f = 0;unsigned char clr_string_f = 0;unsigned char count1=0,count2=0,count3=0;unsigned char server_char = 0;unsigned char server_Data_pos[8];unsigned char namerequest[]="name";

unsigned char sequence_count=0,packet_size=0;unsigned char rcv_thmp[30]; int rfid=2,rfidn=2,rfidalready=2,fingvalid=2,fingnvalid=2,votemarked_status=2;//***************************************************************************** bit rcve_flag=0,no_finger=0,length_calc=0,checksum_bit=0,length_calc2=0, rcvd_server_f=0,rcvd_thmp_f=0,finger_valid_flag=0, checksum_bit1=0, template_request=0,download_complete=0,length_calc3=0,before_scan=0, after_scan=0,server_resend=0,dataresendbit=0,connection_problem=0, adress_bit=0,delete_all=0,delete_location=0,checksum_calculation_routine=0,startingbit=0; bit rfid_validbit=0, rfid_received_flag=0,server_rcved_flag=0,candidate1_bit=0,candidate2_bit=0,candidate3_bit=0,candidate4_bit=0,namerequest_bit=0;//******************************************************************************** unsigned char location_msb=0,location_lsb=0,datacopysize=0; unsigned char rcve_count=0,sizeoftemplocation=0; unsigned char rcv_thmp_pos = 0; unsigned char check_sum=0; unsigned char sizeofsearch=0,sizeofcharfile=0,sizeofcompare=0,sizeoftempreq=0; unsigned char sizeofdeletebylocation=0,sizeofdeletefull=0,location_msb1=0,location_lsb1; unsigned char original_checksum=0,buffer_location1=0,packet_size2=0,sequence_count2=0,rcv_server_count=0;//*************************************************void my_delay(unsigned int b){while(--b){__delay_ms(10);}}//*************************************************

void init_reqd(){//Initialize allGIE = 0;//TRISC = 0;//E1=0;//E2E3=0;

EECON2 = 0x55;EECON2 = 0xAA;PPSCON = 0; //for UART2 asigned at pins Rx=3,Tx=2RPINR16 = 1; RPOR0= 5;U2R= U2R_PIN; U2T= U2T_REG; //EINT1= EINT1_PIN; //Ext. int. 1,2,3//EINT2= EINT2_PIN;//EINT3= EINT3_PIN;//EECON2 = 0x55;//EECON2= 0xAA;PPSCON = 1;USBEN = 0;//disable USBUTRDIS = 1;//INT0IE = 1; //Ext. Interrupts//INT1IE = 0;//INT2IE = 0;//INT3IE = 0;//INTEDG0 = 0; //Falling Edge//INTEDG1 = 0;//INTEDG2 = 0;//INTEDG3 = 0;//TRISC2 = 0; //test onlyGIE = 1;PEIE = 1; //TRISC0=0; //RC0=1; //TRISB=0X00; PCFG1 = 1; PCFG0 = 1; PCFG8 = 1; PCFG9 = 1; PCFG10=1; PCFG11 = 1; PCFG12=1; PCFG4 = 1; PCFG3 = 1; PCFG2 = 1; PCFG1 = 1; PCFG0 = 1; TRISC0=0; TRISC1=0; TRISC2=0; TRISB0=1; TRISB1=0; TRISB2=0; TRISB3=0; TRISB4=0; TRISB5=0; TRISB6=0; TRISB7=0; TRISA2=0; TRISA3=0; TRISA5=0; TRISC7 =1; TRISC6=0; TRISA0=0; TRISA1=1; }//**************************************************void init_timer(){GIE=1; PEIE=1; TMR0IE=0; T0CON=0B00000100;}//**************************************************void init_serial_ports(){SPEN = 1;SYNC = 0;BRGH = 1;BRG16 = 0;SPBRG = 79; //9600 @ 10MHzTXEN = 1;CREN = 1;RC1IE = 1;SPEN2 = 1;SYNC2 = 0;BRGH2 = 1;BRG162 = 0;SPBRG2 = 79;TXEN2 = 1;CREN2 = 1;RC2IE = 1;PCFG1 = 1;PCFG0 = 1;TRISC7 = 1;SWITCH1_FINGER=0; my_delay(2); SWITCH2_RFID=1; my_delay(2);}//**************************************************void put_serial1(unsigned char c){while(!TRMT); TXREG = c;}void put_serial2(unsigned char c){while(!TRMT2);TXREG2 = c;}void puts_serial1(const unsigned char *c){while(*c)put_serial1(*c++);}//**************************************************//interrupt Functionvoid interrupt fn_isr_hp(void)

{ if(RC1IF==1&&rfid_validbit==0){ RC1IF=0;rcv_Buffer[rcv_Buffer_pos1] = RCREG;//put_serial2(rcv_Buffer[rcv_Buffer_pos1]); //test onlyif(rcv_Buffer[rcv_Buffer_pos1-1]==0xD&&rcv_Buffer[rcv_Buffer_pos1]==0X0A){rcvd_RfidTag_f =1;rcv_Buffer_pos1 = 0; clr_string_f = 1;//put_serial1('S'); RC1IF=0;}rcv_Buffer_pos1++;} if(RC1IF==1&&rfid_validbit==1) {RC1IF=0; switch(sequence_count) { case 0: if(RCREG==0XEF) sequence_count=1; break; case 1: if(RCREG==0X01)

sequence_count=2; else if(RCREG==0XEF) sequence_count=1; else sequence_count=0; break; case 2: if(RCREG==0XFF)sequence_count=3else if(RCREG==0XEF) sequence_count=1; else sequence_count=0; break;case 3: if(RCREG==0XFF) sequence_count=4;else if(RCREG==0XEF) sequence_count=1; elsesequence_count=0 break; case 4: if(RCREG==0XFF) sequence_count=5; else if(RCREG==0XEF) sequence_count=1; else sequence_count=0;break; case 5: if(RCREG==0XFF) sequence_count=6; else if(RCREG==0XEF) sequence_count=1; else sequence_count=0; break; case 6:sequence_count=7; break; } if(sequence_count>6) { rcv_thmp[rcve_count]=RCREG;rcv_thmp[rcve_count+1]='\0';//Finding Packet Sizeif(rcve_count==2) {packet_size=(rcv_thmp[1]*0x100+rcv_thmp[2])+3; length_calc=1; }//Stop Recievingif(rcve_count>=packet_size-1 && length_calc==1){ rcvd_thmp_f=1;sequence_count=0; length_calc=0; }rcve_count++; } } if(RC2IF){ RC2IF=0;rcv_server[rcv_Buffer_pos2] = RCREG2; //put_serial2(RCREG2); if(rcv_server[rcv_Buffer_pos2-1]==0xD&&rcv_server[rcv_Buffer_pos2]==0X0A) {rcvd_ServerData_f = 1; //rcv_Buffer_pos2=0; RC2IF=0; clr_string_f = 1; //RC0=0; //put_serial2('S'); } rcv_Buffer_pos2++; } if(TMR0IF){ TMR0IF =0; buzzer=0; TMR0ON=0;}}

//**************************************************void main(void){ sizeofsearch=sizeof(search);sizeofcharfile=sizeof(charfile);sizeofcompare=sizeof(compare); sizeoftempreq=sizeof(tempreq); sizeoftemplocation=sizeof(templocation); sizeofdeletefull=sizeof(deletefull); sizeofdeletebylocation=sizeof(deletebylocation); initialize();init_reqd();init_serial_ports();lcd_init();init_timer();lcd_goto(0);// select first linelcd_puts("");lcd_goto(0x40);// Select second linelcd_puts("System Init 1 -> OK");lcd_goto(0x14);lcd_puts("System Init 2 -> OK");lcd_goto(0x54);

lcd_puts(""); my_delay(300); lcd_goto(0);// select first linelcd_puts(" ");lcd_goto(0x40);// Select second linelcd_puts(" ");lcd_goto(0x14);lcd_puts(" ");lcd_goto(0x54);lcd_puts(" ");red_led=0; green_led=0; while(1) { if(rcvd_thmp_f==1) { rcvd_thmp_f=0; checksum_bit=checksum_calculation(&rcv_thmp[0],packet_size); }if(checksum_bit==1 && rcv_thmp[0]==ack){ checksum_bit=0; checksum_calculation_routine=0; startingbit=0;lcd_goto(0x16); if(rcv_thmp[3]==0x00) { switch(state) { case srch: state=chrf;break; case chrf: state=cmpr; break; case cmpr: state=match;//matchsound T0CON=0B00000100; buzzer=1;TMR0ON=1; finger_valid_flag=1; break; case tmpreq: template_request=1; send_serial2(&ok[0],12); break; case downloadcmplte: send_serial2(&ok[0],12); CREN2=1; server_init(); state=srch; break;

case deleteall: send_serial2(&ok[0],12); CREN2=1; server_init(); state=srch; break; case deletelocation: send_serial2(&ok[0],12); CREN2=1; server_init(); state=srch; break; }}else if(rcv_thmp[3]==0x01) { request(); } else {switch(state){case(cmpr): state=mmatch;buzzer=1;T0CON=0B10001000; state=srch; break;default: break; } }if(state!=match&&template_request==0){initialize();if(state==srch){ //before_scan= !status_switch;} request();}} if(finger_valid_flag) { finger_valid_flag=0; address_bit=1; send_serial2(&adress[0],6); send_serial2(&rcv_thmp[0],packet_size); rcv_server[0]='\0'; packet_size2=0; sequence_count2=0; rcv_server_count=0; } if(rcvd_ServerData_f && namerequest_bit==0){ rcvd_ServerData_f = 0; lcd_goto(0); lcd_puts(" "); lcd_goto(0x40); lcd_puts(" "); lcd_goto(0x14); lcd_puts(" "); lcd_goto(0x54); lcd_puts(" "); //lcd_goto(0); //lcd_puts("WELCOME"); //lcd_goto(0x40); rcv_server[3]='\0'; rfid=strcmp("RFY",rcv_server); rfidn=strcmp("RFN",rcv_server); rfidalready=strcmp("RFV",rcv_server); fingvalid=strcmp("FIY",rcv_server); fingnvalid=strcmp("FIN",rcv_server); votemarked_status=strcmp("VMC",rcv_server); rcv_server[0]='\0'; rcv_Buffer_pos2=0; } if(rfid==0) { rfid=2; SWITCH1_FINGER=1;my_delay(2); SWITCH2_RFID=0; my_delay(2); lcd_clear(); lcd_goto(0); lcd_puts("YOUR ID IS MATCHING"); lcd_goto(0X40); lcd_puts("PUT YOUR FINGER"); rfid_validbit=1; state=srch; request(); } if(rfidn==0){lcd_goto(0);lcd_puts(" ");lcd_goto(0X40);lcd_puts(" ");rfidn=2;lcd_clear();lcd_goto(0);lcd_puts("YOUR ID NOT MATCHING");red_led=1;buzzer=1;green_led=0;my_delay(500);red_led=0;buzzer=0;lcd_clear();rcv_Buffer[0]='\0';}if(fingvalid==0){fingvalid=2;namerequest_bit=1;send_serial2(&namerequest[0],4);}if(namerequest_bit==1&&rcvd_ServerData_f==1){rcvd_ServerData_f=0;namerequest_bit=0;lcd_goto(0);lcd_puts(" ");lcd_goto(0X40);lcd_puts(" ");rcv_Buffer[8]='\0';rcv_server[rcv_Buffer_pos2-2]='\0'; lcd_goto(0);lcd_puts(rcv_server);lcd_goto(0x40);lcd_puts("ID:");lcd_puts(rcv_Buffer);green_led=1;red_led=0;my_delay(500);green_led=0;rcv_server[0]='\0';rcv_Buffer[0]='\0';rcv_Buffer_pos2=0;}if(fingnvalid==0){fingnvalid=2;lcd_goto(0);lcd_puts(" ");lcd_goto(0X40);lcd_puts(" ");lcd_goto(0);lcd_puts("FINGER NOT MATCHING");rcv_Buffer[0]='\0';rfid_validbit=0;SWITCH1_FINGER=0;my_delay(2);SWITCH2_RFID=1;my_delay(2);red_led=1;my_delay(500);red_led=0;}if(votemarked_status==0){lcd_clear();lcd_goto(0);lcd_puts("*WELCOME TO BANK NAME*");rfid_validbit=0;SWITCH1_FINGER=0;my_delay(2);SWITCH2_RFID=1;my_delay(2);red_led=0;green_led=0;} if(rcvd_RfidTag_f==1) { rcvd_RfidTag_f=0; put_serial2('R'); put_serial2('F'); send_serial2(&rcv_Buffer[0],8); //rcv_Buffer_pos2=0; rcv_Buffer_pos1=0; //rcv_Buffer[0]='\0'; }}}void send_serial2(unsigned char *serial2,unsigned char array_size){unsigned char *fp2,ps2,*start2=0;fp2=serial2;ps2=array_size;for(start2=fp2;start2


Recommended