Sei sulla pagina 1di 80


Page No List of Figures List of tables iv

Chapter 1-Introduction 1. Introduction

1 1

Chapter 2- Block diagram and circuit diagram 2.1

Chapter 3- Microcontroller AT89S52 3.1 3.2 3.3 3.4 Chapter 4- Various components used

4.1 4.2 4.3 Chapter 5- Results and Discussion 5.1 5.2

Chapter 6-Conclusion Limitations And Future scope




Fig. No. 3.1 Description Intel's WREL Demo in action - a 60W light bulb lights up with no cables attached 3.2 4.1 Electrical Conduction A depiction of a solar satellite that could send electric energy by microwaves to a space vessel or planetary surface 4.2 5.1 5.2 Laser beam centered on its panel of photovoltaic cells Stationary High Altitude Relay Platform Sharp System 13 15 17 19 8 9 Page No.

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.


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 ptype 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 .

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. COLOR CODING: Color Infrared Red Potential Difference 1.6 V 1.8 V to 2.1 V

Orange Yellow Green Blue -

2.2 V 2.4 V 2.6 V 3.0 V to 3.5 V 3.0 V to 3.5 V 3.5V

White Ultraviolet

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

ADVANTAGES: 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 lightproduction 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


1. POWER SUPPLY UNIT 1 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.2 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.3 Power supply circuit diagram

Fig 3.2 power supply circuit diagram

3.4 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.4.1 Step-up transformer Step-up transformers increase voltage, as per our requirement. 3.4.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.5 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.5.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.

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

Fig 3.4 bridge rectifier circuit

3.5.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





(using only half the AC wave)

Fig 3.5 Single diode rectifier

3.6 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.7 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

2. 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.

Monostable Mode:
The 555 in fig. 9a is shown here in it's utmost 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 flipflop. 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 single-duration 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 oneshots 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 power-dissipation 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.

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-bytwo flip-flop, but minimum and maximum voltage high and low time specifications must be observed. 4. 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: 4.1 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. 4.2 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. 4.3 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. 4.4 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)



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 micro-controllers. 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.


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


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



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 on-chip 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.


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 pull-ups 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.


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.


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 ALEdisable 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












P0 P1 P2 P3




Architecture of 89S52


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.


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

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

External Clock drives Configuration.


4.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

High-power resistors and rheostats

The symbol for a resistor is shown in the following diagram (upper: American symbol, lower: European symbol.)

Resistor symbols 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.

1.1 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.

Rough size Rating power Thickness Length (W) (mm) (mm) From the top of the1/8 2photograph 3 1/8W 1/4W 1/4 2 6 1/2W 1/2 3 9

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.

1.2 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.

Rough size Rating power Thickness Length (W) (mm) (mm) 1/8 3 From the top of the2photograph 1/8W (tolerance 1%) 1/4 26 1/4W (tolerance 1%) 1W (tolerance 5%) 13.5 12 2W (tolerance 5%) 2515

4-3 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. 1.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.

1.4a 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.

1.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

1.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:

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





0 1 2 3 4 5 6 7 8 9 ** TC - Temp. Coefficient, only for SMD devices 1*10-6/K 0.5% 0.25% 0.1% 10*10-6/K 5*10-6/K 1% 2% 100*10-6/K 50*10-6/K 15*10-6/K 25*10-6/K

Fig. 1.1: b. 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 2R2 = 2 point 2 ohms 22R = 22 ohms 2k2 = 2,200 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 highaccuracy 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 1-degree 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.

2. 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. 2.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.

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.1a 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.

47F 100F 220F 1000F

(16V) (25V) (25V) (50V)

[diameter [diameter [diameter [diameter

6 5 8 18

mm, mm, mm, mm, on

high high high high the

5 11 12 40 So

mm] mm] mm] mm] the

The size of the capacitor sometimes depends sizes shown here on this page are just examples.


2.1b Tantalum Capacitors

