Anda di halaman 1dari 51

CHAPTER 1 INTRODUCTION

1. Introduction The objective of this work is to design an adaptive traffic light controller (ATLC), which can help to mitigate the prevailing problems associated with the classical traffic light controller, on a busy intersection on Indian roads. The Indian Roads Congress code (IRC): 93 - 1985, which specifies the guidelines on design of road traffic light signalsl, recommends that while designing, one should analyze the traffic volume at an intersection during morning and evening peak hours of the day, as well as off peak hours and accordingly determine the cycle time of the signals. However, since the development of this code, the ground conditions have undergone a sea change. Traffic volume has increased many folds, traffic jams have become regular affair, apart from long queues at the intersections. In order to mitigate the sufferings of the road users, reduce environmental pollution and fuel consumption, a new adaptive traffic controller system has been proposed in this paper. The duration for which the signal for an approach remains green is called duty cycle and the time between two consecutive green signals is inter green period. The sum of duty cycle and inter green period is the total cycle time of the signal. The first major problem with conventional controller is that its duty cycle as well as the inter-green period is pre determined, irrespective of the number of vehicles present on the roads at any given time of the day. This problem is attempted to be solved by making the duty cycle adaptive to the number of vehicles present on the roads at any given time using a logic controller block in the present design. The second problem is that the conventional controller runs in a cyclic order, whether traffic is present or not. This causes unnecessary wastage of time if there is no vehicle and so no need of green signal on minor roads. Giving green signal to minor roads only when there is traffic, otherwise keeping the major road in the green state, solves this problem. Third problem of pedestrians is removed by giving them priority when they are present; otherwise, the traffic controller works in the normal order. An adaptive traffic light controller (ATLC) has been designed, which controls the traffic on a busy intersection as per density of traffic, sensed by IR placed on the roads on each approach. This sensed signal is used to determine the duty cycle for the green signal allowing larger period for the roads with larger number of vehicles.

Fig 1.1 :- Four Way Traffic Control Pattern

CHAPTER 2 BLOCK DIAGRAM AND CIRCIUT DIAGRAM


2. Introduction 2.1 Block Diagram The block diagram for the intelligent traffic light controller is shown as:1. Power supply unit. The project INTELLIGENT TRAFFIC LIGHT CONTROLLER operates on 5 volt D.C. to ontain this voltage we need a power supply unit which consists of a 220v/12 v ac stepdown transformer followed by a pure d.c. supply. 2. Microcontroller. 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 industry-standard 80C51 instruction set and pinout. The on-chip Flash allows the programmemory to be reprogrammed in-system or by a conventional nonvolatile memory programmer.By combining a versatile 8-bit CPU with in-system programmable Flash ona monolithic chip, the Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible and cost-effective solution to many embedded control applications. 3. Density sensor. Infrared LED'S:Gallium arsenide is a direct-gap semiconductor with an energy gap of 1.4eV at room temperature. A typical GaPs LED is made by solid-state impurity diffusion with zinc as the p-type impurity diffused into an n-type substate doped with tin, tellurium or silicon. The external efficiency at room temperature is typically 5 percent. A GaAs diode can also be fabricated by liquid-phase epitaxy with silicon as both its n and p dopants. If a silicon atom replaces a Ga atom, it provides one additional electron, thus the resulting GaAs in as n-type. If a silicon atom replaces arsenic atoms, an electron is missing and the resulting GaAs is a p-type. In Si doped GaAs diode, the emission peak shifts down to 1.32eV. Since the emission is in infrared region, GaAs light sources are suitable for application such as the optical isolator. The high switching speed, with a recovery time between 2 and 10ns, makes them ideal for data transmission.

The disadvantages of the GaAs emitter are emitted wavelength and the associated attenuation an dispersion. A critical issue of using an LED for the fibre optics is the coupling of light from the semiconductor to the fibre. Because of the larger refractive index of GaAs relative to air, the internal efficiency of LED can be quite low. The IR transmitter and receiver both together are used as a density sensor. The IR transmitter is installed on one side of the road where as the IR receiver is connected to the other side of the road. The transmitter is continously sending the IR signal to the receiver. The presence of the vehicle is detected as the vehicle cuts the IR signal between the transmitter and the receiver. 4. Special vehicle sensor. Again the IR detector system is used for special vehicle passage. In this case two IR detector systems are used. At one end the system is used to detect the approaching vehicle and then provide a green signal to it and at the other end the detector system is used to sense that the special aehicle has crossed the traffic signal and the traffic light then starts operating in normal density checking mode. 5. LEDs as traffic controller. Light Emitting Diode (LED) A light-emitting diode (LED) is a semiconductor diode that emits incoherent narrow spectrum light when electrically biased in the forward direction of the pn-junction, as in the common LED circuit. This effect is a form of electroluminescence. While sending a message in the form of bits such as 1,the data is sent to the receiver side correspondingly the LED glows representing the data is being received simultaneously when we send 8 as a data the LED gets off .

Fig 2.1 LED

As in the simple LED circuit, The effect is a form of electroluminescence where incoherent and narrow-spectrum light is emitted from the p-n junction. LEDs are widely used as indicator lights on electronic devices and increasingly in higher power applications such as flashlights and area lighting. An LED is usually a small area (less than 1 mm2) light source, often with optics added to the chip to shape its radiation pattern and assist in reflection. The color of the emitted light depends on the composition and condition of the semi conducting material used, and can be infrared, visible, or ultraviolet. Besides lighting, interesting applications include using UV-LEDs for sterilization of water and disinfection of devices, and as a grow light to enhance photosynthesis in plants.

Fig 2.2 Close-up of a typical LED in its case showing the internal structure)

Color coding: Color Infrared Red Orange Yellow Green Blue Potential Difference 1.6 V 1.8 V to 2.1 V 2.2 V 2.4 V 2.6 V 3.0 V to 3.5 V

White Ultraviolet Advantages:

3.0 V to 3.5 V 3.5V

LEDs have many advantages over other technologies like lasers. As compared to laser diodes or IR sources LEDs are conventional incandescent lamps. For one thing, they don't have a filament that will burn out, so they last much longer. Additionally, their small plastic bulb makes them a lot more durable. They also fit more easily into modern electronic circuits.

The main advantage is efficiency. In conventional incandescent bulbs, the light-production process involves generating a lot of heat (the filament must be warmed). Unless you're using the lamp as a heater, because a huge portion of the available electricity isn't going toward producing visible light.

LEDs generate very little heat. A much higher percentage of the electrical power is going directly for generating light, which cuts down the electricity demands considerably.

LEDs offer advantages such as low cost and long service life. Moreover LEDs have very low power consumption and are easy to maintain.

