Smart Traffic Lightsynpsis

download Smart Traffic Lightsynpsis

of 84

Transcript of Smart Traffic Lightsynpsis

  • 8/6/2019 Smart Traffic Lightsynpsis

    1/84

    I.E.C COLLEGE OF ENGINEERING AND

    TECHNOLOGY, GR.NOIDA

    TOWARDS PARTIAL FULLFILMENT OF THE REQUIREMENT OFUTTAR PRADESH TECHNICAL UNIVERSITY

    FOR BACHELOR OF TECHNOLOGYIN

    ELECTRONICS AND COMMUNICATION ENGINEERING

    PROJECT ON

    SMART TRAFFIC LIGHT SIGNAL

    WITH

    IGNITION OFF SYSTEM

    PREPARED AND SUBMITTED BY

    SUDHA TALAN ROLL NO.0509031115

    NIDHI VERMA ROLL NO.0509031070

    PALLAVI MISHRA ROLL NO.0509031074

    PARTH PARWAL ROLL NO.0509031077

    SUBMITTED TO :-

    MR. HIRDESH SINGH MR. BHUSHAN MITAL( PROJECT GUIDE) H.O.D. (E.C.E)

  • 8/6/2019 Smart Traffic Lightsynpsis

    2/84

    ACKNOWLEDEGMENT

    Acknowledegement is not a mere formality or ritual but a

    genuine opportunity to express the gratitude to all those

    without whose active support and encouragement this project

    would not have been possible. One of the most pleasing aspects

    in collecting the necessary information and compiling it is the

    opportunity to thank those who have actively contributed to it.

    It is our profound privilege in presenting this project. We

    express a deep sense of gratitude to all those who helped us in

    the completion of this project work in time. We are indebted to

    our experienced project guide, MR. HIRDESH SINGH for

    their consistent interest , invaluable & timely guidance,

    invaluable support towards completion of this project , and

    liberal assistance all through the present project work . we are

    also thankful to MR. BHUSHAN MITAL (H.O.D ,E.C

    DEPTT) without whose sincere efforts successful

    implementation of this project would not have been possible.

    We are extremely grateful to our batch colleagues for their

    valuable suggestions, whenever required to make this project a

    success.

  • 8/6/2019 Smart Traffic Lightsynpsis

    3/84

    CERTIFICATE

    TO WHOM SO EVER IT MAY CONCERN:

    This is to certify that Mr./Ms.____________________________

    ROLL NO.______________________ is a bonafide student ofB.Tech course in electronics and communication branch.

    He/she has completed the project work on

    SMART TRAFFIC LIGHT CONTROL WITH IGNITON OFFSYSTEM .

    The project work has been completed under my guidance

    The project work is satisfactory.

    Name of the faculty:-________________________

    (Signature)

  • 8/6/2019 Smart Traffic Lightsynpsis

    4/84

  • 8/6/2019 Smart Traffic Lightsynpsis

    5/84

    INTRODUCTION

    THIS PROJECT DEALS WITH PROBLEMS FACED BY AUSUAL TRAFFIC LIGHT SIGNAL. IN PRESENT SCENARIOWE CAN SEE THAT TRAFFIC IS INCREASING DAY BYDAY. IN METROPOLITAN CITIES SOMETIMES ONE-SIDETRAFFIC REMAINS VERY HEAVY AND OTHER SIDE ITREMAINS LIGHT.THE USUSAL TRAFFIC LIGHT SIGNAL PROVIDE EQUALTIMING TO ALL THE SIDES IRRESPECTIVE OF THE

    DENSITY OF TRAFFIC AND WHILE ON RED LIGHTPEOPLE KEEP THERE ENGINE RUNNING WHICH CAUSEFUEL WASTAGE AND SOMETIMES THEY JUMP REDLIGHT TOO.

    TO SORT OUT ALL THESE PROBLEMS WE HAVE DEVISEDTHIS PROJECT .

    THIS SYSTEM WORKS ON THE BASIS OF DENSITY OFTHE TRAFFIC.IT ALSO WORKS FOR RED LIGHT JUMP PREVENTIONAND FUEL CONSERVATION.

    OUR PROJECT CONSIST OF TWO PARTS :-

    1. SMART TRAFFIC LIGHT SYSTEM

    2. IGNITION OFF SYSTEM

  • 8/6/2019 Smart Traffic Lightsynpsis

    6/84

    1. SMART TRAFFIC LIGHT :-

    WE ARE STANDING ON FIRST TRAFFIC LIGHT, WEWILL GET 20 SEC. TO CROSS THE LIGHT.THIS SYSTEMCHECKS THE DENSITY OF TRAFFIC,IF WE GET HEAVYTRIFFIC ON THAT TRACK WE WILL GET EXTENSIONOF 5 SEC. TILL 90 SECOND TO CROSS MAXIMUMTRAFFIC ON THE SAME ROUTE.

    AFTER THAT LIGHT MOVES ON 2ND SIGNAL CHECKSTHE DENSITY ON THAT SIGNAL FOR 20 SEC ANDWORK ACCORDINGLY . THEN 3RD AND 4TH FOR THESAME.

    AFTER THAT HEAVY TRAFFIC LIGHT COMES AGAIN,TRAFFIC LIGHT SENSE FOR 20 SEC AND WORK AS PERPROGRAM.

    ON THE OTHER SIDE THREE SIGNAL LIGHTS WILLREMAIN SAME AS USUALLY GOING ON

    2. IR AUTOMATED VEHICLE IGNITION OFF

    CIRCUIT:-

    IT WORKS NEAR BY 3-5 INCH AREA STRAIGHT AND ITOFF THE IGNITTION SUPPLY OF THE VEHICLE FOR STOP.THIS IGNITION OFF CIRCUIT PREVENTS THE RED LIGHTJUMPING BY VEHICLES USING AN IR TRANSMITTER.

  • 8/6/2019 Smart Traffic Lightsynpsis

    7/84

    THESE IR TRANSMITTERS ARE IMPLEMENTED ALONGWITH THE RED LIGHT WHICH STARTS TRANSMITTING IRSIGNAL AS SOON AS THE RED LIGHT IS ON FOR THE

    SIDE OF TRAFFIC.

    BY RECEIVING THIS IR SIGNAL THE VECHILE IGNITIONIS AUTOMATICALLY SWITCHED OFF BY THE CIRCUITIMPLEMENTED ALONG WITH THE MOTOR

    WORKING DETAIL

  • 8/6/2019 Smart Traffic Lightsynpsis

    8/84

    A POLE TRAFFIC LIGHT IS GREEN OTHER THREE

    POLES ARE RED AND THEY ARE TRANSMITTING IR

    WAVE FROM THE IR TRANMITTING LED.

    CIRCUIT DIAGRAM :-

  • 8/6/2019 Smart Traffic Lightsynpsis

    9/84

    HOW IGNITION OFF CIRCUIT WORKS :-

    RF JOYSTICK CONTROL CAR

    THIS IS A SIMPLE JOYSTICK CONTROL CAR WE FIX IR

    RECEIVER CIRCUIT IN IT, WHEN CAR GET IR

    TRANSMITTER WAVE (FROM RED LIGHT POLE) IT

    STOP FORWARD MOVEMENT.

    IR RECEVIR CIRCUIT USING IN OUR JOYSTICK CONTROL CAR

  • 8/6/2019 Smart Traffic Lightsynpsis

    10/84

    FINAL MODEL VIEW

    DUE TO COST CUTTING WE ARE SHOWING ONLY TWO POLES A

    AND D IN OUR PROJECT, TRAFFIC LIGHT PASSES DIRECTLY FROM

    A TO D POLE.

    POLE-A POLE-D

    POLE A :- WE ARE SHOWING IR HEAVY TRAFFIC PASSING CIRCUIT (5

    SEC. GRACE TIME).

    POLE D :- WE ARE SHOWING IR AUTOMATED VEHICLE IGNITION OFF

    CIRCUITS.

  • 8/6/2019 Smart Traffic Lightsynpsis

    11/84

    COMPONENT LIST :-

    COMPONENT QUANTITY1. AT 89S51 MICRO CONTROLLER 01

    2. RELAY 01

    3. BC 548 NPN TRANSISTER 05

    4. CRYSTAL OSCILLATOR (11.05MHZ) 01

    5. CAPACITANCE (100uF, 470uF) 01

    6. 7805 VOLTAGE REGULATOR 01

    7. IR SENSOR PAIR 02

    8. SEVEN SEGMENT DISPLAY 01

    9. LEDS (RED, GREEN, YELLOW) 10

    10. ADAPTER 01

    11. RESISTANCE 26(330;47;220 ohm,10;1;110 kohm)

    12. TOY CAR 01

    13. CONNECTING WIRE 10MTS

    14. DC GEAR MOTOR 01

  • 8/6/2019 Smart Traffic Lightsynpsis

    12/84

    COMPONENT DETAILS

    AT89S51 (ATMEL)

    The AT89S51 is a low-power, high-performance CMOS 8-bitmicrocontroller with 4K bytes of In-System Programmable Flashmemory. The device is manufactured using Atmels high-densitynonvolatile memory technology and is compatible with theindustry-standard 80C51 instruction set and pinout. The on-chipFlash allows the program memory to be reprogrammed in-systemor by a conventional nonvolatile memory programmer.By combining a versatile 8-bit CPU with In-System ProgrammableFlash on a monolithic chip, the Atmel AT89S51 is a powerfulmicrocontroller which provides a highly-flexible and cost-effectivesolution to many embedded control applications.The AT89S51 provides the following standard specifications:

    1. 4K bytes of Flash2. 128 bytes of RAM

    3. 32 I/O lines4. Watchdog timer5. Two data pointers6. Two 16-bit timer/counters,7. A five-vector two-level interrupt architecture8. A full duplex serial port, on-chip oscillator,9. Clock circuitry.

    In addition, the AT89S51 is designed with static logic for

    operation down to zero frequency and supports two softwareselectable power saving modes. The Idle Mode stops the CPUwhile allowing the RAM, timer/counters, serial port, and interruptsystem to continue functioning. The Power-down mode saves theRAM contents but freezes the oscillator, disabling all other chipfunctions until the next external interrupt and hardware reset.

  • 8/6/2019 Smart Traffic Lightsynpsis

    13/84

    FEATURES:

    Compatible with MCS-51 Products

    4K Bytes of In-System Programmable (ISP) Flash MemoryEndurance: 1000 Write/Erase Cycles

    4.0V to 5.5V Operating Range

    Fully Static Operation: 0 Hz to 33 MHz

    Three-level Program Memory Lock

    Six Interrupt Sources

    Full Duplex UART Serial Channel

    Low-power Idle and Power-down Modes

    Interrupt Recovery from Power-down Mode

    Dual Data Pointer

    Power-off Flag

    Fast Programming Time

    Flexible ISP Programming (Byte and Page Mode)

    Green (Pb/Halide-free) Packaging Option

  • 8/6/2019 Smart Traffic Lightsynpsis

    14/84

    PIN DIAGRAM:-

  • 8/6/2019 Smart Traffic Lightsynpsis

    15/84

    PIN DISCRIPTION:-

    1. VCC

    Supply voltage (all packages except 42-PDIP).

    2. GND

    Ground (all packages except 42-PDIP; for 42-PDIP GND connectsonly the logic core and the embedded program memory).

    3. VDD

    Supply voltage for the 42-PDIP which connects only the logic core

    and the embedded program memory.

    4. PWRVDD

    Supply voltage for the 42-PDIP which connects only the I/O PadDrivers. The application board must connect both VDD andPWRVDD to the board supply voltage.

    5. PWRGND

    Ground for the 42-PDIP which connects only the I/O Pad Drivers.PWRGND and GND are weakly connected through the commonsilicon substrate, but not through any metal link. Theapplication board must connect both GND and PWRGND to the

    board ground.

    6. Port 0

    Port 0 is an 8-bit open drain bi-directional I/O port. As an outputport, each pin can sink eight TTL inputs. When 1s are written toport 0 pins, the pins can be used as high-impedance inputs.Port 0 can also be configured to be the multiplexed low-orderaddress/data bus during accesses to external program and datamemory. In this mode, P0 has internal pull-ups.

  • 8/6/2019 Smart Traffic Lightsynpsis

    16/84

    Port 0 also receives the code bytes during Flash programming andoutputs the code bytes during program verification. External pull-ups are required during program verification.

    7. Port 1Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. ThePort 1 output buffers can sink/source four TTL inputs. When 1s arewritten to Port 1 pins, they are pulled high by the internal pull-upsand can be used as inputs. As inputs, Port 1 pins that are externally

    being pulled low will source current (IIL) because of the internalpull-ups. Port 1 also receives the low-order address bytes duringFlash programming and verification.

    Port Pin Alternate FunctionsP1.5 MOSI (used for In-System Programming)P1.6 MISO (used for In-System Programming)P1.7 SCK (used for In-System Programming)

    8. Port 2

    Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. ThePort 2 output buffers can sink/source four TTL inputs. When 1s are

    written to Port 2 pins, they are pulled high by the internal pull-upsand can be used as inputs. As inputs, Port 2 pins that are externallybeing pulled low will source current (IIL) because of the internalpull-ups. Port 2 emits the high-order address byte during fetchesfrom external program memory and during accesses to externaldata memory that use 16-bit addresses (MOVX @ DPTR). In thisapplication, Port 2 uses strong internal pull-ups when emitting 1s.During accesses to external data memory that use 8-bit addresses(MOVX @ RI), Port 2 emits the contents of the P2 Special

    Function Register. Port 2 also receives the high-order address bitsand some control signals during Flash programming andverification.

  • 8/6/2019 Smart Traffic Lightsynpsis

    17/84

    9. Port 3

    Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. ThePort 3 output buffers can sink/source four TTL inputs. When 1s are

    written to Port 3 pins, they are pulled high by the internal pull-upsand can be used as inputs. As inputs, Port 3 pins that are externally

    being pulled low will source current (IIL) because of the pull-ups.Port 3 receives some control signals for Flash programming andverification. Port 3 also serves the functions of various specialfeatures of the AT89S51, as shown in the following table.

    10. RST

    Reset input. A high on this pin for two machine cycles while theoscillator is running resets the device. This pin drives High for 98oscillator periods after the Watchdog times out. The DISRTO

    bit in SFR AUXR (address 8EH) can be used to disable thisfeature. In the default state of bit DISRTO, the RESET HIGH outfeature is enabled.

    11. ALE/PROG

    Address Latch Enable (ALE) is an output pulse for latching thelow byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flashprogramming.Port Pin Alternate Functions

    P3.0 RXD (serial input port)P3.1 TXD (serial output port)P3.2 INT0 (external interrupt 0)P3.3 INT1 (external interrupt 1)

    P3.4 T0 (timer 0 external input)P3.5 T1 (timer 1 external input)P3.6 WR (external data memory write strobe)P3.7 RD (external data memory read strobe)

  • 8/6/2019 Smart Traffic Lightsynpsis

    18/84

    BLOCK DIAGRAM:

    Interrupt

    control

    Buscontrol

    Serialport

    ETC.

    Osc

    CPU

    4 I/OPorts

    On-chipRAM

    On-chipROM forprogram

    code

    Timer 0

    Timer 1

    CounterIn

    puts

    P0 P1 P2 P3 TXD RXD

    ADDRESS/DATA

    External

    Interrupt

    s

  • 8/6/2019 Smart Traffic Lightsynpsis

    19/84

    THE 89S51 REGISTERS:

    The most widely used registers are A (accumulator), B, R0, R1,R2, R3, R4, R5, R6, R7, DPTR (data pointer), and PC (programcounter). All of the above registers are 8-bits, except DPTR andthe program counter. The 8 bots of a register are shown belowfrom the MSB (most significant bit) D7 to the LSB (leastsignificant bit) D0.

    D7 D6 D5 D4 D3 D2 D1 D0

    PROGRAM COUNTER:

    The program counter points to the address of the next instruction tobe executed. As the CPU fetches the opcode from the programROM, the program counter is incremented to point to the nextinstruction. The PC is 16 bits wide i.e. it can access program

    addresses 0000 to FFFFH, a total of 64K bytes of code.

    PSW (PROGRAM STATUS WORD) REGISTER

    The PSW contains status bits that reflect the current state of theCPU and is also called flag register. The PSW contains the Carry

    bit, the Auxiliary Carry bit, the two register bank select bits, the

    overflow flag bit, a parity bit, and two user definable status flags.

    CY AC F0 RS1 RS0 OV --- P

    CY PSW.7 Carry flag.

  • 8/6/2019 Smart Traffic Lightsynpsis

    20/84

    AC PSW.6 Auxiliary carry flag.--- PSW.5 Available to the user for general purpose.RS1 PSW.4 Register Bank selector bit 1.RS0 PSW.3 Register Bank selector bit 0.

    OV PSW.2 Overflow flag.--- PSW.1 User definable bit.P PSW.0 Parity flag.

    RS1 RS0 REGISTER BANK ADDRESS

    0 0 0 00H 07H0 1 1 08H 0FH1 0 2 10H 17H

    1 1 3 18H 1FH

    CY, THE CARRY FLAG

    This flag is set whenever there is a carry out from the D7 bit. Thisflag bit is affected after an 8-bit addition or subtraction. It can also

    be set to 1 or 0 directly by an instruction such as SETB C andCLR C where SETB C stands for set bit carry and CLR C

    for clear carry.

    AC, THE AUXILIARY CARRY FLAG

    If there is a carry from D3 to D4 during an ADD or SUBoperation, this bit is set; otherwise, it is cleared. This flag is used

    by instructions that perform BCD (binary coded decimal)arithmetic.

    P, THE PARITY FLAG

    The parity flag reflects the number of 1s in the A (accumulator)register only. If the A register contains an odd number of 1s, thenP=1. Therefore, P=0 if A has an even number of 1s.

  • 8/6/2019 Smart Traffic Lightsynpsis

    21/84

    OV, THE OVERFLOW FLAG

    This flag is set whenever the result of a signed number operation istoo large, causing the high-order bit to overflow into the sign bit.

    MEMORY ALLOCATION

    There are 128 bytes of RAM , which are assigned addresses 00 to7FH. These 128 bytes are divided into three different groups:

    1. A total of 32 bytes from locations 00 to 1H hex are set asidefor register banks and the stack.

    2. A total of 16 bytes from locations 20H to 2FH are set asidefor bit-addressable read/write memory.

    3. A total of 80 bytes from locations 30H to 7FH are used for

    read and write storage, or what is normally called a scratchpad. These80 locations of RAM are widely used for the purpose ofstoring data and parameters by 8051 programmers.

    7F Scratch pad RAM302F

    Bit-Addressable RAM20

  • 8/6/2019 Smart Traffic Lightsynpsis

    22/84

    1F Register Bank 318

    17 Register Bank 2

    10

    0F Register Bank 1 (stack)0807

    Register Bank 0

    00

    REGISTER BANKS

    The 32 bytes of RAM which is set aside for the register banks andstack is divided into 4 banks of registers in which each bank has 8registers, R0 R7. RAM locations from 0 to 7 are set aside for

    bank 0 of R0 R7

    where R0 is RAM location 0, R1 is RAM location 1, R2 is location2, and so on, until memory location 7 which belongs to R7 of bank0. The second bank of registers R0 R7 starts at RAM location 08and goes to location 0FH. The third bank of R0 R7 starts atmemory location 10H and goes to location 17H; and finally RAMlocations 18H to 1FH are set aside for the fourth bank of R0 R7.The following tables shows how the 32 bytes are allocated into 4

    banks:

  • 8/6/2019 Smart Traffic Lightsynpsis

    23/84

    Bank 0 Bank 1 Bank 2 Bank 3

    STACK

    The stack is a section of RAM used by the CPU to storeinformation temporarily. This information could be data or anaddress. The CPU needs this storage area since there are only a

    limited number of registers. The register used to access the stack iscalled the SP (stack pointer) register. The stack pointer in the 8051is only 8 bits wide i.e. it can take values of 00 to FFH. When the8051 is powered up, the SP

    R7 7

    R6 6

    R5 5

    R4 4

    R3 3

    R2 2

    R1 1

    R0 0

    R7 7

    R6 6

    R5 5

    R4 4

    R3 3

    R2 2

    R1 1

    R0 0

    R7 7

    R6 6

    R5 5

    R4 4

    R3 3

    R2 2

    R1 1

    R0 0

    R7 7

    R6 6

    R5 5

    R4 4

    R3 3

    R2 2

    R1 1

    R0 0

  • 8/6/2019 Smart Traffic Lightsynpsis

    24/84

    register contains value 07 which implies that RAM location 08 isthe first location being used for the stack by the 8051. The storingof a CPU register in the stack is called a PUSH, and loading thecontents of the stack back into a CPU register is called a POP. In

    other words, a register is pushed onto the stack to save it andpopped off the stack to retrieve it.

    PUSHING ONTO THE STACK:

    In the 8051 the stack pointer (SP) is pointing to the last usedlocation of the stack. As data is pushed onto the stack, the stack

    pointer (SP) is incremented by one and the contents of the register

    are saved on the stack. To push the registers onto the stack, RAMaddresses are used.

    POPPING FROM THE STACK:

    Popping the contents of the stack back into a given register is theopposite process of pushing. With every pop, the top byte of thestack is copied to the register specified by the instruction and the

    stack pointer is decremented once.

    ADDRESSING MODES:

    The addressing modes in the microcontroller instruction set are asfollows:

    1. DIRECT ADDRESSING

    In direct addressing, the operand is specified by an 8-bit addressfield in the instruction. Only internal RAM and SFRs cab bedirectly accessed.

  • 8/6/2019 Smart Traffic Lightsynpsis

    25/84

    2. INDIRECT ADDRESSING

    In indirect addressing, the instruction specifies a register that

    specifies a register that contains the address of the operand. Bothinternal and external RAM can be indirectly accessed.

    The address register for 8-bit addresses can be either the stack pointer or R0 or R1 of the selected register bank. The addressregister for 16-bit addresses can be only the 16-bit data pointerregister, DPTR.

    3. REGISTER INSTRUCTIONS

    The register banks, which contain registers R0 through R7, can beaccessed by instructions whose opcodes carry a 3-bit registerspecification. Instructions that access the registers this way makeefficient use of code, since this mode eliminates an address byte.When the instruction is executed, one of the eight registers in theselected bank is accessed. One of four banks is selected at

    execution time by the two bank select bits in the PSW.

    4. REGISTER-SPECIFIC INSTRUCTIONS

    Some instructions are specific to a certain register. For example,some instructions always operate on the Accumulator, so noaddress byte is needed to point to it. In these cases, the opcodeitself points to the correct register.

    5. IMMEDIATE CONSTANTS

    The value of a constant can follow the opcode in program memory.For example,

    MOV A, #100

  • 8/6/2019 Smart Traffic Lightsynpsis

    26/84

    Loads the Accumulator with the decimal number 100. The samenumber could be specified in hex digits as 64H.

    6. INDEXED ADDRESSING

    Program memory can only be accessed via indexed addressing.This addressing mode is intended for reading look-up labels in

    program memory. A 16-bit base register (either DPTR or theProgram Counter) points to the base of the table, and theaccumulator is set up with the table entry number. The address of

    the table entry in program memory is formed by adding theaccumulator data to the base pointer.

    SPECIAL FUNCTION REGISTERS:-

    A map of the on-chip memory area called the Special Function

    Register (SFR) space .Note that not all of the addresses are occupied, and unoccupiedaddresses may not be implemented on the chip. Read accesses tothese addresses will in general return random data, and writeaccesses will have an indeterminate effect.User software should not write 1s to the unlisted locations, sincethey may be used in future products to invoke new features. In thatcase, the reset or inactive values of the new bits will always be 0.

    Interrupt Registers: The individual interrupt enable bits are in theIE register. Two priorities can be set for each of the five interruptsources in the IP register.

  • 8/6/2019 Smart Traffic Lightsynpsis

    27/84

    Dual Data Pointer Registers: To facilitate accessing both internaland external data memory, two banks of 16-bit Data PointerRegisters are provided: DP0 at SFR address locations 82H-83H and DP1 at 84H-85H. Bit DPS = 0 in SFR AUXR1 selects

    DP0 and DPS = 1 selects DP1.The user should always initialize the DPS bit to the appropriatevalue before accessing the respective Data Pointer Register.

    Power Off Flag: The Power Off Flag (POF) is located at bit 4(PCON.4) in the PCON SFR. POF is set to 1 during power up. Itcan be set and rest under software control and is not affected byreset

    MEMORY ORGANIZATIONMCS-51 devices have a separate address space for Program andData Memory. Up to 64K bytes each of external Program and DataMemory can be addressed.1. Program MemoryIf the EA pin is connected to GND, all program fetches aredirected to external memory.On the AT89S51, if EA is connected to VCC, program fetches toaddresses 0000H through FFFH are directed to internal memoryand fetches to addresses 1000H through FFFFH are directed toexternal memory.2. Data MemoryThe AT89S51 implements 128 bytes of on-chip RAM. The 128

    bytes are accessible via direct and indirect addressing modes. Stackoperations are examples of indirect addressing, so the 128 bytes ofdata RAM are available as stack space.

    Watchdog Timer (One-time Enabled withReset-out)

  • 8/6/2019 Smart Traffic Lightsynpsis

    28/84

    The WDT is intended as a recovery method in situations where theCPU may be subjected to software upsets. The WDT consists of a14-bit counter and the Watchdog Timer Reset (WDTRST) SFR.The WDT is defaulted to disable from exiting reset. To enable the

    WDT, a user must write 01EH and 0E1H in sequence to theWDTRST register (SFR location 0A6H). When the WDT isenabled, it will increment every machine cycle while the oscillatoris running. The WDT timeout period is dependent on the externalclock frequency. There is no way to disable the WDT exceptthrough reset (either hardware reset or WDT overflow reset).When WDT overflows, it will drive an output RESET HIGH pulseat the RST pin.

    1. Using the WDTTo enable the WDT, a user must write 01EH and 0E1H insequence to the WDTRST register(SFR location 0A6H). When theWDT is enabled, the user needs to service it by writing 01EHand 0E1H to WDTRST to avoid a WDT overflow. The 14-bit

    counter overflows when it reaches 16383 (3FFFH), and this willreset the device. When the WDT is enabled, it will increment everymachine cycle while the oscillator is running. This means the usermust reset the WDT at least. To reset the WDT the user must write01EH and 0E1H to WDTRST.

    WDTRST is a write-only register. The WDT counter cannot beread or written. WhenWDT overflows, it will generate an output

    RESET pulse at the RST pin. The RESET pulse durationis 98xTOSC, where TOSC = 1/FOSC. To make the best use of theWDT, it should be serviced in those sections of code that will

    periodically be executed within the time required to prevent aWDT reset.

  • 8/6/2019 Smart Traffic Lightsynpsis

    29/84

    2. WDT During Power-down and IdleIn Power-down mode the oscillator stops, which means the WDTalso stops. While in Power down mode, the user does not need toservice the WDT. There are two methods of exiting Power-down

    mode: by a hardware reset or via a level-activated externalinterrupt, which is enabled prior to entering Power-down mode.When Power-down is exited with hardware reset, servicing theWDT should occur as it normally does whenever the AT89S51 isreset. Exiting Power-down with an interrupt is significantlydifferent. The interrupt is held low long enough for the oscillator tostabilize. When the interrupt is brought high, the interrupt isserviced. To prevent the WDT from resetting the device while the

    interrupt pin is held low, the WDT is not started until the interruptis pulled high. It is suggested that the WDT be reset during theinterrupt service for the interrupt used to exit Power-down mode.To ensure that the WDT does not overflow within a few states ofexiting Power-down, it is best to reset the WDT just beforeentering Power-down mode. Before going into the IDLE mode, theWDIDLE bit in SFR AUXR is used to determine whether theWDT continues to count if enabled. The WDT keeps counting

    during IDLE (WDIDLE bit = 0) as the default state. To prevent theWDT from resetting the AT89S51 while in IDLE mode, theuser should always set up a timer that will periodically exit IDLE,service the WDT, and reenter IDLE mode.With WDIDLE bitenabled, the WDT will stop to count in IDLE mode and resumesthe count upon exit from IDLE.

    INTERRUPTS

    The AT89S51 has a total of five interrupt vectors: two externalinterrupts (INT0 and INT1), two timer interrupts (Timers 0 and 1),and the serial port interrupt.Each of these interrupt sources can be individually enabled ordisabled by setting or clearing a bit in Special Function RegisterIE. IE also contains a global disable bit, EA, which disables all

  • 8/6/2019 Smart Traffic Lightsynpsis

    30/84

    interrupts at once.User software should not write 1s to these bit positions, since they

    may be used in future AT89 products.The Timer 0 and Timer 1 flags, TF0 and TF1, are set at S5P2 of

    the cycle in which the timers overflow. The values are then polledby the circuitry in the next cycle.

    OSCILLATOR CHARACTERISTICS:

    XTAL1 and XTAL2 are the input and output, respectively, of aninverting amplifier, which can be configured for use as an on-chiposcillator. Either a quartz crystal or ceramic resonator may be used.

    To drive the device from an external clock source, XTAL2 shouldbe left unconnected while XTAL1 is driven.

    Figure: Oscillator Connections

    C1, C2 = 30 pF +/- 10 pF for Crystals

    XT

    AL

    1

    XT

    AL

    2

    C

    1

    C

    2

    G

    N

    D

  • 8/6/2019 Smart Traffic Lightsynpsis

    31/84

    = 40 pF +/- 10 pF for Ceramic Resonators

    There are no requirements on the duty cycle of the external clocksignal, since the input to the internal clocking circuitry is through a

    divide-by-two flip-flop, but minimum and maximum voltage highand low time specifications must be observed.

    Idle ModeIn idle mode, the CPU puts itself to sleep while all the on-chip

    peripherals remain active. The mode is invoked by software. Thecontent of the on-chip RAM and all the special function registersremain unchanged during this mode. The idle mode can beterminated by any enabled interrupt or by a hardware reset.

    Note that when idle mode is terminated by a hardware reset, thedevice normally resumes program execution from where it left off,up to two machine cycles before the internal reset algorithm takescontrol. On-chip hardware inhibits access to internal RAM in thisevent, butaccess to the port pins is not inhibited. To eliminate the

    possibility of an unexpected write to a port pin when idle mode is

    terminated by a reset, the instruction following the one thatinvokes idle mode should not write to a port pin or to externalmemory.Power-down Mode

    In the Power-down mode, the oscillator is stopped, and theinstruction that invokes Power-down is the last instructionexecuted. The on-chip RAM and Special Function Registers retaintheir values until the Power-down mode is terminated. Exit from

    Power-down mode can be initiated either by a hardware reset or byactivation of an enabled external interrupt (INT0 or INT1). Resetredefines the SFRs but does not change the on-chip RAM. Thereset should not be activated before VCC is restored to its normaloperating level and must be held active long enough to allow theoscillator to restart and stabilize.

  • 8/6/2019 Smart Traffic Lightsynpsis

    32/84

    INSTRUCTION SET

    MNEMONIC:

    The MNEMONIC column contains the 8051 Instruction SetMnemonic and a brief description of the instruction's operation.OPERATION:

    The OPERATION column describes the 8051 Instruction Set inunambiguous symbology. Following are the definitions of thesymbols used in this column. Bits of a register inclusive. For example, PC

    means bits 0 through 10 inclusive of the PC. Bit 0 isalways the least significant bit.

    + Binary addition- Binary 2s complement subtraction/ Unsigned integer division

    X Unsigned integer multiplication~ Binary complement (1s complement)^ Logical Andv Inclusive Orv Exclusive Or> Greater than Not equal to= Equals

    -> Is written into. For example, A + SOper -> A meanstheresult of the binary addition between A and the SourceOperand is written into A.

    A The 8-bit Accumulator Register.

  • 8/6/2019 Smart Traffic Lightsynpsis

    33/84

    AC The Auxiliary Carry Flag in the Program Status WordCF The Carry Flag in the Program Status WordDoper The Destination Operand used in the instruction.

    DPTR 16-bit Data Pointer

    Interrupt Active Flag Internal Flag that holds off interruptsuntil the Flag is cleared.

    Jump Relative to PC A Jump that can range between -128

    bytes and +127 bytes from the PC value of the next instruction.

    Paddr A 16-bit Program Memory addressPC The 8051 Program Counter. This 16-bit register points to the

    byte in the Program Memory space that isfetched as part of the instruction stream.

    PM (addr) Byte in Program Memory space pointed to

    by addr.

    Remainder Integer remainder of unsigned integer division

    Soper The Source Operand used in theinstruction.

    SP 8-bit Stack Pointer

    STACK The Last In First Out data structure that iscontrolled by the 8-bit Stack Pointer (SP).Sixteen bit quantities are pushed on thestack low byte first.

  • 8/6/2019 Smart Traffic Lightsynpsis

    34/84

    HEX OPCODE:This column gives the machine language hexadecimal opcode for

    each 8051 instruction.

    BYTE:

    This column gives the number of bytes in each 89s51 instruction.

    CYC:

    This column gives the number of cycles of each 8051 instruction.The time value of a cycle is defined as 12 divided by the oscillatorfrequency. For example, if running an 8051 family component at12 MHz, each cycle takes 1 microsecond.

    RELAY

    It is often desirable or essential to isolate one circuit electricallyfrom another, while still allowing the first circuit to control thesecond. For example, if you wanted to control a high-voltagecircuit from your computer, you would probably not want toconnect it directly to the a low-voltage port on the back of yourcomputer in case something went wrong and the mains electricityended up destroying the expensive parts inside your computer.

    One simple method of providing electrical isolation between twocircuits is to place a relay between them, as shown in the circuitdiagram of figure 1. A relay consists of a coil that may beenergized by the low-voltage circuit and one or more sets of switchcontacts, which may be connected to the high-voltage circuit.

  • 8/6/2019 Smart Traffic Lightsynpsis

    35/84

    HOW RELAY WORKS?In figure 2a the relay is off. The metal arm is at its rest position andso there is contact between the Normally Closed (N.C.) switchcontact and the 'common' switch contact.

    If a current is passed through the coil, the resulting magnetic fieldattracts the metal arm and there is now contact between the

    Normally Open (N.O.) switch contact and the common switch

    contact.

    ADVANTAGES OF RELAY

    The complete electrical isolation improves safety by ensuringthat high voltages and currents cannot appear where they

    should not be. Relays come in all shapes and sizes for different applications

    and they have various switch contact configurations. DoublePole Double Throw (DPDT) relays are common and even 4-

    pole types are available. You can therefore control several

  • 8/6/2019 Smart Traffic Lightsynpsis

    36/84

    circuits with one relay or use one relay to control thedirection of a motor.

    It is easy to tell when a relay is operating - you can hear aclick as the relay switches on and off and you can sometimes

    see the contacts moving.

    DISADVANTAGES OF RELAY

    Being mechanical though, relays do have some disadvantages overother methods of electrical isolation:

    Their parts can wear out as the switch contacts become dirty -

    high voltages and currents cause sparks between the contacts. They cannot be switched on and off at high speeds because

    they have a slow response and the switch contacts willrapidly wear out due to the sparking.

    Their coils need a fairly high current to energise, whichmeans some micro-electronic circuits can't drive themdirectly without additional circuitry.

    The back-emf created when the relay coil switches off can

    damage the components that are driving the coil. To avoidthis, a diode can be placed across the relay coil, as will beseen in any Electronics in Meccano circuits that use relayswith sensitive components.

    CHOOSING A RELAY:-

    When choosing a relay to use in a circuit, you need to bear in mind

    properties of both the coil and the switch contacts. Firstly, you willneed to find a relay that has the required number of switch polesfor your application. You then need to make sure that the switchcontacts can cope with the voltage and current you intend to use -for example, if you were using the relay to switch a 60W mainslamp on and off, the switch contacts would need to be rated for at

  • 8/6/2019 Smart Traffic Lightsynpsis

    37/84

    least 250mA at 240V AC (or whatever the mains voltage is in yourcountry).

    Also of importance is the material that the switch contacts are

    made of - gold is good for low-voltages, whereas tungsten issuitable for switching high voltages and currents.Finally, you need to choose a relay that has a coil that can beenergised by your low-voltage control circuit. Relay coils aregenerally rated by their voltage and resistance, so you can work outtheir current consumption using Ohm's Law. You will need tomake sure that the circuit powering the coil can supply enoughcurrent, otherwise the relay will not operate properly.

    THE LATCHING CIRCUIT

    If a relay is connected as shown in figure 3, it will become 'latched'on when the coil is energised by pressing the Trigger button. Theonly way to turn the relay off will then be to cut the power supply

    by pressing the Reset button (which must be a push-to-break type).

    The technical name for this type of behaviour is 'bistable', since thecircuit has two stable states for its output - on and off. Bistablecircuits can also be constructed using many other components,including the 555 timer IC and transistors.

  • 8/6/2019 Smart Traffic Lightsynpsis

    38/84

    What's the point of this circuit? The Normally Open switch contact

    of the relay could also be connected to a device such as a motor, asshown by the dotted connections in figure 3. The device will thenrun indefinitely until some event (maybe triggered by the device)momentarily presses the Reset button, thereby turning off the coilready for the Trigger button to be pressed again.This system could be used in a model which needs a 'Push toOperate' button. A motor and gearing system in the model can beused to press the Reset button to cut the power to the relay coil

    after the model has been running for a certain amount of time, oruntil a certain event has occurred. Of course, you would have to besure that there was enough momentum in the mechanism that the

    button is released ready for the next cycle.

    BC 548 NPN TRANSISTER

    It is an epitaxial planar NPN transistor. It is used for generalpurpose applications and switching applications.Features:-

    High voltage:- V(ceo) = 65V

    Complementary with PNP type

    CHARACTERSTICS (T=25C) :-

    1. Collector-Base Voltage :- 30V2. Collector-Emitter Voltage :- 30V3. Emitter-Base Voltage :- 5V4. Collector Current :- 100mA5. Emitter Current :- -100mA6. Collector Power Dissipation :- 625mW7. Junction Temprature :- 150C

  • 8/6/2019 Smart Traffic Lightsynpsis

    39/84

    8. transition frequency:- 150MHz

    The name is transistor derived from transfer resistors indicatinga solid state Semiconductor device. In addition to conductor andinsulators, there is a third class of material that exhibits proportionof both. Under some conditions, it acts as an insulator, and underother conditions its a conductor. This phenomenon is called Semi-conducting and allows a variable control over electron flow. So,the transistor is semi conductor device used in electronics foramplitude. Transistor has three terminals, one is the collector, one

    is the base and other is the emitter, (each lead must be connected inthe circuit correctly and only then the transistor will function).Electrons are emitted via one terminal and collected on anotherterminal, while the third terminal acts as a control element. Eachtransistor has a number marked on its body. Every number has itsown specifications.

    There are mainly two types of transistor (i) NPN & (ii) PNP

    NPN Transistor:

    When a positive voltage is applied to the base, the transistorbegins to conduct by allowing current to flow through the collectorto emitter circuit. The relatively small current flowing through the

    base circuit causes a much greater current to pass through theemitter / collector circuit. The phenomenon is called current gainand it is measure in beta.

    PNP Transistor:It also does exactly same thing as above except that it has anegative voltage on its collector and a positive voltage on itsemitter.

  • 8/6/2019 Smart Traffic Lightsynpsis

    40/84

    Transistor is a combination of semi-conductor elementsallowing a controlled current flow. Germanium and Silicon is thetwo semi-conductor elements used for making it. There are twotypes of transistors such as POINT CONTACT and JUNCTIONTRANSISTORS. Point contact construction is defective so is now

    out of use. Junction triode transistors are in many respectsanalogous to triode electron tube.

    A junction transistor can function as an amplifier or oscillatoras can a triode tube, but has the additional advantage of long life,small size, ruggedness and absence of cathode heating power.

    Junction transistors are of two types which can be obtained

    while manufacturing.

    The two types are: -

    1) PNP TYPE: This is formed by joining a layer of P typeof germanium to an N-P Junction

    P N P

  • 8/6/2019 Smart Traffic Lightsynpsis

    41/84

    2) NPN TYPE: This is formed by joining a layer of N typegermanium to a P-N Junction.

    Bothtypes are shown in figure, with theirsymbols for representation. The centresection is called the base, one of theoutside sections-the emitter and the other outside section-thecollector. The direction of the arrowhead gives the direction of the

    conventional current with the forward bias on the emitter. Theconventional flow is opposite in direction to the electron flow.

    OPERATION OF PNP TRANSISTOR:-

    A PNP transistor is made by sand witching two PN germanium orsilicon diodes, placed back to back. The centre of N-type portion isextremely thin in comparison to P region. The P region of the left

    is connected to the positive terminal and N-region to the negativeterminal i.e.

    PN is biased in the forward direction while P region of right isbiased negatively i.e. in the reverse direction as shown in Fig. TheP region in the forward biased circuit is called the emitter and Pregion on the right, biased negatively is called collector. The centreis called base.

    N P N

  • 8/6/2019 Smart Traffic Lightsynpsis

    42/84

    The majority carriers (holes) of P region (known as emitter) moveto N region as they are repelled by the positive terminal of battery

    while the electrons of N region are attracted by the positiveterminal. The holes overcome the barrier and cross the emitter

    junction into N region. As the width of base region is extremelythin, two to five percent of holes recombine with the free electronsof N-region which result in a small base current while theremaining holes (95% to 98%) reach the collector junction. Thecollector is biased negatively and the negative collector voltageaids in sweeping the hole into collector region.

    As the P region at the right is biased negatively, a very smallcurrent should flow but the following facts are observed:-

    1) A substantial current flows through it when the emitterjunction is biased in a forward direction.

    2) The current flowing across the collector is slightly less than

    that of the emitter, and

    3) The collector current is a function of emitter current i.e. withthe decrease or increase in the emitter current a

    corresponding change in the collector current is observed.

  • 8/6/2019 Smart Traffic Lightsynpsis

    43/84

    The facts can be explained as follows:-

    1. As already discussed that 2 to 5% of the holes are lost inrecombination with the electron n base region, which result in asmall base current and hence the collector current is slightly lessthan the emitter current.

    2. The collector current increases as the holes reaching thecollector junction are attracted by negative potential applied to the

    collector.

    3. When the emitter current increases, most holes are injected intothe base region, which is attracted by the negative potential of thecollector and hence results in increasing the collector current. Inthis way emitter is analogous to the control of plate current bysmall grid voltage in a vacuum triode.

    Hence we can say that when the emitter is forward biased andcollector is negatively biased, a substantial current flows in boththe circuits. Since a small emitter voltage of about 0.1 to 0.5 volts

    permits the flow of an appreciable emitter current the input poweris very small. The collector voltage can be as high as 45 volts.

    CRYSTAL OSCILLATOR:-The crystal oscillator used in our circuit is of 11.05MHz.

    A crystal oscillator is an electronic circuit that uses themechanical resonance of a vibrating crystal of piezoelectricmaterial to create an electrical signal with a very precisefrequency. This frequency is commonly used to keep track of time(as in quartz wristwatches), to provide a stable clock signal for

    http://en.wikipedia.org/wiki/Electronic_circuithttp://en.wikipedia.org/wiki/Resonancehttp://en.wikipedia.org/wiki/Crystalhttp://en.wikipedia.org/wiki/Piezoelectricity#Materialshttp://en.wikipedia.org/wiki/Piezoelectricity#Materialshttp://en.wikipedia.org/wiki/Frequencyhttp://en.wikipedia.org/wiki/Quartz_clockhttp://en.wikipedia.org/wiki/Clock_signalhttp://en.wikipedia.org/wiki/Electronic_circuithttp://en.wikipedia.org/wiki/Resonancehttp://en.wikipedia.org/wiki/Crystalhttp://en.wikipedia.org/wiki/Piezoelectricity#Materialshttp://en.wikipedia.org/wiki/Piezoelectricity#Materialshttp://en.wikipedia.org/wiki/Frequencyhttp://en.wikipedia.org/wiki/Quartz_clockhttp://en.wikipedia.org/wiki/Clock_signal
  • 8/6/2019 Smart Traffic Lightsynpsis

    44/84

    digital integrated circuits, and to stabilize frequencies for radiotransmitters and receivers. The most common type of piezoelectricresonator used is the quartz crystal, so oscillator circuits designedaround them were called "crystal oscillators".

    OPERATION:-

    A crystal is a solid in which the constituent atoms, molecules, orions are packed in a regularly ordered, repeating pattern extendingin all three spatial dimensions.

    Almost any object made of an elastic material could be used like acrystal, with appropriate transducers, since all objects have natural

    resonant frequencies of vibration. For example, steel is very elasticand has a high speed of sound. It was often used in mechanicalfilters before quartz. The resonant frequency depends on size,shape, elasticity, and the speed of sound in the material. High-frequency crystals are typically cut in the shape of a simple,rectangular plate. Low-frequency crystals, such as those used indigital watches, are typically cut in the shape of a tuning fork. Forapplications not needing very precise timing, a low-cost ceramic

    resonatoris often used in place of a quartz crystal.

    When a crystal ofquartz is properly cut and mounted, it can bemade to distort in an electric field by applying a voltage to anelectrode near or on the crystal. This property is known as

    piezoelectricity. When the field is removed, the quartz willgenerate an electric field as it returns to its previous shape, and thiscan generate a voltage. The result is that a quartz crystal behaveslike a circuit composed of an inductor, capacitorand resistor, witha precise resonant frequency.

    Quartz has the further advantage that its elastic constants and itssize change in such a way that the frequency dependence ontemperature can be very low. The specific characteristics willdepend on the mode of vibration and the angle at which the quartz

    http://en.wikipedia.org/wiki/Digitalhttp://en.wikipedia.org/wiki/Integrated_circuitshttp://en.wikipedia.org/wiki/Radio_transmitterhttp://en.wikipedia.org/wiki/Radio_transmitterhttp://en.wikipedia.org/wiki/Radio_receiverhttp://en.wikipedia.org/wiki/Quartz_crystalhttp://en.wikipedia.org/wiki/Crystalhttp://en.wikipedia.org/wiki/Solidhttp://en.wikipedia.org/wiki/Atomhttp://en.wikipedia.org/wiki/Moleculehttp://en.wikipedia.org/wiki/Ionhttp://en.wikipedia.org/wiki/Resonancehttp://en.wikipedia.org/wiki/Steelhttp://en.wikipedia.org/wiki/Elasticity_(physics)http://en.wikipedia.org/wiki/Tuning_forkhttp://en.wikipedia.org/wiki/Ceramic_resonatorhttp://en.wikipedia.org/wiki/Ceramic_resonatorhttp://en.wikipedia.org/wiki/Quartzhttp://en.wikipedia.org/wiki/Voltagehttp://en.wikipedia.org/wiki/Electrodehttp://en.wikipedia.org/wiki/Piezoelectricityhttp://en.wikipedia.org/wiki/Inductorhttp://en.wikipedia.org/wiki/Capacitorhttp://en.wikipedia.org/wiki/Resistorhttp://en.wikipedia.org/wiki/Digitalhttp://en.wikipedia.org/wiki/Integrated_circuitshttp://en.wikipedia.org/wiki/Radio_transmitterhttp://en.wikipedia.org/wiki/Radio_transmitterhttp://en.wikipedia.org/wiki/Radio_receiverhttp://en.wikipedia.org/wiki/Quartz_crystalhttp://en.wikipedia.org/wiki/Crystalhttp://en.wikipedia.org/wiki/Solidhttp://en.wikipedia.org/wiki/Atomhttp://en.wikipedia.org/wiki/Moleculehttp://en.wikipedia.org/wiki/Ionhttp://en.wikipedia.org/wiki/Resonancehttp://en.wikipedia.org/wiki/Steelhttp://en.wikipedia.org/wiki/Elasticity_(physics)http://en.wikipedia.org/wiki/Tuning_forkhttp://en.wikipedia.org/wiki/Ceramic_resonatorhttp://en.wikipedia.org/wiki/Ceramic_resonatorhttp://en.wikipedia.org/wiki/Quartzhttp://en.wikipedia.org/wiki/Voltagehttp://en.wikipedia.org/wiki/Electrodehttp://en.wikipedia.org/wiki/Piezoelectricityhttp://en.wikipedia.org/wiki/Inductorhttp://en.wikipedia.org/wiki/Capacitorhttp://en.wikipedia.org/wiki/Resistor
  • 8/6/2019 Smart Traffic Lightsynpsis

    45/84

    is cut (relative to its crystallographic axes). Therefore, the resonantfrequency of the plate, which depends on its size, will not changemuch, either. This means that a quartz clock, filter or oscillator willremain accurate. For critical applications the quartz oscillator is

    mounted in a temperature-controlled container, called a crystaloven, and can also be mounted on shock absorbers to prevent

    perturbation by external mechanical vibrations.

    Quartz timing crystals are manufactured for frequencies from afew tens ofkilohertz to tens ofmegahertz. More than two billion(2109) crystals are manufactured annually. Most are small devicesfor consumer devices such as wristwatches, clocks, radios,

    computers, and cellphones. Quartz crystals are also found insidetest and measurement equipment, such as counters, signalgenerators, and oscilloscopes

    MODELLING:-

    Schematic symbol

    A quartz crystal can be modelled as an electrical network with alow impedance (series) and a high impedance (parallel) resonance

    point spaced closely together. Mathematically (using the Laplace

    transform) the impedance of this network can be written as:

    or,

    http://en.wikipedia.org/wiki/Crystal_ovenhttp://en.wikipedia.org/wiki/Crystal_ovenhttp://en.wikipedia.org/wiki/Kilohertzhttp://en.wikipedia.org/wiki/Megahertzhttp://en.wikipedia.org/wiki/Wristwatchhttp://en.wikipedia.org/wiki/Clockhttp://en.wikipedia.org/wiki/Radiohttp://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/Cellphonehttp://en.wikipedia.org/wiki/Signal_generatorhttp://en.wikipedia.org/wiki/Signal_generatorhttp://en.wikipedia.org/wiki/Oscilloscopehttp://en.wikipedia.org/wiki/Electrical_impedancehttp://en.wikipedia.org/wiki/Electrical_impedancehttp://en.wikipedia.org/wiki/Laplace_transformhttp://en.wikipedia.org/wiki/Laplace_transformhttp://en.wikipedia.org/wiki/File:Crystal-oscillator-IEC-Symbol.svghttp://en.wikipedia.org/wiki/Crystal_ovenhttp://en.wikipedia.org/wiki/Crystal_ovenhttp://en.wikipedia.org/wiki/Kilohertzhttp://en.wikipedia.org/wiki/Megahertzhttp://en.wikipedia.org/wiki/Wristwatchhttp://en.wikipedia.org/wiki/Clockhttp://en.wikipedia.org/wiki/Radiohttp://en.wikipedia.org/wiki/Computerhttp://en.wikipedia.org/wiki/Cellphonehttp://en.wikipedia.org/wiki/Signal_generatorhttp://en.wikipedia.org/wiki/Signal_generatorhttp://en.wikipedia.org/wiki/Oscilloscopehttp://en.wikipedia.org/wiki/Electrical_impedancehttp://en.wikipedia.org/wiki/Electrical_impedancehttp://en.wikipedia.org/wiki/Laplace_transformhttp://en.wikipedia.org/wiki/Laplace_transform
  • 8/6/2019 Smart Traffic Lightsynpsis

    46/84

    where s is the complex frequency (s =j), s is the series resonantfrequency in radians per second and p is the parallel resonantfrequency in radians per second.

    Adding additional capacitance across a crystal will cause theparallel resonance to shift downward. This can be used to adjustthe frequency at which a crystal oscillator oscillates. Crystal

    manufacturers normally cut and trim their crystals to have aspecified resonant frequency with a known 'load' capacitanceadded to the crystal. For example, a 6 pF 32 kHz crystal has a

    parallel resonance frequency of 32,768 Hz when a 6.0 pF capacitoris placed across the crystal. Without this capacitance, theresonance frequency is higher than 32,768 Hz.

    Crystal Specifications:-

    Series and Parallel Resonance:-

    There is no such thing as a series cut crystal as opposed to aparallel cut crystal. The same crystal can be made to oscillate inseries resonance mode or parallel resonance mode. The frequencyof oscillation of a crystal is usually specified by the manufactureras either the series resonance frequency or the parallel resonance

    frequency. A crystal can oscillate in series resonance, meaning thatLs is resonating with Cs.

    Some oscillator circuits are designed for series resonance and theoscillation frequency shall equal the specified series resonancevalue. These series mode oscillators, however, are more sensitive

    http://en.wikipedia.org/wiki/Radianhttp://en.wikipedia.org/wiki/Radian
  • 8/6/2019 Smart Traffic Lightsynpsis

    47/84

    to temperature and component variations. In fact, most crystalsoscillators in today's ICs are of the parallel resonance type.The oscillation frequency of a parallel mode oscillator is alwayshigher than fseries. The actual oscillation frequency of a parallel

    mode oscillator is dependent on the equivalent capacitance seen bythe crystal.

    Crystal Power Dissipation:-

    This is one of the more important specifications for a crystal. Inoperation, if the power dissipated in the crystal exceeds thespecified drive level, the crystal may have long term reliability

    problems. The oscillation frequency may shift from the desiredvalue, and in extreme cases the crystal may crack and stoposcillating altogether.

    Pullability and Cs:-

    Most crystal manufacturers do not specify Cs explicitly. However,one can measure Cs indirectly by measuring the change infrequency for a given change in load capacitance.

    Oscillator Startup Time and PLL Lock Time:-

    Oscillator start-up time is primarily a function of the size of theinverting amplifier. Measured oscillator startup time is about 1 msfor Chrontels clock chips. PLL lock time is a function of the PLLunity gain frequency and the frequency spanned in themeasurement.PLLs with external loop filters will have a longer lock time,

    depending on the external filter capacitor value.

    CAPACITORThe capacitors used in our circuit are of 100uF (10V), 470uF(16V).It is an electronic component whose function is to accumulatecharges and then release it.

  • 8/6/2019 Smart Traffic Lightsynpsis

    48/84

  • 8/6/2019 Smart Traffic Lightsynpsis

    49/84

    7805 VOLTAGE REGULATOR

    It is monolithic 3-terminal positive voltage regulators employinternal current-limiting, thermal shutdown and safe-areacompensation, making them essentially indestructible. If adequateheat sinking is provided, they can deliver over 1.0A output current.They are intended as fixed voltage regulators in a wide range of

    applications including local (on-card) regulation for elimination ofnoise and distribution problems associated with single-pointregulation. In addition to use as fixed voltage regulators, thesedevices can be used with external components to obtain adjustableoutput voltages and currents.It is not necessary to bypass the output, although this does improvetransient response. Input bypassing is needed only if the regulatoris located far from the filter capacitor of the power supply. The 5V,

    12V, and 15V regulator options are available in the steel TO-3power package.

    FEATURES:-1. Output current to 1.5 A.

  • 8/6/2019 Smart Traffic Lightsynpsis

    50/84

    2. Output voltage of 5V.

    3. Thermal overload protection.

    4. Short circuit protection.

    5. Output transition SOA protection.

    6. Complete specifications at 1A load.

    7. Output voltage tolerances of 2% at Tj = 25C and 4%

    over the temperature range.8. Line regulation of 0.01% of VOUT/V of VIN at 1A load.

    9. Load regulation of 0.3% of VOUT/A.

    10. Internal thermal overload protection.

    11. Internal short-circuit current limit.

    12. Output transistor safe area protection.

    13. P+ Product Enhancement tested.

    7805 IC is used as regulator in 5V power supply.

    7805

    1 3 2

    1 - IN

    2 - OUT3 - GND

  • 8/6/2019 Smart Traffic Lightsynpsis

    51/84

    IN 7805 pin no.1 is input pin through which non-regulated signal isapplied. Pin no.3 is grounded & the regulated output is taken from

    pin no.2.

    INRA RED SENSORS

    We used IR sensors in our circuit for sensing the density of trafficon road and for transmission of high pulses during red light toactivate the relay circuit attached to the motor of vehicle to stop themotion of the vehicle.

    Infrared (IR) radiation is electromagnetic radiation whosewavelength is longer than that of visible light (400-700 nm), butshorter than that ofterahertz radiation (100 m - 1 mm) and

    microwaves (~30,000 m). Infrared radiation spans roughly threeorders of magnitude (750 nm and 100 m).

    IR data transmission is employed in short-range communication.These devices usually conform to standards published by IrDA, the

    Infrared Data Association. IrDA devices use infrared light-emitting diodes (LEDs) to emit infrared radiation which is focused

    by a plastic lens into a narrow beam. The beam is modulated, i.e.switched on and off, to encode the data. The receiver uses a silicon

    photodiode to convert the infrared radiation to an electric current.It responds only to the rapidly pulsing signal created by thetransmitter, and filters out slowly changing infrared radiation fromambient light. Infrared communications are useful for indoor use in

    areas of high population density. IR does not penetrate walls andso does not interfere with other devices in adjoining rooms.Infrared is the most common way forremote controls to commandappliances.

    http://en.wikipedia.org/wiki/Electromagnetic_radiationhttp://en.wikipedia.org/wiki/Wavelengthhttp://en.wikipedia.org/wiki/Visible_lighthttp://en.wikipedia.org/wiki/Terahertz_radiationhttp://en.wikipedia.org/wiki/Microwaveshttp://en.wikipedia.org/wiki/Order_of_magnitudehttp://en.wikipedia.org/wiki/Infrared_Data_Associationhttp://en.wikipedia.org/wiki/Light-emitting_diodehttp://en.wikipedia.org/wiki/Light-emitting_diodehttp://en.wikipedia.org/wiki/Lens_(optics)http://en.wikipedia.org/wiki/Modulationhttp://en.wikipedia.org/wiki/Datahttp://en.wikipedia.org/wiki/Siliconhttp://en.wikipedia.org/wiki/Photodiodehttp://en.wikipedia.org/wiki/Electric_currenthttp://en.wikipedia.org/wiki/Remote_controlhttp://en.wikipedia.org/wiki/Electromagnetic_radiationhttp://en.wikipedia.org/wiki/Wavelengthhttp://en.wikipedia.org/wiki/Visible_lighthttp://en.wikipedia.org/wiki/Terahertz_radiationhttp://en.wikipedia.org/wiki/Microwaveshttp://en.wikipedia.org/wiki/Order_of_magnitudehttp://en.wikipedia.org/wiki/Infrared_Data_Associationhttp://en.wikipedia.org/wiki/Light-emitting_diodehttp://en.wikipedia.org/wiki/Light-emitting_diodehttp://en.wikipedia.org/wiki/Lens_(optics)http://en.wikipedia.org/wiki/Modulationhttp://en.wikipedia.org/wiki/Datahttp://en.wikipedia.org/wiki/Siliconhttp://en.wikipedia.org/wiki/Photodiodehttp://en.wikipedia.org/wiki/Electric_currenthttp://en.wikipedia.org/wiki/Remote_control
  • 8/6/2019 Smart Traffic Lightsynpsis

    52/84

    SEVEN SEGMENT DISPLAY

    The 7 segment display is used as a numerical indicator on manytypes of test equipment. It is an assembly of light emitting diodeswhich can be powered individually. They most commonly emit redlight. They are arranged and labelled as shown in the diagram.

    Powering all the segments will display the number 8.Poweringa,b,c d and g will display the number 3. Numbers 0 to 9 can bedisplayed.The d.p represents a decimal point. The one shown is a commonanode display since all anodes are joined together and go to the

    positive supply. The cathodes are connected individually to zerovolts. Resistors must be placed in series with each diode to limitthe current through each diode to a safe value.

    One common requirement for many different digital devices isa visual numeric display. Individual LEDs can of coursedisplay the binary states of a set of latches or flip-flops.However, we're far more used to thinking and dealing withdecimal numbers. To this end, we want a display of some kindthat can clearly represent decimal numbers without any

  • 8/6/2019 Smart Traffic Lightsynpsis

    53/84

    requirement of translating binary to decimal or any otherformat.

    One possibility is a matrix of 28 LEDs in a 74 array. We can

    then light up selected LEDs in the pattern required forwhatever character we want. Indeed, an expanded version ofthis is used in many ways, for fancy displays. However, if allwe want to display is numbers, this becomes a bit expensive. Amuch better way is to arrange the minimum possible number ofLEDs in such a way as to represent only numbers in a simplefashion.

    This requires just seven LEDs (plus an eighth one for thedecimal point, if that is needed). A common technique is touse a shaped piece of translucent plastic to operate as aspecialized optical fiber, to distribute the light from theLED evenly over a fixed bar shape. The seven bars are laidout as a squared-off figure "8". The result is known as aseven-segment LED.

    We've all seen seven-segment displays in a wide range ofapplications. Clocks, watches, digital instruments, andmany household appliances already have such displays. Inthis experiment, we'll look at what they are and how they

    can display any of the ten decimal digits 0-9 on demand.

  • 8/6/2019 Smart Traffic Lightsynpsis

    54/84

    FEATURES:-

    Standard Common Cathode Seven-Segment Display. Current Limiting Resistors Included. Easy to Connect Female Headers. Decimal Point also connected. Standard 5V control for most microcontrollers.

    DISPLAY LAYOUT:-Seven-segment displays can be packaged in a number ofways. Three typical packages are possible. On the left wesee three small digits in a single 12-pin DIP package. Theindividual digits are very small, so a clear plastic bubble ismolded over each digit to act as a magnifying lens. The

  • 8/6/2019 Smart Traffic Lightsynpsis

    55/84

    sides of the end bubbles are flattened so that additionalpackages of this type can be placed end-to-end to create adisplay of as many digits as may be needed.

    The second package is essentially a 14-pin DIP designed tobe installed vertically. Note that for this particular device,the decimal point is on the left. This is not true of all seven-segment displays in this type of package.

    One limitation of the DIP package is that it cannot supportlarger digits. To get larger displays for easy reading at adistance, it is necessary to change the package size andshape. The package on the right above is larger than theother two, and thus can display a digit that is significantlylarger than will fit on a standard DIP footprint. Even largerdisplays are also available; some digital clocks sport digitsthat are two to five inches tall.

    Seven-segment displays can be constructed using any of a

    number of different technologies. The three most commonmethods are fluorescent displays (used in many line-powered devices such as microwave ovens and some clocksand clock radios), liquid crystal displays (used in many

    battery-powered devices such as watches and many digitalinstruments), and LEDs (used in either line-powered or

    battery-powered devices). However, fluorescent displaysrequire a fairly high driving voltage to operate, and liquidcrystal displays require special treatment.

    RESISTANCE

  • 8/6/2019 Smart Traffic Lightsynpsis

    56/84

    Resistance is the opposition of a material to the current. It is

    measured in Ohms . All conductors represent a certain amount of

    resistance, since no conductor is 100% efficient. To control the

    electron flow (current) in a predictable manner, we use resistors.Electronic circuits use calibrated lumped resistance to control the

    flow of current. Broadly speaking, resistor can be divided into two

    groups viz. fixed & adjustable (variable) resistors. In fixed

    resistors, the value is fixed & cannot be varied. In variable

    resistors, the resistance value can be varied by an adjuster knob. It

    can be divided into (a) Carbon composition (b) Wire wound (c)

    Special type. The most common type of resistors used in ourprojects is carbon type. The resistance value is normally indicated

    by colour bands. Each resistance has four colours, one of the band

    on either side will be gold or silver, this is called fourth band and

    indicates the tolerance, others three band will give the value of

    resistance (see table). For example if a resistor has the following

    marking on it say red, violet, gold. Comparing these coloured rings

    with the colour code, its value is 27000 ohms or 27 kilo ohms andits tolerance is 5%. Resistor comes in various sizes (Power

    rating). The bigger, the size, the more power rating of 1/4 watts.

    The four colour rings on its body tells us the value of resistor value

    as given below.

    COLOURS CODE

    Black--------------------------------------0Brown-------------------------------------1Red----------------------------------------2Orange------------------------------------3Yellow------------------------------------4Green--------------------------------------5

  • 8/6/2019 Smart Traffic Lightsynpsis

    57/84

    Blue----------------------------------------6Violet--------------------------------------7Grey---------------------------------------8White--------------------------------------9

    The first rings give the first digit. The second ring gives the seconddigit. The third ring indicates the number of zeroes to be placed

    after the digits. The fourth ring gives tolerance (gold 5%, silver 10%, No colour 20%).

    In variable resistors, we have the dial type of resistance boxes.There is a knob with a metal pointer. This presses over brass pieces

    placed along a circle with some space b/w each of them.

    Resistance coils of different values are connected b/w the gaps.When the knob is rotated, the pointer also moves over the brass

    pieces. If a gap is skipped over, its resistance is included in thecircuit. If two gaps are skipped over, the resistances of bothtogether are included in the circuit and so on.

  • 8/6/2019 Smart Traffic Lightsynpsis

    58/84

    LED

    When a junction diode is forward biased, energy is released at thejunction diode is forward biased, energy is released at the junctiondue to recombination of electrons and holes. In case of silicon andgermanium diodes, the energy released is in infrared region. In the

    junction diode made of gallium arsenate or indium phosphide, theenergy is released in visible region. Such a junction diode is calleda light emitting diode or LED.

    ADAPTER

    Adapter is used in our circuit as an ac to dc converter.

    An adapter oradaptor is a device whose purpose is to convertattributes of one device or system to those of an otherwiseincompatible device or system.

    Some adapters may only affect physical attributes:

    An electrical adapter may enable connection of a socket usedin one region to aplug used in another by offeringconnections for the disparate contact arrangements, while notchanging the voltage.

    A garden hose adapter can convert between threads andquick-release, "snap"-type connections.

    One kind ofserial port adapter enables connections between25-contact and nine-contact connectors, but does not affect

    electrical power- and signalling-related attributes.

    Other adapters may affect electrical attributes:

    A transformeradapts household electric current from highvoltage (100 to 240 voltsAC) to low voltage suitable forconsumer electronics.

    http://en.wikipedia.org/wiki/Toolhttp://en.wikipedia.org/wiki/Sockethttp://en.wikipedia.org/wiki/Plughttp://en.wikipedia.org/wiki/Garden_hosehttp://en.wikipedia.org/wiki/Screw_threadhttp://en.wikipedia.org/wiki/Serial_porthttp://en.wikipedia.org/wiki/DB-25http://en.wikipedia.org/wiki/D-subminiaturehttp://en.wikipedia.org/wiki/Transformerhttp://en.wikipedia.org/wiki/Electric_currenthttp://en.wikipedia.org/wiki/Voltagehttp://en.wikipedia.org/wiki/Volthttp://en.wikipedia.org/wiki/Alternating_currenthttp://en.wikipedia.org/wiki/Consumer_electronicshttp://en.wikipedia.org/wiki/Toolhttp://en.wikipedia.org/wiki/Sockethttp://en.wikipedia.org/wiki/Plughttp://en.wikipedia.org/wiki/Garden_hosehttp://en.wikipedia.org/wiki/Screw_threadhttp://en.wikipedia.org/wiki/Serial_porthttp://en.wikipedia.org/wiki/DB-25http://en.wikipedia.org/wiki/D-subminiaturehttp://en.wikipedia.org/wiki/Transformerhttp://en.wikipedia.org/wiki/Electric_currenthttp://en.wikipedia.org/wiki/Voltagehttp://en.wikipedia.org/wiki/Volthttp://en.wikipedia.org/wiki/Alternating_currenthttp://en.wikipedia.org/wiki/Consumer_electronics
  • 8/6/2019 Smart Traffic Lightsynpsis

    59/84

    Most of the digital circuits operate on 5 volt DC supply which is obtained bythe following circuit. The power supply circuit consists of a step down

    transformer, bridge rectifier and 7805 voltage regulator IC.

    PROGRAM CODE

    Hardware. C

    #include

    sbit TRAFIC_E = P1^0;sbit TRAFIC_W = P1^1;sbit R_E = P1^2;sbit Y_E = P1^3;sbit G_E = P1^4;

    sbit R_W = P1^5;sbit Y_W = P1^6;sbit G_W = P1^7;

    sbit TRAFIC_N = P3^0;sbit TRAFIC_S = P3^1;

    ACSUPPLY

    D1

    D2

    D3

    D4

    1

    B 2

    A

    3 4

    7805

    1000 F + +

    --

    5 VDC

  • 8/6/2019 Smart Traffic Lightsynpsis

    60/84

    sbit R_N = P3^2;sbit Y_N = P3^3;sbit G_N = P3^4;sbit R_S = P3^5;

    sbit Y_S = P3^6;sbit G_S = P3^7;

    #define SEVEN_SEG P2sbit CS1_E = SEVEN_SEG^0;sbit CS2_E = SEVEN_SEG^1;sbit CS1_W = SEVEN_SEG^2;sbit CS2_W = SEVEN_SEG^3;

    sbit CS1_N = SEVEN_SEG^4;sbit CS2_N = SEVEN_SEG^5;sbit CS1_S = SEVEN_SEG^6;sbit CS2_S = SEVEN_SEG^7;

    #define SEGMENTPORT P0

    typedef unsigned char uc;

    typedef unsigned int ui;#define HIGH 1#define LOW 0#define TRUE 1#define FALSE 0#define THERE 0#define NOT_THERE 1

    #define SEG_E_HB 0

    #define SEG_E_LB 1#define SEG_W_HB 2#define SEG_W_LB 3#define SEG_N_HB 4#define SEG_N_LB 5#define SEG_S_HB 6

  • 8/6/2019 Smart Traffic Lightsynpsis

    61/84

    #define SEG_S_LB 7

    #define YELLOW_TIME 3#define MIN_TIME 20

    #define MAX_TIME 90#define ADD_TIME 5

    ; Standard SFR SymbolsACC DATA 0E0H

    B DATA 0F0HSP DATA 81HDPL DATA 82HDPH DATA 83H

    NAME ?C_STARTUP

    ?C_C51STARTUP SEGMENT CODE?STACK SEGMENT IDATA

    RSEG ?STACKDS 1

    EXTRN CODE (?C_START)PUBLIC ?C_STARTUP

    CSEG AT 0?C_STARTUP: LJMP STARTUP1

    RSEG ?C_C51STARTUP

    STARTUP1:

  • 8/6/2019 Smart Traffic Lightsynpsis

    62/84

    IF IDATALEN 0MOV R0,#IDATALEN - 1CLR A

    IDATALOOP: MOV @R0,ADJNZ R0,IDATALOOP

    ENDIF

    IF XDATALEN 0MOV DPTR,#XDATASTARTMOV R7,#LOW (XDATALEN)

    IF (LOW (XDATALEN)) 0

    MOV R6,#(HIGH (XDATALEN)) +1ELSE

    MOV R6,#HIGH (XDATALEN)ENDIF

    CLR AXDATALOOP: MOVX @DPTR,A

    INC DPTRDJNZ R7,XDATALOOP

    DJNZ R6,XDATALOOPENDIF

    IF PPAGEENABLE 0MOV PPAGE_SFR,#PPAGE

    ENDIF

    IF PDATALEN 0MOV R0,#LOW (PDATASTART)

    MOV R7,#LOW (PDATALEN)CLR A

    PDATALOOP: MOVX @R0,AINC R0DJNZ R7,PDATALOOP

    ENDIF

  • 8/6/2019 Smart Traffic Lightsynpsis

    63/84

    IF IBPSTACK 0EXTRN DATA (?C_IBP)

    MOV ?C_IBP,#LOW IBPSTACKTOPENDIF

    IF XBPSTACK 0EXTRN DATA (?C_XBP)

    MOV ?C_XBP,#HIGH XBPSTACKTOPMOV ?C_XBP+1,#LOW XBPSTACKTOP

    ENDIF

    IF PBPSTACK 0EXTRN DATA (?C_PBP)

    MOV ?C_PBP,#LOW PBPSTACKTOPENDIF

    MOV SP,#?STACK-1

    ; This code is required if you use L51_BANK.A51 with BankingMode 4; EXTRN CODE (?B_SWITCH0); CALL ?B_SWITCH0 ; init bank mechanism tocode bank 0

    LJMP ?C_START

    END

    Main.c#include"hardware.c"

    bit yellowflag;extern uc direction;extern uc count;

  • 8/6/2019 Smart Traffic Lightsynpsis

    64/84

    void delay(ui time);

    extern void display();

    uc timecount;void main(){ uc limit = MIN_TIME;

    /*TIMER 0 INITIALIZATION*/P1 = 0x03;P3 = 0x03;

    yellowflag = FALSE;

    IE = 0x82;TH0 = 0X8a;TL0 = 0Xa2;timecount = 120;TR0 = 1;

    count = 0;

    direction = 'E';while(1){ if(count == MAX_TIME-YELLOW_TIME)

    yellowflag = TRUE;else if(count == limit-YELLOW_TIME && yellowflag

    == FALSE){ switch(direction)

    { case 'E': if(TRAFIC_E == THERE)limit = limit +

    ADD_TIME;else

    yellowflag = TRUE;break;

    case 'W': if(TRAFIC_W == THERE)

  • 8/6/2019 Smart Traffic Lightsynpsis

    65/84

    limit = limit +ADD_TIME;

    elseyellowflag = TRUE;

    break;case 'N': if(TRAFIC_N == THERE)

    limit = limit +ADD_TIME;

    elseyellowflag = TRUE;

    break;case 'S': if(TRAFIC_S == THERE)

    limit = limit +ADD_TIME;

    elseyellowflag = TRUE;

    break;}

    }else if(count == limit || count == MAX_TIME)

    { switch(direction){ case 'E': direction = 'W';break;case 'W': direction = 'N';break;case 'N': direction = 'S';break;case 'S': direction = 'E';break;

    }count = 0;limit = MIN_TIME;yellowflag = FALSE;

    }display();

    }}

  • 8/6/2019 Smart Traffic Lightsynpsis

    66/84

    /*******************INTERRUPT SERVICE ROUTINE FORTIMER0***********************************************/void timer0isr()interrupt 1 using 1

    { TR0=0;TH0 = 0X00;TL0 = 0X00;if(timecount == 0){ timecount = 120; // ONE SECOND

    count++;}else

    timecount--; //NOT A SECOND , HENCEDECREMENT THE INTERRUPT COUNT

    TR0=1; //ENABLE TIMER AGAIN}/*******************************************************************************************************/

    seven segment.c#include "hardware.c"

    uc direction;uc count;extern bit yellowflag;void show(char val, char seg);void display()

    { uc counthb,countlb,temp;temp = count;countlb = temp%10;temp/=10;counthb = temp%10;

  • 8/6/2019 Smart Traffic Lightsynpsis

    67/84

    switch(direction){ case 'E': if(yellowflag == FALSE)

    { R_E = 0; Y_E = 0; G_E = 1;R_W = 1; Y_W = 0; G_W = 0;

    R_N = 1; Y_N = 0; G_N = 0;R_S = 1; Y_S = 0; G_S = 0;

    }else{ R_E = 0; Y_E = 1; G_E = 0;

    R_W = 1; Y_W = 0; G_W = 0;R_N = 1; Y_N = 0; G_N = 0;R_S = 1; Y_S = 0; G_S = 0;

    }

    show(countlb,SEG_E_LB);show(counthb,SEG_E_HB);break;case 'W': if(yellowflag == FALSE)

    { R_E = 1; Y_E = 0; G_E = 0;R_W = 0; Y_W = 0; G_W = 1;R_N = 1; Y_N = 0; G_N = 0;

    R_S = 1; Y_S = 0; G_S = 0;}else{ R_E = 1; Y_E = 0; G_E = 0;

    R_W = 0; Y_W = 1; G_W = 0;R_N = 1; Y_N = 0; G_N = 0;R_S = 1; Y_S = 0; G_S = 0;

    }

    show(countlb,SEG_W_LB);show(counthb,SEG_W_HB);break;case 'N': if(yellowflag == FALSE)

    { R_E = 1; Y_E = 0; G_E = 0;R_W = 1; Y_W = 0; G_W = 0;R_N = 0; Y_N = 0; G_N = 1;

  • 8/6/2019 Smart Traffic Lightsynpsis

    68/84

    R_S = 1; Y_S = 0; G_S = 0;}else{ R_E = 1; Y_E = 0; G_E = 0;

    R_W = 1; Y_W = 0; G_W = 0;R_N = 0; Y_N = 1; G_N = 0;R_S = 1; Y_S = 0; G_S = 0;

    }

    show(countlb,SEG_N_LB);show(counthb,SEG_N_HB);break;case 'S': if(yellowflag == FALSE)

    { R_E = 1; Y_E = 0; G_E = 0;R_W = 1; Y_W = 0; G_W = 0;R_N = 1; Y_N = 0; G_N = 0;R_S = 0; Y_S = 0; G_S = 1;

    }else{ R_E = 1; Y_E = 0; G_E = 0;

    R_W = 1; Y_W = 0; G_W = 0;

    R_N = 1; Y_N = 0; G_N = 0;R_S = 0; Y_S = 1; G_S = 0;}

    show(countlb,SEG_S_LB);show(counthb,SEG_S_HB);break;}

    }

    void show(char val, char seg){ int i;

    switch(val){ case 0x00: SEGMENTPORT = 0XC0; break;

    case 0x01: SEGMENTPORT = 0XF9; break;

  • 8/6/2019 Smart Traffic Lightsynpsis

    69/84

    case 0x02: SEGMENTPORT = 0XA4; break;case 0x03: SEGMENTPORT = 0XB0; break;case 0x04: SEGMENTPORT = 0X99; break;case 0x05: SEGMENTPORT = 0X92; break;

    case 0x06: SEGMENTPORT = 0X82; break;case 0x07: SEGMENTPORT = 0XF8; break;case 0x08: SEGMENTPORT = 0X80; break;case 0x09: SEGMENTPORT = 0X90; break;case 0x0A: SEGMENTPORT = 0X46; break;//degree

    centigradedefault: SEGMENTPORT = 0Xbf; break;//dash

    }

    switch(seg){ case SEG_E_LB: SEVEN_SEG = 0X01;break;

    case SEG_E_HB: SEVEN_SEG = 0X02;break;case SEG_W_LB: SEVEN_SEG = 0X04;break;case SEG_W_HB: SEVEN_SEG = 0X08;break;case SEG_N_LB: SEVEN_SEG = 0X10;break;case SEG_N_HB: SEVEN_SEG = 0X20;break;case SEG_S_LB: SEVEN_SEG = 0X40;break;

    case SEG_S_HB: SEVEN_SEG = 0X80;break;}for(i=100;i>0;i--);SEVEN_SEG = 0X00;

    }

    include.c#include

    sbit TRAFIC_E = P1^0;sbit TRAFIC_W = P1^1;sbit R_E = P1^2;sbit Y_E = P1^3;sbit G_E = P1^4;

  • 8/6/2019 Smart Traffic Lightsynpsis

    70/84

    sbit R_W = P1^5;sbit Y_W = P1^6;sbit G_W = P1^7;

    sbit TRAFIC_N = P3^0;sbit TRAFIC_S = P3^1;sbit R_N = P3^2;sbit Y_N = P3^3;sbit G_N = P3^4;sbit R_S = P3^5;sbit Y_S = P3^6;sbit G_S = P3^7;

    #define SEVEN_SEG P2sbit CS1_E = SEVEN_SEG^0;sbit CS2_E = SEVEN_SEG^1;sbit CS1_W = SEVEN_SEG^2;sbit CS2_W = SEVEN_SEG^3;sbit CS1_N = SEVEN_SEG^4;sbit CS2_N = SEVEN_SEG^5;

    sbit CS1_S = SEVEN_SEG^6;sbit CS2_S = SEVEN_SEG^7;

    #define SEGMENTPORT P0

    typedef unsigned char uc;typedef unsigned int ui;#define HIGH 1#define LOW 0

    #define TRUE 1#define FALSE 0#define THERE 0#define NOT_THERE 1

    #define SEG_E_HB 0

  • 8/6/2019 Smart Traffic Lightsynpsis

    71/84

    #define SEG_E_LB 1#define SEG_W_HB 2#define SEG_W_LB 3#define SEG_N_HB 4

    #define SEG_N_LB 5#define SEG_S_HB 6#define SEG_S_LB 7

    #define YELLOW_TIME 3#define MIN_TIME 20#define MAX_TIME 90#define ADD_TIME 5

    $NOMOD51;------------------------------------------------------------------------------; This file is part of the C51 Compiler package; Copyright (c) 1988-2002 Keil Elektronik GmbH and KeilSoftware, Inc.

    ;------------------------------------------------------------------------------; STARTUP.A51: This code is executed after processor reset.;; To translate this file use A51 with the following invocation:;; A51 STARTUP.A51;; To link the modified STARTUP.OBJ file to your application usethe following

    ; BL51 invocation:;; BL51 , STARTUP.OBJ ;;------------------------------------------------------------------------------;

  • 8/6/2019 Smart Traffic Lightsynpsis

    72/84

    ; User-defined Power-On Initialization of Memory;; With the following EQU statements the initialization of memory; at processor reset can be defined:

    ;; ; the absolute start-address of IDATA memory is always0IDATALEN EQU 80H ; the length of IDATA memory in

    bytes.;XDATASTART EQU 0H ; the absolute start-address ofXDATA memory

    XDATALEN EQU 0H ; the length of XDATA memoryin bytes.;PDATASTART EQU 0H ; the absolute start-address ofPDATA memoryPDATALEN EQU 0H ; the length of PDATA memoryin bytes.;

    ; Notes: The IDATA space overlaps physically the DATA andBIT areas of the; 8051 CPU. At minimum the memory space occupied fromthe C51; run-time routines must be set to zero.;------------------------------------------------------------------------------;; Reentrant Stack Initilization;

    ; The following EQU statements define the stack pointer forreentrant; functions and initialized it:;; Stack Space for reentrant functions in the SMALL model.IBPSTACK EQU 0 ; set to 1 if small reentrant is used.

  • 8/6/2019 Smart Traffic Lightsynpsis

    73/84

    IBPSTACKTOP EQU 0FFH+1 ; set top of stack to highestlocation+1.;; Stack Space for reentrant functions in the LARGE model.

    XBPSTACK EQU 0 ; set to 1 if large reentrant is used.XBPSTACKTOP EQU 0FFFFH+1; set top of stack to highestlocation+1.;; Stack Space for reentrant functions in the COMPACT model.PBPSTACK EQU 0 ; set to 1 if compact reentrant isused.PBPSTACKTOP EQU 0FFFFH+1; set top of stack to highest

    location+1.;;------------------------------------------------------------------------------;; Page Definition for Using the Compact Model with 64 KBytexdata RAM;; The following EQU statements define the xdata page used for

    pdata; variables. The EQU PPAGE must conform with the PPAGEcontrol used; in the linker invocation.;PPAGEENABLE EQU 0 ; set to 1 if pdata object areused.;PPAGE EQU 0 ; define PPAGE number.

    ;PPAGE_SFR DATA 0A0H ; SFR that supplies uppermostaddress byte; (most 8051 variants use P2 as uppermost address byte);;------------------------------------------------------------------------------

  • 8/6/2019 Smart Traffic Lightsynpsis

    74/84

    ; Standard SFR SymbolsACC DATA 0E0HB DATA 0F0H

    SP DATA 81HDPL DATA 82HDPH DATA 83H

    NAME ?C_STARTUP

    ?C_C51STARTUP SEGMENT CODE

    ?STACK SEGMENT IDATA

    RSEG ?STACKDS 1

    EXTRN CODE (?C_START)PUBLIC ?C_STARTUP

    CSEG AT 0?C_STARTUP: LJMP STARTUP1

    RSEG ?C_C51STARTUP

    STARTUP1:

    IF IDATALEN 0MOV R0,#IDATALEN - 1

    CLR AIDATALOOP: MOV @R0,A

    DJNZ R0,IDATALOOPENDIF

    IF XDATALEN 0

  • 8/6/2019 Smart Traffic Lightsynpsis

    75/84

    MOV DPTR,#XDATASTARTMOV R7,#LOW (XDATALEN)

    IF (LOW (XDATALEN)) 0MOV R6,#(HIGH (XDATALEN)) +1

    ELSEMOV R6,#HIGH (XDATALEN)

    ENDIFCLR A

    XDATALOOP: MOVX @DPTR,AINC DPTRDJNZ R7,XDATALOOPDJNZ R6,XDATALOOP

    ENDIF

    IF PPAGEENABLE 0MOV PPAGE_SFR,#PPAGE

    ENDIF

    IF PDATALEN 0MOV R0,#LOW (PDATASTART)

    MOV R7,#LOW (PDATALEN)CLR APDATALOOP: MOVX @R0,A

    INC R0DJNZ R7,PDATALOOP

    ENDIF

    IF IBPSTACK 0EXTRN DATA (?C_IBP)

    MOV ?C_IBP,#LOW IBPSTACKTOPENDIF

    IF XBPSTACK 0EXTRN DATA (?C_XBP)

  • 8/6/2019 Smart Traffic Lightsynpsis

    76/84

    MOV ?C_XBP,#HIGH XBPSTACKTOPMOV ?C_XBP+1,#LOW XBPSTACKTOP

    ENDIF

    IF PBPSTACK 0EXTRN DATA (?C_PBP)

    MOV ?C_PBP,#LOW PBPSTACKTOPENDIF

    MOV SP,#?STACK-1; This code is required if you use L51_BANK.A51 with Banking

    Mode 4; EXTRN CODE (?B_SWITCH0); CALL ?B_SWITCH0 ; init bank mechanism tocode bank 0

    LJMP ?C_START

    END

    #include"hardware.c"

    bit yellowflag;extern uc direction;extern uc count;

    void delay(ui time);

    extern void display();

    uc timecount;void main(){ uc limit = MIN_TIME;

    /*TIMER 0 INITIALIZATION*/P1 = 0x03;P3 = 0x03;

  • 8/6/2019 Smart Traffic Lightsynpsis

    77/84

    yellowflag = FALSE;

    IE = 0x82;

    TH0 = 0X8a;TL0 = 0Xa2;timecount = 120;TR0 = 1;

    count = 0;direction = 'E';while(1)

    { if(count == MAX_TIME-YELLOW_TIME)yellowflag = TRUE;

    else if(count == limit-YELLOW_TIME && yellowflag== FALSE)

    { switch(direction){ case 'E': if(TRAFIC_E == THERE)

    limit = limit +ADD_TIME;

    else yellowflag = TRUE;break;

    case 'W': if(TRAFIC_W == THERE)limit = limit +

    ADD_TIME;else

    yellowflag = TRUE;break;

    case 'N': if(TRAFIC_N == THERE)limit = limit +

    ADD_TIME;else

    yellowflag = TRUE;break;

  • 8/6/2019 Smart Traffic Lightsynpsis

    78/84

    case 'S': if(TRAFIC_S == THERE)limit = limit +

    ADD_TIME;else

    yellowflag = TRUE;break;

    }}else if(count == limit || count == MAX_TIME){ switch(direction)

    { case 'E': direction = 'W';break;case 'W': direction = 'N';break;

    case 'N': direction = 'S';break;case 'S': direction = 'E';break;

    }count = 0;limit = MIN_TIME;yellowflag = FALSE;

    }display();

    }}

    #include "hardware.c"

    uc direction;uc count;extern bit yellowflag;

    void show(char val, char seg);void display(){ uc counthb,countlb,temp;

    temp = count;countlb = temp%10;temp/=10;

  • 8/6/2019 Smart Traffic Lightsynpsis

    79/84

    counthb = temp%10;

    switch(direction){ case 'E': if(yellowflag == FALSE)

    { R_E = 0; Y_E = 0; G_E = 1;R_W = 1; Y_W = 0; G_W = 0;R_N = 1; Y_N = 0; G_N = 0;R_S = 1; Y_S = 0; G_S = 0;

    }else{ R_E = 0; Y_E = 1; G_E = 0;

    R_W = 1; Y_W = 0; G_W = 0;

    R_N = 1; Y_N = 0; G_N = 0;R_S = 1; Y_S = 0; G_S = 0;

    }

    show(countlb,SEG_E_LB);show(counthb,SEG_E_HB);break;case 'W': if(yellowflag == FALSE)

    { R_E = 1; Y_E = 0; G_E = 0;

    R_W = 0; Y_W = 0; G_W = 1;R_N = 1; Y_N = 0; G_N = 0;R_S = 1; Y_S = 0; G_S = 0;

    }else{ R_E = 1; Y_E = 0; G_E = 0;

    R_W = 0; Y_W = 1; G_W = 0;R_N = 1; Y_N = 0; G_N = 0;R_S = 1; Y_S = 0; G_S = 0;

    }

    show(countlb,SEG_W_LB);show(counthb,SEG_W_HB);break;case 'N': if(yellowflag == FALSE)

    { R_E = 1; Y_E = 0; G_E = 0;

  • 8/6/2019 Smart Traffic Lightsynpsis

    80/84

    R_W = 1; Y_W = 0; G_W = 0;R_N = 0; Y_N = 0; G_N = 1;R_S = 1; Y_S = 0; G_S = 0;

    }

    else{ R_E = 1; Y_E = 0; G_E = 0;

    R_W = 1; Y_W = 0; G_W = 0;R_N = 0; Y_N = 1; G_N = 0;R_S = 1; Y_S = 0; G_S = 0;

    }

    show(countlb,SEG_N_LB);show(counthb,SEG_N_HB);break;case 'S': if(yellowflag == FALSE)

    { R_E = 1; Y_E = 0; G_E = 0;R_W = 1; Y_W = 0; G_W = 0;R_N = 1; Y_N = 0; G_N = 0;R_S = 0; Y_S = 0; G_S = 1;

    }else

    { R_E = 1; Y_E = 0; G_E = 0;R_W = 1; Y_W = 0; G_W = 0;R_N = 1; Y_N = 0; G_N = 0;R_S = 0; Y_S = 1; G_S = 0;

    }

    show(countlb,SEG_S_LB);show(counthb,SEG_S_HB);break;}

    }

    void show(char val, char seg){ int i;

    switch(val)

  • 8/6/2019 Smart Traffic Lightsynpsis

    81/84

    { case 0x00: SEGMENTPORT = 0XC0; break;case 0x01: SEGMENTPORT = 0XF9; break;case 0x02: SEGMENTPORT = 0XA4; break;case 0x03: SEGMENTPORT = 0XB0; break;

    case 0x04: SEGMENTPORT = 0X99; break;case 0x05: SEGMENTPORT = 0X92; break;case 0x06: SEGMENTPORT = 0X82; break;case 0x07: SEGMENTPORT = 0XF8; break;case 0x08: SEGMENTPORT = 0X80; break;case 0x09: SEGMENTPORT = 0X90; break;case 0x0A: SEGMENTPORT = 0X46; break;//degree

    centigrade

    default: SEGMENTPORT = 0Xbf; break;//dash}switch(seg)

    { case SEG_E_LB: SEVEN_SEG = 0X01;break;case SEG_E_HB: SEVEN_SEG = 0X02;break;case SEG_W_LB: SEVEN_SEG = 0X04;break;

    case SEG_W_HB: SEVEN_SEG = 0X08;break;case SEG_N_LB: SEVEN_SEG = 0X10;break;case SEG_N_HB: SEVEN_SEG = 0X20;break;case SEG_S_LB: SEVEN_SEG = 0X40;break;case SEG_S_HB: SEVEN_SEG = 0X80;break;

    }for(i=100;i>0;i--);SEVEN_SEG = 0X00;

    }

  • 8/6/2019 Smart Traffic Lightsynpsis

    82/84

    CONCLUSION

    This project is a multipurpose project which provide extensivefeatures to the ordinary traffic light control system with the facilityof red light jump control by use of ignition off system. This projectcan help in prevention of traffic jams in metropolitan cities and canalso provide fuel conservation by automatic ignition off. The

    project can be implemented by the step of government of

    implementation of our automatic ignition off circuit in all thevehicles running on the road.

  • 8/6/2019 Smart Traffic Lightsynpsis

    83/84

    REFERENCES

    1. Intel Application Note AP-155, Oscillators forMicrocontrollers, 1983.

    2. ^ Nicholson, Alexander M.. "Generating and transmittingelectric currents". US Patent No. 2212845.., filed April 10,1918, granted August 27, 1940

    3. ^ Marrison, Warren (1948). "The Evolution of the QuartzCrystal Clock".Bell System Technical Journal(AT&T) 27:

    510588. ^^ Virgil E Bottom (1982).4. ^ Dr. S. C. Liew, "Electromagnetic Waves", Centre for

    Remote Imaging, Sensing and Processing,5. Henderson, Roy, "Wavelength Considerations", Instituts fr

    Umform- und Hochleistungs,

    http://en.wikipedia.org/wiki/Crystal_oscillator#cite_ref-0http://patimg1.uspto.gov/.piw?Docid=02212845&homeurl=http%3A%2F%2Fpatft.uspto.gov%2Fnetacgi%2Fnph-Parser%3FSect1%3DPTO2%2526Sect2%3DHITOFF%2526p%3D1%2526u%3D%25252Fnetahtml%25252FPTO%25252Fsearch-bool.html%2526r%3D1%2526f%3DG%2526l%3D50%2526co1%3DAND%2526d%3DPALL%2526s1%3D2212845.PN.%2526OS%3DPN%2F2212845%2526RS%3DPN%2F2212845&PageNum=&Rtype=&SectionNum=&idkey=NONE&Input=View+first+pag