Tantalum Capacitors are electrolytic capacitors that are use a material called tantalum for the electrodes. Large values of capacitance similar to aluminum electrolytic capacitors can be obtained. Also, tantalum capacitors are superior to aluminum electrolytic capacitors in temperature and frequency characteristics. When tantalum powder is baked in order to solidify it, a crack forms inside. An electric charge can be stored on this crack. These capacitors have polarity as well. Usually, the "+" symbol is used to show the positive component lead. Do not make a mistake with the polarity on these types.

Tantalum capacitors are a little bit more expensive than aluminum electrolytic capacitors. Capacitance can change with temperature as well as frequency, and these types are very stable. Therefore, tantalum capacitors are used for circuits which demand high stability in the capacitance values. Also, it is said to be common sense to use tantalum capacitors for analog signal systems, because the current-spike noise that occurs with aluminum electrolytic capacitors does not appear. Aluminum electrolytic capacitors are fine if you don't use them for circuits which need the high stability characteristics of tantalum capacitors.

The photograph on the Bottom illustrates the tantalum capacitor. The capacitance values are as follows, from the left:

The "+" symbol is used to show the positive lead of the component. It is written on the body.



0.47 10


(35V) (35V)

2.1c Ceramic Capacitors

Ceramic capacitors are constructed with materials such as titanium acid barium used as the dielectric. Internally, these capacitors are not constructed as a coil, so they can be used in high frequency applications. Typically, they are used in circuits which bypass high frequency signals to ground. These capacitors have the shape of a disk. Their capacitance is comparatively small.

The capacitor on the left is a 100pF capacitor with a diameter of about 3 mm. The capacitor on the right side is printed with 103, so 10 x 10 3pF becomes 0.01 F. The diameter of the disk is about 6 mm. Ceramic capacitors have no polarity. Ceramic capacitors should not be used for analog circuits, because they can distort the signal.

2.1d Multilayer Ceramic Capacitors

The multilayer ceramic capacitor has a many-layered dielectric. These capacitors are small in size, and have good temperature and frequency characteristics. These capacitors are not polarized. That is, they have no polarity. Square wave signals used in digital circuits can have a comparatively high frequency component included.

This capacitor is used to bypass the high frequency to ground.

In the photograph, the capacitance of the component on the left is displayed as 104. So, the capacitance is 10 x 104 pF = 0.1 F. The thickness is 2 mm, the height is 3 mm, the width is 4 mm. The capacitor to the right has a capacitance of 103 (10 x 10 3 pF = 0.01 F). The height is 4 mm, the diameter of the round part is 2 mm.

2.3 Marking the block-capacitors Commonly, capacitors are marked by a set of numbers representing the capacity. Beside this value is another number representing the maximal working voltage, and sometimes tolerance, temperature coefficient and some other values are printed as well. But on the smallest capacitors (such as surface-mount) there are no markings at all and you must not remove them from their protective strips until they are needed. The size of a capacitor is never an indication of its value as the dielectric and the number of layers or "plates" can vary from manufacturer to manufacturer.

The value of a capacitor on a circuit diagram, marked as 4n7/40V, means the capacitor is 4,700pF and its maximal working voltage is 40v. Any other 4n7 capacitor with higher maximal working voltage can be used, but they are larger and more expensive. Sometimes, capacitors are identified with colors, similar to the 4-band system used for resistors (figure 2.2). The first two colors (A and B) represent the first two digits, third color (C) is the multiplier, fourth color (D) is the tolerance, and the fifth color (E) is the working voltage. With disk-ceramic capacitors (figure 2.2b) and tubular capacitors (figure 2.2c) working voltage is not specified, because these are used in circuits with low DC voltage. If a tubular capacitor has five color bands on it, the first color represents the temperature coefficient, while the other four specify the capacity in the previously described way.

COLOR Black Brown Red Orange Yellow Green Blue Violet Grey White

DIGIT 0 1 2 3 4 5 6 7 8 9

MULTIPLIER TOLERANCE x 1 pF x 10 pF x 100 pF x 1 nF x 10 nF x 100 nF x 1 F x 10 F x 100 F x 1000 F 10% 5% 20% 1% 2% 2.5%