Disadvantages of LEDS: LEDs performance largely depends on the ambient temperature of the operating environment. LEDs must be supplied with the correct current. LEDs do not approximate a "point source" of light, so cannot be used in applications needing a highly collimated beam. But the disadvantages are quite negligible as the negative properties of LEDs do not apply and the advantages far exceed the limitations. These LEDs are connected at the 8 bits of the port 2 and the 4 bits of port 3 i.e, from pin P3.0 to P3.3 of port 3 and pin2.0 to pin2.7 of port 2

2.2 Circuit Diagram

Fig2.3 Circuit Diagram

CHAPTER 3 POWER SUPPLY UNIT


3. Introduction to power supply Power supply is a device designed to convert high voltage AC mains electricity to a suitable low voltage supply for electronic circuits and other devices. A power supply can by broken down into a series of blocks, each of which performs a particular function: 3.1 Block Diagram of a Regulated Power Supply System

Fig 3.1 block diagram of a regulated power supply system

Each of the blocks is described in more detail below:


1. 2. 3. 4.

Transformer - steps down high voltage AC mains to low voltage AC. Rectifier - converts AC to DC, but the DC output is varying. Smoothing - smooths the DC from varying greatly to a small ripple. Regulator - eliminates ripple by setting DC output to a fixed voltage.

3.2 Power supply circuit diagram

Fig 3.2 power supply circuit diagram

3.3 Transformer 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. As a transformer converts one voltage into another therefore it can be either step-up or step-down transformer.

Fig 3.3 Circuit symbol of transformer

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. The two lines in the middle of the circuit symbol represent the core. Transformers waste very little power so the power out is (almost) equal to the power in. Note that as voltage is stepped down current is stepped up. 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.

Vp = primary (input) voltage Np = number of turns on primary coil Vs = secondary (output) voltage Ns = number of turns on secondary coil 3.3.1 Step-up transformer Step-up transformers increase voltage, as per our requirement. 3.3.2 Step-down transformer Step-down transformers reduce voltage. Most power supplies use a step-down transformer to reduce the dangerously high mains voltage (230V) to a safer low voltage. 3.4 Rectifier There are several ways of connecting diodes to make a rectifier to convert AC to DC. The bridge rectifier is the most important and it produces full-wave varying DC. A full-wave rectifier can also be made from just two diodes if a centre-tap transformer is used, but this method is rarely used now that diodes are cheaper. A single diode can

be used as a rectifier but it only uses the positive (+) parts of the AC wave to produce half-wave varying DC. 3.4.1 Full wave Bridge rectifier circuit 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 the entire 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. Bridge rectifiers are rated by the maximum current they can pass and the maximum reverse voltage they can withstand (this must be at least three times the supply RMS voltage so the rectifier can withstand the peak voltages).

Bridge rectifier Alternate pairs of diodes conduct, changing over the connections so the alternating directions of AC are converted to the one direction of DC. Fig 3.4 bridge rectifier circuit

Output: full-wave varying DC (using all the AC wave)

3.4.2 Single diode rectifier A single diode can be used as a rectifier but this produces half-wave varying DC which has gaps when the AC is negative. It is hard to smooth this sufficiently well to supply electronic circuits unless they require a very small current so the smoothing capacitor does not significantly discharge during the gaps.

Single diode rectifier

Output: half-wave varying DC (using only half the AC wave) Fig 3.5 Single diode rectifier

3.5 Smoothing/Filtering 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 (dotted line) and the smoothed DC (solid line). The capacitor charges quickly near the peak of the varying DC, and then discharges as it supplies current to the output.

Fig 3.6 capacitor filter

Note that smoothing significantly increases the average DC voltage to almost the peak value (1.4 RMS value). For example 6V RMS AC is rectified to full wave DC of about 4.6V RMS (1.4V is lost in the bridge rectifier), with smoothing this increases to almost the peak value giving 1.4 4.6 = 6.4V smooth DC. Smoothing is not perfect due to the capacitor voltage falling a little as it discharges, giving a small ripple voltage. For many circuits a ripple which is 10% of the supply voltage is satisfactory and the equation below gives the required value for the smoothing capacitor. A larger capacitor will give fewer ripples. The capacitor value must be doubled when smoothing half-wave DC. 5 Io Smoothing capacitor for 10% ripple, C = Vs f C = smoothing capacitance in farads (F) Io = output current from the supply in amps (A) Vs = supply voltage in volts (V), this is the peak value of the unsmoothed DC f = frequency of the AC supply in hertz (Hz), 50Hz in the UK 3.6 Regulator

Fig 3.7 Voltage Regulator

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 ('overload protection') and overheating ('thermal protection'). Many of the fixed voltage regulator ICs has 3 leads and look like power transistors, such as the 7805 +5V 1A regulator shown on the right. They include a hole for attaching a heat sink if necessary 3.7 555 TIMER The buffer circuit's input has a very high impedance (about 1M ) so it requires only a few A, but the output can sink or source up to 200mA. This enables a high impedance signal source (such as an LDR) to switch a low impedance output transducer (such as a lamp). It is an inverting buffer or NOT gate because the output logic state (low/high) is the inverse of the input state: Input low (< 1/3 Vs) makes output high, +Vs Input high (> 2/3 Vs) makes output low, 0V When the input voltage is between 1/3 and 2/3 Vs the output remains in its present state. This intermediate input region is a deadspace where there is no response, a property called hysteresis, it is like backlash in a mechanical linkage. This type of circuit is called a Schmitt trigger. If high sensitivity is required the hysteresis is a problem, but in many circuits it is a helpful property. It gives the input a high immunity to noise because once the circuit output has switched high or low the input must change back by at least 1/3 Vs to make the output switch back.

Fig3.8 Monostable Mode:

The 555 in fig. 9a is shown here in it's altmost basic mode of operation; as a triggered monostable. One immediate observation is the extreme simplicity of this circuit. Only two components to make up a timer, a capacitor and a resistor. And for noise immunity maybe a capacitor on pin 5. Due to the internal latching mechanism of the 555, the timer will always time-out once triggered, regardless of any subsequent noise (such as bounce) on the input trigger (pin 2). This is a great asset in interfacing the 555 with noisy sources. Just in case you don't know what 'bounce' is: bounce is a type of fast, short term noise caused by a switch, relay, etc. and then picked up by the input pin. The trigger input is initially high (about 1/3 of +V). When a negative-going trigger pulse is applied to the trigger input (see fig. 9a), the threshold on the lower comparator is exceeded. The lower comparator, therefore, sets the flip-flop. That causes T1 to cut off, acting as an open circuit. The setting of the flip-flop also causes a positive-going output level which is the beginning of the output timing pulse. The capacitor now begins to charge through the external resistor. As soon as the charge on the capacitor equal 2/3 of the supply voltage, the upper comparator triggers and resets the control flip-flop. That terminates the output pulse which switches back to zero. At this time, T1 again conducts thereby discharging the capacitor. If a negative-going pulse is applied to the reset input while the output pulse is high, it will be terminated immediately as that pulse will reset the flip-flop. Whenever a trigger pulse is applied to the input, the 555 will generate its singleduration output pulse. Depending upon the values of external resistance and capacitance used, the output timing pulse may be adjusted from approximately one millisecond to as high as on hundred seconds. For time intervals less than approximately 1-millisecond, it is recommended that standard logic one-shots designed for narrow pulses be used instead of a 555 timer. IC timers are normally used where long output pulses are required. In this application, the duration of the output pulse in seconds is approximately equal to: T = 1.1 x R x C (in seconds) The output pulse width is defined by the above formula and with relatively few restrictions, timing components R(t) and C(t) can have a wide range of values. There is actually no theoretical upper limit on T (output pulse width), only practical ones. The lower limit is 10uS. You may consider the range of T to be 10uS to infinity, bounded only by R and C limits. Special R(t) and C(t) techniques allow for timing

