Sie sind auf Seite 1von 49

Intelligent traffic signal controller

A PROJECT REPORT Submitted by

In fulfillment for the award of the degree of

BACHELOR OF ENGINEERING
in

Electronics &Communication

College logo

College name Gujarat Technological University, Ahmedabad


DECEMBER 2011

Acknowledgement
We are very grateful to our Principal _______ for providing us with an environment to complete our project Intelligent traffic signal controller successfully. We are deeply indebted to our Head of the EC Department ______, who modeled us both technically and morally for achieving greater success in life. We are very grateful to our internal guide ____________, for being instrumental in the completion of our project with her complete guidance. We express our sincere thanks to his/her for his/her constant encouragement and support. We also thank all the staff members of our college and technicians for their help in making this project a successful one. Finally, we take this opportunity to extend our deep appreciation to our family and friends, for all that they meant to us during the crucial times of the
completion of our project

Abstract
Vehicular travel is increasing throughout the world, particularly in large urban areas. Therefore the need arises for simulating and optimizing traffic control algorithms to better accommodate this increasing demand. In this paper we study the simulation and optimization of traffic light controllers in a city and present an adaptive optimization algorithm based on reinforcement learning. We have implemented a traffic light simulator, Green Light District, that allows us to experiment with different infrastructures and to compare different traffic light controllers. Experimental results indicate that our adaptive traffic light controllers outperform other fixed controllers on all studied infrastructures.

TABLE OF CONTENTS
Introduction to project Literature review Circuit Diagram Components Software Development Software Simulations Problems faced during project

Introduction to Project:
We are making the working model for the traffic light signals as seen on the road. We are making it completely automatic. As it is intelligent, this circuit can also protect it self. This circuit has a feature to turn on or off the exhaust fan as per requirements. Since, This circuit is a proper working model of our traffic signal systems , when the green light occurs on 1 side, then the car starts moving and it reaches to the next side. The same thing also happens on the road infront of this side. This circuit is also Eco friendly model. Means , it is energy efficient. So reduces energy consumption and therefore the pollution also. It is environmental friendly, as there is a automatic eco friendly Street Light controller system in it. So the street lights are turned off during the day hours and it is in OFF condition and it is turned ON during the night hours. Hence the user doesnt need to keep on/off the street lights manually. So we can call it a User friendly Traffic signal model. During working hours and peak hours traffic need to be controlled in order to avoid jams and accidents in hurry , because nobody has time to wait resulting in jam and accidents. An automatic intelligent traffic controller is a solution to such circumstances. This controller does not only controls the traffic in a sequential manner by giving equal time to all the sides but also prevents pollution on the signals .

When red signals are turned to green and vehicle are started, engine emits lot of black smoke that is much concern to all of us, standing near to signals or staying near to signals , to avoid this we have planned to start an exhaust fan which is fixed below the roads with certain arrangements on the all sides of crossing to suck the black smoke right away and leave it on to high enough into sky. We may not be able to remove all the smoke front the road but at least we can reduce it to certain extent. Project presented here is based on worlds most popular 8051 family of microcontroller.

Literature Review
Generally the project traffic signal lights for the engineering projects is made using the IC CD4017. It is the decade counter IC. Means, it switches the high state condition to some particular pins. So that we can adjust the pin configurations and make Traffic signals by connecting LEDs to this pins. We can vary this time delay by using the NE 555 timer IC.This configuration is as shown in the figure below:

This circuit is based on timer/counter fundamentals. The table for the lights on off state is as shown here.

Hence we get the patterns exactly as per our real life traffic lights. But this circuit is reliable for only 1 traffic signal, Not for 4 traffic signals. Because there are only 3 output terminals in this circuits. When we need more signals we need more output pins. Hence we need to use 4 circuits like above circuit. But this is very complec, because we need to select a very accurate time delay and time synchronization between this 4 traffic signals. This is very typical task, because we need to select R-C values of NE 555 IC very accurate. Even if we do all above tasks successfully, then there will arise a new problem. This circuit cant be reset properly and so once we reset it, all signals will start indicating random values, due to no synchronization between them now Hence we cant use this circuit for our working model. Hence we have decided to use some high level hardware for this working model. And then after so much analysis we concluded that we should use the microcontroller. Once we decided to use the microcontroller, then again a new question was arisen that: Which microcontroller family should be best as per our application? there were lots of possibilities. We can use the microcontrollers