Marking the capacity using colors The figure 2.3 shows how the capacity of miniature tantalum electrolytic capacitors are marked by colors. The first two colors represent the first two digits and have the same values as with resistors. The third color represents the multiplier, to get the capacity expressed in F. The fourth color represents the maximal working voltage.

COLOR Black Brown Red Orange Yellow Green Blue Violet Grey White Pink

DIGIT 0 1 2 3 4 5 6 7 8 9

MULTIPLIER x 1 F x 10 F x 100 F


6.3V 16V 20V

x .01 F x .1 F

25V 3V 35V

Marking the tantalum electrolytic capacitors One important note on the working voltage: The voltage across a capacitor must not exceed the maximal working voltage as the capacitor may get destroyed. In the case when the voltage is unknown, the "worst" case should be considered. There is the possibility that, due to malfunction of some other component, the voltage on capacitor equals the power supply voltage. If, for example, the supply is 12V, the maximal working voltage for the capacitor should be higher than 12V.


A crystal oscillator is an electronic circuit that uses the mechanical resonance of a vibrating crystal of piezoelectric material to create an electrical signal with a very precise frequency. This frequency is commonly used to keep track of time, to provide a stable clock signal for digital integrated circuits, and to stabilize frequencies for radio transmitters.

Piezoelectricity was discovered by Jacques and Pierre Curie in 1880. Paul Langevin first investigated quartz resonators for use in sonar during World War I. The first crystal controlled oscillator, using a crystal of Rochelle salt, was built in 1917 and patented in 1918 by Alexander M. Nicholson at Bell Telephone Laboratories, although his priority was disputed by Walter Guyton Cady. Cady built the first quartz crystal oscillator in 1921

A crystal is a solid in which the constituent atoms, molecules, or ions are packed in a regularly ordered, repeating pattern extending in all three spatial dimensions. Almost any object made of an elastic material could be used like a crystal, with appropriate transducers, since all objects have natural resonant frequencies of vibration. For example, steel is very elastic and has a high speed of sound. It was often used in mechanical filters before quartz. The resonant frequency depends on size, shape, elasticity, and the speed of sound in the material. High-frequency crystals are typically cut in the shape of a simple, rectangular plate. Low-frequency crystals, such as those used in digital watches, are typically cut in the shape of a tuning fork. For applications not needing very precise timing, a low-cost ceramic resonator is often used in place of a quartz crystal. When a crystal of quartz is properly cut and mounted, it can be made to distort in an electric field by applying a voltage to an electrode near or on the crystal. This property is known as piezoelectricity. When the field is removed, the quartz will generate an electric field as it returns to its previous shape, and this can generate a voltage. The result is that a quartz crystal behaves like a circuit composed of an inductor, capacitor and resistor, with a precise resonant frequency. Quartz has the further advantage that its elastic constants and its size change in such a way that the frequency dependence on temperature can be very low. The specific characteristics will depend on the mode of vibration and the angle at which the quartz is cut (relative to its crystallographic axes). Therefore, the resonant frequency of the plate, which depends on its size, will not change much, either. This means that a quartz clock, filter or oscillator will remain accurate. For critical applications the quartz oscillator is mounted in a temperaturecontrolled container, called a crystal oven, and can also be mounted on shock absorbers to prevent perturbation by external mechanical vibrations.

Quartz timing crystals are manufactured for frequencies from a few tens of kilohertz to tens of megahertz. More than two billion (2109) crystals are manufactured annually. Most are small devices for consumer devices such as wristwatches, clocks, radios, computers, and cellophanes. Quartz crystals are also found inside test and measurement equipment, such as counters, signal generators, and oscilloscopes.

Crystal modeling:
A quartz crystal can be modeled as an electrical network with low impedance (series) and a high impedance (parallel) resonance point spaced closely together.

Adding additional capacitance across a crystal will cause the parallel resonance to shift downward. This can be used to adjust the frequency that a crystal oscillator oscillates at. Crystal manufacturers normally cut and trim their crystals to have a specified resonant frequency with a known 'load' capacitance added to the crystal. For example, a 6 pF 32 kHz crystal has a parallel resonance frequency of 32,768 Hz when a 6.0 pF capacitor is placed across the crystal. Without this capacitance, the resonance frequency is higher than 32,768 Hz.