periods of days, weeks, and even months if so desired.However, a reasonable lower limit for R(t) is in the order of about 10Kilo ohm, mainly from the standpoint of power economy. (Although R(t) can be lower that 10K without harm, there is no need for this from the standpoint of achieving a short pulse width.) A practical minimum for C(t) is about 95pF; below this the stray effects of capacitance become noticeable, limiting accuracy and predictability. Since it is obvious that the product of these two minimums yields a T that is less the 10uS, there is much flexibility in the selection of R(t) and C(t). Usually C(t) is selected first to minimize size (and expense); then R(t) is chosen. The upper limit for R(t) is in the order of about 15 Mega ohm but should be less than this if all the accuracy of which the 555 is capable is to be achieved. The absolute upper limit of R(t) is determined by the threshold current plus the discharge leakage when the operating voltage is +5 volt. For example, with a threshold plus leakage current of 120nA, this gives a maximum value of 14M for R(t) (very optimistic value). Also, if the C(t) leakage current is such that the sum of the threshold current and the leakage current is in excess of 120 nA the circuit will never time-out because the upper threshold voltage will not be reached. Therefore, it is good practice to select a value for R(t) so that, with a voltage drop of 1/3 V+ across it, the value should be 100 times more, if practical. So, it should be obvious that the real limit to be placed on C(t) is its leakage, not it's capacitance value, since larger-value capacitors have higher leakages as a fact of life. Low-leakage types, like tantalum or NPO, are available and preferred for long timing periods. Sometimes input trigger source conditions can exist that will necessitate some type of signal conditioning to ensure compatibility with the triggering requirements of the 555. This can be achieved by adding another capacitor, one or two resistors and a small signal diode to the input to form a pulse differentiator to shorten the input trigger pulse to a width less than 10uS (in general, less than T). Their values and criterion are not critical; the main one is that the width of the resulting differentiated pulse (after C) should be less than the desired output pulse for the period of time it is below the 1/3 V+ trigger level. There are several different types of 555 timers. The LM555 from National is the most common one these days, in my opinion. The Exar XR-L555 timer is a micropower version of the standard 555 offering a direct, pin-for-pin (also called plug-compatible) substitute device with an advantage of a lower power operation. It is capable of

operation of a wider range of positive supply voltage from as low as 2.7volt minimum up to 18 volts maximum. At a supply voltage of +5V, the L555 will typically dissipate of about 900 microwatts, making it ideally suitable for battery operated circuits. The internal schematic of the L555 is very much similar to the standard 555 but with additional features like 'current spiking' filtering, lower output drive capability, higher nodal impedances, and better noise reduction system. Maxim's ICM7555, and Sanyo's LC7555 models are a low-power, general purpose CMOS design version of the standard 555, also with a direct pin-for-pin compatibility with the regular 555. It's advantages are very low timing/bias currents, low powerdissipation operation and an even wider voltage supply range of as low as 2.0 volts to 18 volts. At 5 volts the 7555 will dissipate about 400 microwatts, making it also very suitable for battery operation. The internal schematic of the 7555 (not shown) is however totally different from the normal 555 version because of the different design process with cmos technology. It has much higher input impedances than the standard bipolar transistors used. The cmos version removes essentially any timing component restraints related to timer bias currents, allowing resistances as high as practical to be used. This very versatile version should be considered where a wide range of timing is desired, as well as low power operation and low current sync'ing appears to be important in the particular design. A couple years after Intersil, Texas Instruments came on the market with another cmos variation called the LINCMOS (LINear CMOS) or Turbo 555. In general, different manufacturers for the cmos 555's reduced the current from 10mA to 100A while the supply voltage minimum was reduced to about 2 volts, making it an ideal type for 3v applications. The cmos version is the choice for battery powered circuits. However, the negative side for the cmos 555's is the reduced output current, both for sync and source, but this problem can be solved by adding a amplifier transistor on the output if so required. For comparison, the regular 555 can easily deliver a 200mA output versus 5 to 50mA for the 7555. On the workbench the regular 555 reached a limited output frequency of 180Khz while the 7555 easily surpassed the 1.1Mhz mark and the TLC555 stopped at about 2.4Mhz. Components used were 1% Resistors and low-leakage capacitors, supply voltage used was 10volt. Some of the less desirable properties of the regular 555 are high supply current, high trigger current, double output transitions, and inability to run with very low supply

voltages. These problems have been remedied in a collection of CMOS successors. A caution about the regular 555 timer chips; the 555, along with some other timer ic's, generates a big (about 150mA) supply current glitch during each output transition. Be sure to use a hefty bypass capacitor over the power connections near the timer chip. And even so, the 555 may have a tendency to generate double output transitions. 3.8 Crystal Oscillator XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier, which can be configured for use as an on-chip oscillator. 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. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed. 3.9 Working. In this project we have used IR light as traffic density detector. As shown in the figure every side two IR transmitter and two IR receiver is installed (figure shows only two side). IR transmitter transmits IR light and receiver receives corresponding light. Let us consider some cases: No traffic In this case light transmitted by transmitter AB, CD fall on the corresponding receiver which gives signal to the microcontlloler 11,11. Thus microcontroller senses No traffic and Blink all yellow LED. One side no traffic and other side Small traffic In this case light transmitted by transmitter AB, CD don't fall on the corresponding receiver which may gives signal to the microcontlloler 01, 11. Thus microcontroller senses small traffic and start executing predefined traffic signal subroutine with green signal on 01 side. One side small traffic and other side large traffic In this case light transmitted by transmitter AB, CD don't fall on the corresponding receiver which may gives signal to the microcontlloler 01, 00. Thus microcontroller senses mix traffic and start executing predefined traffic signal suroutine with small green signal on 01 side and large green signal on other side.

