Vous êtes sur la page 1sur 46

DENSITY BASED TRAFFIC CONTROL SYSTEM

DARA MANOJ

Department of Electrical and Electronics Engineering

MAHATMA GANDHI INSTITUTE OF TECHNOLOGY


(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)

Chaitanya Bharathi P.O., Gandipet, Hyderabad 500 075

2012-2013

DENSITY BASED TRAFFIC CONTROL SYSTEM


INDUSTRY ORIENTED MINI PROJECT REPORT SUBMITTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF BACHELOR OF TECHNOLOGY IN ELECTRICAL AND ELECTRONICS ENGINEERING BY DARA MANOJ(09261A0215)

Department of Electrical and Electronics Engineering

MAHATMA GANDHI INSTITUTE OF TECHNOLOGY


(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)

Chaitanya Bharathi P.O., Gandipet, Hyderabad 500 075

2012-2013

MAHATMA GANDHI INSTITUTE OF TECHNOLOGY


(Affiliated to Jawaharlal Nehru Technological University, Hyderabad, A.P.)

Chaitanya Bharathi P.O., Gandipet, Hyderabad-500 075


Department of Electrical and Electronics Engineering

CERTIFICATE
This is to certify that the mini project work entitled DENSITY BASED TRAFFIC CONTROL SYSTEM is being submitted by DARA MANOJ bearing Roll No.09261A0215 in partial fulfillment for the award of Degree of BACHELOR OF TECHNOLOGY in ELECTRICAL & ELCTRONICS ENGINEERING by the Jawaharlal Nehru Technological University, Hyderabad during the academic year 201213. The results embodied in this report have not been submitted by the student to any other University or Institution for the award of any degree or diploma.

Mini Project Supervisor


Dr. P Chandra Sekhar Associate professor EEE Department

Head Of The Department


Dr. P Ram Kishore Kumar Reddy Associate professor & Head EEE Department

CERTIFICATE OF THE ORGANISATION

ACKNOWLEDGEMENT
I express my deep sense of gratitude to my beloved Principal Dr. G Chandra Mohan Reddy, for the valuable guidance and for permitting us to carry out this project.

I express my deep sense of gratitude to my beloved professor Dr. P.Ram Kishore Kumar Reddy, Professor and Head, Department of Electrical & Electronics Engineering for the valuable guidance and suggestions, keen interest and through encouragement extended throughout period of project work. I express my deep sense of gratitude to my beloved project guide Mr.V.Ramakrishna for the valuable guidance and suggestions, keen interest and through encouragement extended throughout period of project work. I take immense pleasure to express my deep sense of gratitude to our beloved Guide Dr.P.Chandrasekhar,Associate professor in Electrical and Electronics Engineering, for his valuable suggestions and rare insights, for constant source of encouragement and inspiration through out my project work. I express my thanks to all those who contributed for the successful completion of my project work.

With gratitude,

DARA MANOJ

________________

CONTENTS
CHAPTER NO. TITLE ABSTRACT LIST OF FIGURES LIST OF TABLES 1 INTRODUCTION
1.1 INTRODUCTION 1.2 AIM 1.3 METHODOLOGY 1.4 SIGNIFICANCE 1 1 1 1 2 3 4 4 7 8 9 9 10 11 12 13

PAGENO i ii iii

LITERATURE REVIEW
2.1 AIM 2.2 BLOCK DIAGRAM 2.3 METHODOLOGY 2.4 IR TRANSMITTER & IR RECEIVER 2.5 SCHEMATIC DIAGRAM 2.6 SCHEMATIC DIAGRAM EXPLANATION

HARDWARE COMPONENTS
3.1 AT89S52 MICROCONTROLLER 3.1.1 DISCRIPTION 3.1.2 FEATURES 3.1.3 BLOCK DIAGRAM 3.1.4 PIN DIAGRAM 3.1.5 PIN DISCRIPTION

3.2 POWER SUPPLY 3.3 REGULATOR 3.4 TRANSFORMER 3.5 CAPACITOR FILTER 3.6 LEDS 3.6.1 FUNCTION 3.6.2 CONNECTING 3.6.3 TESTING AN LED 3.7 IR LED 3.7.1 DESCRIPTION 3.7.2 FEATURES 3.8 LCD INTEERFACING 3.8.1 INTRODUCTION 3.8.2 PIN DISCRIPTION

21 21 22 23 24 24 24 25 25 26 26 26 26 26 31 32 33 33 34

WORKING FLOW OF PROJECT


4.1 BLOCK DIAGRAM 4.2 CIRCUIT DESCRIPTION 4.3 SOFTWARE 4.3.1 KEIL VISION 4.3.2 EMBEDDED

CONCLUSION

35

REFERENCES

36

