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
You are here: Home / Topics / programming problem in my rfid based metro system.

programming problem in my rfid based metro system.

|

Projects › Projects › programming problem in my rfid based metro system.

  • This topic has 1 reply, 2 voices, and was last updated 8 years, 4 months ago by Ashutosh Bhatt.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • April 4, 2014 at 5:28 am #3016
    yash mittal
    Participant

    sir i have used microcontroller 8051 AT89S52 in my project .in my project there is a rfid tag which is need to be programmed using 8051 microcontroller .IN my project when the rfid tag is brought near to the rfid reader the screen of the led will show”TOTAL AMOUNT.”a beep sound will create and the motor will open the gate and the passenger will go into the metro.actually sir the code which i have used in my project i cannot understand it.please help me to understand it.sir i have pasted my code below .sir please explain this code at earliest to me.

     

                       // RFID BASED METRO TRAIN PROTOTYPE

    #include<reg51.h>

     

    sbit START_POINT=P3^2;

    sbit TERMINATE_POINT=P3^3;

     

    sbit S1=P0^0;

    sbit S2=P0^1;

    sbit S3=P0^2;

    sbit S4=P0^4;

     

    sbit BUZZPORT=P1^7;

     

    sbit RS=P3^6;

    sbit EN=P3^7;

     

    void lcdinit();

    void lcdData(unsigned char l);

    void lcdcmd(unsigned char k);

    void buzzer(unsigned int time);

    void DelayMs(unsigned int count);

    void display(unsigned char s, t, u,v);

    void Welcome(unsigned char c[],unsigned char d[]);

    void ConvertAndDisplay(signed int value1);

    void delaysec(unsigned char i);

    void dcMotor();

     

    void main()

    {

    unsigned char i=0;

    unsigned int j=0;

    unsigned char c[15];

    signed int amount1=1000;

    signed int amount2=1000;

     

    BUZZPORT=0;

     

    S1=1;

    S2=1;

    S3=1;

    S4=1;

     

    lcdinit();

    Welcome(“RFID BASED”,”METRO TRAIN PROTOTYPE:”);

    DelayMs(1000);

     

    while(1)

    {

    known:

    while(1)

    {

    for(i=0;i<11;i++)                       

    {

    c=0xFF;

    }

     

    while(RI==0);

     

    for(i=0;i<10;i++)                          //command to recv data

    {

    j=0;

    while(RI==0)

    {

    if(j>=1000)

    goto timeout;

    DelayMs(1);

    j++;

    }

    c=SBUF;

    RI=0;

    }

    timeout:

    for(i=0;i<15;i++)

    {

     

    if(c==’4′ && c[i+1]==’2′ && c[i+2]==’0′ && c[i+3]==’0′ && c[i+4]==’6′ && c[i+5]==’B’ && c[i+6]==’6′ && c[i+7]==’1′ && c[i+8]==’9′ && c[i+9]==’1′

    )

    {

    lcdinit();

    Welcome(“PRESS A BUTTON”,”TO ENTER STATION”);

    while(S1==1 &&  S2==1 && S3==1 && S4==1);

    if(S1==0)

    {

    while(S1==0);

    Welcome(“STATION1 Amount:”,”Detected:10″);

    DelayMs(1000);

    amount2-=10;

    }

     

    if(S2==0)

    {

    while(S2==0);

    Welcome(“STATION2 Amount:”,”Detected:20″);

    DelayMs(1000);

    amount2-=20;

    }

     

    if(S3==0)

    {

    while(S3==0);

    Welcome(“STATION3 Amount:”,”Detected:30″);

    DelayMs(1000);

    amount2-=30;

    }

     

    if(S4==0)

    {

    while(S4==0);

    Welcome(“STATION4 Amount:”,”Detected:40″);

    DelayMs(1000);

    amount2-=40;

    }

     

    if(amount2>=0)

    {

    ConvertAndDisplay(amount2);

    dcMotor();

    }

    else

    {

      Welcome(“VISITOR A Amount:”,”BALANCE NIL”);

      buzzer(10);

    }

    if(amount2==20)

    {

     

                    

      Welcome(“VISITOR A Amount:”,”BALANCE LOW”);

      buzzer(10);

     

    }

    DelayMs(1000);

     

     

     

     

    goto known;

    }

     

     

     

    }

    }

    }

    }

    void Welcome(unsigned char c[],unsigned char d[])

    {

    unsigned int i=0;

     

    lcdcmd(0x01);

    DelayMs(10);

    lcdcmd(0x80);

    DelayMs(10);

     

    i=0;

    while(c!=’’)

    {

    lcdData(c);

    i++;

    }

     

    lcdcmd(0xc0);

    DelayMs(10);

     

    i=0;

    while(d!=’’)

    {

    lcdData(d);

    i++;

    }

    }

     

     

    void delaysec(unsigned char i)

    {                                

    unsigned char x;

            for(x=0;x<i;x++)

            {

                    DelayMs(250);

                    DelayMs(250);

     

                   

            }

    }

     

     

     

    void ConvertAndDisplay(signed int value1)

    {

    unsigned int i,a=0,b=0;

    unsigned char c[]=”BALANCE AMOUNT”;

    unsigned char d1,d2,d3,d4;

     

     

    while(value1!=0)

    {

            a++;

     

            

             b=value1%10;

             value1=value1/10;

             switch(a)

             {

                      case 1:

                                    d4=b;

                                    break;

                    case 2:

                                    d3=b;

                                    break;

                    case 3:

                                    d2=b;

                                    break;

                    case 4:

                                    d1=b;

                                    break;

                    default:

                                    break;

     

     

             }

     

     

    }

    lcdcmd(0x01);

    DelayMs(10);

    lcdcmd(0x80);

    DelayMs(10);

     

    i=0;

    while(c!=’’)

    {

    lcdData(c);

    i++;

    }

     

     

     

    display(d1,d2,d3,d4);

    }

    //


    // Lcd initialization subroutine

    //


    void lcdinit(void)

    {

    lcdcmd(0x38);

    DelayMs(250);

    lcdcmd(0x0E);

    DelayMs(250);

    lcdcmd(0x01);

    DelayMs(250);

    lcdcmd(0x06);

    DelayMs(250);

    lcdcmd(0x80);

    DelayMs(250);

    }

     

    //


    // Lcd data display

    //


    void lcdData(unsigned char l)

    {

    P2=l;

    RS=1;

    EN=1;

    DelayMs(1);

    EN=0;

    return;

    }

     

    //


    // Lcd command

    //


    void lcdcmd(unsigned char k)

    {

    P2=k;

    RS=0;

    EN=1;

    DelayMs(1);

    EN=0;

    return;

    }                          

     

    //


    // Delay mS function

    //


    void DelayMs(unsigned int count)

    {  // mSec Delay 11.0592 Mhz

        unsigned int i;                      // Keil v7.5a

        while(count) {

            i = 115;                          // 115        exact value

                    while(i>0)

                    i–;

            count–;

        }

    }

    void dcMotor()

    {

                    START_POINT=1;

                    TERMINATE_POINT=0;

                    delaysec(1);

                    START_POINT=0;

                    TERMINATE_POINT=0;

                    delaysec(5);

                    START_POINT=0;

                    TERMINATE_POINT=1;        

                    delaysec(1);

                    START_POINT=0;

                    TERMINATE_POINT=0;                        

    }

     

    void display(unsigned char s, t, u,v)

    {

    lcdcmd(0xc0);

    DelayMs(10);

    s=s+0x30;

    t=t+0x30;

    u=u+0x30;

    v=v+0x30;

    lcdData(s);

    DelayMs(10);

    lcdData(t);

    DelayMs(10);

    lcdData(u);

    DelayMs(10);

    lcdData(v);

    DelayMs(10);

    }

    void buzzer(unsigned int time)

    {

                   

                    BUZZPORT=1;

                     DelayMs(time);

                     BUZZPORT=0;

    }

    SIR PLEASE EXPLAIN IT FULLY TO ME…..you can mail me explanation of this code on my gmail id – [email protected]

     

     

    April 5, 2014 at 1:35 pm #11472
    Ashutosh Bhatt
    Participant

    you need to understand functionality bro.

    the code is just implementation of functionality.

    try to understand your project fully u will get the idea what the code does

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

RSS Recent Posts

  • How know if solder iron has good quality tip? August 18, 2022
  • How does a transistor works as a switch? August 18, 2022
  • Peltier control August 18, 2022
  • How to set USB port as RS-485 entrance? How to interpret Growatt solar inverter commands? August 18, 2022
  • Component Identification August 18, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 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