Density detector circuit working The infrared sensor is used to sense traffic density. In the infrared sensor we use IC 555 as a main component. Pin no 4 and pin no 8 is connected to the positive supply. Pin no 1 is connected to the negative voltage. One capacitor is grounded from the pin no 5 for noise cancellation. Output is available on the pin no 3. Sensor is connected to the pin no 2. In the case of infra red sensor Pin no 2 is negative bias through the 33k ohm resistor and pin no is positively biased through the photodiode. One infrared transmitter led is focused to the photodiode. Infra red led is directly connected to the positive and negative supply through the 330ohm resistor. In normal stage when light is focusing on the DR. diode then pin no 2 is positively biased IR diode. If pin no 2 is positive then negative output is available on the pin no 3. Now when any body interrupts the light then there is no light on the photodiode and pin no 2 is now gets its voltage from only 33 k ohm resistor. If pin no 2 is become negative then output is shifted to the pin no 3. When positive output is available on the pin no 3 and with the help of this voltage NPN transistor is on and npn transistor provide a negative voltage as a pulse to the microcontroller (pin No 36, 37, 38, 39)

CHAPTER 4 MICROCONTROLLER AT89S52


4.1 Introduction To Microcontroller Microcontrollers as the name suggests are small controllers. They are like single chip computers that are often embedded into other systems to function as

processing/controlling unit. For example the remote control you are using probably has microcontrollers inside that do decoding and other controlling functions. They are also used in automobiles, washing machines, microwave ovens, toys ... etc, where automation is needed. Micro-controllers are useful to the extent that they communicate with other devices, such as sensors, motors, switches, keypads, displays, memory and even other microcontrollers. Many interface methods have been developed over the years to solve the complex problem of balancing circuit design criteria such as features, cost, size, weight, power consumption, reliability, availability, manufacturability. Many microcontroller designs typically mix multiple interfacing methods. In a very simplistic form, a micro-controller system can be viewed as a system that reads from (monitors) inputs, performs processing and writes to (controls) outputs. Embedded system means the processor is embedded into the required application. An embedded product uses a microprocessor or microcontroller to do one task only. In an embedded system, there is only one application software that is typically burned into ROM. Example: printer, keyboard, video game player Microprocessor - A single chip that contains the CPU or most of the computer Microcontroller - A single chip used to control other devices Microcontroller differs from a microprocessor in many ways. First and the most important is its functionality. In order for a microprocessor to be used, other components such as memory, or components for receiving and sending data must be added to it. In short that means that microprocessor is the very heart of the computer. On the other hand, microcontroller is designed to be all of that in one. No other external components are needed for its application because all necessary peripherals are already built into it. Thus, we save the time and space needed to construct devices. 4.2 Microprocessor Vs Microcontroller: Microprocessor: CPU is stand-alone, RAM, ROM, I/O, timer are separate

Designer can decide on the amount of ROM, RAM and I/O ports. expensive versatility general-purpose

Microcontroller: CPU, RAM, ROM, I/O and timer are all on a single chip fix amount of on-chip ROM, RAM, I/O ports for applications in which cost, power and space are critical single-purpose

4.3 Microcontroller 89S52 FEATURES: 8K Bytes of In-System Reprogrammable Flash Memory Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz 256 x 8-bit Internal RAM 32 Programmable I/O Lines Three 16-bit Timer/Counters Eight Interrupt Sources Programmable Serial Channel Low-power Idle and Power-down Modes Description: The AT89C52 is a low-power, high-performance CMOS 8-bit microcomputer with 8Kbytes of Flash programmable and erasable read only memory (PEROM). The onchip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C52 is a powerful microcomputer, which provides a highly flexible and cost-effective solution to many embedded control applications.

4.3.1 PIN Diagram - AT89S52:

Fig4.1 Pin Diagram 4.3.2 PIN DESCRIPTION: VCC - Supply voltage. GND - Ground. Port 0: Port 0 is an 8-bit open drain bi-directional 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 during program verification. External pullups are required during program verification.

Port 1: Port 1 is an 8-bit bi-directional 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 internal 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. 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 Port 2: Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 2output buffers can sink/source four TTL inputs. When 1s are written to Port 2 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled low will source current (I IL) because of the internal pull-ups. Port 2 emits the high-order address byte during fetches from external program memory and during accesses to external data memory that uses 16-bit addresses (MOVX @ DPTR). In this application, Port 2 uses strong internal pullups when emitting 1s. During accesses to external data memory that uses 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 programming and verification. Port 3: Port 3 is an 8-bit bi-directional I/O port with internal pullups. 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 internal pullups and can be used as inputs. As inputs, Port 3 pins that are externally being pulled low will source current (I IL) because of the pullups. Port 3 also serves the functions of various special features of the AT89C51. Port 3 also receives some control signals for Flash programming and verification. 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). RST: Reset input. A high on this pin for two machine cycles while the oscillator is running resets the device. ALE/PROG: Address Latch Enable 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. However, that one ALE pulse is skipped during 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. PSEN: Program Store Enable is the read strobe to external program memory. When the AT89C52 is executing code from external program memory, PSEN is activated twice each machine cycle, except that two PSEN activations are skipped during each access to external data memory. EA/VPP: External Access Enable (EA) must be strapped to GND in order to enable the device to fetch code from external pro-gram memory locations starting at 0000H up to FFFFH. However, if lock bit 1 is programmed, EA will be internally latched on reset. EA should be strapped to VCC for internal program executions. This pin also receives the 12V programming enable voltage (VPP) during Flash programming when 12V programming is selected. XTAL1: input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2:

It is an output from the inverting oscillator amplifier 4.3.3 Block Diagram OF 89S52:

Fig 4.2 Block Diagram

4.3.4 Architechture of 8052 Microcontroller:

Fig4.3Architecture of 89S52

4.4 Oscillator Characteristics: XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier, which can be configured for use as an on-chip oscillator. 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. There are no requirements on the duty cycle of the external clock signal, since the input to the internal clocking circuitry is through a divide-by-two flip-flop, but minimum and maximum voltage high and low time specifications must be observed. Idle mode: In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain active. The mode is invoked by software. The content of the on-chip RAM and all the special functions registers remain unchanged during this mode. The idle mode can be terminated by any enabled interrupt or by a hardware reset. It should be noted that when idle is terminated by a hardware reset, the device normally resumes program execution, from where it left off, up to two machine cycles before the internal reset algorithm takes control. On-chip hardware inhibits access to internal RAM in this event, but access to the port pins is not inhibited. To eliminate the possibility of an unexpected write to a port pin when Idle is terminated by reset, the instruction following the one that invokes Idle should not be one that writes to a port pin or to external memory. Oscillator connections:

Fig 4.4 Oscillator Connections