ABSTRACT
Traffic is formally organized in many jurisdictions, with marked lanes, sjunctions, intersections, interchanges, traffic signals, or signs. Traffic is often classified by type: heavy motor vehicle (e.g., car, truck); other vehicle (e.g., moped, bicycle); and pedestrian. Different classes may share speed limits and easement, or may be segregated. Some jurisdictions may have very detailed and complex rules of the road. One of the main problems in our citys is traffic, this project proposed new solution to traffic control. The main design accept of this project is to control the traffic automatically and adding human inelegancy to that automatic controller. "Four-way" intersection is the most common configuration for roads that cross each other, and the most basic type. If signals do not control a 4-way intersection, signs or other features are typically used to control movements and make clear priorities. In this project we are going to use IR communication to analyze traffic density. IR signals from IR receiver are given to microcontroller and microcontroller gives appropriate result according to traffic. For better result we are going to use some bunch of IR transmitters and IR receivers in all directions. When there is a more traffic in one side more no. of IR receivers will not get the signals and result will compare with all other directions and microcontroller gives green signals at one side where more no of IR receivers will not get the signals. For IR communication we are using an IR transmitter and IR receiver. Here IR LED will acts as a transmitter. As we know microcontroller having inbuilt I/O ports and we are interfacing IR receivers to those I/O ports. For controlling of traffic we are using red, green and yellow color LEDs. These LEDs are connected to different I/O ports of microcontroller. When there is a more traffic microcontroller gives signal to green LED and it will glow. So by using this project we can control the traffic automatically like a human being. i

LIST OF FIGURES
FIG.NO 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 TITLE A JUNCTION WITH LED & IR SENSORS BLOCK DIAGRAM CIRCUIT OF IR TRANSMITTER CIRCUIT OF IR RECEIVER SCHEMATIC DIAGRAM OF CIRCUIT AT89S52 MICROCONTROLLER BLOCK DIAGRAM OF AT89S52 MICROCONTROLLER PAGE.NO 1 2 4 4 6 9 10 11 18 19 20 21 22 23 23 24 24 30

PIN DIAGRAM OF AT89S52


OSCILLATOR CONNECTIONS EXTERNAL CLOCK DRIVE CONFIGURATION REGULATED POWER SUPPLY EXAMPLE CIRCUIT SHOWING 5V DC OUTPUT AN ELECTRICAL TRANSFORMER LED CIRCUIT DIAGRAM OF LED IR LED SCHEMATIC DIAGRAM OF IR LED BLOCK DIAGRAM OF WORKING OF PROJECT

ii

LIST OF TABLES

TABLE.NO

TITLE

PAGE.NO

PORTS SHOWING THE ALTERNATE FUNCTIONS AT PORT 1 PORTS SHOWING THE ALTERNATE FUNCTIONS AT PORT 3

12

14

3 4 5

TIMER 2 OPERATING MODES PIN DISCRIPTION OF LCD


EMBEDDED C DATA TYPES

17 26 33

iii

Chapter-1 INTRODUCTION
1.1 Introduction:
In this system IR sensors are used to measure the density of the vehicles which are fixed within a fixed distance. All the sensors are interfaced with the microcontroller which in turn controls the traffic signal system according to densitydetected bythe sensors If the traffic density is high on particular side more priority is given for that side. The sensors continuously keep sensing density on all sides and the green signal is given to the side on priority basis, where the sensors detect high density. The side with next priority level follows the first priority level. By using this system traffic can be cleared without irregularities and time delay seven though there is no traffic on the other side can be avoided

1.2 Aim:
The main Aim of this project is to control the traffic lights based on the densityof the vehicles.

1.3 Methodology:
The project is to solve traffic congestion which is a severe problem in many modern cities all over the world. To solve the problem, we have designed a framework for a dynamic and automatic traffic light control system and developed a simulation model with codes in to help build the system on hardware. Generally, each traffic light on an intersection is assigned a constant green signal time. It is possible to propose dynamic time-based coordination schemes where the green signal time of the traffic lights is assigned based on the present conditions of traffic. The intelligent work which is done by traffic inspector will be perfectly done by the microcontroller in the circuit with the help of sensors and the program which is coded to the microcontroller.

1.4 Significance Of The Project:


This type of project is used in heavy traffic roads and the junction because this type of project is based on the time as well as the density and the time will be controlled by programme coded in microcontroller and the density will be controlled by IR sensors and they are controlled by microcontroller 1

Chapter-2 LITERATURE REVIEW


2.1 Introduction:
The project intelligent traffic management system for metro cites, is based on the microcontroller which will provide the controlling of the traffic depending upon the density. According to the signaling i.e. continuity between the IR transmitter and IR receiver the Timing of the green, red lights will be glown for the particular time depending upon the density. The micro controller will monitor the all control functionalities. According to the controller signalling the density will be monitored by lights. Microcontroller based traffic control system is an application specific project, which is used to control the traffic. An embedded system is developed which consists of a microcontroller, IR transmitter and receiver, LEDs This project is implemented by placing IR transmitters, receivers and leds at the 4 way junction, the four paths are represented as R1,R2,R3,R4

FIG 1: A JUNCTION WITH LED & IR SENSORS Transmitters and receivers are placed at either sides of the four paths, and 4 leds at corner of the junction When there is a traffic along the paths,value of R would be 000 which are the values of IR sensors and if there is no traffic the value is 111

