Copy of Project_report (1)

Embed Size (px)

Citation preview

  • 8/6/2019 Copy of Project_report (1)

    1/41

    RFID Based Toll System

    1. INTRODUCTION

    Presently in India, at toll plazas there are long queues and congestions. These problems are

    due to increasing traffic and the lack of a toll system capable of handling heavy traffic load.

    The growing traffic volume plying on national highways causes additional

    congestions at the toll plazas which result in loss of time and fuel. Environment pollution and

    noise generation are other side effects of these problems.

    As a solution, an Electronic Toll Collection system is proposed that involves non-stop

    tax collection. This system is based on technologies such as radio frequency identification. A

    tag and a road side unit called reader are required. The tag has a unique identification number

    to identify the vehicle.

    While driving through the lane, the reader installed by the lane detects the id and

    deducts the toll amount from the users account. Usually, the commuter is not required to

    stop and the toll is collected while the vehicle passes through the plaza. For demonstration

    purposes, we assume that the motorist slows down while approaching the reader and the tag

    is flashed at the reading area of the reader. After sensing the tag, the amount is deducted and

    the barrier is opened. If the balance is zero the barrier will not open and the motorist will be

    asked to recharge his card at that very moment. The motorist can recharge using the keypad.

    The barrier is controlled by the motor which can rotate in both directions. The LCD display

    will show the appropriate messages. Some of the key features of this system are listed below.

    This system is user friendly and easy to mount. It also provides a convenient and

    quick service to the vehicle owners. Traffic flow at toll gates will be smooth and fast as the

    user will not wait to give the money. The driver will just have to show the card in front of the

    reader. The driver will not have to carry money at all, just the rfid card. Standalone operation

    is possible. Moreover this system reduces man power. The system can also be interfaced with

    the PC.

    VJCET, Vazhakulam1

  • 8/6/2019 Copy of Project_report (1)

    2/41

    RFID Based Toll System

    2. BLOCK DIAGRAM

    VJCET, Vazhakulam2

    RFI

    D

    Car

    RFID

    Read

    er

    PIC

    Microcontroll

    er

    LCD

    Displa

    y

    Motor

    Keypad

  • 8/6/2019 Copy of Project_report (1)

    3/41

    RFID Based Toll System

    3. SCHEMATIC DIAGRAM

    VJCET, Vazhakulam3

  • 8/6/2019 Copy of Project_report (1)

    4/41

    RFID Based Toll System

    VJCET, Vazhakulam4

  • 8/6/2019 Copy of Project_report (1)

    5/41

    RFID Based Toll System

    VJCET, Vazhakulam5

  • 8/6/2019 Copy of Project_report (1)

    6/41

    RFID Based Toll System

    VJCET, Vazhakulam6

  • 8/6/2019 Copy of Project_report (1)

    7/41

    RFID Based Toll System

    VJCET, Vazhakulam7

  • 8/6/2019 Copy of Project_report (1)

    8/41

    RFID Based Toll System

    4. SCHEMATIC DIAGRAM DESCRIPTION

    4.1 RFID Reader and tag

    Radio Frequency Identification (RFID) is a term for non-contacting technologies that

    use radio waves to automatically identify people or objects. An RFID system consists of a

    reader and one or more tags. There are several methods of identification, but the most

    common is to store a unique serial number that identifies a person or object on a microchip

    that is attached to an antenna. The combined antenna and microchip are called an "RFID

    transponder" or "RFID tag" and work in combination with an "RFID reader" (sometimes

    called an "RFID interrogator").

    The antenna is used to transmit the identification information through radio frequency

    (RF) energy to a reader. Depending on the tag type, the energy is "harvested" by the tag's

    antenna and used to power up the internal circuitry of the tag. The tag will then modulate the

    electromagnetic waves generated by the reader in order to transmit its data back to the reader.

    The reader receives the modulated radio waves and converts them into digital data.

    There are two major types of tag technologies. "Passive tags" are tags that do not

    contain their own power source. When radio waves from the reader reach the chips antenna,

    the energy is converted by the antenna into electricity that can power up the microchip in the

    tag (known as "parasitic power"). The tag is then able to send back any information stored on

    the tag by reflecting the electromagnetic waves as described above.

    "Active tags" have their own power source and transmitter. The power source, usually

    a battery, is used to run the microchip's circuitry and to broadcast a signal to a reader. They

    also transmit at higher powers. Due to the fact that passive tags do not have their own

    transmitter and must reflect their signal to the reader, the reading distance is much shorter

    than with active tags.

    VJCET, Vazhakulam8

  • 8/6/2019 Copy of Project_report (1)

    9/41

    RFID Based Toll System

    Semi passive tags are also available. They have their own power source, but the

    battery only powers the microchip and does not broadcast a signal. The RF energy is to store

    energy from the reader like a passive tag. An alternative use for the battery is to store energy

    from the reader to emit a response in the future, usually by means of backscattering. Since

    RFID tags do not require barcodes, they last longer.

    The RFID Reader Module is designed specifically for low-frequency (125 kHz)

    passive tags. Frequency refers to the size of the radio waves used to communicate between

    the RFID system components. RFID tags and readers have to be tuned to the same frequency

    in order to communicate effectively. RFID readers are composed of a radio frequency

    module, a control unit and an antenna to interrogate electronic tags via radio frequency (RF)

    communication. The reader has three main functions: energizing, demodulating and

    decoding. It is generally safe to assume that a higher frequency equates to a faster data

    transfer rate and longer read ranges, but also more sensitivity to environmental factors such

    as liquid and metal that can interfere with radio waves. The read range of a tag ultimately

    depends on many factors: the frequency of RFID system operation, the power of the reader,

    and interference from other RF devices. The reader receives the code and converts it into

    RS232 standard and transmits to the microcontroller. The controller is programmed

    in inte rrup ted mod e to r ece iv e th e d a ta th ro u g h i t s s e r i a l p o r t . Th e co d e

    re ce iv ed to by th e s e r i a l p o r t i s compared with the database in the program. If the

    code received by the controller match with the pre existing data base then the system

    grant an access to the card holder.

    4.2 Interfacing devices

    4.2.1 Data transmission through RS-232 Serial Port

    VJCET, Vazhakulam9

    http://en.wikipedia.org/wiki/Backscatteringhttp://en.wikipedia.org/wiki/Backscattering
  • 8/6/2019 Copy of Project_report (1)

    10/41

    RFID Based Toll System

    Fig 4.2.1

    The RFID module is interfaced with the PIC microcontroller using an RS-232 serial

    port this in this case is a connector DB9. RS-232 communication is dependent on a set timing

    speed at which both pieces of hardware communicate. In other words, the hardware knows

    how long a bit should high or low be. RS-232 also specifies the use of start and stop bits.

    Every time a character is sent, the same communication occurs.

    1. Start bit sent.

    2. Seven data bits sent.

    3. Stop bit sent.

    This communication is dependent on the fact that both devices are sampling the bits at the

    same rate. Only 3 pins are being used here, i.e. 2, 3 and 5. Pins 2 and 3 are used to receive

    and transmit data and they are connected to MAX232.

    VJCET, Vazhakulam10

  • 8/6/2019 Copy of Project_report (1)

    11/41

    RFID Based Toll System

    4.2.2 MAX 232:

    Fig 4.2.2

    VJCET, Vazhakulam11

  • 8/6/2019 Copy of Project_report (1)

    12/41

    RFID Based Toll System

    RS-232 Features:

    RS-232 TTL Logic

    -15V.-3V +2V.+5V High

    +3V..+15V 0V+0.8V Low

    Thus the RS-232 signal levels are far too high for TTL electronics, and the negative

    RS-232 voltage for high cant be handled at all by computer logic. To receive serial data

    from an RS-232 interface, the voltage has to be reduced. Also the low and high voltage level

    has to be inverted. This level converter uses a Max232 and five capacitors. The max232 is

    quite cheap. MAX-232 is also known as Level Converter.

    The MAX232 was the first IC which in one package contains the necessary

    drivers and receivers to adapt the RS-232 signal voltage levels to TTL logic. It became

    popular, because it just needs one voltage (+5V or +3.3V) and generates the necessary RS-

    232 voltage levels.

    MAX232 is connected to the PIC microcontroller using pins 11 and 12 pins ofMAX232 to 25 and 26 of PIC microcontroller.

    4.3 LCD Display

    Fig 4.3

    VJCET, Vazhakulam12

  • 8/6/2019 Copy of Project_report (1)

    13/41

    RFID Based Toll System

    Pin 1 and 2 are the power supply pins. They need to be connected to the negative rail

    and the positive rail of a +5v power supply respectively.

    Pin 3 is the contrast setting pin. It is said that it must be connected to a potentiometer

    to control the contrast or just connect a variable resistor in series with it to GND. The lower

    the resistance, the greater the contrast.

    Pins 7 to 14: are the Data pins of the LCD. In this project the LCD is connected in 4

    bit mode, wherein the higher nibbles are connected to the Pic microcontroller. Pin 7 is the

    least significant bit and pin 14 is the most significant bit of the data inputs. If you want to

    display some number or letter on the display, you have to input the appropriate codes for

    that character on these pins. These pins are also used for giving certain commands to the

    display like clearing the display or moving the cursor to a different location. Upon giving the

    correct signals to the 3 control pins, the character codes or the commands that you have given

    to the Data pins will be written to the display or executed by the LCD respectively.

    Pins 15 and 16: Most LCDs have a backlight. A backlight is a light within the LCD

    panel which makes seeing the characters on screen easier. The Backlight is nothing but an

    LED. So, a resistor must be connected in series with it to limit the current.

    The 3 control pins: R/S, R/W and E. They are pins 4, 5 and 6 respectively.

    The RS Pin: The LCD has basically two operating modes: Instruction mode and

    Character Mode. Depending on the status of this pin, the data on the 8 data pins (D0-D7) is

    treated as either an instruction or as character data. You have to activate the command mode

    if you want to give an Instruction to the LCD. Example Clear the display, Move cursor

    to home etc. You have to activate the character mode if you want to tell the LCD to display

    some character. To set the LCD in Instruction mode, you set the 4th pin of the LCD (R/S) to

    GND. To put it in character mode , you connect it to Vcc.

    The Enable Pin: It is just the clock input for the LCD. The instruction or the

    character data at the data pins (D0-D7) is processed by the LCD on the falling edge of this

    pin. The Enable pin should be normally held at Vcc by a pull up resistor. Your instruction or

    character will be executed on the falling edge of the pulse. (ie. The moment the switch

    closes).

    VJCET, Vazhakulam13

  • 8/6/2019 Copy of Project_report (1)

    14/41

    RFID Based Toll System

    The RW Pin: Generally , we always use the LCD to show things on the screen.

    However , in some rare cases , we may need to read from the LCD what it is displaying. In

    such cases, the R/W pin is used. For all practical purposes , the R/W pin has to be

    permanently connected to GND.

    4.4 L293D IC

    Fig 4.4

    L293D is a dual H-Bridge motor driver, So with one IC we can interface two DC

    motors which can be controlled in both clockwise and counter clockwise direction. L293D

    has output current of 600mA and peak output current of 1.2A per channel. Moreover for

    protection of circuit from back EMF ouput diodes are included within the IC. The output

    supply (VCC2) has a wide range from 4.5V to 36V, which has made L293D a best choice for

    DC motor . Three pins are needed for interfacing a DC motor (Motor1,Motor2, Motor3). If

    you want the o/p to be enabled completely then you can connect Enable(Motor1) to VCC and

    only 2 pins are needed from controller to make the motor work.

    The truth table is as shown:

    Motor2 Motor3

    0 0 Motor stops or breaks

    0 1 Motor moves in anticlockwise direction

    1 0 Motor moves in clockwise direction

    VJCET, Vazhakulam14

  • 8/6/2019 Copy of Project_report (1)

    15/41

    RFID Based Toll System

    1 1 Motor stops or breaks

    4.5 Power Supply:

    The voltage regulator 7805, has three legs and converts varying input voltage andproduces a constant regulated output voltage. The 78XX series of voltage regulators are

    designed for positive input. And the 79XX series is designed for negative input. The

    LM78XX series typically has the ability to drive current up to 1A. As mentioned above, the

    component has three legs: Input leg which can hold up to 36VDC Common leg (GND) and

    an output leg with the regulator's voltage. The 7805 takes in a voltage between 7 and 30 volts

    and regulates it down to exactly 5 volts. The first capacitortakes out any ripple coming from

    the transformer so that the 7805 is receiving a smooth input voltage, and the second capacitor

    acts as a load balancer to ensure consistent output from the 7805.

    4.6 PIC Microcontroller

    Between pins 13 and 14 a 20Mhz crystal is connected which provides the external

    clock. There are 5 ports namely A,B,C,D and E.

    The pins 2,3 and 4 of port A are connected to the motor.

    Port B is a bidirectional input/output port. All the 7 pins of this port are connected to

    the keypad.

    Port C is also a bidirectional input/output port. Pins 15,16,17 of Port B are connected

    to the LCD. Pins 25 and 26 of Port B are connected to the UART.

    Port D is a bidirectional input/output port. Pins 19,20,21 and 22 of Port Dare

    connected to the LCD.Pins 12 and 31 are connected to the Ground and Pins 32 and 11 are

    connected to the Vcc.

    This microcontroller has 33 input/output (I/O) pins, (8K*14words) of Enhanced

    FLASH program memory,(368*8bytes) of RAM, (256*8bytes) of data EEPROM. The PIC

    does not have an operating system and simply runs the program in its memory when it is

    turned on

    VJCET, Vazhakulam15

    http://electronics.howstuffworks.com/capacitor.htmhttp://electronics.howstuffworks.com/capacitor.htm
  • 8/6/2019 Copy of Project_report (1)

    16/41

    RFID Based Toll System

    4.7 Keypad

    The metrics key pad use a matrix with the rows and columns made up of 16 push

    button switches. When a key is pressed, a one column line makes contact with a row line and

    completes a circuit. Thus matrix method was used in order to identify a key through pin

    coordination. In the 4x4matrix keypad, every key is a open push button switch. Thus when

    any of the switches pressed, the input is read as digital signal into the PIC micro controller.

    Each key is assigned to the micro controller inputs. Then keypad controller program detects

    this closed circuit and identifies it as a key press and then responds according to the key

    press.

    Consider the Metrics key pad consist of (44) 16 keys. Each key has a unique grid

    location, much like points on a graph. The Keys in the Metrics key pad and their

    corresponding pins of the PIC16F877A microcontroller are shown below

    Key In Keypad Pins in microcontroller

    Column 1 PortB,3

    Column 2 PortB,2

    Column 3 PortB,1

    Column4 PortB,0

    Row1 PortB,4

    Row2 PortB,5

    Row3 PortB,6

    Row4 PortB,7

    The purpose is to allow the PIC micro controller to read a definite value as input. Each key

    is a simple push button with each number having unique paths from the PIC through the

    keypad and back into the PIC micro controller. A continuous unique path is created when the

    key is pressed. Each key pressing has a unique value corresponds to the key press. The

    microcontrollers ports connected to the columns set as inputs and kept in high impedance.

    When no key connected to it is being pressed, all the row pins of that row are

    VJCET, Vazhakulam16

  • 8/6/2019 Copy of Project_report (1)

    17/41

    RFID Based Toll System

    kept in the low state . When a key is pressed, the column pin is connected to the row pin and

    if, in that moment, that column is in high impedance, it is instead driven high by the

    microcontroller. The row is driven at the high state. To read the state of the keys of a row, it

    is needed to drive high one column and to wait a few milliseconds for the columns signalsettling and to avoid the keys rebound; at this moment the rows state can be read on ports

    connected to columns. In order to detect whether a key has been pressed, the controller will

    scan all columns. When a column is activated, the controller will search for which row is

    activated.

    VJCET, Vazhakulam17

  • 8/6/2019 Copy of Project_report (1)

    18/41

    RFID Based Toll System

    5. FLOWCHART

    no

    yes

    yes no

    no

    yes

    VJCET, Vazhakulam18

    start

    display default

    statement

    Swipe the card

    display

    not in

    database

    Motor activated Deduct Rs 10

    If the cardis

    detected

    If the card

    is entered

    in the

    data base

    If balance

    is less

    than 10

    recharge stop

  • 8/6/2019 Copy of Project_report (1)

    19/41

    RFID Based Toll System

    6. SOFTWARE

    #include

    #define NO_MATCH 0x01

    #define TRUE 1

    #define FALSE 0

    unsigned char CARDDETECT = FALSE;

    const unsigned char ID[5][11] =

    {

    {0x00 ,0x00 ,0x00 ,0x31 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00,0x00 ,0x00 },

    {0x31 ,0x37 ,0x30 ,0x31 ,0x34 ,0x39 ,0x39 ,0x32 ,0x33,0x0D ,0x0A },

    {0x31 ,0x37 ,0x30 ,0x34 ,0x31 ,0x32 ,0x30 ,0x39 ,0x55,0x0D ,0x0A },

    {0x31 ,0x37 ,0x30 ,0x31 ,0x36 ,0x33 ,0x35 ,0x34 ,0x79,0x0D ,0x0A },

    {0x31 ,0x37 ,0x30 ,0x33 ,0x31 ,0x31 ,0x33 ,0x32 ,0x31,0x0D ,0x0A }

    };

    unsigned char ID_BAL[5];

    unsigned char IDS[8];

    #include "lcd.h"

    #include "usart.h"

    #include "matrixkey.h"

    #include "MEM.h"

    #include "function.h"

    CONFIG(FOSC_XT & WDTE_OFF & PWRTE_OFF & BOREN_OFF & LVP_OFF &

    CPD_OFF & WRT_OFF & DEBUG_OFF & CP_OFF);

    #define LCD_L1() writecmd(0x80) // * Begin at Line 1 //

    #define LCD_L2() writecmd(0xC0) // * Begin at Line 2 //interrupt isr(void)

    {

    char buf,count;

    GIE = 0;

    count=0;

    buf = RCREG;

    while(buf != 0x0A)

    {

    VJCET, Vazhakulam19

  • 8/6/2019 Copy of Project_report (1)

    20/41

    RFID Based Toll System

    IDS[count] = buf;

    count++;

    while(!RCIF);buf = RCREG;

    }

    CARDDETECT = TRUE;

    GIE = 1;

    }

    void main()

    {

    unsigned char x,y,c_bal;

    lcdinit();

    uart_init();

    TRISB = 0xF0;

    for(x=1;x

  • 8/6/2019 Copy of Project_report (1)

    21/41

    RFID Based Toll System

    GIE = 0;

    writecmd(0x01);

    writestr("CARD DETECTED");

    delayms(500);CARDDETECT = FALSE;

    c_bal = compare();

    CHK_LO:

    if(c_bal == NO_MATCH)

    {

    LCD_L2();

    writestr("NO DATABASE");

    delayms(500);

    goto STARTOVER;

    }

    if(ID_BAL[c_bal] < 10)

    {

    recharge(c_bal);

    goto STARTOVER;

    }

    x= ID_BAL[c_bal];

    x= x - 10;

    ID_BAL[c_bal] = x;

    y = x;

    writecmd(1);

    writestr("BAL: Rs");

    echo(y/100);y=y%100;

    echo(y/10);y=y%10;

    echo(y);

    writestr("/-"); delayms(2000);

    motor();

    goto STARTOVER;

    }

    }

    VJCET, Vazhakulam21

  • 8/6/2019 Copy of Project_report (1)

    22/41

    RFID Based Toll System

    lcd.h

    #define LCDEN RC2 // CHANGE

    #define LCDRW RC1

    #define LCDRS RC0#define LCDD4 RD0

    #define LCDD5 RD1

    #define LCDD6 RD2

    #define LCDD7 RD3

    #define COMM 0

    #define DATA 1

    void delayms(int d)

    {

    int x;

    for(;d!=0;d--)

    {

    for(x=100;x!=0;x--);

    }

    }

    void lcdinit(void)

    {

    TRISC2=0; // LCD

    TRISC1=0; // LCD

    TRISC0=0; // LCD

    TRISD =0; // LCD

    LCDEN=1;//enable lcd

    LCDEN=0;//disable lcd

    LCDD4 = 0;

    LCDD5 = 1;

    LCDD6 = 0;

    LCDD7 = 0;

    LCDRS = COMM;

    LCDRW = 0;

    LCDEN=1;//enable lcd

    VJCET, Vazhakulam22

  • 8/6/2019 Copy of Project_report (1)

    23/41

    RFID Based Toll System

    LCDEN=0;//disable lcd

    delayms(6);

    LCDD4 = 0;

    LCDD5 = 1;LCDD6 = 0;

    LCDD7 = 0;

    LCDRS = COMM;

    LCDRW = 0;

    LCDEN=1;

    LCDEN=0;

    delayms(6);

    LCDD7 = 1;

    LCDD6 = LCDD5 = LCDD4 = 0;

    LCDEN=1;

    LCDEN=0;

    delayms(6);

    LCDD7 = LCDD6 = LCDD5 = LCDD4 = 0;

    LCDEN=1;

    LCDEN=0;

    delayms(6);

    LCDD7 = LCDD6 = LCDD5 = LCDD4 = 1;

    LCDEN=1;

    LCDEN=0;

    delayms(6);

    LCDD7 = LCDD6 = LCDD5 = LCDD4 = 0;

    LCDEN=1;\

    LCDEN=0;

    delayms(6);

    LCDD5 = LCDD6 = 1;

    LCDD7 = LCDD4 = 0;

    LCDEN=1;

    LCDEN=0;

    delayms(6);

    VJCET, Vazhakulam23

  • 8/6/2019 Copy of Project_report (1)

    24/41

    RFID Based Toll System

    }

    void writec(unsigned char w)

    {

    if((w & 0x10)==0)LCDD4 = 0;

    else

    LCDD4 = 1;

    if((w & 0x20)==0) LCDD5 = 0;

    else LCDD5 = 1;

    if((w & 0x40)==0) LCDD6 = 0;

    else LCDD6 = 1;

    if((w & 0x80)==0) LCDD7 = 0;

    else LCDD7 = 1;

    LCDRS=DATA;

    LCDRW=0;

    LCDEN=1;

    LCDEN=0;

    delayms(6);

    if((w & 0x01)==0) LCDD4 = 0;

    else LCDD4 = 1;

    if((w & 0x02)==0) LCDD5 = 0;

    else LCDD5 = 1;

    if((w & 0x04)==0) LCDD6 = 0;

    else LCDD6 = 1;

    if((w & 0x08)==0) LCDD7 = 0;

    else LCDD7 = 1;

    LCDRS=DATA;

    LCDRW=0;

    LCDEN=1;

    LCDEN=0;

    delayms(6);

    }

    void writecmd(unsigned char c)

    VJCET, Vazhakulam24

  • 8/6/2019 Copy of Project_report (1)

    25/41

    RFID Based Toll System

    {

    if((c & 0x10)==0) LCDD4 = 0;

    else LCDD4 = 1;

    if((c & 0x20)==0) LCDD5 = 0;else LCDD5 = 1;

    if((c & 0x40)==0) LCDD6 = 0;

    else LCDD6 = 1;

    if((c & 0x80)==0) LCDD7 = 0;

    else LCDD7 = 1;

    LCDRS=COMM;

    LCDRW=0;

    LCDEN=1;

    LCDEN=0;

    delayms(6);

    if((c & 0x01)==0) LCDD4 = 0;

    else LCDD4 = 1;

    if((c & 0x02)==0) LCDD5 = 0;

    else LCDD5 = 1;

    if((c & 0x04)==0) LCDD6 = 0;

    else LCDD6 = 1;

    if((c & 0x08)==0) LCDD7 = 0;

    else LCDD7 = 1;

    LCDRS=COMM;

    LCDRW=0;

    LCDEN=1;

    LCDEN=0;

    delayms(6);

    }

    void writestr(char *s)

    {

    while(*s != 0x00)

    {

    writec(*s);

    VJCET, Vazhakulam25

  • 8/6/2019 Copy of Project_report (1)

    26/41

    RFID Based Toll System

    s++;

    }

    }

    void clrscr (void){

    writecmd(1);

    delayms(6);

    }

    usart.h

    void uart_init(void)

    {

    // Configure UART serial transmit

    // Configured for:

    // 9600 Baud

    // 8N1

    // SPBRG - Baud Rate Generator Register

    INTCON = 0x00; //[GIE PEIE tmr0ie inte rbie tmr0if intf rbif]

    PIE1 = 0x00; //[PSPIE ADIE RCIE TXIE SSPIE CCP1IE TMR2IE TMR1IE]

    SPBRG = 25; // 4MHz => 9600 baud (BRGH = 1)

    // BRGH - High Baud Rate Select Bit

    BRGH = 1; // (0 = low speed)

    // SYNC - USART Mode select Bit

    SYNC = 0; // (0 = asynchronous)

    TRISC7 = 1; // (1 = pin set as input) RX of USART

    TRISC6 = 0; // (0 = pin set as output)TX of USART

    // SPEN - Serial Port Enable Bit

    SPEN = 1; // (1 = serial port enabled)

    // TXIE - USART Transmit Interupt Enable Bit

    // TX9 - 9-bit Transmit Enable Bit

    TX9 = 0; // (0 = 8-bit transmit)

    // RX9 - 9-bit Receive Enable Bit

    RX9 = 0; // (0 = 8-bit reception)

    // TXEN - Trasmit Enable Bit

    VJCET, Vazhakulam26

  • 8/6/2019 Copy of Project_report (1)

    27/41

    RFID Based Toll System

    TXEN = 1; // (1 = transmit enabled)

    RCIE = 1; // (1 = enabled)

    // CREN - Continuous Receive Enable Bit

    CREN = 1; // (1 = Enables receiver)// GIE - Global Interrupt Enable Bit

    GIE = 0; // (1 = Enable all unmasked interrupts)

    // PEIE - Peripheral Interrupt Enable Bit

    PEIE = 1; // (1 = Enable all unmasked peripheral interrupts)

    }

    matrixkey.h

    // matrix key

    /* COL1 COL2 COL3 COL4 (INPUT-IDEAL.HI)

    ROW1 1 2 3 A

    ROW2 4 5 6 B

    ROW3 7 8 9 C

    ROW4 * 0 # D

    (OP.LOW)*/

    #define ROW1 RB0

    #define ROW2 RB1

    #define ROW3 RB2

    #define ROW4 RB3

    #define COL1 RB4

    #define COL2 RB5

    #define COL3 RB6

    #define COL4 RB7

    unsigned char matrixscan(void)

    {

    delayms(10);

    if(!COL1)

    {

    // COL1 colomn pressed

    delayms(15);

    VJCET, Vazhakulam27

  • 8/6/2019 Copy of Project_report (1)

    28/41

    RFID Based Toll System

    if(COL1)

    goto exit1;

    ROW1=ROW2=ROW3=ROW4=1; // putt all high

    ROW1=0;if(!COL1)

    return 1;

    ROW1=1;

    ROW2=0;

    if(!COL1)

    return 4;

    ROW2=1;

    ROW3=0;

    if(!COL1)

    return 7;

    ROW3=1;

    ROW4=0;

    if(!COL1)

    return '*';

    ROW4=1;

    }

    exit1:

    if(!COL2)

    {

    // COL2 colomn pressed

    delayms(15);

    if(COL2)

    goto exit2;

    ROW1=ROW2=ROW3=ROW4=1; // putt all high

    ROW1=0;

    if(!COL2)

    return 2;

    ROW1=1;

    ROW2=0;

    VJCET, Vazhakulam28

  • 8/6/2019 Copy of Project_report (1)

    29/41

    RFID Based Toll System

    if(!COL2)

    return 5;

    ROW2=1;

    ROW3=0;if(!COL2)

    return 8;

    ROW3=1;

    ROW4=0;

    if(!COL2)

    return 0x00;

    ROW4=1;

    }

    exit2:

    if(!COL3)

    {

    // COL3 colomn pressed

    delayms(15);

    if(COL3)

    goto exit3;

    ROW1=ROW2=ROW3=ROW4=1; // putt all high

    ROW1=0;

    if(!COL3)

    return 3;

    ROW1=1;

    ROW2=0;

    if(!COL3)

    return 6;

    ROW2=1;

    ROW3=0;

    if(!COL3)

    return 9;

    ROW3=1;

    VJCET, Vazhakulam29

  • 8/6/2019 Copy of Project_report (1)

    30/41

    RFID Based Toll System

    ROW4=0;

    if(!COL3)

    return '#';

    ROW4=1;}

    exit3:

    if(!COL4)

    {

    // COL1 clomn pressed

    delayms(15);

    if(COL4)

    goto exit4;

    ROW1=ROW2=ROW3=ROW4=1;// putt all high

    ROW1=0;

    if(!COL4)

    return 0x0A;

    ROW1=1;

    ROW2=0;

    if(!COL4)

    return 0x0B;

    ROW2=1;

    ROW3=0;

    if(!COL4)

    return 0x0C;

    ROW3=1;

    ROW4=0;

    if(!COL4)

    return 0x0D;

    ROW4=1;

    }

    exit4:

    return 0xFF;

    }

    VJCET, Vazhakulam30

  • 8/6/2019 Copy of Project_report (1)

    31/41

    RFID Based Toll System

    function.h

    #define MOTOR_EN RA0;

    #define PIN_MOTOR RA1;#define PIN_MOTOR1 RA2;

    echo(unsigned char x)

    {

    if(x = 0)

    {

    x += 0x30;

    writec(x);

    }

    else

    {

    switch(x)

    {

    case '*': writec('*');break;

    case '#': writec('#');break;

    case 0x0A: writec('A');break;

    case 0x0B: writec('B');break;

    case 0x0C: writec('C');break;

    case 0x0D: writec('D');break;

    }

    }

    }

    unsigned char compare()

    {

    unsigned char crd;

    unsigned char x;

    crd = 0;

    nextcrd:

    crd++;

    VJCET, Vazhakulam31

  • 8/6/2019 Copy of Project_report (1)

    32/41

    RFID Based Toll System

    for(x = 0; x

  • 8/6/2019 Copy of Project_report (1)

    33/41

    RFID Based Toll System

    writestr("ENTER AMOUNT+* :");

    writecmd(0xC0) ;

    do

    {ROW1=ROW2=ROW3=ROW4=0;

    nRBPU = 0;

    delayms(10);

    echo(key = matrixscan());

    if(key >= 0 && key

  • 8/6/2019 Copy of Project_report (1)

    34/41

    RFID Based Toll System

    // delay

    // rotate motor ACW direction

    PIN_MOTOR = 1;

    PIN_MOTOR1=0;delay(5000); // rotate for 5 sec

    PIN_MOTOR = 0;

    PIN_MOTOR1=1;

    }

    VJCET, Vazhakulam34

  • 8/6/2019 Copy of Project_report (1)

    35/41

    RFID Based Toll System

    7. PCB LAYOUT

    VJCET, Vazhakulam35

  • 8/6/2019 Copy of Project_report (1)

    36/41

    RFID Based Toll System

    8. FABRICATION OF PCB

    The printed circuit board(PCB) provides the electrical interconnections between

    various components and as well as provides mechanical support to the components. The

    components are soldered to the PCB. The quality of soldering directly affects the reliability

    of the circuit. The procedure for fabricating the PCB for any general project is described

    below.

    PCB MAKING

    The making of PCB essentially involves two steps.

    1.Preparing PCBdrawing

    2.Fabricating PCB from the drawing.

    PCB Drawing

    Making of PCB drawing involves placement of components , locating holes ,optimum area

    each componenet, should occupy, shape and size of pads for the componenets , track size and

    spacing and prevention of overcrowding of components at a particular area. With these

    details the sketch of the PCB is made.

    8.1 PCB FABRICATION

    The fabrication of the PCB starts by transferring the PCB drawing onto a copper clad sheet.

    For a small number of PCBs a direct photographic transfer of the PCB drawing from a

    negative image of the drawing to a photo sensitised copper clad sheet is carried out. The

    copper from the unexposed area is later etched away.

    For large quantity production, screen printing method is used to transfer the PCB drawing

    image to the copper clad sheet. For etching the copper clad sheet 20-30grms of ferric chloride

    in 75ml of water heated to about 60degree celsius may be used . The copper clad sheet is

    placed in the solution with its copper side upwards in a plastic tray. Stirring the solution

    VJCET, Vazhakulam36

  • 8/6/2019 Copy of Project_report (1)

    37/41

    RFID Based Toll System

    helps in speedy etching. The dissolution of unwanted copper would take about 45min. If

    etching takes longer, the solution may be heated again andthe process is repeated. The paint

    on the

    pattern can be removed by rubbing with a rag soaked in thinner, turpentine or acetone. The

    PCB can then be washed and dried. The pads are drilled with proper drill sizes

    of0.9mm,1mm,3mm etc for the leads and mounting holes.

    8.2 ASSEMBLY AND TESTING

    Assembly consists of soldering of components and wires on to the PCB and mechanical

    fitting of wired PCB and other assemblies. Testing is carried out even at design phase itself

    in breadboard level to verify the design, so that little or no circuit changes are required after

    designing the PCB.

    8.2.1 Soldering

    Before soldering, all the discrete components are tested. The leads of the components are

    cleaned with a fine abrasive paper. The PCB also thoroughly cleaned by scratching the areas

    to be soldered. The leads of the components are bend properly, inserted into the holes and

    placed correctly. A small quantity of flux is applied to the component leads and pads toremove the oxide coating. The leads are soldered with good quality solder with sufficient

    heat from the soldering iron. Excess heat will result in improper soldering and may damage

    the component. All the joints are checked after the soldering.

    8.2.2 Testing

    After soldering the components on to the PCB, the board is thoroughly cleaned for any

    residual flux and wire leads. All the components are checked for their value and for the

    proper orientation if applicable. Before ICs are inserted into the sockets, power applied to the

    board and voltages are measured at the IC power point. Power is switched off before the ICs

    are inserted

    Press the required switch and check whether the corresponding code is available at various

    stages (decoder and demultiplexer). If all these requirements are satisfied connect the

    required appliance in the circuit.

    VJCET, Vazhakulam37

  • 8/6/2019 Copy of Project_report (1)

    38/41

    RFID Based Toll System

    8.2.3Assembly

    The tested PCB is placed inside a plastic box in a compact manner. Four holes are drilled onthe box and bulb holders are fitted in it. A small hole is made in the box to connect the

    necessary wires to the AC supply.

    VJCET, Vazhakulam38

  • 8/6/2019 Copy of Project_report (1)

    39/41

    RFID Based Toll System

    9. CONCLUSION

    The project implements a toll system that allows only authorised people to pass

    through by verifying the password of the RFID card with that stored in the PIC. The system

    has a rfid module, PIC microcontroller based embedded system connected to a LCD module,

    Keyboard, and interfacing circuitry.

    This project has been successfully implemented. It was implemented on a small scale.

    The main objective of this project was to ensure a smooth flow of traffic at toll gates and to

    avoid congestions at toll gates. Also the use of cash has been eliminated totally. The whole

    system is simply controlled by this embedded system because of which man power is not

    required.

    This system is cost effective and motorists do not have to waste their valuable time on

    highways awaiting human assistance to make toll payments. This system is also user

    friendly.

    VJCET, Vazhakulam39

  • 8/6/2019 Copy of Project_report (1)

    40/41

    RFID Based Toll System

    10. FUTURE ENHANCEMENTS

    In the present situation vehicles will have to stop at the toll gate to

    make toll payments by swiping the cards. We can change the scenario by letting the vehicles

    pass through the toll gates wherein, their cards are pasted on the windshields. Thus saving

    time and free flow of traffic is also ensured.

    If the card does not have enough balance, vehicle owners will receive

    a message(sms) notifying them to recharge their cards. These cards can be recharged either

    by top up cards or by credit card transactions through the internet.

    VJCET, Vazhakulam40

  • 8/6/2019 Copy of Project_report (1)

    41/41

    RFID Based Toll System

    11. BIBLIOGRAPHY

    BOOKS REFERRED

    Rfid: Applications And Cases Krishna S Jaya

    SITES REFERRED

    www.engineersgarage.com

    www.microchip.com

    http://www.flipkart.com/author/krishna-s-jayahttp://www.flipkart.com/author/krishna-s-jaya