Note: C1, C2 = 30 pF 10 pF for Crystals = 40 pF 10 pF for Ceramic Resonators

Fig 4.5 External Clock drives Configuration.

CHAPTER 5 VARIOUS COMPONENTS USED


5. Component Used 5.1 Resistor Resistors are the most commonly used component in electronics and their purpose is to create specified values of current and voltage in a circuit. A number of different resistors are shown in the photos. (The resistors are on millimeter paper, with 1cm spacing to give some idea of the dimensions). Photo 1.1a shows some low-power resistors, while photo 1.1b shows some higher-power resistors. Resistors with power dissipation below 5 watt (most commonly used types) are cylindrical in shape, with a wire protruding from each end for connecting to a circuit (photo 1.1-a). Resistors with power dissipation above 5 watt are shown below (photo 1.1-b).

Some low-power resistors Resistor symbols

High-power resistors and rheostats

Fig 5.1 Some commonly used resistors and rheostats

The unit for measuring resistance is the OHM. (the Greek letter - called Omega). Higher resistance values are represented by "k" (kilo-ohms) and M (meg ohms). For example, 120 000 is represented as 120k, while 1 200 000 is represented as 1M2. The dot is generally omitted as it can easily be lost in the printing process. In some circuit diagrams, a value such as 8 or 120 represents a resistance in ohms. Another common practice is to use the letter E for resistance in ohms. The letter R can also be used. For example, 120E (120R) stands for 120 , 1E2 stands for 1R2 etc. 5.2 Carbon film resistors: This is the most general purpose, cheap resistor. Usually the tolerance of the resistance value is 5%. Power ratings of 1/8W, 1/4W and 1/2W are frequently used.Carbon film resistors have a disadvantage; they tend to be electrically noisy. Metal film resistors are recommended for use in analog circuits. However, I have never experienced any problems with this noise. The physical size of the different resistors is as follows.

Fig5.2 Carbon Film

This resistor is called a Single-In-Line(SIL) resistor network. It is made with many resistors of the same value, all in one package. One side of each resistor is connected with one side of all the other resistors inside. One example of its use would be to control the current in a circuit powering many light emitting diodes (LEDs). In the photograph on the left, 8 resistors are housed in the package. Each of the leads on the package is one resistor. The ninth lead on the left side is the common lead. The face value of the resistance is printed. ( It depends on the supplier. ) Some resistor networks have a "4S" printed on the top of the resistor network. The 4S indicates that the package contains 4 independent resistors that are not wired together inside. The housing has eight leads instead of nine. The internal wiring of these typical resistor networks has been illustrated below. The size (black part) of the resistor network which I have is as follows: For the type with 9 leads, the thickness is 1.8 mm, the height 5mm, and the width 23 mm. For the types with 8 component leads, the thickness is 1.8 mm, the height 5 mm, and the width 20 mm. 5.3 Metal film resistors: Metal film resistors are used when a lower tolerance (more accurate value) is needed. They are much more accurate in value than carbon film resistors. They have about 0.05% tolerance. They have about 0.05% tolerance. I don't use any high tolerance resistors in my circuits. Resistors that are about 1% are more than sufficient. Ni-Cr (Nichrome) seems to be used for the material of resistor. The metal film resistor is used for bridge circuits, filter circuits, and low-noise analog signal circuits. 5.4 Nonlinear resistors Resistance values detailed above are a constant and do not change if the voltage or current-flow alters. But there are circuits that require resistors to change value with a change in temperate or light. This function may not be linear, hence the name NONLINEAR RESISTORS.

There are several types of nonlinear resistors, but the most commonly used include : NTC resistors (figure a) (Negative Temperature Co-efficient) - their resistance lowers with temperature rise. PTC resistors (figure b) (Positive Temperature Co-efficient) their resistance increases with the temperature rise. LDR resistors (figure c) (Light Dependent Resistors) - their resistance lowers with the increase in light. VDR resistors (Voltage dependent Resistors) - their resistance critically lowers as the voltage exceeds a certain value. Symbols representing these resistors are shown below.

Fig. 5.3: Nonlinear resistors - a. NTC, b. PTC, c. LDR

In amateur conditions where nonlinear resistor may not be available, it can be replaced with other components. For example, NTC resistor may be replaced with a transistor with a trimmer potentiometer, for adjusting the required resistance value. Automobile light may play the role of PTC resistor, while LDR resistor could be replaced with an open transistor. As an example, figure on the right shows the 2N3055, with its upper part removed, so that light may fall upon the crystal inside.

Fig5.4 Cds Elements (LDR):

Some components can change resistance value by changes in the amount of light hitting them. One type is the Cadmium Sulfide Photocell. (Cd) The more light that hits it, the smaller its resistance value becomes. There are many types of these devices. They vary according to light sensitivity, size, resistance value etc. Pictured at the left is a typical CDS photocell. Its diameter is 8 mm, 4 mm high, with a cylinder form. When bright light is hitting it, the value is about 200 ohms, and when in the dark, the resistance value is about 2M ohms. This device is using for the head lamp illumination confirmation device of the car, for example. 5.5 Resistor Power Dissipation

If the flow of current through a resistor increases, it heats up, and if the temperature exceeds a certain critical value, it can be damaged. The wattage rating of a resistor is the power it can dissipate over a long period of time. Wattage rating is not identified on small resistors. The following diagrams show the size and wattage rating: Resistor dimensions Most commonly used resistors in electronic circuits have a wattage rating of 1/2W or 1/4W. There are smaller resistors (1/8W and 1/16W) and higher (1W, 2W, 5W, etc). In place of a single resistor with specified dissipation, another one with the same resistance and higher rating may be used, but its larger dimensions increase the space taken on a printed circuit board as well as the added cost. Power (in watts) can be calculated according to one of the following formulae, where U is the symbol for Voltage across the resistor (and is in Volts), I is the symbol for Current in Amps and R is the resistance in ohms:

For example, if the voltage across an 820W resistor is 12V, the wattage dissipated by the resistors is:

A 1/4W resistor can be used. In many cases, it is not easy to determine the current or voltage across a resistor. In this case the wattage dissipated by the resistor is determined for the "worst" case. We should assume the highest possible voltage across a resistor, i.e. the full voltage of the power supply (battery, etc). If we mark this voltage as VB, the highest dissipation is:

For example, if VB=9V, the dissipation of a 220W resistor is:

A 0.5W or higher wattage resistor should be used 5.6 Resistor Markings

Resistance value is marked on the resistor body. Most resistors have 4 bands. The first two bands provide the numbers for the resistance and the third band provides the number of zeros. The fourth band indicates the tolerance. Tolerance values of 5%, 2%, and 1% are most commonly available. The following table shows the colors used to identify resistor values:
Table LED