2.2 Block Diagram:


POWER SUPPLY ROAD 3

RED

IR Transmitter signals From all directions Micro controller (ATS8952)

GREEN

ROAD 4

Signals from IR receivers from all directions ROAD 2

RED

GREEN

RED

ROAD 1

GREEN

RED

GREEN

FIG 2: BLOCK DIAGRAM

2.3Block Diagram Explanation:


The main objective of this project is to control the traffic depending upon the density .As there is much time wastage with the traffic lights which involves the Time, we are designing the new system which controls the traffic depending upon the density. Here we place IR transmitter and the IR receivers at both ends of the roads. Whenever the vehicles pass in-between them the continuity will be lost. Hence the microcontroller senses the density is high. Then the microcontroller will be making the light (green) to be glow much time at the place where the traffic is high. The same procedure will be followed by four sides of the road. The signalling from the four sides will be taken into consideration and depending upon the density controller will make the decision . The system uses a compact circuitry build around flash version of AT89S52 Microcontroller with a non-volatile memory. Programs will be developed in EMBEDDED C language. FLASH MAGIC is used for loading of programs into microcontroller.

2.4 IR Transmitter & Receiver:


The purpose of the transmitter is to transform the information we want to send into a signal that can be propagated by the channel. In the case of our wired copper channel, this means we want the information to be transformed into a modulated voltage level, something like the pulse train. For a wireless channel, however, the transmitter needs to encode the information onto an EM wave that can be easily propagated.

IR Transmitter:

FIG 3: CIRCUIT OF IR TRANSMITTER The IR transmitter part consists of an Infra red light emitting diode that can capable of sending modulated data within infra red band. To match the receiver frequency the the data is modulated at 38.7 KHZ by configuring 555 timer at astable mode of operation, which generates frequency using the components R2 and C2 as shown in above fig. This frequency can be varied over a long range just by varying the preset R1 and C1.

IR Receiver:

FIG 4: CIRCUIT OF IR RECEIVER 5

The IR receiver consists of TSOP 1738 module which is a simple yet effective IR proximity sensor built around the TSOP 1738 module. The TSOP module is commonly found at the receiving end of an IR remote control system; e.g., in TVs, CD players etc. These modules require the incoming data to be modulated at a particular frequency and would ignore any other IR signals. It is also immune to ambient IR light, Such modules are available for different carrier frequencies from 32 kHz to 42kHz. In this particular proximity sensor, we will be generating a constant stream of square wave signal using IC555 centered at 38 kHz and would use it to drive an IR led. So whenever this signal bounces off the obstacles, the receiver would detect it and change its output. Since the TSOP 1738 module works in the active-low configuration, its output would normally remain high and would go low when it detects the signal (the obstacle). Basically an ir sensor is used for detecting an obstacle, there are some areas where valuable things are placed, an IR transmitter and receiver is placed there, an infrared path is established and if any person comes into that path the buzzer gets on which gives out a long beep Similarly a fire sensor is used to detect fire The sensed data is given to the microcontroller, processing is done according to the logic in the microcontroller and then writes onto GSM which will further send sms to the mobile at the user A buzzer is interfaced to microcontroller to give out a beep sound whenever an obstacle and fire is detected

2.5 Schematic Diagram:

FIG 5: SCHEMATIC DIAGRAM OF CIRCUIT 7

2.6 Schematic Explanation: Power Supply:


The schematic diagram gives the basic hardware connections used in the project. Beginning from the power supply the secondary of the step-down transformer wires are given to the two ends (2,4) of bridge rectifier which is having the four diodes in the bridge formate.The other two ends 1,3)are connected to the input(pin 1) and output pin 3 of the 7805 regulator and pin no 2 is connected to ground as shown in schematic diagram. The 1000 micro farad capacitor is connected in between the bridge rectifier and regulator to eliminate the ac ripples presented in the rectified output. The 100 micro farad capacitor is used to eliminate the noise at regulator output. Now 5V is available at the pin no 3 of regulator and connected to pin no 40 of micro controller.

AT89S52 micro controller :


The 8051 micro controller consists 40 pins and every pin has its own functionality as shown in the schematic diagram. The port 0 is having the pull up resistor which is having eight 10K resistors in parallel each connected to the each pin of it.

IR Led:
The IR LED is arranged with a resistor ,in such a way that Vcc is applied to the positive terminal of the IR LED.These are connected to the port 1 of the microcontroller.

IR Receiver:
The IR receivers are arranged with the transistor logic as shown in the diagram. The two transistors are connected in such a manner that collector terminal is connected to the base terminal of the other. The photo diode is connected to the base of the transistor along with the combination of the resistor. The IR Receivers are connected to the port 2 P2.0,,P2.1,P2.2,P2.3 pins of the microcontroller.

Chapter-3 HARDWARE COMPONENTS


3.1 AT89S52 Microcontroller:

3.1.1 Description:
The AT89S52 is a low-power, high-performance CMOS 8-bit microcontroller with 8K bytes of in-system programmable Flash memory. The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the indus-try-standard 80C51 instruction set and pinout. The onchip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory pro-grammer. By combining a versatile 8-bit CPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and costeffective solution to many embedded control applications. The AT89S52 provides the following standard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-chip oscillator, and clock circuitry. In addition, the AT89S52 is designed with static logic for operation down to zero frequency and supports two software selectable power saving modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port, and interrupt system to continue functioning. The Power-down mode saves the RAM con-tents but freezes the oscillator, disabling all other chip functions until the next interrupt or hardware reset.

FIG 6: AT89S52 MICROCONTROLLER

3.1.2 Features :
Compatible with MCS-51 Products 8K Bytes of In-System Programmable (ISP) Flash Memory 4.0V to 5.5V Operating Range Fully Static Operation: 0 Hz to 33 MHz Three-level Program Memory Lock 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Full Duplex UART Serial Channel Low-power Idle and Power-down Modes Interrupt Recovery from Power-down Mode Watchdog Timer Dual Data Pointer 10

Power-off Flag Fast Programming Time Flexible ISP Programming (Byte and Page Mode) Green (Pb/Halide-free) Packaging Option

3.1.3BlockDiagram:

FIG 7: BLOCK DIAGRAM OF AT89S52 MICROCONTROLLER

11

3.1.4 Pin Diagram:

FIG 8: PIN DIAGRAM OF AT89S52

12

Pin Description: VCC: Supply voltage. GND: Ground. PORT 0: Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each
pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as high-impedance inputs. Port 0 can also be configured to be the multiplexed low-order address/data bus during accesses to external program and data memory. In this mode, P0 has internal pull-ups. Port 0 also receives the code bytes during Flash programming and outputs the code bytes dur-ing program verification.

PORT 1:
Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs. When 1s are written to Port 1 pins, they are pulled high by the inter-nal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. In addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external count input (P1.0/T2) and the timer/counter 2 trigger input (P1.1/T2EX), respectively, as shown in the follow-ing table. Port 1 also receives the low-order address bytes during Flash programming and verification.

TABLE 1: PORTS SHOWING THE ALTERNATE FUNCTIONS AT PORT 1 13

PORT 2:
Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the inter-nal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (IIL) because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and dur-ing accesses to external data memory that use 16-bit addresses (MOVX @ DPTR). In this application, 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 bits and some control signals during Flash program-ming and verification.

Port Pin Alternate Functions:


P1.0 T2 (external count input to Timer/Counter 2), clock-out P1.1 T2EX (Timer/Counter 2 capture/reload trigger and direction control) P1.5 MOSI (used for In-System Programming) P1.6 MISO (used for In-System Programming) P1.7 SCK (used for InSystem Programming)5 1919DMICRO6/

PORT 3:
Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs. When 1s are written to Port 3 pins, they are pulled high by the inter-nal pull-ups and 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 and verification. Port 3 also serves the functions of various special features of the AT89S52, as shown in the fol-lowing table.

14

TABLE 2:PORTS SHOWING THE ALTERNATE FUNCTIONS AT PORT 3

RST:
Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. This pin drives high for 98 oscillator periods after the Watchdog times out. The DISRTO bit in SFR AUXR (address 8EH) can be used to disable this feature. In the default state of bit DISRTO, the RESET HIGH out feature is enabled.