Crystals and frequency:

The crystal oscillator circuit sustains oscillation by taking a voltage signal from the quartz resonator, amplifying it, and feeding it back to the resonator. The rate of expansion and contraction of the quartz is the resonant frequency, and is determined by the cut and size of the crystal. A regular timing crystal contains two electrically conductive plates, with a slice or tuning fork of quartz crystal sandwiched between them. During startup, the circuit around the crystal applies a random noise AC signal to it, and purely by chance, a tiny fraction of the noise will be at the resonant frequency of the crystal. The crystal will therefore start oscillating in synchrony with that signal. As the oscillator amplifies the signals coming out of the crystal, the crystal's frequency will become stronger, eventually dominating the output of the oscillator. Natural resistance in the circuit and in the quartz crystal filter out all the unwanted frequencies.

One of the most important traits of quartz crystal oscillators is that they can exhibit very low phase noise. In many oscillators, any spectral energy at the resonant frequency will be amplified by the oscillator, resulting in a collection of tones at different phases. In a crystal oscillator, the crystal mostly vibrates in one axis. Therefore, only one phase is dominant. This property of low phase noise makes them particularly useful in telecommunications where stable signals are needed and in scientific equipment where very precise time references are needed. The output frequency of a quartz oscillator is either the fundamental resonance or a multiple of the resonance, called an overtone frequency. A typical Q for a quartz oscillator ranges from 104 to 106. The maximum Q for a high stability quartz oscillator can be estimated as Q = 1.6 107/f, where f is the resonance frequency in megahertz.

Commonly used crystal frequencies

Frequency (MHz) 32.768 kHz 1.8432 2.4576 3.2768 3.575611 3.579545 3.582056 3.686400 4.096000 4.194304 Primary uses Real-time clocks, allows binary division to 1 Hz signal (215 1 Hz); also often used in low-speed low-power circuits UART clock; allows integer division to common baud rates UART clock; allows integer division to common baud rates up to 38400 Allows binary division to 100 Hz (32768 100 Hz, or 215 100 Hz) PAL M color sub carrier NTSC M color sub carrier; very common and inexpensive, used in many other applications, eg. DTMF generators PAL N color subcarrier UART clock (2 1.8432 MHz); allows integer division to common baud rates Allows binary division to 1 kHz (212 1 kHz) Real-time clocks, clearly divides to 1 Hz signal (222 1 Hz)

4.43361875 PAL B/D/G/H/I and NTSC M4.43 color subcarrier 4.9152 Used in CDMA systems; divided to 1.2288 MHz baseband frequency as specified by JSTD-008

5.068 6.144

Used in radio transceivers as an IF source Digital audio systems - DAT, Minidisk, sound cards; 128 48 kHz (27 48 kHz). Also allows integer division to common UART baud rates up to 38400. Allows binary division to 100 Hz (65536 100 Hz, or 216 100 Hz); used also in red boxes NTSC M color sub carrier (2 3.579545 MHz) UART clock (4 1.8432 MHz); allows integer division to common baud rates PAL B/G/H color subcarrier (2 4.433618 MHz) Allows integer division to 1024 kHz and its halves (16 kHz, 32 kHz, 64 kHz...) Used in CDMA systems (2 4.9152); divided to 1.2288 MHz baseband frequency Used in radio transceivers; mixes with 10.7 MHz sub carrier yielding 455 kHz signal, a common second IF for FM radio and first IF for AM radio[1] Used in radio transceivers as an IF source UART clock (6 1.8432 MHz); allows integer division to common baud rates Used in compact disc digital audio systems and CDROM drives; allows binary division to 44.1 kHz (256 44.1 kHz), 22.05 kHz, and 11.025 kHz Digital audio systems - DAT, Minidisk, sound cards; 256 48 kHz (28 48 kHz). Also allows integer division to common UART baud rates up to 38400. Master clock for PAL/NTSC DVD players, Digital TV receivers etc. (13.5 MHz is an exact multiple of the PAL and NTSC line frequencies) Used in some teletext circuits; 2 6.9375 MHz (clock frequency of PAL B teletext; SECAM uses 6.203125 MHz, NTSC M uses 5.727272 MHz, PAL G uses 6.2031 MHz, and PAL I uses 4.4375 MHz clock) NTSC M color sub carrier (4 3.579545 MHz). Also common on VGA cards. UART clock (8 1.8432 MHz); allows integer division to common baud rates Commonly used for down-conversion and sampling in GPS-receivers. Generates intermediate frequency signal at +4.092 MHz. 16.3676 or 16.367667 MHz are sometimes used to avoid perfect lineup between sampling frequency and GPS spreading code.

