1st Rev Road Ragging

download 1st Rev Road Ragging

of 45

Transcript of 1st Rev Road Ragging

  • 8/2/2019 1st Rev Road Ragging

    1/45

    TRAFFIC SCRUNITING SYSTEM

    ON ROAD RAGGING

  • 8/2/2019 1st Rev Road Ragging

    2/45

    ABSTRACT

    our proposed project aims to control the traffic,

    and save time and their by providing space for their

    movement .( for emergency vehicle such as

    ambulance,govt vehicles etc) .

    ####### copy from base paper #########

  • 8/2/2019 1st Rev Road Ragging

    3/45

    INTRODUCTION

    In cities, traffic control can become chaotic when anemergency vehicle must travel through a busy intersection.The device, will transmit signals to traffic lights in trafficjunctions. The signal will command all other junction lightsto turn red so that the emergency vehicle (an ambulance,fire engine or police car) can make a safe path through busyintersections. As a result, the vehicle will get to itsdestination in a way that is safe for those inside it and forothers on the road. The project will involve designing thewireless transceiver to be connected to the control circuit of

    the junction and a corresponding transmitter for the vehicle.They will also keep constant surveillance on the junctionbecause it is so busy.

  • 8/2/2019 1st Rev Road Ragging

    4/45

  • 8/2/2019 1st Rev Road Ragging

    5/45

    Second Vehicle

    ATMEL

    Micro Controller

    AT89S52

    Power Supply

    Max 232

    ZigbeeIEEE 802.15.4

    LCD

    2 x 16

  • 8/2/2019 1st Rev Road Ragging

    6/45

    Master Vehicle

    ATMEL

    Micro Controller

    AT89S52

    Power Supply

    Max 232

    ZigbeeIEEE 802.15.4

    LCD

    2 x 16

  • 8/2/2019 1st Rev Road Ragging

    7/45

    Base Station

    ATMEL

    Micro controller

    AT89S52

    Power Supply

    Signal 1

    Signal 2

  • 8/2/2019 1st Rev Road Ragging

    8/45

    #include

    void delay(unsigned int);

    void lcd_data(unsigned char);

    void lcd_command(unsigned char);void lcd_str(unsigned char*);

    sbit irin=P0^7;

    sbit trans=P0^6;

    sbit rled=P1^5;

    sbit yled=P1^6;

    sbit gled=P1^7;sbit rs=P3^2;

    sbit rw=P3^3;

    sbit en=P3^4;

    sfr p0=0x80;

    sfr p1=0x90;

    sfr p2=0xA0;sfr p3=0xB0;

    void main()

    {

    unsigned char T,G;

    p0=0xff;

  • 8/2/2019 1st Rev Road Ragging

    9/45

    rs=0;

    rw=0;

    en=0;

    TMOD=0x21;

    TH1=0xFD;

    SCON=0x50;

    TR1=1;

    lcd_command(0x01);

    lcd_command(0x0E);

    lcd_command(0x38);

    lcd_command(0x80);

    delay(14);

    lcd_data('p');

    SBUF='p';

    while(TI==0);TI=0;

    lcd_data('a');

    SBUF='a';

    while(TI==0);

    TI=0;

  • 8/2/2019 1st Rev Road Ragging

    10/45

    lcd_data('r');

    SBUF='r';

    while(TI==0);

    TI=0;

    lcd_data('i');

    SBUF='i';

    while(TI==0);

    TI=0;

    lcd_data('n');SBUF='n';

    while(TI==0);

    TI=0;

    lcd_data('g');

    SBUF='g';while(TI==0);

    TI=0;

    delay(5);

    lcd_command(0x80);

    lcd_str("Traffic System");

    while(1)

  • 8/2/2019 1st Rev Road Ragging

    11/45

    {

    lcd_command(0x01);

    lcd_command(0x0E);

    lcd_command(0x80);

    yled=0;

    lcd_command(0x80);lcd_str("yellow");

    delay(42);

    lcd_command(0x01);

    yled=1;

    gled=0;

    lcd_command(0x80);lcd_str("green");

    delay(180);

    lcd_command(0x01);

    gled=1;

    INTERRUPT:

    rled=0;lcd_command(0x80);

    lcd_str("red");

    for(T=0;T

  • 8/2/2019 1st Rev Road Ragging

    12/45

    if(trans==0)

    {

    lcd_command(0xC0);

    lcd_str("scanning");

    lcd_command(0xC0);

    lcd_str("signal sending");delay(14);

    SBUF='A';

    while(TI==0);

    TI=0; delay(103);

    SBUF='B';

    while(TI==0);TI=0;

    lcd_command(0xC0);

    lcd_str(" ");

    }

    delay(G);

    }lcd_command(0x01);

    gled=1;

    yled=0;

    lcd_command(0x80);

    lcd_str("yellow");

    delay(42);lcd command 0x01

  • 8/2/2019 1st Rev Road Ragging

    13/45

    gled=0;

    lcd_command(0x01);

    lcd_command(0x80);

    lcd_str("green");for(G=0;G

  • 8/2/2019 1st Rev Road Ragging

    14/45

    }

    delay(G);

    }

    lcd_command(0x01);

    gled=1;

    yled=0;lcd_command(0x80);

    lcd_str("yellow");

    delay(42);

    lcd_command(0x01);

    yled=1;

  • 8/2/2019 1st Rev Road Ragging

    15/45

    goto INTERRUPT;

    }

    delay(T);

    }

    lcd_command(0x01);rled=1;

    }

    }

    void lcd_str(unsigned char *disp)

    {

    int x;

    for(x=0;disp[x]!='\0';x++)

    {

    lcd_data(disp[x]);

    }

    }

    id d l ( i d i )

  • 8/2/2019 1st Rev Road Ragging

    16/45

    void delay(unsigned int n)

    {

    int i;

    for(i=0;i

  • 8/2/2019 1st Rev Road Ragging

    17/45

    void lcd_data(unsigned char k)

    {

    p2=k;

    rs=1;

    rw=0;

    en=1;delay(1);

    en=0;

    }

  • 8/2/2019 1st Rev Road Ragging

    18/45

    #include

    void lcd_data(unsigned char);

    void lcd_command(unsigned char);

    void delay(unsigned int);

    void lcd_str(unsigned char *);

    sbit rs=P3^2; sbit rw=P3^3;

    sbit en=P3^4;

    sbit buzzer=P3^7;

    sfr p0=0x80;

    sfr p1=0x90;

    sfr p2=0xA0;

    sfr p3=0xB0;

    unsigned char temp,input,i;

    id i ()

  • 8/2/2019 1st Rev Road Ragging

    19/45

    void main()

    {

    TMOD=0x21;

    TH1=0xFD;

    SCON=0x50;

    TR1=1;lcd_command(0x01);

    lcd_command(0x0E);

    lcd_command(0x38);

    lcd_command(0x80);

    buzzer=1;

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;

    lcd_data(input);

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;

    lcd_data(input);

    hil (RI 0)

  • 8/2/2019 1st Rev Road Ragging

    20/45

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;

    lcd_data(input);

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;

    lcd_data(input);

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;

    lcd_data(input);

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;

    lcd_data(input);

  • 8/2/2019 1st Rev Road Ragging

    21/45

    delay(3);

    lcd_command(0x80);

    lcd_str(" First Vehicle ");

    while(1)

    {

    lcd_command(0xC0);

    lcd_str(" ");

    lcd_command(0xC0);

    while(RI==0);

    temp=SBUF; RI=0;

    input=temp;

    if(input=='A')

    {

    lcd_str("amb : way please");

    buzzer=0;

    lcd_command(0xC0);

    lcd_str(" scanning ");

    lcd_command(0xC0);

    delay(5);

  • 8/2/2019 1st Rev Road Ragging

    22/45

    lcd_str("signal sending");

    delay(70);

    buzzer=1;

    }

    }

    }

    void lcd_str(unsigned char *disp)

    {

    int x;

    for(x=0;disp[x]!='\0';x++)

    {

    lcd_data(disp[x]);

    } }

    void lcd_command(unsigned char a)

    {

    p2=a;

    rs=0;

    rw=0;

    en=1; delay(1);

    en=0;

    }

    void lcd data(unsigned char b)

  • 8/2/2019 1st Rev Road Ragging

    23/45

    void lcd_data(unsigned char b)

    {

    p2=b;

    rs=1;

    rw=0;

    en=1;delay(1);

    en=0;

    }

    void delay(unsigned int n){

    int i;

    for(i=0;i

  • 8/2/2019 1st Rev Road Ragging

    24/45

    #include

    void lcd_data(unsigned char);

    void lcd_command(unsigned char);

    void delay(unsigned int);

    void transmit(unsigned char);

    void lcd_str(unsigned char *);sbit rs=P3^2;

    sbit rw=P3^3;

    sbit en=P3^4;

    sbit buzzer=P3^7;

    sbit led=P1^7;

    sfr p0=0x80;sfr p1=0x90;

    sfr p2=0xA0;

    sfr p3=0xB0;

    unsigned char temp,input,i;

    void main()

    {TMOD=0x21;

    TH1=0xFD;

    SCON=0x50;

    TR1=1;

  • 8/2/2019 1st Rev Road Ragging

    25/45

    TR1=1;

    lcd_command(0x01);

    lcd_command(0x0E);

    lcd_command(0x38);

    lcd_command(0x80);

    buzzer=1;

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;lcd_data(input);

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;lcd_data(input);

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;lcd_data(input);

    while(RI==0);

  • 8/2/2019 1st Rev Road Ragging

    26/45

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;

    lcd_data(input);

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;

    lcd_data(input);

    while(RI==0);

    temp=SBUF;

    RI=0;

    input=temp;

    lcd_data(input);

    delay(3);

    lcd_command(0x80);

    lcd_str(" Second Vehicle ");

    while(1)

  • 8/2/2019 1st Rev Road Ragging

    27/45

    while(1)

    {

    lcd_command(0xC0);

    lcd_str(" ");

    lcd_command(0xC0);

    while(RI==0);temp=SBUF;

    RI=0;

    input=temp;

    if(input=='B')

    {

    lcd_str("amb : way please");delay(14);

    for(i=0;i

  • 8/2/2019 1st Rev Road Ragging

    28/45

    void lcd_str(unsigned char disp)

    {

    int x;

    for(x=0;disp[x]!='\0';x++)

    {

    lcd_data(disp[x]);

    }

    }

    void lcd_command(unsigned char a)

    {

    p2=a;

    rs=0;

    rw=0;

    en=1;delay(1);

    en=0;

    }

  • 8/2/2019 1st Rev Road Ragging

    29/45

    void lcd_data(unsigned char b)

    {

    p2=b;

    rs=1;

    rw=0;en=1;

    delay(1);

    en=0;

    }

    void delay(unsigned int n)

    {

    int i;

    for(i=0;i

  • 8/2/2019 1st Rev Road Ragging

    30/45

  • 8/2/2019 1st Rev Road Ragging

    31/45

    Microcontroller -AT89S52

    Microcontroller is a microprocessor designedspecifically for control applications, and isequipped with ROM, RAM and facilities I / O

    on a single chip. AT89S52 is one of the family MCS-51/52

    equipped with an internal 8 Kbyte FlashEPROM (Erasable and Programmable Read

    Only Memory), which allows memory to bereprogrammed.

  • 8/2/2019 1st Rev Road Ragging

    32/45

    AT89S52 Microcontroller Features :

    A CPU (Central Processing Unit) 8 Bit. 256 bytes of RAM (Random Access Memory) internally. Four-port I / O, which each consist of eight bits the internal oscillator and timing circuits. Two timer / counters 16 bits Five interrupt lines (two fruits and three external interrupt

    internal interruptions). A serial port with full duplex UART (Universal Asynchronous

    Receiver Transmitter). Able to conduct the process of multiplication, division, and

    Boolean. the size of 8 KByte EPROM for program memory. Maximum speed execution of instructions per cycle is 0.5 s at 24

    MHz clock frequency.If the microcontroller clock frequency used is 12 MHz, the speed is1 s instruction execution

  • 8/2/2019 1st Rev Road Ragging

    33/45

    Pin Configuration

    Th f ti f h i AT89S52 i

  • 8/2/2019 1st Rev Road Ragging

    34/45

    The function of each pin AT89S52 is:Pin 1 to 8 (Port 1) is an 8-bit parallel port of a two-way (bidirectional) that can be used for different

    purposes (general purpose).

    Pin 9 is a pin reset, reset is active if a high ration.

    P3.0 (10): RXD (serial port data receiver) P3.1 (11): TXD (serial port data sender)

    P3.2 (12): INT0 (external interrupt 0 input, active low)

    P3.3 (13): INT1 (ekstrernal an interrupt input, active low)

    P3.4 (14): T0 (external input timer / counter 0)

    P3.5 (15): T1 (external input timer / counter 1)

    P3.6 (16): WR (Write, active low) control signal from port 0 write data to memory and input-output

    data externally. P3.7 (17): RD (Read, active low) control signal of the reading of input-output data memory

    external to the port 0. XTAL pin 18 as the second, the output is connected to the crystal oscillator.

    XTAL pin 19 as the first, high berpenguatan input to the oscillator, connected to the crystal.

    Pin 20 as Vss, is connected to 0 or ground on the circuit.

    Pin 21 to 28 (Port 2) is 8 bits parallel ports in both directions. This port sends the address byte when

    accessing external memory is carried on.

    Pin 29 as the PSEN (Program Store Enable) is the signal used for reading, move the program theexternal memory (ROM / EPROM) to microcontroller (active low).

    Pin 30 as the ALE (Address Latch Enable) to hold down the address for accessing external memory.

    This pin also functions as a prog (active low) that is activated when the internal program flash

    memory on the microcontroller (on chip).

    Pin 31 as the EA (External Accesss) to select the memory to be used, the internal program memory

    (EA = Fcc) or external program memory (EA = Vss)

  • 8/2/2019 1st Rev Road Ragging

    35/45

    ZigBee Protocol

    ZigBee is a

    Networking Protocol

    that Rides on top of

    the IEEE 802.15.4Radio Protocol

    802.15.4 Specifications

    Supported Networks Point-Point

    Point-Multipoint/Star

    Types of Nodes

    Coordinator End Node

    Reliable Delivery

    CSMA/CA

    MAC-level (pt-pt)

    Retries/Acknowledgments

    64-bit IEEE and 16-bit short

    Addressing

    16 DSSS RF Channels

  • 8/2/2019 1st Rev Road Ragging

    36/45

    802.15.4 Protocol

  • 8/2/2019 1st Rev Road Ragging

    37/45

    ZIGBEE SPECIFICATIONS

    Addressing

    64-bit IEEE Address

    Unique to every 802.15.4 device in the world

    Permanent, assigned during mfg

    16-bit Network Addressing

    Unique to each module within a PAN

    Used in Routing Tables

    Used for data transmissions, etc.

    Volatile Address - Can Change

  • 8/2/2019 1st Rev Road Ragging

    38/45

    ZIGBEE PROTOCOL NEEDS/USES

    802.15.4 Data Transmission modesBroadcast Mode

    To send a broadcast packet to all radios regardless

    of 16-bit or 64-bit addressing

    Unicast ModeGuaranteed Delivery 64-bit IEEE Addressing

    Destination 64-bit Address to match 64-bit source

    address of intended receiver.

    16-bit Network Addressing

    Destination 16-bit Address to match 16-bit source

    address of intended receiver

  • 8/2/2019 1st Rev Road Ragging

    39/45

    PAN NETWORK FORMATION

    Coordinator must select an unused operating

    channel and PAN ID

    Energy scan on all channels

    Sends Beacon request (Broadcast PAN ID)

    Listens to all responses and logs the results

    After the Coordinator has started, it will allow

    nodes to join to it for a time based on the

    specified Node Join Time

    C

  • 8/2/2019 1st Rev Road Ragging

    40/45

    ROUTER STARTUP

    A new Router must locate a Router that has

    already joined a PAN or a Coordinator

    Sends a Broadcast PAN ID on each channel Returns sent via Unicast

    Router will then try to join to a Router or

    Coordinator that is allowing joining

    R

  • 8/2/2019 1st Rev Road Ragging

    41/45

    END NODE: LOW-POWER SLEEP MODES

    End Node Startup

    A new End node must locate a Router that has

    already joined a PAN or a Coordinator

    Sends a Broadcast PAN ID on each channel

    Returns sent via Unicast

    End node will then try to join to a parent (Router

    or Coordinator) that is allowing joining

    E

  • 8/2/2019 1st Rev Road Ragging

    42/45

    42

    UART PIN CONNECTION

    DB-9 9-Pin Connector

  • 8/2/2019 1st Rev Road Ragging

    43/45

    43

    RxD and TxD pins in the 8051

    RxD and TxD pins in the 8051

    8051 has two pins used for transferring and receiving data

    serially

    TxD and RxD are part of the port 3 group

    pin 11 (P3.1) is assigned to TxD

    pin 10 (P3.0) is designated as RxD

    these pins are TTL compatible

    require a line driver to make them RS232 compatible

    driver is the MAX232 chip

  • 8/2/2019 1st Rev Road Ragging

    44/45

    44

    8051 CONNECTION TO RS232

    MAX232:

    converts from RS232 voltage levels to TTL voltage levels

    uses a +5 V power source

    MAX232 has two sets of line drivers for transferring andreceiving data

    line drivers used for TxD are called T1 and T2

    line drivers for RxD are designated as R1 and R2

    T1 and R1 are used together for TxD and RxD of the 8051

    second set is left unused

  • 8/2/2019 1st Rev Road Ragging

    45/45

    8051 CONNECTION TO RS232

    (a) Inside MAX232