ALE/PROG:
Address Latch Enable (ALE) is an output pulse for latching the low byte of the address during accesses to external memory. This pin is also the program pulse input (PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped dur-ing each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has no effect if the microcontroller is in external execution mode 15

PSEN: Program Store Enable (PSEN) is the read strobe to external program
memory.When the AT89S52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped

XTAL1: Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.

XTAL2 :Output from the inverting oscillator amplifier. Program Memory:


If the EA pin is connected to GND, all program fetches are directed to external memory. On the AT89S52, if EA is connected to VCC, program fetches to addresses 0000H through 1FFFH are directed to internal memory and fetches to addresses 2000H through FFFFH are to external memory.

Data Memory: The AT89S52 implements 256 bytes of on-chip RAM. The upper 128
bytes occupy a parallel address space to the Special Function Registers. This means that the upper 128 bytes have the same addresses as the SFR space but are physically separate from SFR space. When an instruction accesses an internal location above address 7FH, the address mode used in the instruction specifies whether the CPU accesses the upper 128 bytes of RAM or the SFR space. Instructions which use direct addressing access the SFR space. For example, the following direct addressing instruction accesses the SFR at location 0A0H (which is P2). MOV 0A0H, #data Instructions that use indirect addressing access the upper 128 bytes of RAM. For example, the following indirect addressing instruction, where R0 contains 0A0H, accesses the data byte at address 0A0H, rather than P2 (whose address is 0A0H). MOV @R0, #data Note that stack operations are examples of indirect addressing, so the upper 128 bytes of data RAM are available as stack space.

16

Watchdog Timer (One-Time Enabled With Reset-Out):


The WDT is intended as a recovery method in situations where the CPU may be subjected to software upsets. The WDT consists of a 14-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 the WDTRST register (SFR location 0A6H). When the WDT is enabled, it will increment every machine cycle while the oscillator is running. The WDT timeout period is dependent on the external clock frequency. There is no way to disable the WDT except through reset (either hardware reset or WDT overflow reset). When WDT over-flows, it will drive an output RESET HIGH pulse at the RST pin.

Using The WDT:


To enable the WDT, a user must write 01EH and 0E1H in sequence to the WDTRST register (SFR location 0A6H). When the WDT is enabled, the user needs to service it by writing 01EH and 0E1H to WDTRST to avoid a WDT overflow. The 14-bit counter overflows when it reaches 16383 (3FFFH), and this will reset the device. When the WDT is enabled, it will increment every machine cycle while the oscillator is running. This means the user must reset the WDT at least every 16383 machine cycles. To reset the WDT the user must write 01EH and 0E1H to WDTRST. WDTRST is a write-only register. The WDT counter cannot be read or written. WhenWDT overflows, it will generate an output RESET pulse at the RST pin. The RESET pulse dura-tion is 98xTOSC, where TOSC = 1/FOSC. To make the best use of the WDT, it should be serviced in those sections of code that will periodically be executed within the time required to prevent a WDT reset.

UART :The UART in the AT89S52 operates the same way as the UART in the
AT89S52 and AT89C52.

17

Timer 0 and 1:
Timer 0 and Timer 1 in the AT89S52 operate the same way as Timer 0 and Timer 1 in the AT89S52 and AT89C52.

Timer 2:
Timer 2 is a 16-bit Timer/Counter that can operate as either a timer or an event counter. The type of operation is selected by bit C/T2 in the SFR T2CON (shown in Table 5-2). Timer 2 has three operating modes: capture, auto-reload (up or down counting), and baud rate generator. The modes are selected by bits in T2CON, as shown in Table 10-1. Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timer function, the TL2 register is incremented every machine cycle. Since a machine cycle consists of 12 oscillator periods, the count rate is 1/12 of the oscil-lator frequency.

TABLE3: TIMER 2 OPERATING MODES In the Counter function, the register is incremented in response to a 1-to-0 transition at its corre-sponding external input pin, T2. In this function, the external input is sampled during S5P2 of every machine cycle. When the samples show a high in one cycle and a low in the next cycle, the count is incremented. The new count value appears in the register during S3P1 of the cycle following the one in which the transition was detected. Since two machine cycles (24 oscillator periods) are required to recognize a 1-to-0 transition, the maximum count rate is 1/24 of the oscillator frequency. 18

To ensure that a given level is sampled at least once before it changes, the level should be held for at least one full machine cycle.

Oscillator Characteristics:
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that can be configured for use as an on-chip oscillator, as shown in Figure 16-1. Either a quartz crystal or ceramic resonator may be used. To drive the device from an external clock source, XTAL2 should be left unconnected while XTAL1 is driven, as shown in Figure 16-2. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clock-ing circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed.

FIG9: OSCILLATOR CONNECTIONS

19

FIG 10: EXTERNAL CLOCK DRIVE CONFIGURATION

Programming The Flash Parallel Mode:


The AT89S52 is shipped with the on-chip Flash memory array ready to be programmed. The programming interface needs a high-voltage (12-volt) program enable signal and is compatible with conventional third-party Flash or EPROM programmers. The AT89S52 code memory array is programmed byte-by-byte.

Programming Algorithm:
Before programming the AT89S52, the address, data, and control signals should be set up according to the Flash Programming Modes (Table 22-1) and Figure 22-1 and Figure 22-2. To program the AT89S52, take the following steps: 1. Input the desired memory location on the address lines. 2. Input the appropriate data byte on the data lines. 3. Activate the correct combination of control signals. 4. Raise EA/VPP to 12V. 5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-write cycle is self-timed and typically takes no more than 50 s. Repeat steps 1 through 5, changing the address and data for the entire array or until the end of the object file is reached.

20

3.2 Power Supply:


The power supplies are designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronics circuits and other devices. A power supply can by broken down into a series of blocks, each of which performs a particular function. A d.c power supply which maintains the output voltage constant irrespective of a.c mains fluctuations or load variations is known as Regulated D.C Power Supply

FIG 11: 5V REGULATED POWER SUPPLY

3.3 Voltage Regulator:


Voltage regulator ICs is available with fixed (typically 5, 12 and 15V) or variable output voltages. The maximum current they can pass also rates them. Negative voltage regulators are available, mainly for use in dual supplies. Most regulators include some automatic protection from excessive current ('overload protection') and overheating ('thermal protection'). Many of the fixed voltage regulator ICs have 3 leads and look like power transistors, such as the 7805 +5V 1A regulator shown on the right. The LM7805 is simple to 21

use. You simply connect the positive lead of your unregulated DC power supply (anything from 9VDC to 24VDC) to the Input pin, connect the negative lead to the Common pin and then when you turn on the power, you get a 5 volt supply from the output pin.

FIG 12: EXAMPLE CIRCUIT SHOWING 5V DC OUTPUT

3.4 Transformer:
A transformer is an electrical device which is used to convert electrical power from one Electrical circuit to another without change in frequency. Transformers convert AC electricity from one voltage to another with little loss of power. Transformers work only with AC and this is one of the reasons why mains electricity is AC. Step-up transformers increase in output voltage, step-down The transformers decrease in output voltage. Most power supplies use a step-down transformer to reduce the dangerously high mains voltage to a safer low voltage. 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. The two lines in the middle of the circuit symbol represent the core. is stepped up. Transformers waste very little power so the power out is (almost) equal to the power in. Note that as voltage is stepped down current The ratio of the number of turns on each coil, called the turns ratio, determines the ratio of the voltages. A step-down transformer has a large number of turns on its primary (input) coil which is connected to the high voltage mains supply, and a small number of turns on its secondary (output) coil to give a low output voltage. 22

FIG 13: An Electrical Transformer Turns ratio = Vp/ VS = Np/NS Power Out= Power In VS X IS=VP X IP Vp = primary (input) voltage Np = number of turns on primary coil Ip = primary (input) current

3.5 Capacitor Filter:


We have seen that the ripple content in the rectified output of half wave rectifier is 121% or that of full-wave or bridge rectifier or bridge rectifier is 48% such high percentages of ripples is not acceptable for most of the applications. Ripples can be removed by one of the following methods of filtering. (a) A capacitor, in parallel to the load, provides an easier by pass for the ripples voltage though it due to low impedance. At ripple frequency and leave the d.c.to appears the load. (b) An inductor, in series with the load, prevents the passage of the ripple current (due to high impedance at ripple frequency) while allowing the d.c (due to low resistance to d.c) (c) Various combinations of capacitor and inductor, such as L-section filter section

filter, multiple section filter etc. which make use of both the properties mentioned in (a) and (b) above. Two cases of capacitor filter, one applied on half wave rectifier and another with full wave rectifier. 23

Filtering 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 capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output. Filtering significantly increases the average DC voltage to almost the peak value (1.4 RMS value). To calculate the value of capacitor(C), C = *3*f*r*Rl Where, f = supply frequency, r = ripple factor, Rl = load resistance Note: In our circuit we are using 1000F. Hence large value of capacitor is placed to reduce ripples and to improve the DC component.

3.6 Light Emitting Diodes (LED'S):

Example:

Circuit symbol:

FIG 14: LED

FIG 15: CIRCUIT OF LED

3.6.1 Function:
LEDs emit light when an electric current passes through them.

3.6.2 Connecting And Soldering:


LEDs must be connected the correct way round, the diagram may be labelled a or + for anode and k or - for cathode (yes, it really is k, not c, for cathode!). The cathode is the short lead and there may be a slight flat on the body of round LEDs. If you can see inside the LED the cathode is the larger electrode (but this is not an official identification method). 24

LEDs can be damaged by heat when soldering, but the risk is small unless you are very slow. No special precautions are needed for soldering most LEDs.

3.6.3 Testing An Led:


Never connect an LED directly to a battery or power supply! It will be destroyed almost instantly because too much current will pass through and burn it out. LEDs must have a resistor in series to limit the current to a safe value, for quick testing purposes a 1k resistor is suitable for most LEDs if your supply voltage is 12V or less. Remember to connect the LED the correct way round!

3.7 IR Led: 3.7.1 Description:


The QED233 / QED234 is a 940 nm GaAs/AlGaAs LED encapsulated in a clear untinted, plastic T-1 3/4 package.

FIG16: IR LED

FIG17: SCHEMATIC OF IR LED

25

3.7.2 Features:
Lambda= 940 nm Chip material =GaAs with AlGaAs window Package type: T-1 3/4 (5mm lens diameter) Matched Photo sensor: QSD122/123/124 Medium Emission Angle, 40 High Output Power Package material and color: Clear, untinted, plastic Ideal for remote control applications

3.8 LCD Interfacing:


3.8.1 Introduction:
The most commonly used Character based LCDs are based on Hitachi's HD44780 controller or other which are compatible with HD44580. In this tutorial, we will discuss about character based LCDs, their interfacing with various microcontrollers, various interfaces (8-bit/4-bit), programming, special stuff and tricks you can do with these simple looking LCDs which can give a new look to your application.

3.8.2 Pin Description:


The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line LCDs which have only 1 controller and support at most of 80 characters, whereas LCDs supporting more than 80 characters make use of 2 HD44780 controllers. Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins (two pins are extra in both for back-light LED connections). Pin description is shown in the table below.

26

Pin No. Pin no. 1 Pin no. 2 Pin no. 3 Pin no. 4

Name VSS VCC VEE RS

Description Power supply (GND) Power supply (+5V) Contrast adjust 0 = Instruction input 1 = Data input 0 = Write to LCD module

Pin no. 5

R/W

1 = Read from LCD module

Pin no. 6 Pin no. 7 Pin no. 8 Pin no. 9

EN D0 D1 D2

Enable signal Data bus line 0 (LSB) Data bus line 1 Data bus line 2 Data bus line 3 Data bus line 4 Data bus line 5 Data bus line 6 Data bus line 7 (MSB)

Pin no. 10 D3 Pin no. 11 D4 Pin no. 12 D5 Pin no. 13 D6 Pin no. 14 D7

TABLE 4: PIN DISCRIPTION OF LCD


27

DDRAM - Display Data RAM:


Display data RAM (DDRAM) stores display data represented in 8-bit character codes. Its extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM (DDRAM) that is not used for display can be used as general data RAM. So whatever you send on the DDRAM is actually displayed on the LCD. For LCDs like 1x16, only 16 characters are visible, so whatever you write after 16 chars is written in DDRAM

CGROM - Character Generator ROM:


Now you might be thinking that when you send an ASCII value to DDRAM, how the character is displayed on LCD? So the answer is CGROM. The character generator ROM generates 5 x 8 dot or 5 x 10 dot character patterns from 8-bit character codes (see Figure 5 and Figure 6 for more details). It can generate 208 5 x 8 dot character patterns and 32 5 x 10 dot character patterns. User defined character patterns are also available by maskprogrammed ROM.As you can see in both the code maps, the character code from 0x00 to 0x07 is occupied by the CGRAM characters or the user defined characters. If user wants to display the fourth custom character then the code to display it is 0x03 i.e. when user sends 0x03 code to the LCD DDRAM then the fourth user created character or pattern will be displayed on the LCD.

CGRAM - Character Generator RAM:


As clear from the name, CGRAM area is used to create custom characters in LCD. In the character generator RAM, the user can rewrite character patterns by program. For 5 x 8 dots, eight character patterns can be written, and for 5 x 10 dots, four character patterns can be written.

BF - Busy Flag:
Busy Flag is a status indicator flag for LCD. When we send a command or data to the LCD for processing, this flag is set (i.e. BF =1) and as soon as the instruction is executed 28

successfully this flag is cleared (BF = 0). This is helpful in producing and exact amount of delay for the LCD processing.To read Busy Flag, the condition RS = 0 and R/W = 1 must be met and The MSB of the LCD data bus (D7) act as busy flag. When BF = 1 means LCD is busy and will not accept next command or data and BF = 0 means LCD is ready for the next command or data to process.

Instruction Register (IR) and Data Register (DR):


There are two 8-bit registers in HD44780 controller Instruction and Data register. Instruction register corresponds to the register where you send commands to LCD e.g. LCD shift command, LCD clear, LCD address etc. and Data register is used for storing data which is to be displayed on LCD. When send the enable signal of the LCD is asserted, the data on the pins is latched in to the data register and data is then moved automatically to the DDRAM andhenceisdisplayedontheLCD. Data Register is not only used for sending data to DDRAM but also for CGRAM, the address where you want to send the data, is decided by the instruction you send to LCD.

4-Bit Programming Of LCD:In 4-bit mode the data is sent in nibbles, first we send
the higher nibble and then the lower nibble. To enable the 4-bit mode of LCD, we need to follow special sequence of initialization that tells the LCD controller that user has selected 4-bit mode of operation. We call this special sequence as resetting the LCD. Following is the reset sequence of LCD.

Wait for about 20mS Send the first init value (0x30) Wait for about 10mS Send second init value (0x30) Wait for about 1mS Send third init value (0x30) Wait for 1mS Select bus width (0x30 - for 8-bit and 0x20 for 4-bit) 29

The busy flag will only be valid after the above reset sequence. Usually we do not use busy flag in 4-bit mode as we have to write code for reading two nibbles from the LCD. Instead we simply put a certain amount of delay usually 300 to 600uS. This delay might vary depending on the LCD you are using, as you might have a different crystal frequency on which LCD controller is running. So it actually depends on the LCD module you are using. In 4-bit mode, we only need 6 pins to interface an LCD. D4-D7 are the data pins connection and Enable and Register select are for LCD control pins. We are not using Read/Write (RW) Pin of the LCD, as we are only writing on the LCD so we have made it grounded permanently. If you want to use it, then you may connect it on your controller but that will only increase another pin and does not make any big difference. Potentiometer RV1 is used to control the LCD contrast. The unwanted data pins of LCD i.e. D0-D3 are connected to ground.

Sending data/command in 4-bit Mode:


We will now look into the common steps to send data/command to LCD when working in 4-bit mode. In 4-bit mode data is sent nibble by nibble, first we send higher nibble and then lower nibble. This means in both command and data sending function we need to separate the higher 4-bits and lower 4-bits.The common steps are:

Mask lower 4-bits Send to the LCD port Send enable signal Mask higher 4-bits Send to LCD port Send enable signal

30

Chapter-4 WORKING FLOW OF THE PROJECT&CONCLUSION


4.1 Block Diagram:

IR RECIEVER LCD 8051 MICRO CONTROLLER

IR TRANSMITTER

REGULATED POWER SUPPLY

FIG 18: BLOCK DIAGRAM OF WORKING OF PROJECT This project is mainly designed to reduce traffic problems. i.e. in general the four sides of the road at a signal point are controlled at regular intervals of time with a certain time delay. But in order to reduce the time at one side of the signal point with respect to the other side where there is more traffic we use IR sensors. It mainly consists of a microcontroller. 31

IR transmitter placed nearer to the signal point and when it detects more density of traffic at any side it and it transmits signal to the receiver. The receiver receives this signal to the microcontroller. Thus accordingly the LCD displays the time depending on the density of traffic. Here the regulated power supply is used to drive the microcontroller. Hence with the help of IR transmitter we can easily control traffic.

4.2 Circuit Description:


In this project we required operating voltage for Microcontroller 89C51 is 5V. Hence the 5V D.C. power supply is needed for the ICs. This regulated 5V is generated by stepping down the voltage from 230V to 18V now the step downed a.c voltage is being rectified by the Bridge Rectifier using 1N4007 diodes. The rectified a.c voltage is now filtered using a C filter. Now the rectified, filtered D.C. voltage is fed to the Voltage Regulator. This voltage regulator provides/allows us to have a Regulated constant Voltage which is of +5V. The rectified; filtered and regulated voltage is again filtered for ripples using an electrolytic capacitor 100F. Now the output from this section is fed to 40th pin of 89C51 microcontroller to supply operating voltage. The microcontroller 89C51 with Pull up resistors at Port0 and crystal oscillator of 11.0592 MHz crystal in conjunction with couple of 30-33pf capacitors is placed at 18th & 19th pins of 89s52 to make it work (execute) properly. One of the main problems in our citys is traffic, this project proposed new solution to traffic control. The main design accept of this project is to control the traffic automatically and adding human inelegancy to that automatic controller. "Four-way" intersection is the most common configuration for roads that cross each other, and the most basic type. If signals do not control a 4-way intersection, signs or other features are typically used to control movements and make clear priorities. For IR communication we are using an IR transmitter and IR receiver. Here IR LED will acts as a transmitter. As we know microcontroller having inbuilt I/O ports and we are interfacing IR receivers to those I/O ports. For controlling of traffic we are using red, green and yellow color LEDs. 32

These LEDs are connected to different I/O ports of microcontroller. When there is a more traffic microcontroller gives signal to green LED and it will glow. So by using this project we can control the traffic automatically like a human being.

4.3 Software:
Software used is: *Keil software for C programming *Express PCB for lay out design *Express SCH for schematic design

4.3.1 Keil Vision:


What's New in Vision3? Vision3 adds many new features to the Editor like Text Templates, Quick Function Navigation, and Syntax Coloring with brace high lighting Configuration Wizard for dialog based startup and debugger setup. Vision3 is fully compatible to Vision2 and can be used in parallel with Vision2. What is Vision3? Vision3 is an IDE (Integrated Development Environment) that helps you write, compile, and debug embedded programs. It encapsulates the following components: A project manager. A make facility. Tool configuration. Editor. A powerful debugger.

Express PCB: Express PCB is a Circuit Design Software and PCB manufacturing service. One can learn almost everything you need to know about Express PCB from the help topics included with the programs given. Details: Express PCB, Version 5.6.0

33

Express SCH: The Express SCH schematic design program is very easy to use. This software enables the user to draw the Schematics with drag and drop options. A Quick Start Guide is provided by which the user can learn how to use it. Details: Express SCH, Version 5.6.0

4.3.2 Embedded C:
The programming Language used here in this project is an Embedded C Language. This Embedded C Language is different from the generic C language in few things like a) Data types b) Access over the architecture addresses. The Embedded C Programming Language forms the user friendly language with access over Port addresses, SFR Register addresses etc.