6.5536 7.15909 7.3728 8.86724 9.216 9.83040 10.245 10.700 11.0592 11.2896




14.3182 14.7456



Used in compact disc digital audio systems and CDROM drives; allows integer division to 44.1 kHz (384 44.1 kHz), 22.05 kHz, and 11.025 kHz. Also allows integer division to common UART baud rates. PAL B/G/H color sub carrier (4 4.433618 MHz) UART clock (10 1.8432 MHz); allows integer division to common baud rates. Also allows integer division to 48 kHz (384 48 kHz), 96 kHz, and 192 kHz sample rates used in high-end digital audio. Used in CDMA systems (4 4.9152); divided to 1.2288 MHz baseband frequency Digital audio systems - DAT, Minidisk, sound cards; 512 48 kHz (29 48 kHz) Master clock for PAL/NTSC DVD players, Digital TV receivers etc. (27 MHz is an exact multiple of the PAL and NTSC line frequencies) UART clock (16 1.8432 MHz); allows integer division to common baud rates



19.6608 24.576 27.000 29.4912

4. 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.

This symbol is used to indicate a diode in a circuit diagram. The meaning of the symbol is (Anode) (Cathode). Current flows from the anode side to the cathode side. 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




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.

4.2 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.

4.3 Light Emitting Diode (LED):

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"..

4.5 Diode Marking:

European diodes are marked using two or three letters and a number. The first letter is used to identify the material used in manufacturing the component (A - germanium, B - silicon), or, in case of letter Z, a Zener diode. The second and third letters specify the type and usage of the diode. Some of the verities are: A - low power diode, like the AA111, AA113, AA121, etc. - they are used in the detector of a radio receiver; BA124, BA125 : varicap diodes used instead of variable capacitors in receiving devices, oscillators, etc., BAY80, BAY93, etc. - switching diodes used in devices using logic circuits. BA157, BA158, etc. - these are switching diodes with short recovery time. B - two capacitive (varicap) diodes in the same housing, like BB104, BB105, etc. Y - regulation diodes, like BY240, BY243, BY244, etc. - these regulation diodes come in a plastic packaging and operate on a maximum current of 0.8A. If there is another Y, the diode is intended for higher current. For example, BYY44 is a diode whose absolute maximum current rating is 1A. When Y is the second letter in a Zener diode mark (ZY10, ZY30, etc.) it means it is intended for higher current. G, G, PD - different tolerance marks for Zener diodes. Some of these are ZF12 (5% tolerance), ZG18 (10% tolerance), ZPD9.1 (5% tolerance). The third letter is used to specify a property (high current, for example).

American markings begin with 1N followed by a number, 1N4001, for example (regulating diode), 1N4449 (switching diode), etc. Japanese style is similar to American, the main difference is that instead of N there is S, 1S241 being one of them.

To modify this circuit so that it signals when a voltage drops below some predefined level, the Zener diode and Rx are swapped. For example, by using a 12V Zener diode, we can make a car battery level indicator. So, when the voltage drops below 12V, the battery is ready for recharge. Figure 5.3e shows a noise-producing circuit, which produces a rain-like sound. DC current flowing through diode AA121 isn't absolutely constant and this creates the noise which is amplified by the transistor (any NPN transistor) and passed to a filter (resistor-capacitor circuit with values 33nF and 100k).

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


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.


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.

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.

. . .


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.

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;


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;


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

//y1=1; r3=1;


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++) { ; }

} }


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.


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


Hand book for Digital ICs from Analogic Devices