COLOR Silver Gold Black Brown Red Orange Yellow Green Blue Violet Grey White

DIGIT

MULTIPLIERTOLERANCETC 10% 5% 1% 2% 100*10-6/K 50*10-6/K 15*10-6/K 25*10-6/K 10*10-6/K 5*10-6/K 1*10-6/K

0 1 2 3 4 5 6 7 8 9

0.5% 0.25% 0.1%

** TC - Temp. Coefficient, only for SMD devices

Fig. 5.5: Four-band resistor, c. Five-band resistor, d. Cylindrical SMD resistor, e. Flat SMD resistor

NOTES: The resistors above are "common value" 5% types. The fourth band is called the "tolerance" band. Gold = 5% (tolerance band Silver =10% but no modern resistors are 10%!!) "common resistors" have values 10 ohms to 22M. RESISTORS LESS THAN 10 OHMS When the third band is gold, it indicates the value of the "colors" must be divided by 10. Gold = "divide by 10" to get values 1R0 to 8R2 See 1st Column above for examples. When the third band is silver, it indicates the value of the "colors" must be divided by 100. (Remember: more letters in the word "silver" thus the divisor is "larger.") Silver = "divide by 100" to get values 0R1 (one tenth of an ohm) to 0R82 e.g: 0R1 = 0.1 ohm 0R22 = point 22 ohms

See 4th Column above for examples. The letters "R, k and M" take the place of a decimal point. The letter "E" is also used to indicate the word "ohm." e.g: 1R0 = 1 ohm 2k2 = 2,200 ohms 2R2 = 2 point 2 ohms 22R = 22 ohms 100k = 100,000 ohms

2M2 = 2,200,000 ohms Common resistors have 4 bands. These are shown above. First two bands indicate the first two digits of the resistance; third band is the multiplier (number of zeros that are to be added to the number derived from first two bands) and fourth represents the tolerance. Marking the resistance with five bands is used for resistors with tolerance of 2%, 1% and other high-accuracy resistors. First three bands determine the first three digits, fourth is the multiplier and fifth represent the tolerance. For SMD (Surface Mounted Device) the available space on the resistor is very small. 5% resistors use a 3 digit code, while 1% resistors use a 4 digit code. Some SMD resistors are made in the shape of small cylinder while the most common type is flat. Cylindrical SMD resistors are marked with six bands - the first five are "read" as with common five-band resistors, while the sixth band determines the

Temperature Coefficient (TC), which gives us a value of resistance change upon 1degree temperature change. The resistance of flat SMD resistors is marked with digits printed on their upper side. First two digits are the resistance value, while the third digit represents the number of zeros. For example, the printed number 683 stands for 68000W, that is 68k. It is self-obvious that there is mass production of all types of resistors. Most commonly used are the resistors of the E12 series, and have a tolerance value of 5%. Common values for the first two digits are: 10, 12, 15, 18, 22, 27, 33, 39, 47, 56, 68 and 82. The E24 series includes all the values above, as well as: 11, 13, 16, 20, 24, 30, 36, 43, 51, 62, 75 and 91. What do these numbers mean? It means that resistors with values for digits "39" are: 0.39W, 3.9W, 39W, 390W, 3.9kW, 39kW, etc are manufactured. (0R39, 3R9, 39R, 390R, 3k9, 39k) For some electrical circuits, the resistor tolerance is not important and it is not specified. In that case, resistors with 5% tolerance can be used. However, devices which require resistors to have a certain amount of accuracy, need a specified tolerance. 5.7. Capacitors Capacitors are common components of electronic circuits, used almost as frequently as resistors. The basic difference between the two is the fact that capacitor resistance (called reactance) depends on the frequency of the signal passing through the item. The symbol for reactance is Xc and it can be calculated using the following formula:

f representing the frequency in Hz and C representing the capacitance in Farads. For example, 5nF-capacitor's reactance at f=125kHz equals:

while, at f=1.25MHz, it equals:

A capacitor has an infinitely high reactance for direct current, because f=0. Capacitors are used in circuits for many different purposes. They are common components of filters, oscillators, power supplies, amplifiers, etc.

The basic characteristic of a capacitor is its capacity - the higher the capacity, the higher is the amount of electricity it can hold. Capacity is measured in Farads (F). As one Farad represents fairly high capacity, smaller values such as microfarad (F), nanofarad (nF) and picofarad (pF) are commonly used. As a reminder, relations between units are: 1F=106F=109nF=1012pF, that is 1F=1000nF and 1nF=1000pF. It is essential to remember this notation, as same values may be marked differently in some circuits. For example, 1500pF is the same as 1.5nF, 100nF is 0.1F. A simpler notation system is used as with resistors. If the mark on the capacitor is 120 the value is 120pF, 1n2 stands for 1.2nF, n22 stands for 0.22nF, while .1 (or .1u) stands for 0.1F. Capacitors come in various shapes and sizes, depending on their capacity, working voltage, type of insulation, temperature coefficient and other factors. All capacitors can divided in two groups: those with changeable capacity values and those with fixed capacity values. These will covered in the following chapters. 1. Block-capacitors (Fixed value): Capacitors with fixed values (the so called block-capacitors) consist of two thin metal plates (these are called "electrodes" or sometimes called the "foil"), separated by a thin insulating material such as plastic. The most commonly used material for the "plates" is aluminum, while the common materials used for insulator include paper, ceramic, mica, etc after which the capacitors get named. A number of different block-capacitors are shown in the photo below. A symbol for a capacitor is in the upper right corner of the image.

Fig 5.6 Block capacitors

Most of the capacitors, block-capacitors included, are non-polarized components, meaning that their leads are equivalent in respect of the way the capacitor can be

placed in a circuit. Electrolytic capacitors represent the exception as their polarity is important. This will be covered in the following chapters. 2. Electrolytic capacitors Aluminum is used for the electrodes by using a thin oxidization membrane. Large values of capacitance can be obtained in comparison with the size of the capacitor, because the dielectric used is very thin. Electrolytic capacitors represent the special type of capacitors with fixed capacity value. Thanks to special construction, they can have exceptionally high capacity, ranging from one to several thousand F. They are most frequently used in circuits for filtering; however they also have other purposes. Electrolytic capacitors are polarized components, meaning they have positive and negative leads, which is very important when connecting it to a circuit. The positive lead or pin has to be connected to the point with a higher positive voltage than the negative lead. If it is connected in reverse the insulating layer inside the capacitor will be "dissolved" and the capacitor will be permanently damaged. Explosion may also occur if capacitor is connected to voltage that exceeds its working voltage. In order to prevent such instances, one of the capacitor's connectors is very clearly marked with a + or -, while the working voltage is printed on the case. Several models of electrolytic capacitors, as well as their symbols, are shown on the picture below.

