Professional Documents
Culture Documents
1 .1 G E NE R AL INTRODUCTION
TRAFFIC DENSITY ANALYZER CUM SIGNALLING FOR METRO CITIES is an application specific project which provides an intelligent environment. The heart of my project is microcontroller, which will provide the controlling of the traffic depending upon the density in each junction. In this project IR communication is used to analyze traffic density. The IR rays are continuously transmitted and received by the IR transmitter and IR
receiver respectively. Whenever discontinuity occurs in the this process, the microcontroller senses the result, compares it with all the four junctions and shows the green signal for longer time period (where the traffic density is heavy) while the red signal is shown to the other three roads.
Two 16-bit timer/counters Six interrupt sources Full duplex UART serial channel Low-power idle and power-down modes
2.2.3 DESCRIPTION
The AT89S51 is a low-power, high-performance CMOS 8-bit microcontroller with 4K bytes of in-system programmable Flash memory. The device is manufactured using Atmels high-density nonvolatile memory technology and is compatible with the industrystandard 80C51 instruction set and pin out. 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-bitCPU with in-system programmable Flash on a monolithic chip, the Atmel AT89S51 isa powerful microcontroller which provides a highly-flexible and cost-effectivesolution to many embedded control applications.
Fig.(2.2): Microcontroller
PORT 0
Port 0 is an 8-bit open drain bidirectional I/O port. As an output port, each pin can sink eight TTL inputs. When 1s are written to port 0 pins, the pins can be used as highimpedance inputs. Port 0 can also be configured to be the multiplexed low order address/data bus during access 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 bidirectional I/O port with internal pull-ups. The port 1output 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. Port 1 also receives the low-order address bytes during flash programming and verification.
PORT 2
Port 2 is an 8-bit bidirectional 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 (IIL) because of the internal pull-ups. 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 bidirectional I/O port with internal pull-ups. The port 3output buffers can sink/source four TTL inputs. When 1s are written to port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs. As inputs, port 3 pins that are externally being pulled low will source current (IIL) because of the pull ups.
Port 3 receives some control signals for flash programming and verification. Port 3 also serves the functions of various special features of the AT89S51, as shown in the following table.
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 (ALE) is an output pulse for latching the low byte of the address during access to external memory. This pin is also the program pulse input(PROG) during Flash programming. In normal operation, ALE is emitted at a constant rate of 1/6 the oscillator frequency and may be used for external timing or clocking purposes. Note, however, that one ALE pulse is skipped during each access to external data memory. If desired, ALE operation can be disabled by setting bit 0 of SFR location8EH. 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 (PSEN) is the read strobe to external program memory. When the AT89S51 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 program memory locations starting at 0000H upto FFFFH. However, that 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 12-volt programming enable voltage (VPP) during Flash programming.
XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating circuit. XTAL2 Output from the inverting oscillator amplifier.
long time ago for the micro controllers, which are out of production now.
2.2.7MEMORY ORGANIZATION
MCS-51 devices have a separate address space for program and data memory. Up to 64K bytes each of external program and data memory can be addressed. Program memory: if the EA pin is connected to GND, all program fetches are directed to external memory. On the AT89C51, if EA is connected to VCC, program fetches to addresses 0000H through FFFFH are directed to internal memory and fetches to addresses 1000H through FFFFH are directed to external memory. Data memory: The AT89C51 implements 128 bytes of on-chip RAM. The 128 bytes are accessible via direct and indirect addressing modes. Stack operations are examples of indirect addressing, so the 128 bytes of data RAM are available as stack space.
10
11
Most of the power supplies use a step-down transformer to reduce the dangerous high mains voltage to a safer low voltage. 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.
2.5 RECTIFIER
A circuit which is used to convert ac to dc is known as rectifier . The process of conversion of ac to dc is called rectification.
12
TYPES OF RECTIFIERS Half wave Rectifier Full wave rectifier 1. Centre tap full wave rectifier 2. Bridge type full wave rectifier 2.5.1 HALF-WAVE RECTIFIER The Half wave rectifier is a circuit, which converts an ac voltage to dc voltage When a diode is connected to a source of alternating voltage, it will be alternately forward-biased, and then reverse-biased, during each cycle of the AC sine-wave. When a single diode is used in a rectifier circuit, current will flow through the circuit only during one-half of the input voltage cycle. For this reason, this rectifier circuit is called a half -wave rectifier 2.5.2FULL-WAVE RECTIFIER A Full Wave Rectifier is a circuit, which converts an ac voltage into a pulsating dc voltage using both half cycles of the applied ac voltage. It uses two diodes of which one conducts during one half cycle while the other conducts during the other half cycle of the applied ac voltage.
13
2.5.3BRIDGE RECTIFIER
A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full- wave rectification. This is a widely used configuration, both with individual diodes wired as shown and with single component bridges where the diode bridge is wired internally.
14
During negative half cycle of secondary voltage, the diodes D1 and D4 are in forward biased while D2 and D3 are in reverse biased as shown in the fig(3.8). The current flow direction is shown in the fig.(3.8) with dotted arrows.
15
The capacitor charges quickly near the peak of the varying DC and then discharges as it supplies current to the output. Filtering significantly increases the average DC voltage to almost the peak value (1.4 RMS value). To calculate the value of capacitor(C), C = * 3 * f * r * Rl Where, f = supply frequency, r = ripple factor, Rl = load resistance
2.7 REGULATOR
Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output voltages. The maximum current they can pass also rates them. Negativ e voltage regulators are available, mainly for use in dual supplies. Many of the fixed voltage regulators ICs have 3 leads and look like power transistors, such as the 7805 +5V 1A regulator shown in the fig (3.5). The LM7805 is simple to use . The positive lead of an unregulated DC power supply (anything from 9V DC to 24V DC) is connected to the input pin, and connect the negative lead to the common pin and when the power is on, 5V appear at the output pin.
16
FEATURES
Output current of 1.5A Output voltage tolerance of 5% Internal thermal overload protection Internal short-circuit limited No external component Output voltage 5V, 6V, 8V, 9V, 10V, 12V, 15V, 18V, 24V
for connecting a resonant network to form an oscillator typically a quartz crystal and capacitors are employed. The crystal frequency is the basic internal clock frequency of the microcontroller.
Fig.(2.15):Oscillator Connections
17
Fig.(2.16): External Clock Drive Configuration 2.9 LIGHT EMITTING DIODE 2.9.1 LED DESCRIPTION
It is a semiconductor diode having radioactive recombination. It requires a definite amount of energy to generate an electron-hole pair. The same energy is released when an electron recombines with a hole. This released energy may result in the emission of photon and such a recombination. Here the amount of energy released when the electro reverts from the conduction band to the valence band appears in the form of radiation. Alternatively the released energy may result in a series of phonons causing lattice vibration. Finally the released energy may be transferred to another electron. Therecombinati on radiation may lie in the infra-red and visible light spectrum. In forward it is peaked around the band gap energy and the phenomenon is called injection luminescence. In a junction biased, in the avalanche breakdown region, there results a spectrum of photons carrying much higher energies, almost white light gets emitted from micro-plasma breakdown region in silicon junction. Diodes having radioactive recombination are termed as Light Emitting Diode, abbreviated as LED.
18
19
VS= supply voltage VL= LED voltage (usually 2V, but 4V for blue and white LEDs) I = LED current (e.g. 20mA), this must be less than the maximum permitted
MERITS
The following are the merits of LEDs over conventional incandescent and other types of lamps 1. Low working voltages and currents 2. Less power consumption 3. Very fast action 4. Emission of monochromatic light 5. Small size and weight 6. No effect of mechanical vibrations 7. Extremely long life Typical LED uses a forward voltage of about 2V and current of 5 - 10mA.GaAs LED produces infra-red light while red, green and orange lights are produced by gallium arsenide phosphide (GaAsP) and gallium phosphide (GaP).
20
PRINCIPLE OF OPERATION
A photodiode is a PN junction or PIN structure. When a photon of sufficient energy strikes the diode, it excites an electron thereby creating a mobile electron and a positively charged electron hole. If the absorption occurs in the junctions depletion
21
region, or one diffusion length away from it, these carriers are swept from the junction by the built-in field of the depletion region. Thus holes move towards the anode and electrons towards the cathode and a photocurrent is produced.
MATERIALS
The material used to make a photodiode is critical to define its properties, because only photons with sufficient energy to excite electrons across the materials band gap will produce significant photocurrents.
22
23
AT89S51 MICROCONTROLLER
The 8051 microcontroller consist 40 pins and every pin has its ownfunctionality as shown in the schematic diagram. The port 0 is having the pull up resistor which is having eight 10K resistors in parallel each connected to the each pin of it.
IR LED
The IR LED is arranged with a resistor, in such a way that Vcc is applied to the positive terminal of the IR LED. These are connected to the port 1 of the microcontroller.
IR RECEIVER
The IR receivers are arranged with the transistor logic as shown in the schematic diagram. The two transistors are connected in such a manner that collector terminal is connected to the base terminal of the other. The photo diode is connected to the base of the transistor along with the combination of the resistor. The IR Receivers are connected to the different ports of the microcontroller.
24
KEIL VISION3
Vision3 is an IDE (Integrated Development Environment) that helps you write, compile, anddebug embedded programs. It encapsulates the following components:
A project manager. A make facility. Tool configuration. Editor. A powerful debugger. This software is used for execution of microcontroller programs.Keil development
tools for the MC architecture support every level of software developer fromthe professional applications engineer to the student just learning about embedded softwaredevelopment. The industry-standard keil C compilers, macro assemblers, debuggers,real, time Kernels, Single-boardcomputers and emulators support all avr derive--atives and help you to get more projects completed onschedule. The keil software development tools are designed to solve the complex problems facingembedded software developers.
25
When starting a new project, simply select the microcontroller you the device database and the vision IDE sets all compiler, assembler, linker, and memory options for you.
Numerous example programs are included to help you get started with the most popular embedded avr devices
The keil Vision debugger accurately simulates on-chip peripherals(PC, CAN, UART, SPI, Interrupts ,I/O ports, A/D converter, D/A converter and PWM modules)of your avr device. Simulation helps you understand h/w configurations and avoids time wasted on setup problems. Additionally, with simulation, you can write and test applications before target h/w is available.
When you are ready to begin testing your s/w application with target h/w, use the MON51,MON390, MONADI, or flash MON51 target monitors, the ISD51 InSystem Debugger, or the ULINK USB-JTAG adapter to download and test program code on your target system.
EXPRESS PCB
Express PCB is a Circuit Design Software and PCB manufacturing service. One can learnalmost everything you need to know about Express PCB from the help topics included with the programsgiven. Details: Express PCB, Version 5.6.0
EXPRESS SCH
The Express SCH schematic design program is very easy to use. This software enables the user to draw the Schematics with drag and drop options. A Quick Start Guide is provided by which the user can learn how to use it. Details: Express SCH, Version 5.6.0
26
EMBEDDED C
The programming Language used here in this project is anEmbeddedCLanguage. ThisEmbedded C Language is different from the generic C language in few things like a)Data types b)Access over the architecture addresses The Embedded C Programming Language forms the user friendly language with access over Portaddresses, SFR Register addresses etc. Signed char: o Used to represent the - or + values. o As a result, we have only 7 bits for the magnitude of the signed number, giving us values from -128 to +127.
27
CREATING YOUR OWN APPLICATIONINVISION2 TO CREATE A NEW PROJECT IN VISION2, YOU MUST
1. Select Project - New Project. 2. Select a directory and enter the name of the project file. 3. Select Project - Select Device and select an 8051, 251, or C16x/ST10 device from the Device DatabaseTM. 4. Create source files to add to the project. 5. Select Project - Targets, Groups, Files, Add/Files, select Source Group1, and add the source files to the project. 6. 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 typically only need to configure the memory map of your target hardware. Default memory model settings are optimal for most applications. 7. Select Project - Rebuild all target files or Build target.
28
WINDOW - FILES
Now use from the menu Project Select Device for Target and select a CPU for your project. TheSelect Device dialog box shows theVision2 device database. Just select the microcontroller you use. We are using for our examples the Philips 80C51RD+ CPU. This selection sets necessary tool options forthe 80C51RD+ device and simplifies in this way the tool Configuration
enabled. You may start your PROMprogramming utility after the make process when you specify the program under the option Run UserProgram #1.
CPUSIMULATION
Vision2 simulates up to 16 Mbytes of memory from which areas can be mapped for read,write, or code execution access. TheVision2 simulator traps and reports illegal memory accesses beingdone. In addition to memory mapping, the simulator also provides support for the integrated peripherals of the various 8051 derivatives. The on-chip peripherals of the CPU you have selected are configured fromthe Device.
DATABASE SELECTION
You have made when you create your project target. Refer to page 58 for more Informationabout selecting a device. You may select and display the on-chip peripheral components using theDebug menu. You can also change the aspects of each peripheral using the controls in the dialog boxes.
START DEBUGGING
You start the debug mode of Vision2 with the Debug - Start/Stop Debug Session command.Depending on the Options for Target - Debug Configuration,Vision2 will load the application program and run the startup codeVision2 saves the editor screen layout and restores the screen layout of thelast debug session. If the program execution stops,Vision2 opens an editor window with the sourcetext or shows CPU instructions in the disassembly window. The next executable statement is markedwith a yellow arrow. During debugging, most editor features are still available. For example, you can use the find command or correct program errors. Program source text of your application is shown in the same windows. TheVision2 debug mode differs from the edit mode inthe following aspects:
30
- The Debug Menu and Debug Commands described on page 28 are Available. The additional debugwindows are discussed in the following. - The project structure or tool parameters cannot be modified. All build Commands are disabled.
DISASSEMBLYWINDOW
The Disassembly window shows your target program as mixed source and assembly program or just assembly code. A trace history of previously executed instructions may be displayed with Debug -View Trace Records. To enable the trace history, set Debug -Enable/Disable Trace Recording. If you select the Disassembly Window as the active window all program step commands work on CPUinstruction level rather than program source lines. You can select a text line and set or modify codebreakpoints using toolbar buttons or the context menu commands. You may use the dialog Debug - Inline Assembly. to modify the CPU instructions. That allowsyou to correct mistakes or to make temporary changes to the target program you are debugging
31
CHAPTER 5 RESULT
5. RESULT
This project showed a tremendous result in monitoring and controlling the traffic by giving green signal for more amount of time to the road which had heavy traffic and quite less time to the junction having less traffic, thereby reducing the traffic density
32
FUTURE SCOPE
The future Scope of this project is, it can send the message according to traffic density, to other zones/traffic control room/FM stations by interfacing the GSM Modem.By this we can divert the people who were going in that way and to clear the traffic easily & the traffic density can be reduced.
33