Data Types unsigned char signed char unsigned int signed int sbit Bit sfr

Size in Bits 8-bit 8-bit 16-bit 16-bit 1-bit 1-bit 8-bit

Data Range/Usage 0-255 -128 to +127 0 to 65535 -32,768 to +32,767 SFR bit addressable only RAM bit addressable only RAM addresses 80-FFH only

TABLE5: EMBEDDED C DATA TYPES 34

Chapter-5 CONCLUSION
The project density based traffic control system has been successfully designed and tested. Integrating features of all the hardware components used have developed it. Presence of every module has been reasoned out and placed carefully thus contributing to the best working of the unit. Secondly, using highly advanced ICs and with the help of growing technology the project has been successfully implemented.

35

References:
[1]. The 8051 Micro controller and Embedded Systems-Muhammad Ali Mazidi,Janice Gillispie Mazidi [2]. The 8051 Micro controller Architecture Programming & Applications-Kenneth J.Ayala [3]. Fundamentals Of Micro processors and Micro computers -B.Ram [4]. Micro processor Architecture, Programming & Applications S.Gaonkar [5]. Electronic Components [6]. Wireless Communications [7]. Mobile Tele Communications -D.V.Prasad - Theodore S. Rappaport - William C.Y. Lee -Ramesh

REFERENCE ON WEB:
www.national.com www.nxp.com www.8052.com www.microsoftsearch.com www.geocities.com

36

Vous aimerez peut-être aussi