Fig 5.7 Electrolytic capacitors

5.8. Diode A diode is a semiconductor device which allows current to flow through it in only one direction. Although a transistor is also a semiconductor device, it does not operate the way a diode does. A diode is specifically made to allow current to flow through it in only one direction. Some ways in which the diode can be used are listed here. A diode can be used as a rectifier that converts AC (Alternating Current) to DC (Direct Current) for a power supply device. Diodes can be used to separate the signal from radio frequencies. Diodes can be used as an on/off switch that controls current.

Fig 5.8 Different types of Diodes

This symbol symbol is cathode side.

is used to indicate a diode in a circuit diagram. The meaning of the (Anode) (Cathode). Current flows from the anode side to the

Although all diodes operate with the same general principle, there are different types suited to different applications. For example, the following devices are best used for the applications noted.

Diode symbols: a - standard diode, b - LED, c, d - Zener, e - photo, f,g - tunnel, h Schottky, i - breakdown, j - capacitative

V-I characteristics:

Fig 5.9 V-I characteristics

The graph on the right shows the electrical characteristics of a typical diode. When a small voltage is applied to the diode in the forward direction, current flows easily. Because the diode has a certain amount of resistance, the voltage will drop slightly as current flows through the diode. A typical diode causes a voltage drop of about 0.6 1V (VF) (In the case of silicon diode, almost 0.6V) This voltage drop needs to be taken into consideration in a circuit which uses many diodes in series. Also, the amount of current passing through the diodes must be considered. When voltage is applied in the reverse direction through a diode, the diode will have a great resistance to current flow. Different diodes have different characteristics when reverse-biased. A given diode should be selected depending on how it will be used in the circuit. The current that will flow through a diode biased in the reverse direction will vary from several mA to just A, which is very small. The limiting voltages and currents permissible must be considered on a case by case basis. For example, when using diodes for rectification, part of the time they will be required to withstand a reverse voltage. If the diodes are not chosen carefully, they will break down. 5.8.1 Rectification / Switching / Regulation Diode: The stripe stamped on one end of the diode shows indicates the polarity of the diode. The stripe shows the cathode side. The top two devices shown in the picture are diodes used for rectification. They are made to handle relatively high currents. The device on top can handle as high as 6A, and the one below it can safely handle up to 1A. However, it is best used at about 70% of its rating because this current value is a maximum rating.

The third device from the top (red color) has a part number of 1S1588. This diode is used for switching, because it can switch on and off at very high speed. However, the maximum current it can handle is 120 mA. This makes it well suited to use within digital circuits. The maximum reverse voltage (reverse bias) this diode can handle is 30V.

The device at the bottom of the picture is a voltage regulation diode with a rating of 6V. When this type of diode is reverse biased, it will resist changes in voltage. If the input voltage is increased, the output voltage will not change. (Or any change will be an insignificant amount.) While the output voltage does not increase with an increase in input voltage, the output current will. This requires some thought for a protection circuit so that too much current does not flow. The rated current limit for the device is 30 mA. Generally, a 3-terminal voltage regulator is used for the stabilization of a power supply. Therefore, this diode is typically used to protect the circuit from momentary voltage spikes. 3 terminal regulators use voltage regulation diodes inside. Rectification diodes are used to make DC from AC. It is possible to do only 'half wave rectification' using 1 diode. When 4 diodes are combined, 'full wave rectification' occurrs. Devices that combine 4 diodes in one package are called diode bridges. They are used for full-wave rectification.

Fig 5.10 Shows half and full wave rectification

5.9 Light Emitting Diode (LED):

Fig 5.11LEDs

Light emitting diodes must be chosen according to how they will be used, because there are various kinds. The diodes are available in several colors. The most common colors are red and green, but there are even blue ones. The device on the far right in the photograph combines a red LED and green LED in one package. The component lead in the middle is common to both LEDs. As for the remains two leads, one side is for the green, the other for the red LED. When both are turned on simultaneously, it becomes orange. When an LED is new out of the package, the polarity of the device can be determined by looking at the leads. The longer lead is the Anode side, and the short one is the Cathode side. The polarity of an LED can also be determined using a resistance meter, or even a 1.5 V battery. When using a test meter to determine polarity, set the meter to a low resistance measurement range. Connect the probes of the meter to the LED. If the polarity is correct, the LED will glow. If the LED does not glow, switch the meter probes to the opposite leads on the LED. In either case, the side of the diode which is connected to the black meter probe when the LED glows, is the Anode side. Positive voltage flows out of the black probe when the meter is set to measure resistance. It is possible to use an LED to obtain a fixed voltage. The voltage drop (forward voltage, or VF) of an LED is comparatively stable at just about 2V. I explain a circuit in which the voltage was stabilized with an LED in "Thermometer of bending apparatus-2"..

5.10 IC 7805 The MC78XX/LM78XX/MC78XXA series of three terminal positive regulators are available in the TO-220/D-PAK package and with several fixed output voltages, making them useful in a wide range of applications. Each type employs internal current limiting, thermal shut down and safe operating area protection, making it essentially indestructible. If adequate heat sinking is provided, they can deliver over 1A output current. Although designed primarily as fixed voltage regulators, these devices can be used with external components to obtain adjustable voltages and currents. Features Output Current up to 1A Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V Thermal Overload Protection Short Circuit Protection Output Transistor Safe Operating Area Protection

TO-220 D-PAK

1. Input 2. GND 3. Output


Fig 5.12 IC 7805

CHAPTER 6 RESULTS AND DISCUSSION


6. Results and DISCUSSION This chapter lists down the results realized from the practical work and examines whether ideas/solution approaches recommended in research are met by the practical implementation. For this project the main communication is by using IR technology .The IR sensors sense density on roads and also sense when a emergency vehicle is approaching towards a traffic light and accordingly turns all other lights to red while switching to green light for emergency vehicle only. In this way traffic jams on roads can be reduced as the signals will purely work on density on the roads as compared to present traffic light controllers which are time based. The infrared signals coming from the transmitter of emergency vehicle will be sensed by infrared sensor and the sensor signal is fed to microcontroller 8051 the microcontroller develops a logic and gives a green signal to the emergency vehicle while making all other signals red. Introduction To KIEL Software Many companies provide the 8051 assembler, some of them provide shareware version of their product on the Web, Kiel is one of them. We can download them from their Websites. However, the size of code for these shareware versions is limited and we have to consider which assembler is suitable for our application. Kiel U Vision2: This 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

To get start here are some several example programs Building AN Application In Uvision2: To build (compile, assemble, and link) an application in uVision2, you must: Select ProjectOpen Project