from Intel 8051, AVR , PIC families. Even we could use the processors like ARM processors, ATmega processors etc.. Then we finally concluded that we must use 8051 microcontroller due to its following features in our project: User friendly Easily available development tools Easily programmable Future extension easily possible and Low cost

Circuit Diagram:
There are two parts in it : 8051 hardware: LED with 8051 microcontroller LEDs are by far the most widely used means of taking output. They find huge application as indicators during experimentations to check the validity of results at different stages. They are very cheap and easily available in a variety of shape, size and colors. The principle of operation of LEDs is simple. The commonly available LEDs have a drop voltage of 1.7 V and need 10 mA to glow at full intensity. The following circuit describes how to glow an led.

The value of resistance R can be calculated using the equation, R= (V-1.7)/10 mA. Since most of the controllers work on 5V, so substituting V= 5V, the value of resistance comes out to be 330 ohm. The resistance 220 ohm, 470 ohm is commonly used substitute in case 330 ohm is not available. 8051 microcontroller is a 40 pin microcontroller which belongs to 8051 series of microcontroller. It has four ports each of 8 bits P0, P1, P2 and P3.The AT89C51 has 4K bytes of programmable flash. The port P0 covers the pin 32 to pin 39, the port P1 covers the pin 1 to pin 8, the port P2 covers the pin 21 to pin 28 and the port P3 covers the pin 10 to pin 17. Pin 9 is the reset pin. The reset is active high. Whenever the controller is given supply, the reset pin must be given a high signal to reset the controller and bring the program counter to the starting address 0x0000. The controller can be reset by manually connecting a switch or by connecting a combination of resistor and capacitor as shown in the circuit diagram. A 12 MHz crystal is connected between pin 18 pin 19. Pin 40 is Vcc and pin 20 is ground. Pin 31, is connected to Vcc as we are using the internal memory of the controller. LEDs are connected to the port P0. LEDs need approximately 10mA current to flow through them in order to glow at maximum intensity. However the output of the controller is not sufficient enough to drive the LEDs, so if the positive leg of the LED is connected to the pin and the negative to ground as shown in the figure, the LED will not glow at full illumination.

To overcome this problem LEDs are connected in the reverse order and they run on negative logic i.e., whenever 1 is given on any pin of the port, the LED will switch off and when logic 0 is provided the LED will glow at full intensity. As soon as we provide supply to the controller, the LEDs start blinking i.e., they become on for a certain time duration and then become off for the same time duration. This delay is provided by calling the delay function. The values inside the delay function have been set to provide a delay in multiples of millisecond (delay (100) will provide a delay of 100 millisecond)

DC motor part: How to drive a +12V load (e.g. a relay) from 8051 port pin?
If only a single output is required, we try the following diagram:

or a modification with less current consumption:

However, note that 1N4148 is a signal diode and if it drives a "bigger" relay coil, it can be easily destroyed (literally) by the induction "kick" from the relay coil. It has to withstand at least the same current as flows in the coil when the transistor is on, but there is no need to have a high reverse voltage type. Make sure that the diode turn-on time is shorter than the transistor's turn-off time, otherwise the diode won't protect the transistor from the induction kick properly. There are also integrated solutions available, with multiple drivers per package (e.g. ULN2803/2804/2003/2004 - second sourced by more manufacturers). They contain also a freewheeling diode for each driver, but usually the relay is situated away from the drivers (sometimes not even on the PCB, but connected via cables/connectors) and the inductive current flowing back to the diode would cause problems - the diode must be placed directly at the coil. They are also similar or better drivers with added shift register and latch, so multiple loads can be driven using only a couple of pins (such as TI's TPIC6B595 and similar). Another option to drive a higher voltage load would be to use an opt coupler to decouple the two supply voltages, for example:

As a driver, also bipolar transistor can be used, with appropriate biasing resistors.

Automatic Street light controller circuit: Automatic Street Light Control System is a simple yet powerful concept, which uses transistor as a switch. By using this system manual works are 100% removed. It automatically switches ON lights when the sunlight goes below the visible region of our eyes. This is done by a sensor called Light Dependant Resistor (LDR) which senses the light actually like our eyes. It automatically switches OFF lights whenever the sunlight comes, visible to our eyes. By using this system energy consumption is also reduced because nowadays the manually operated street lights are not switched off even the sunlight comes and also switched on earlier before sunset. In this project, no need of manual operation like ON time and OFF time setting. LDR and transistor are the main components of the project. The resistance of light dependant resistor (LDR) varies according to the light falling on it. This LDR is connected as biasing resistor of the transistor. According to the light

falls on the LDR, the transistor is operated in saturation and cut off region. This transistor switches the relay to switch on / off the light. This project uses regulated 12V, 750mA power supply. 7812 three terminal voltage regulator is used for voltage regulation. Bridge type full wave rectifier is used to rectify the ac out put of secondary of 230/18V step down transformer.

The circuit diagram present here is that of a street light that automatically switches ON when the night falls and turns OFF when the sun rises.In fact you can this circuit for implementing any type of automatic night light. The circuit uses an LDR to sense the light .When there is light the resistance of LDR will be low. So the voltage drop across POT R2 will be high. This keeps the transistor Q1 ON. The collector of Q1(BC107) is coupled to base of Q2(SL100).So Q2 will be OFF and so do the relay. The bulb will remain OFF. When night falls the resistance of LDR increases to make the voltage across the POT R2 to decrease below 0.6V.This makes transistor Q1 OFF which in turn makes Q2 ON. The relay will be energized and the bulb will glow. The generalized block diagram of this circuit is like this:

This circuit gets the supply from following process. We are using the 7805 regulator IC here.

Advantages: 1. Highly sensitive 2. Works according to the light intensity 3. Fit and Forget system 4. Low cost and reliable circuit 5. Complete elimination of manpower 6. Can handle heavy loads up to 7A 7. System can be switched into manual mode whenever required Applications: 1. Balcony / stair case / parking Lightings 2. Street lights 3. Garden Lights

Components:
Resistors: 8.2k,1k Ceramic capacitor 33pF, Electrolyte Capacitor 10uF, 1uF Microcontroller AT89C52 Transistors BC 548 IC-7805 Heat sink 12V relay Transistor BC 548 Transistor BC 558 DC motors DC socket LEDs LDR 12V DC battery

Resistor: A resistor is a two-terminal electronic component that produces a voltage across its terminals that is proportional to the electric current through it.

VOLTAGE EQUATION: V= IR Resistor is a frequency independent component.

SERIES CONNECTION:In series connection, the resistors are connected end to end as shown below:

THE TOTAL RESISTAILL BE: R1+R2+R3 PARELLEL CONNECTION:

THE TOTAL RESISTANCE WILL BE :1/Rab = 1/R1 + 1/R2 + 1/R3.

Capacitor: A capacitor consists of two conducting plates separated by an insulating material called the dielectric. A capacitor is a passive electronic component that stores energy in the form of an electrostatic field.

Capacitance:The ratio of change in electric charge to change in voltage is defined as capacitance of the capacitor and its unit is farade. Capacitance is defined as the rate of change of current.

C=dV/dt When the voltage is applied across the capacitor, it immediately gets charged and then it is discharged with time. Capacitor is a frequency dependent component Capacitors in parallel:

The total capacitance will be:

Capacitors in series:

The total capacitance will be:

Applications: Capacitors are widely used in electronic circuits to block direct current, Allowing alternating current to pass, In filter networks, for smoothing the output of power supplies.

8051 Microcontroller: Compatible with MCS-51 Products 4K Bytes of In-System Programmable (ISP) Flash Memory Endurance: 10,000 Write/Erase Cycles 4.0V to 5.5V Operating Range Fully Static Operation: 0 Hz to 33 MHz 128 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources 8051 Family Intel fabricated the original 8051 which is known as MCS-51. The other two members of the 8051 family are: i. 8052 This microcontroller has 256 bytes of RAM and 3 timers. In addition to the standard features of 8051, this microcontroller has an added 128 bytes of RAM and timer. It has 8K bytes of on chip program ROM. The programs written for projects using 8051 microcontroller can be used to run on the projects using 8052 microcontroller as 8051 is a subset of 8052. ii. 8031 This microcontroller has all the features of 8051 except for it to be ROM-less. An external ROM that can be as large as 64 K bytes should be programmed and added to this chip for execution. The disadvantage of adding external ROM is that 2 ports (out of the 4 ports) are used. Hence, only 2 ports are left for I/O operations which can also be added externally if required for execution.

Comparison of 8051 family members:


Features RAM(bytes) ROM Timers Serial port I/O pins Interrupt sources 8051 128 4K 2 1 32 6 8052 256 8K 3 1 32 8 8031 128 0K 2 1 32 6

The 8051 microcontroller architecture This microcontroller is also called as System on a chip because it has all the features on a single chip. The Block Diagram of 8051 Microcontroller is as shown in Figure

Memory Architecture The 4 discrete types of memory in 8051 are:

i.

Internal RAM This memory is located from address 0 to 0xff. The

memory locations from 0x00 to 0x7F are accessed directly. The bytes from 0x20 to 0x2F are bit-addressable. Loading R0 and R1 the memory location from 0x80 to 0xFF can easily accessed. ii. Special Function Registers (SFR) Located from address 0x80 to 0xFF of the memory location. The same instructions used for lower half of Internal RAM can be used to access SFRs. The SFRs are bit addressable too. iii. Program Memory This is read only memory which is located at address 0. With the help of 16 bit Special Function Register DPTR, this memory can also save the tables of constants. iv. External Data Memory Located at address 0. The Instruction MOVX (Move External) should be used to access the external data memory. Figure shows the pin configuration of the 89S52, where the function of each pin is written next to it, and, if it exists, the dual function is written between brackets. The pins are written in the same order as in the block diagram of figure 1.2.A, except for the VCC and GND pins which I usually note at the top and the bottom of any device. Note that the pin that have dual functions, can still be used normally as an input/output pin. Unless you program uses their dual functions, All the 32 I/O pins of the microcontroller are configured as input/output pins.

Basic Pins PIN 9: PIN 9 is the reset pin which is used to reset the microcontrollers internal registers and ports upon starting up. (Pin should be held high for 2 machine cycles.) PINS 18 & 19: The 8051 has a built-in oscillator amplifier hence we need to only connect a crystal at these pins to provide clock pulses to the circuit. PIN 40 and 20: Pins 40 and 20 are VCC and ground respectively. The 8051 chip needs +5V 500mA to function properly, although there are lower powered versions like the Atmel 2051 which is a scaled down version of the 8051 which runs on +3V. PINS 29, 30 & 31: As described in the features of the 8051, this chip contains a built-in flash memory. In order to program this we need to supply a voltage of +12V at pin 31. If external memory is connected then PIN 31, also called EA/VPP, should be connected to ground to indicate the presence of external memory. PIN 30 is called ALE (address latch enable), which is used when multiple memory chips are connected to the controller and only one of them needs to be selected.We will deal with this in depth in the later chapters. PIN 29 is called PSEN. This is "program store enable". In order to use the external memory it is required to provide the low voltage (0) on both PSEN and EA pins. Ports There are 4 8-bit ports: P0, P1, P2 and P3.

PORT P1 (Pins 1 to 8): The port P1 is a general purpose input/output port which can be used for a variety of interfacing tasks. The other ports P0, P2 and P3 have dual roles or additional functions associated with them based upon the context of their usage.The port 1 output buffers can sink/source four TTL inputs. When 1s are written to portn1 pins are pulled high by the internal pull-ups and can be used as inputs. PORT P3 (Pins 10 to 17): PORT P3 acts as a normal IO port, but Port P3 has additional functions such as, serial transmit and receive pins, 2 external interrupt pins, 2 external counter inputs, read and write pins for memory access. PORT P2 (pins 21 to 28): PORT P2 can also be used as a general purpose 8 bit port when no external memory is present, but if external memory access is required then PORT P2 will act as an address bus in conjunction with PORT P0 to access external memory. PORT P2 acts as A8-A15, as can be seen from fig PORT P0 (pins 32 to 39) PORT P0 can be used as a general purpose 8 bit port when no external memory is present, but if external memory access is required then PORT P0 acts as a multiplexed address and data bus that can be used to access external memory in conjunction with PORT P2. P0 acts as AD0AD7, as can be seen from figure. As years passed by, the quality of technology surpassed the expectation of the greatest minds, with gadgets becoming smaller, sleeker and more efficient. Microcontrollers were seen as the answer to the requirements raised in advanced electronics. This is the reason why manufacturers have now focused their production around the following main developmental aspects: i. Ease-of-use

ii. iii. iv. v. vi.

Market availability Less power usage Smaller processing power More integrated features like RF and USB Smaller form factors Transistor BC 548: A BJT transistor such as the NPN BC548 shown on the right can function as a switch.When a small amount of power is supplied to its base (middle leg), power is allowed to flow between its collector (left leg) and emitter (right leg). When the base is grounded no power can flow between collector and emitter Symbol:

NPN Transistor(BC 548) Operation: The BC548 transistor is an NPN bipolar transistor. Most bipolar transistors used today are NPN. NPN transistors consist of a layer of P-doped semiconductor between two N-doped layers. A small current entering the base in common-emitter mode is amplified in the collector output. In other terms, an NPN transistor is "on" when its base is pulled high relative to the

emitter. The arrow in the NPN transistor symbol is on the emitter leg and points in the direction of the conventional current flow when the device is in forward active mode. when a positive voltage is applied to the base emitter junction, the equilibrium between thermally generated carriers and the repelling electric field of the depletion region becomes unbalanced, allowing thermally excited electrons to inject into the base region. These electrons wander through the base from the region of high concentration near the emitter towards the region of low concentration near the collector. The electrons in the base are called minority carriers because the base is doped ptype which would make holes the majority carrier in the base. Comparison with Relay: Indirectly we can say that the relay and transistor are doing same function. But the basic fundamental differences between them are: A transistor is made from semiconductor material; it can be used as a switch - due to saturation at set voltages. Whereas the relay works on the principle of the principle of production of electromagnetic field in the coil. Transistors also provide current gain, but relay doesnt do this. Power Supply: The power supply for the circuit is provided through a 5V regulator IC LM7805. A 12V step-down transformer with a bridge rectifier and a capacitor filter provides an unregulated DC input to LM7805. The regulator IC provides a constant 5V supply for the circuit.

Bridge rectifiers Transformer:: Transformers convert AC electricity from one voltage to another with little loss of power. Transformers work only with AC. The input coil is called the primary and the output coil is called the secondary. There is no electrical connection between the two coils, instead they are linked by an alternating magnetic field created in the soft-iron core of the transformer. Bridge rectifier: A bridge rectifier can be made using four individual diodes, but it is also available in special packages containing the four diodes required. It is called a full-wave rectifier because it uses all the AC wave (both positive and negative sections). 1.4V is used up in the bridge rectifier because each diode uses 0.7V when conducting and there are always two diodes conducting, as shown in the diagram below.

Output waveform of bridge rectifier

Smoothing: Smoothing is performed by a large value electrolytic capacitor connected across the DC supply to act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier is falling. The diagram shows the unsmoothed varying DC and the smoothed DC.The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output.

output waveform of smoothing Regulator IC: Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output voltages. They are also rated by the maximum current they can pass. Negative voltage regulators are available, mainly for use in dual supplies. Most regulators include some automatic protection from excessive current and overheating

Regulator IC

LED Interface: A light-emitting diode (LED) is a semiconductor light source. The first practical visible-spectrum (red) LED was developed in 1962 by Nick Holonyak Jr., while working at General Electric Company. Holonyak is seen as the "father of the light-emitting diode".We have used high brightness White LED here. It is made from yellow phosphorus.

LED The principle of operation of LEDs is simple. The commonly available LEDs have a drop voltage of 1.7 V and need 10 mA to glow at full intensity. The following circuit describes how to glow an led with 8051 microcontroller using transistor.

LED connections with 8051 Suppose we want to turn this LED ON then we need to send 1 to this pin P2.2=1. Here the transistor BC 548 helps us to amplify the signal level. Heat Sink: A heat sink is a term for a component or assembly that transfers heat generated within a solid material to a fluid medium, such as air or a liquid A heat sink is physically designed to increase the surface area in contact with the cooling fluid surrounding it, such as the air. Approach air velocity, choice of material, fin (or other protrusion) design and surface treatment are some of the design factors which influence the thermal resistance, i.e. thermal performance, of a heat sink.

Heat Sink One engineering application of heat sinks is in the thermal management of electronics, often computer central processing unit (CPU) or graphics processors. For these, heat sink attachment methods and thermal interface materials also influence the eventual junction or die temperature of the processor(s). Thermal adhesive (also known as thermal grease) is added to the base of the heat sink to help its thermal performance.

Reset: RESET is an active High input When RESET is set to High, 8051 goes back to the power on state. The 8051 is reset by holding the RST high for at least two machine cycles and then returning it low.

Power-On Reset: - Initially charging of capacitor makes RST High - When capacitor charges fully it blocks DC. Manual reset: -closing the switch momentarily will make RST High. After a reset, the program counter is loaded with 0000H but the content of on-chip RAM is not affected. Relay: A relay is electrically operated switch.Current flowing through coil of the relay creates a agnetic field which attracts a lever and changes the switch contacts.The coil current can be on/off so relay have 2 switch positions and

most have double throw switch contacts as the diagram

Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits, the link is magnetic and mechanical.

Operation:The graphical operation of Relay is as shown below. The relay's switch connections are usually labeled: COM, NC and NO: COM = Common, always connect to this, it is the moving part of the switch.

NC = Normally Closed, COM is connected to this when the relay coil is off. NO = Normally Open, COM is connected to this when the relay coil is on. Applications: Control a high-voltage circuit with a low-voltage signal, as in some types of modems or audio amplifiers, Detect and isolate faults on transmission and distribution lines by opening and closing circuit breakers i.e., protection relays Crystal circuit: The 8051 uses the crystal for precisely that: to synchronize its operation. Effectively, the 8051 operates using what are called "machine cycles." A single machine cycle is the minimum amount of time in which a single 8051 instruction can be executed. Although many instructions take multiple cycles.

8051 has an on-chip oscillator. It needs an external crystal that decides the operating frequency of the 8051.The crystal is connected to pins 18 and 19 with stabilizing capacitors. 12 MHz(11.059MHz) crystal is often used and the capacitance ranges from 20pF to 40pF.

How fast 8051 works ? A cycle is, in reality, 12 pulses of the crystal. That is to say, if an instruction takes one machine cycle to execute, it will take 12 pulses of the crystal to execute. Since we know the crystal is pulsing 11,059,000 times per second and that one machine cycle is 12 pulses, we can calculate how many instruction cycles the 8051 can execute per second: 11,059,000 / 12 = 921,583

Software Development
The use of C language to program microcontrollers is becoming too common. And most of the time its not easy to buld an application in assembly which instead you can make easily in C. So Its important that you know C language for microcontroller which is commonly known as Embedded C. As we are going to use Keil C51 Compiler, hence we also call it Keil C. The C programming language is a general-purpose programming language that provides code efficiency, elements of structured programming, and a rich set of operators. C is not a big language and is not designed for any one particular area of application. Its generality combined with its absence of restrictions, makes C a convenient and effective programming solution for a wide variety of software tasks. Many applications can be solved more easily and efficiently with C than with other more specialized languages. The Cx51 Optimizing C Compiler is a complete implementation of the American National Standards Institute (ANSI) standard for the C language. The Cx51 Compiler is not a universal C compiler adapted for the 8051 target. It is a ground-up implementation, dedicated to generating extremely fast and compact code for the 8051 microprocessor. The Cx51 Compiler provides you with the flexibility of programming in C and the code efficiency and speed of assembly language. The C language on its own is not capable of performing operations (such as input and output) that would normally require intervention from the

operating system. Instead, these capabilities are provided as part of the standard library. Because these functions are separate from the language itself, C is especially suited for producing code that is portable across a wide number of platforms. Since the Cx51 Compiler is a cross compiler, some aspects of the C programming language and standard libraries are altered or enhanced to address the peculiarities of an embedded target processor. Hence are using the KEIL IDE in this project.

Program code of 8051 #include<regx52.h> sbit red1=P1^4; sbit yellow1=P1^3; sbit green1=P1^2; sbit red2=P3^7; sbit yellow2=P3^6; sbit green2=P3^5; sbit red3=P3^4; sbit yellow3=P3^3; sbit green3=P3^2;

sbit red4=P1^7; sbit yellow4=P1^6; sbit green4=P1^5; sbit exhaust=P2^7; sbit motor1=P2^0; sbit motor2=P2^4; static unsigned int state; enum state{ timeslot1, timeslot2, timeslot3, timeslot4, timeslot5, timeslot6, timeslot7, timeslot8, timeslot9, }; void delay(unsigned int delay); void delay1(unsigned int delay1); void motordelay(unsigned int mdelay);

void main() { while(1) { P1=0x00; P3=0x00; motor1=1; motor2=1; exhaust=1; switch (state) { case timeslot1: green1=1; red2=1; red3=1; red4=1; delay(150); delay1(150); state++; break; case timeslot2: green1=0; yellow1=1; red2=0; //all motors off;

yellow2=1; red3=1; red4=1; delay(50); state++; break; case timeslot3: yellow1=0; red1=1; yellow2=0; red3=1; red4=1; green2=1; motor1=0; //motor1 is on; motordelay(1); motor1=1; //motor1 is off; delay(148); delay1(148); green2=0; state++; break; case timeslot4:

red1=1; yellow2=1; red3=0; red4=1; yellow3=1; delay(50); state++; break; case timeslot5: red1=1; yellow2=0; red2=1; green3=1; red4=1; delay(148); delay1(148); green3=0; state++; break; case timeslot6: red1=1; red2=1; yellow3=1; red4=0;

yellow4=1; delay(50); state++; break;

case timeslot7: red1=1; red2=1; yellow3=0; red3=1; green4=1; motor2=0; //motor2 is on; motordelay(1); motor2=1; //motor2 is off; delay(148); delay1(148); state++; break; case timeslot8: red1=0; yellow1=1; red2=1;

red3=1; green4=0; yellow4=1; delay(50); exhaust=0; delay(1); delay1(1); exhaust=1; state++; break; case timeslot9: red1=0; yellow1=1; red2=1; red3=1; green4=0; yellow4=1; delay(50); state=0; break; default: state=0; //exhaust is off; //exhaust is on;

break; } } } void delay(unsigned int delay) { unsigned int j,k; k=0; if(k<delay) { for(j=0;j<=50000;j++); k++; } } void delay1(unsigned int delay1) { unsigned int l,m; m=0; if(m<delay1) {

for(l=0;l<=50000;l++); m++; } } void motordelay(unsigned int mdelay) { unsigned int l,m; m=0; if(m<mdelay) { for(l=0;l<=35000;l++); m++; } }

Software simulation
After designing the all above hardware sections and programming sections we should not directly implement it on the real hardware. It would be better if once we check it in any simulator software. Hence we simulated this whole system in the PROTEAUS 7.6.0 simulator. We just placed the components and interfacing sections in the I.D.E. of proteaus and loaded the program in 8051 microcontroller. Then we started the simulation and everything was working properly. First we see the functional overview of circuit diagram. This is as shown in the figure below:

Now we see the simulated circuit in the proteaus IDE.

Practical problems faced during project


The main problem was to run the whole system in such a manner so that the every signal is in real time synchronization with the every other traffic signals. So we required to design the microcontroller 8051 to run each machine cycle very accurately. So that no signal is operating in past or future state then the other ones. Hence we calculated and designed the execution time of each machine cycle of 8051 microcontroller. Then again we needed to perform some ecofriendly tasks to make this environment friendly. So we finally concluded to use the Automatic street light system. And so we also needed to integrate this system with our whole proposed circuit. Finally we have used a circuit based on the LDR(Light dependent Resistor). Then we used some amplifier peripherals to solve the low power issue. Hence we finally connected the white LEDs to this circuit. Hence when the day light is available, the street lights are turned off. Same way when no daylight is available, the street lights are kept on automatically in the ON state. So the manually switching process doesnt takes place here. this is quite user friendly concept. This circuit is a working model of real time Traffic control systems. Hence we need to put some real time events in this project. Hence we decided to put a system, which moves a car automatically whenever this signal is switched to green colour. This happens only once in this project. We can repeat this by pressing the reset button again and again. For this purpose we are putting belt elevator with the wels below the road surface here.

Das könnte Ihnen auch gefallen