EngineersGarage

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

RFID BASED TOLLPLAZA

|

Microcontroller › 8051 › RFID BASED TOLLPLAZA

  • This topic has 16 replies, 5 voices, and was last updated 11 years, 6 months ago by ghuran.
Viewing 15 posts - 1 through 15 (of 17 total)
1 2 →
  • Author
    Posts
  • April 5, 2014 at 7:42 pm #3021
    ghuran
    Participant

    sir i have used microcontroller 8051 AT89C51 in my project .in my project there is a rfid tag which is need to be programmed using 8051 microcontroller .i have taken code from this site only,but it doesnot show any thing on the LCD.pls help me out where is the problem.

     

    the code is :-

     #include<reg51.h>

    #define port P1
    #define key P0  // Port for keypad
     void memory();
     
     sfr lcd_data_pin=0xA0;
     sbit rs = P1^3;
     sbit rw = P1^4;
     sbit en = P1^5;
     
     sbit col1=key^4;
     sbit col2=key^5;
     sbit col3=key^6;
     sbit row1=key^0;
     sbit row2=key^1;
     sbit row3=key^2;
     sbit row4=key^3;
     unsigned int number=0,pointer=1;
     unsigned char card_mem[4][12];
     unsigned char card_id[12],index=0,key1=0,lcd,print=0,new_user=0,recharge=0,user_index,t,tool=0;
     unsigned int amount[4];
     unsigned char current_byte = 0,money[6];
     unsigned char pos=0,set=0;
     
    void delay(unsigned char count) //Function to provide time delay
    {
      unsigned int j;
    unsigned char i;
      for(i=0;i<count;i++)
      for(j=0;j<1275;j++);
    }
     
    void lcd_command(unsigned char comm)   //LCD command funtion 
    {
      lcd_data_pin=comm;
      en=1;
      rs=0;
      rw=0;
      delay(1);
      en=0;
    }
     
    void lcd_data(unsigned char disp)  //LCD data function 
    {
      lcd_data_pin=disp;
      en=1;
      rs=1;
      rw=0;
      delay(1);
      en=0;
    }
     
    lcd_string(unsigned char *disp) //LCD string function 
    {
      char x;
      for(x=0;disp[x]!=0;x++)
    {
      lcd_data(disp[x]);
    }
    }
     
    void lcd_ini()  //Function to initialize the LCD
    {
    lcd_command(0x38);   
    delay(5);
    lcd_command(0x0F);        
    delay(5);
     
    }
     
    lcd_display(unsigned int val)
    {
    unsigned char flg=0;
    lcd_command(0xCC);
    if(val==0)
    lcd_data(‘0’);
    while(val>0)
    { 
    lcd=val%10;
    val=val/10;
    lcd_command(0xCC-flg);
    lcd_data(lcd+’0′);
    flg++;
    }
    }
     
     
    void recieve() interrupt 4 //Function to recieve data serialy from RS232 
    {
    card_id[current_byte]=SBUF;
    RI=0; // Reset the serial interrupt after recieving the byte
    current_byte++;
    }
     
    void display(unsigned char value)
    {
    lcd_command(0x80+pos);
    if(value==10)
    {
    print=1; 
    }
    if(value==12)
    {
    set=1; 
    }
    if(value<=9)
    {
    lcd_data(‘0’+value);
    money[pos]=value;
    pos++;
    }
    }
     
    check_col1()
    {
    row1=row2=row3=row4=1;
    row1=0;
    if(col1==0)
    display(1);
    row1=1;
    row2=0;
    if(col1==0)
    display(4);
    row2=1;
    row3=0;
    if(col1==0)
    display(7);
    row3=1;
    row4=0;
    if(col1==0)
    display(10);
    row4=1;
    }
     
    check_col2()
    {
    row1=row2=row3=row4=1;
    row1=0;
    if(col2==0)
    display(2);
    row1=1;
    row2=0;
    if(col2==0)
    display(5);
    row2=1;
    row3=0;
    if(col2==0)
    display(8);
    row3=1;
    row4=0;
    if(col2==0)
    display(0);
    row4=1;
    }
     
    check_col3()
    {
    row1=row2=row3=row4=1;
    row1=0;
    if(col3==0)
    display(3);
    row1=1;
    row2=0;
    if(col3==0)
    display(6);
    row2=1;
    row3=0;
    if(col3==0)
    display(9);
    row3=1;
    row4=0;
    if(col3==0)
    display(12);
    row4=1;
    }
     
    keypad()
    {
    row1=row2=row3=row4=0;
    if(col1==0)
    check_col1();
    if(col2==0)
    check_col2();
    if(col3==0)
    check_col3();
    }
      
    void show()
    {
    unsigned char count,i,key,val,flag=0,in;
    unsigned int balance,j;
    TMOD=0x00; //Enable Timer 1
    TH1=0x00;
    SCON=0x00;
    TR1=0;
    IE=0x00; 
    lcd_command(0x01);
    val=index;
    for(i=0;i<index;i++)
    { 
    key=0;
    for(count=0;count<12;count++)
    { 
    if(card_id[count]==card_mem[count])
    {
    key++;
    }
    }
    if(key==12)
    {
    flag=1;
    if(amount<=10)
    {
    user_index=i;
    lcd_string(“Insuff. balance”);
    lcd_command(0xC0);
    lcd_string(“Pls recharge”);
    delay(250);
    lcd_command(0x01);
    lcd_string(“To recharge”);
    lcd_command(0xC0);
    lcd_string(“press *”);
    for(in=0;in<250;in++)
    {
    for(j=0;j<1275;j++)
    {
    row1=row2=row3=row4=0;
    if(col1==0)
    {
    tool=1;
    recharge=1;
    t=1;
    keypad();
    break;
    }
    }
    if(t==1)
    break;
    }
    lcd_command(0x01);
    lcd_string(“Pls scan your ID”);
    break;  
    }
    if(tool==0)
    {
    lcd_string(“Thank you User “);
    lcd_command(0x8F);
    lcd_data(49+i);
    delay(250);
    lcd_command(0x01);
    lcd_string(“Charges 10.00”);
    amount=amount-10;
    lcd_command(0xC0);
    lcd_string(“Amt left  “);
    balance=amount;
    lcd_display(balance);
    lcd_command(0xCD);
    lcd_string(“.00”);
    delay(250);
    lcd_command(0x01);
    if(amount<=30)
    {
    user_index=i;
    lcd_string(“Pls recharge”);
    lcd_command(0xC0);
    lcd_string(“your account”);
    delay(250);
    lcd_command(0x01);
    lcd_string(“To recharge”);
    lcd_command(0xC0);
    lcd_string(“press *”);
    for(in=0;in<250;in++)
    {
    for(j=0;j<1275;j++)
    {
    row1=row2=row3=row4=0;
    if(col1==0)
    {
    recharge=1;
    t=1;
    keypad();
    break;
    }
    }
    if(t==1)
    break;
    } 
    }
    }
    t=0;
    lcd_command(0x01);
    lcd_string(“Pls scan your ID”); 
    break;
    }
    }
    if(flag==0)
    {
    lcd_string(“Wrong ID”);
    delay(100);
    }
    if(flag==0)
    {
    lcd_command(0x01);
    lcd_string(“New user press *”);
    new_user=1;
    }
    current_byte=0;
    tool=0;
    TMOD=0x20; //Enable Timer 1
    TH1=0xFD;
    SCON=0x50;
    TR1=1;
    IE=0x94;
    }
     
    recharge_acc()
    {
    unsigned char pin;
    lcd_command(0x01);
    lcd_string(“Pls enter the”);
    lcd_command(0xC0);
    lcd_string(“Balance”);
    delay(250);
    lcd_command(0x01);
    while(set!=1)
    {
    keypad();
    delay(40); 
    }
    set=0;
    lcd_command(0x01);
    lcd_string(“Your balance is”);
    for(pin=0;pin<=pos;pin++)
    {
    number=number+money[pos-pin-1]*pointer;
    pointer=pointer*10;
    }
    amount[user_index]=amount[user_index]+number;
    lcd_command(0xC0);
    lcd_display(amount[user_index]);
    lcd_command(0xCD);
    lcd_string(“.00”);
    delay(250);
    lcd_command(0x01);
    number=0;
    pointer=1;
    pos=0;
    lcd_string(“Pls scan your ID”);
    }
     
    void memory()
    {
    unsigned char i,key=0,count,pin,try=0;
    lcd_command(0x01);
    lcd_string(“New user scan ID”);
    current_byte=0;
    while(current_byte!=12);
    for(i=0;i<4;i++)
    { 
    key=0;
    for(count=0;count<12;count++)
    { 
    if(card_id[count]==card_mem[count])
    {
    key++;
    }
    }
    if(key==12)
    {
    lcd_command(0x01);
    lcd_string(“Sorry ! You are”);
    lcd_command(0xC0);
    lcd_string(“already an user”); 
    delay(200);
    lcd_command(0x01);
    lcd_string(“Pls scan your ID”);
    key=0;
    try=1;
    current_byte=0;
    break;
    }
    }
    if(key<12 && try==0)
    {
    key=0;
    for(i=0;i<12;i++)
    {
    card_mem[index]=card_id;
    }
    current_byte=0;
    lcd_command(0x01);
    lcd_string(“Pls scan again”);
    while(current_byte!=12);
    for(i=0;i<12;i++)
    {
    if(card_mem[index]==card_id)
    {
    key++;
    }
    }
    current_byte=0;
    TMOD=0x00;
    TH1=0x00;
    SCON=0x00;
    TR1=0;
    IE=0x00; 
    if(key==12)
    {
    lcd_command(0x01);
    lcd_string(“Congratulation !”);
    lcd_command(0xC0);
    lcd_string(“You are User”);
    lcd_command(0xCC);
    lcd_data(index+49);
    delay(250);
    lcd_command(0x01);
    lcd_string(“Pls enter the”);
    lcd_command(0xC0);
    lcd_string(“Balance”);
    delay(150);
    lcd_command(0x01);
    while(set!=1)
    {
    keypad();
    delay(40); 
    }
    set=0;
    lcd_command(0x01);
    lcd_string(“Your balance is”);
    for(pin=0;pin<=pos;pin++)
    {
    number=number+money[pos-pin-1]*pointer;
    pointer=pointer*10;
    }
    lcd_command(0xC0);
    lcd_display(number);
    lcd_command(0xCD);
    lcd_string(“.00”);
    amount[index]=number;
    delay(250);
    lcd_command(0x01);
    number=0;
    pointer=1;
    pos=0;
    lcd_string(“Pls scan your ID”); 
    }
    else
    {
    lcd_command(0x01);
    lcd_string(“ERROR”);
    delay(200);
    for(i=0;i<12;i++)
    {
    card_mem[index]=0;
    }
    lcd_command(0x01);
    lcd_string(“Pls scan your ID”);
    }
    if(key==12)
    index++;
    }
    TMOD=0x20; //Enable Timer 1
    TH1=0xFD;
    SCON=0x50;
    TR1=1;
    IE=0x94;
    }
     
    void main()
    {
    col1=col2=col3=1;
    TMOD=0x20;
    TH1=0xFD;
    SCON=0x50;
    TR1=1;
    IE=0x94;
    lcd_ini(); //Place cursor to second position of first line 
    lcd_string(“Pls scan your ID”);
    while(1)
    {
    row1=row2=row3=row4=0;
    if(col1==0)
    {
    keypad();
    }
    if(print==1 && new_user==1)
    {
    memory();
    print=0;
    new_user=0;
    }
    if(print==1 && recharge==1)
    {
    recharge_acc();
    print=0;
    recharge=0;
    }
    if(current_byte==12)
    {
    show();
    }
    }
    }
     
        
     
      sir pls reply me back as soon as possible…
     
     
    April 6, 2014 at 6:11 am #11475
    khushi
    Participant

    hi ghuran,

     

    Please use port 0 for Data lines that is D0-D7.

     

    I mean to say instead of  sfr lcd_data_pin=0xA0; use address 0x80.

     

    it will work. u try this & let me know.

    April 6, 2014 at 11:08 am #11477
    SHAH DISHANT H.
    Participant

    Hi,

     

    lcd_string(unsigned char *disp) //LCD string function 
    {
      char x;
      for(x=0;disp[x]!=’’;x++)
    {
      lcd_data(disp[x]);
    }
    }
     
    Correct this function…!!!
     
    First check LCD without RFID…
    April 6, 2014 at 1:02 pm #11485
    ghuran
    Participant

    khushi ma’m

                             

                         i hv made d changes as u said, and i simulate the project on ‘proteus’ , but i still get nothing on LCD.

              can u please simulate it on proteus..

                

    April 6, 2014 at 1:06 pm #11486
    ghuran
    Participant

    SHAH DISHANT H. sir

                                

                                   i hv made the changes in the programme but i still get nothing.

     

                                      please help me out of this…

                                            thank u

    April 6, 2014 at 8:15 pm #11487
    ghuran
    Participant

    Hi,

        

           i have made the changes in programme  and it works,but it only print “pls scan your ID”

             and after that it prints “4 times 1369”. please refer the project “RFID BASED TOLL PLAZA”

                pls help me…!! 

    April 7, 2014 at 4:29 am #11488
    SHAH DISHANT H.
    Participant

    Hi,

     

     

    In receive interrupt, provide delay. It seems its scanning TAG many times when you are moving it only once.

     

    Try with enough Delay and post result back.

    April 7, 2014 at 6:50 pm #11497
    khushi
    Participant

    hi ghuran,

     

    In my previous post u did that minor changes only.

     

    all the lcd function given in code which u have mentioned is correct.

     

    Please see the below simulation which i have done, i think so u r suppose to missing to keep “resistor array”. i. e Pull up resistor.

     

    b’coz Port P0 is open collector port so that it requires.

     

    u do it this kind of arrangement it will  definetely work.

     

    wysiwyg_imageupload:12117:

    April 7, 2014 at 7:49 pm #11498
    ghuran
    Participant

    Hi,

            khushi ma’m i hv done the simulation , on the lcd it prints “pls scan your id”, but after that it automatically takes 4 times 1369….

                           here is the simulation..

     

                          

    wysiwyg_imageupload:12119:

    April 7, 2014 at 9:37 pm #11499
    ghuran
    Participant

    Hi, 

          

             i hv successfully done my project, thanxx a lot to KHUSHI ma;m & DISHANT sir

     

                 but i’m facing one problem with kepad, when i pressed the keyword it only print 1,4,7

                   and for other keywords it prints after i pressed many times…..

                    

                      pls let me know…

     

    April 8, 2014 at 4:38 pm #11507
    khushi
    Participant

    hi ghuran,

     

    many congratulations.

     

    every keypad routine checks key debounce so once u decrease  it time delay, it will not prints slow.

     

    one more thing here in the program which u have posted is checking that if key is pressed continually it will print the no. until u release it.

     

    other wise the program is upto date no more changes are required.

     

     

    please check once again ghuran. 

    April 10, 2014 at 3:29 am #11511
    SHAH DISHANT H.
    Participant

    Congrats…!!

     

    Solve keypad with less delay…!!! If not solved, I will send you my tested code for that…!!!

     

     

    Keep one thing in mind…!!

    Once you have completed your project, do not forget to share it with all…!!!

     

    All the best…!!

    April 17, 2014 at 4:28 am #11579
    kailey jazyln
    Participant

    hello Sir ,

      Please provide me the correct code of Automatic toll vechicle cateogry system…………………. keypad not working i have to place on another port regardless P0..

    April 17, 2014 at 10:12 am #11580
    sachin kumar dagur
    Participant

    Hi.. jhuran can u please provide me the corrected code of Rfid based toll collection system i have also facing same keypad problem in my hardware. pls. share the code so that i can complete my project hardware.

     pls reply me back as soon as possible…

    April 17, 2014 at 10:19 am #11582
    sachin kumar dagur
    Participant

    hello Dishant Sir ,

                                  I m facing problem in toll collection vechicle category system in keypad connected at PORT 0 in hardware pls suggest me the solution . 

                                   

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

RSS Recent Posts

  • Panasonic RQ-A170 Walkman recorder November 16, 2025
  • Looking for obsolete item from Parallax November 16, 2025
  • Can a small solar panel safely trickle-charge old NiMH AA batteries? November 16, 2025
  • TraxMaker Pro? I only have the non-Pro version. Looking for the Pro version that has the integrated pick and place coordinates export. November 16, 2025
  • ESP32-S3 started outputting NMEA GPS location frames after EMC disturbance — what mode is this? November 15, 2025

Stay Up To Date

Newsletter Signup
EngineersGarage

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

Search Engineers Garage

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