(For example, \C166\EXAMPLES\HELLO\HELLO.UV2) Select Project - Rebuild all target files or Build target. UVision2 compiles, assembles, and links the files in your project. 6.1 Creating Your Own Application In Uvision2: To create a new project in uVision2, you must: Select Project - New Project. Select a directory and enter the name of the project file. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the Device Database Create source files to add to the project. Select Project - Targets, Groups, and Files. Add/Files, select Source Group1, and add the source files to the project. Select Project - Options and set the tool options. Note when you select the target device from the Device Database all-special options are set automatically. You only need to configure the memory map of your target hardware. Default memory model settings are optimal for most. Applications: Select Project - Rebuild all target files or Build target.

Debugging An Application In Uvision2: To debug an application created using uVision2, you must: Select Debug - Start/Stop Debug Session. Use the Step toolbar buttons to single-step through your program. You may enter G, main in the Output Window to execute to the main C function. Open the Serial Window using the Serial #1 button on the toolbar. Debug your program using standard options like Step, Go, Break, and so on.

Limitations of evaluation software: The following limitations apply to the evaluation versions of the C51, C251, or C166 tool chains. C51 Evaluation Software Limitations: The compiler, assembler, linker, and debugger are limited to 2 Kbytes of object code but source Code may be any size. Programs that generate more than 2 Kbytes of object code will not compile, assemble, or link the startup

code generated includes LJMP's and cannot be used in single-chip devices supporting Less than 2 Kbytes of program space like the Philips 750/751/752. The debugger supports files that are 2 Kbytes and smaller. Programs begin at offset 0x0800 and cannot be programmed into single-chip devices. No hardware support is available for multiple DPTR registers. No support is available for user libraries or floating-point arithmetic.

6.2 Evaluation Software: Code-Banking Linker/Locator Library Manager. RTX-51 Tiny Real-Time Operating System

Code for microcontroller: #include<reg52.h> #include<intrins.h> void delay_ms(unsigned int i); void send(unsigned char c); void integer_send(a); void print(char *str); sbit g1 =P2^5; sbit y1 =P2^4; sbit r1 =P2^3;

sbit g2 =P0^4; sbit y2 =P0^5; sbit r2=P0^6;

sbit g3=P2^6; sbit y3=P2^7; sbit r3=P0^7;

sbit g4=P2^0; sbit y4=P2^1; sbit r4=P2^2;

unsigned char a,b,c,d; void compare(); unsigned int route_1(); unsigned int route_2(); unsigned int route_3(); unsigned int route_4(); void display();

void fun_a(); void fun_b(); void fun_c(); void fun_d(); void fun_y() ; unsigned int z; unsigned int m=0; bit flag=0; void serial_intr(void) interrupt 4 { if(TI == 1) { TI = 0; flag = 1; } if(RI==1) { } }

void main() { TMOD = 0x20; SCON = 0x50; TH1 = 0xFD;

TR1 = 1; IE = 0x90; TH0=0x00; TL0=0x00; print("TRAFFIC SIGNALS\r\n"); /*fun_a(); fun_b(); fun_c(); fun_d(); */ while(1) { display(); } }

void fun_d( ) { print("\r\nEAST\r\n"); y1=1; r2=0; r3=0; r4=0; y1=1; g1=0; r1=1; delay_ms(1000); g1=1; y1=0; r2=1; y2=0; r1=1; delay_ms(1000);

g1=1; y1=1; r1=0; }

void fun_b( ) { print("\r\nWEST\r\n"); y2=1; r1=0; r3=0; r4=0;

g2=0; y2=1; r2=1; delay_ms(1000); g2=1; y2=0; r3=1; y3=0;

//y3=1; r2=1; delay_ms(1000);

g2=1; y2=1; r2=0;

void fun_c( )

{ print("\r\nNORTH\r\n");

r1=0; r2=0; r4=0;

g3=0; y3=1; r3=1;

delay_ms(1000);

g3=1; y3=0; r4=1; y4=0;

//y1=1; r3=1;

delay_ms(1000);

g3=1; y3=1; r3=0;

} void fun_a( ) { print("\r\nSOUTH\r\n"); r1=0; r2=0;

r3=0;

g4=0; y4=1; r4=1; delay_ms(1000); g4=1; y4=0; r1=1; y1=0;

//y2=1; r4=1; delay_ms(1000);

g4=1; y4=1; r4=0; } /*void fun_y() { r1=1; r2=1; r3=1; r4=1; y1=0; y2=0; y3=0; y4=0; delay_ms(1000); y1=1; y2=1; y3=1; y4=1;

delay_ms(1000); }*/ void delay_ms(unsigned int i) { unsigned int j; while(i-->0) { for(j=0;j<250;j++) { ; } } }

CHAPTER 7 LIMITATIONS CONCLUSION AND FUTURE SCOPE


CONCLUSION In this article we first showed that traffic control is an important research area, and its benefits make investments worthwhile. We described how traffic can be modelled, and showed the practical use of some models. In section 3 we explained reinforcement learning, and showed its use as an optimization algorithm for various control problems. We then described the problem of traffic light control and several intelligent traffic light controllers, before showing how car-based reinforcement learning can be used for the traffic light control problem. In our approach we let cars estimate their gain of setting their lights to green and let all cars vote to generate the traffic light decision. Co-learning is a special feature of our car-based reinforcement learning algorithm that allows drivers to choose the shortest route with lowest expected waiting time. The controller we used having the following featurtes like 8 bit 8051 architecture in a tiny 40 pinDIP package,128B RAM and 4kB on-chip Flash Program Memory. For low end applications thiscontroller is very easy to use and at the same time IR also widely accepted protocol for mobilecommunication.By using IR technology and 8051 architecture based microcontroller we implemented electronic based traffic density control system. Future Scope This project has vast future scope as we have a very high traffic in main cities due to waste increasing of automobiles. When emergency vehicles are not having a possibility to go through this heavy traffic. Due to lagging of this time so many losses are occurred. So, to overcome this problem we need this project. Limitations There are certain limitations which are needed to be overcome for this project to be successful they are as follows: 1) Every signal should be mounted with infrared sensor and receiver. 2) Emergency vehicles like ambulance ,fire brigade should have this sensor and receiver then only they can be permitted to pass through signal in time. 3) The range of IR sensor and receiver should be increased.

REFERENCE TEXT BOOKS REFERED: 1. The 8051 Microcontroller and Embedded Systems by Muhammad Ali Mazidi and Janice Gillispie Mazidi, Pearson Education. 2. 8051 Microcontroller Architecture, programming and application by KENNETH JAYALA

3. ATMEL 89s52 Data sheets 4. Hand book for Digital ICs from Analogic Devices

WEBSITES VIEWED: www.atmel.com www.beyondlogic.org www.dallassemiconductors.com www.maxim-ic.com www.alldatasheets.com www.howstuffworks.com

Anda mungkin juga menyukai