Density based trafiic control

24,754 views

Published on

2 Comments
28 Likes
Statistics
Notes
  • can u please send the code for the program to mensaeddy@gmail.com.will be very much greatfull
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • can u send the c program related to this project please , i want to implement this project. can u send it at akshayjayaprakash7@gmal.com. thank you
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
24,754
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
1,409
Comments
2
Likes
28
Embeds 0
No embeds

No notes for slide

Density based trafiic control

  1. 1. DENSITY BASED TRAFFIC CONTROL SYSTEMDENSITY BASED TRAFFIC CONTROL SYSTEM
  2. 2. DENSITY BASED TRAFFIC CONTROL SYSTEMABSTRACT An adaptive traffic control system was developed where thetraffic load is continuously measured by sensors connected to amicrocontroller-based system which also performs all intersectioncontrol functions. Intersection controllers of an area areinterconnected with a communication network through whichtraffic load and synchronization information is exchanged. As a result, the duration and relative phases of each trafficlight cycle change dynamically. For the basic function of the systemonly the intersection controllers are required.
  3. 3. DENSITY BASED TRAFFIC CONTROL SYSTEM CHAPTER 1 OVERVIEW
  4. 4. DENSITY BASED TRAFFIC CONTROL SYSTEMINTRODUCTIONImplementationMicrocontroller based traffic control system is an applicationspecific project, which is used to control the traffic. An embeddedsystem is developed which consists of a microcontroller, IRtransmitter and receiver, LED’sThis project is implemented by placing IR transmitters, receiversand led’s at the 4 way junction, the four paths are represented asR1,R2,R3,R4Transmitters and receivers are placed at either sides of the fourpaths, and 4 led’s at corner of the junctionWhen there is a traffic along the paths,value of R would be 000which are the values of IR sensors and if there is no traffic the valueis 111
  5. 5. DENSITY BASED TRAFFIC CONTROL SYSTEMFor instance,let the traffic at the path R1 be initially 111 ie there isno traffic , when the traffic reaches the first sensor,the value of Rwould be 011,if it reaches second sensor ,the value of R is 001,andthen if it reaches the last sensor that is the third one,it isrecognized that traffic is heavy and the led glows which indicatesthat vehicles can move forward,traffic is cleared, and the sensorvalues automatically changed to 111.the control goes to the nextpath wher the values of sensors contains more no of zeroesThis entire embedded system is placed at that junctionMicrocontroller is interfaced with led’s and ir sensors The total noof IR sensors required are 12 and led’s 4 Therefore these areconnected to any two ports of microcontroller
  6. 6. DENSITY BASED TRAFFIC CONTROL SYSTEM BLOCK DIAGRAM : AT89S52 LEDIR IR MICROTRANSMITTER RECIEV CONTROLLER ER LCD REGULAT ED POWER SUPPLY
  7. 7. DENSITY BASED TRAFFIC CONTROL SYSTEMBLOCK DIAGRAM DESCRIIPTIONThe block diagram consists of microcontroller interfaced toregulated power supply, led and IR receiver and IR transmitterwhich consists of an IR sensorThe IR sensors and leds are connected to any of the port pins ofmicrocontroller,regulated power supply is connected to the Vcc pinof microcontroller which uses an voltage regulator to get 5 v ofpower supply. The transmit pin of IR receiver is connected to thereceive pin of microcontrollerThis embedded system is placed at the 4 way junction whichcontrols the traffic electronically The system uses a compactcircuitry build around flash version of AT89S52 Microcontrollerwith a non-volatile memory. Programs will be developed inEMBEDDED C language. FLASH MAGIC is used for loading ofprograms into microcontroller.
  8. 8. DENSITY BASED TRAFFIC CONTROL SYSTEMIR TRANSMITTER and receiverThe purpose of the transmitter is to transform the information wewant to send into a signal that can be propagated by the channel.In the case of our wired copper channel, this means we want theinformation to be transformed into a modulated voltage level,something like the pulse train. For a wireless channel, however, thetransmitter needs to encode the information onto an EM wave thatcan be easily propagated.IR TRANSMITTERThe IR transmitter part consists of an Infra red light emitting diodethat can capable of sending modulated data within infra red band.To match the receiver frequency the the data is modulated at 38.7KHZ by configuring 555 timer at astable mode of operation, whichgenerates frequency using the components R2 and C2 as shown in
  9. 9. DENSITY BASED TRAFFIC CONTROL SYSTEMabove fig. This frequency can be varied over a long range just byvarying the preset R1 and C1. IR RECEIVERThe IR receiver consists of TSOP 1738 module which is a simple yeteffective IR proximity sensor built around the TSOP 1738 module.
  10. 10. DENSITY BASED TRAFFIC CONTROL SYSTEMThe TSOP module is commonly found at the receiving end of an IRremote control system; e.g., in TVs, CD players etc. These modulesrequire the incoming data to be modulated at a particular frequencyand would ignore any other IR signals. It is also immune to ambientIR light, so one can easily use these sensors outdoors or underheavily lit conditions.Such modules are available for different carrier frequencies from 32kHz to 42kHz.In this particular proximity sensor, we will be generating a constantstream of square wave signal using IC555 centered at 38 kHz andwould use it to drive an IR led. So whenever this signal bounces offthe obstacles, the receiver would detect it and change its output.Since the TSOP 1738 module works in the active-low configuration,its output would normally remain high and would go low when itdetects the signal (the obstacle).Basically an ir sensor is used for detecting an obstacle, there aresome areas where valuable things are placed, an IR transmitter andreceiver is placed there, an infrared path is established and if anyperson comes into that path the buzzer gets on which gives out along beep Similarly a fire sensor is used to detect fireThe sensed data is given to the microcontroller, processing is doneaccording to the logic in the microcontroller and then writes ontoGSM which will further send sms to the mobile at the userA buzzer is interfaced to microcontroller to give out a beep soundwhenever an obstacle and fire is detected
  11. 11. DENSITY BASED TRAFFIC CONTROL SYSTEMIR receiver module TSOP
  12. 12. DENSITY BASED TRAFFIC CONTROL SYSTEMDescriptionThe TSOP17.. – series are miniaturized receivers for infrared remotecontrol systems. PIN diode and preamplifier are assembled on leadframe, the epoxy package is designed as IR filter.The demodulated output signal can directly be decoded by amicroprocessor. TSOP17.. is the standard IR remote control receiverseries, supporting all major transmission codes.Features  Photo detector and preamplifier in one package  Internal filter for PCM frequency  Improved shielding against electrical field disturbance  TTL and CMOS compatibility  Output active low  Low power consumption  High immunity against ambient light  Continuous data transmission possible (1200 bit/s)  Suitable burst length 10 cycles/burst
  13. 13. DENSITY BASED TRAFFIC CONTROL SYSTEM CHAPTER 2 INTRODUCTION TO MICROCONTROLLER AND EMBEDDEDSYSTEM
  14. 14. DENSITY BASED TRAFFIC CONTROL SYSTEMEMBEDDED SYSTEMAn embedded system is a special-purpose computer systemdesigned to perform one or a few dedicated functions[1], sometimeswith real-time computing constraints. It is usually embedded aspart of a complete device including hardware and mechanical parts.In contrast, a general-purpose computer, such as a personalcomputer, can do many different tasks depending on programming.Embedded systems have become very important today as theycontrol many of the common devices we use.Since the embedded system is dedicated to specific tasks, designengineers can optimize it, reducing the size and cost of the product,or increasing the reliability and performance. Some embeddedsystems are mass-produced, benefiting from economies of scale.Physically, embedded systems range from portable devices such asdigital watches and MP3 players, to large stationary installationslike traffic lights, factory controllers, or the systems controllingnuclear power plants. Complexity varies from low, with a singlemicrocontroller chip, to very high with multiple units, peripheralsand networks mounted inside a large chassis or enclosure.In general, "embedded system" is not an exactly defined term, asmany systems have some element of programmability. For example,
  15. 15. DENSITY BASED TRAFFIC CONTROL SYSTEMHandheld computers share some elements with embedded systems— such as the operating systems and microprocessors which powerthem — but are not truly embedded systems, because they allowdifferent applications to be loaded and peripherals to be connected.An embedded system is some combination of computer hardwareand software, either fixed in capability or programmable, that isspecifically designed for a particular kind of application device.Industrial machines, automobiles, medical equipment, cameras,household appliances, airplanes, vending machines, and toys (aswell as the more obvious cellular phone and PDA) are among themyriad possible hosts of an embedded system. Embedded systemsthat are programmable are provided with a programming interface,and embedded systems programming is a specialized occupation.Certain operating systems or language platforms are tailored for theembedded market, such as EmbeddedJava and Windows XPEmbedded. However, some low-end consumer products use veryinexpensive microprocessors and limited storage, with theapplication and operating system both part of a single program. Theprogram is written permanently into the systems memory in thiscase, rather than being loaded into RAM (random access memory),as programs on a personal computer are.
  16. 16. DENSITY BASED TRAFFIC CONTROL SYSTEMINTRODUCTION TO EMBEDDED SYSTEMWe are living in the Embedded World. You are surrounded withmany embedded products and your daily life largely depends on theproper functioning of these gadgets. Television, Radio, CD player ofyour living room, Washing Machine or Microwave Oven in yourkitchen, Card readers, Access Controllers, Palm devices of yourwork space enable you to do many of your tasks very effectively.Apart from all these, many controllers embedded in your car takecare of car operations between the bumpers and most of the timesyou tend to ignore all these controllers.In recent days, you are showered with variety of information aboutthese embedded controllers in many places. All kinds of magazinesand journals regularly dish out details about latest technologies,new devices, fast applications which make you believe that yourbasic survival is controlled by these embedded products. Now youcan agree to the fact that these embedded products havesuccessfully invaded into our world. You must be wondering aboutthese embedded controllers or systems. What is this EmbeddedSystem?
  17. 17. DENSITY BASED TRAFFIC CONTROL SYSTEMThe computer you use to compose your mails, or create a documentor analyze the database is known as the standard desktopcomputer. These desktop computers are manufactured to servemany purposes and applications.You need to install the relevant software to get the requiredprocessing facility. So, these desktop computers can do manythings. In contrast, embedded controllers carryout a specific workfor which they are designed. Most of the time, engineers designthese embedded controllers with a specific goal in mind. So thesecontrollers cannot be used in any other place.Theoretically, an embedded controller is a combination of a piece ofmicroprocessor based hardware and the suitable software toundertake a specific task.These days designers have many choices inmicroprocessors/microcontrollers. Especially, in 8 bit and 32 bit,the available variety really may overwhelm even an experienceddesigner. Selecting a right microprocessor may turn out as a mostdifficult first step and it is getting complicated as new devicescontinue to pop-up very often.In the 8 bit segment, the most popular and used architecture isIntels 8031. Market acceptance of this particular family has drivenmany semiconductor manufacturers to develop something newbased on this particular architecture. Even after 25 years of
  18. 18. DENSITY BASED TRAFFIC CONTROL SYSTEMexistence, semiconductor manufacturers still come out with somekind of device using this 8031 core.MICROCONTROLLERIn contrast to general-purpose CPUs, microcontrollers may notimplement an external address or data bus as they integrate RAMand non-volatile memory on the same chip as the CPU. Using fewerpins, the chip can be placed in a much smaller, cheaper package.Integrating the memory and other peripherals on a single chip andtesting them as a unit increases the cost of that chip, but oftenresults in decreased net cost of the embedded system as a whole.Even if the cost of a CPU that has integrated peripherals is slightlymore than the cost of a CPU + external peripherals, having fewerchips typically allows a smaller and cheaper circuit board, andreduces the labor required to assemble and test the circuit board.A microcontroller is a single integrated circuit, commonly with thefollowing features: • central processing unit - ranging from small and simple 4-bit processors to complex 32- or 64-bit processors • discrete input and output bits, allowing control or detection of the logic state of an individual package pin
  19. 19. DENSITY BASED TRAFFIC CONTROL SYSTEM • serial input/output such as serial ports (UARTs) • other serial communications interfaces like I²C, Serial Peripheral Interface and Controller Area Network for system interconnect • peripherals such as timers, event counters, PWM generators, and watchdog • volatile memory (RAM) for data storage • ROM, EPROM, [EEPROM] or Flash memory for program and operating parameter storage • clock generator - often an oscillator for a quartz timing crystal, resonator or RC circuit • many include analog-to-digital converters • in-circuit programming and debugging supportThis integration drastically reduces the number of chips and theamount of wiring and PCB space that would be needed to produceequivalent systems using separate chips. Furthermore, and on lowpin count devices in particular, each pin may interface to severalinternal peripherals, with the pin function selected by software.This allows a part to be used in a wider variety of applications thanif pins had dedicated functions. Microcontrollers have proved to behighly popular in embedded systems since their introduction in the1970s.Some microcontrollers use a Harvard architecture: separatememory buses for instructions and data, allowing accesses to takeplace concurrently. Where a Harvard architecture is used,
  20. 20. DENSITY BASED TRAFFIC CONTROL SYSTEMinstruction words for the processor may be a different bit size thanthe length of internal memory and registers; for example: 12-bitinstructions used with 8-bit data registers.The decision of which peripheral to integrate is often difficult. Themicrocontroller vendors often trade operating frequencies andsystem design flexibility against time-to-market requirements fromtheir customers and overall lower system cost. Manufacturers haveto balance the need to minimize the chip size against additionalfunctionality.Microcontroller architectures vary widely. Some designs includegeneral-purpose microprocessor cores, with one or more ROM,RAM, or I/O functions integrated onto the package. Other designsare purpose built for control applications. A microcontrollerinstruction set usually has many instructions intended for bit-wiseoperations to make control programs more compact. For example, ageneral purpose processor might require several instructions to testa bit in a register and branch if the bit is set, where amicrocontroller could have a single instruction that would providethat commonly-required function.Microcontroller A microcontroller (also MCU or µC) is a computer-on-a-chip. It isa type of microprocessor emphasizing high integration, low powerconsumption, self-sufficiency and cost-effectiveness, in contrast toa general-purpose microprocessor (the kind used in a PC). In
  21. 21. DENSITY BASED TRAFFIC CONTROL SYSTEMaddition to the usual arithmetic and logic elements of a generalpurpose microprocessor, the microcontroller typically integratesadditional elements such as read-write memory for data storage,read-only memory, such as flash for code storage, EEPROM forpermanent data storage, peripheral devices, and input/outputinterfaces. At clock speeds of as little as a few MHz or even lower,microcontrollers often operate at very low speed compared tomodern day microprocessors, but this is adequate for typicalapplications. They consume relatively little power (milliwatts), andwill generally have the ability to sleep while waiting for aninteresting peripheral event such as a button press to wake themup again to do something. Power consumption while sleeping maybe just nano watts, making them ideal for low power and longlasting battery applications.Microcontrollers are frequently used in automatically controlledproducts and devices, such as automobile engine control systems,remote controls, office machines, appliances, power tools, and toys.By reducing the size, cost, and power consumption compared to adesign using a separate microprocessor, memory, and input/outputdevices, microcontrollers make it economical to electronicallycontrol many more processes.
  22. 22. DENSITY BASED TRAFFIC CONTROL SYSTEMMICROCONTROLLER VERSUS MICROPROCESSORWhat is the difference between a Microprocessor andMicrocontroller? By microprocessor is meant the general purposeMicroprocessors such as Intels X86 family (8086, 80286, 80386,80486, and the Pentium) or Motorolas 680X0 family (68000,68010, 68020, 68030, 68040, etc). These microprocessors containno RAM, no ROM, and no I/O ports on the chip itself. For thisreason, they are commonly referred to as general-purposeMicroprocessors.A system designer using a general-purpose microprocessor such asthe Pentium or the 68040 must add RAM, ROM, I/O ports, and
  23. 23. DENSITY BASED TRAFFIC CONTROL SYSTEMtimers externally to make them functional. Although the addition ofexternal RAM, ROM, and I/O ports makes these systems bulkierand much more expensive, they have the advantage of versatilitysuch that the designer can decide on the amount of RAM, ROM andI/O ports needed to fit the task at hand. This is not the case withMicrocontrollers.A Microcontroller has a CPU (a microprocessor) in addition to afixed amount of RAM, ROM, I/O ports, and a timer all on a singlechip. In other words, the processor, the RAM, ROM, I/O ports andthe timer are all embedded together on one chip; therefore, thedesigner cannot add any external memory, I/O ports, or timer to it.The fixed amount of on-chip ROM, RAM, and number of I/O portsin Microcontrollers makes them ideal for many applications inwhich cost and space are critical.In many applications, for example a TV remote control, there is noneed for the computing power of a 486 or even an 8086microprocessor. These applications most often require some I/Ooperations to read signals and turn on and off certain bits.MICROCONTROLLERS FOR EMBEDDED SYSTEMSIn the Literature discussing microprocessors, we often see the termEmbedded System. Microprocessors and Microcontrollers are widelyused in embedded system products. An embedded system productuses a microprocessor (or Microcontroller) to do one task only. Aprinter is an example of embedded system since the processor
  24. 24. DENSITY BASED TRAFFIC CONTROL SYSTEMinside it performs one task only; namely getting the data andprinting it. Contrast this with a Pentium based PC. A PC can beused for any number of applications such as word processor, print-server, bank teller terminal, Video game, network server, or Internetterminal. Software for a variety of applications can be loaded andrun. of course the reason a pc can perform myriad tasks is that ithas RAM memory and an operating system that loads theapplication software into RAM memory and lets the CPU run it.In an Embedded system, there is only one application software thatis typically burned into ROM. An x86 PC contains or is connectedto various embedded products such as keyboard, printer, modem,disk controller, sound card, CD-ROM drives, mouse, and so on.Each one of these peripherals has a Microcontroller inside it thatperforms only one task. For example, inside every mouse there is aMicrocontroller to perform the task of finding the mouse positionand sending it to the PC. Table 1-1 lists some embedded products.Intels 8031 ArchitectureThe generic 8031 architecture sports aHarvard architecture, which contains two separate buses for bothprogram and data. So, it has two distinctive memory spaces of 64KX 8 size for both program and data. It is based on an 8 bit centralprocessing unit with an 8 bit Accumulator and another 8 bit Bregister as main processing blocks. Other portions of thearchitecture include few 8 bit and 16 bit registers and 8 bit memorylocations.
  25. 25. DENSITY BASED TRAFFIC CONTROL SYSTEMEach 8031 device has some amount of data RAM built in the devicefor internal processing. This area is used for stack operations andtemporary storage of data.This base architecture is supported with onchip peripheralfunctions like I/O ports, timers/counters, versatile serialcommunication port. So it is clear that this 8031 architecture wasdesigned to cater many real time embedded needs.The following list gives the features of the 8031 architecture: • Optimized 8 bit CPU for control applications. • Extensive Boolean processing capabilities. • 64K Program Memory address space. • 64K Data Memory address space. • 128 bytes of onchip Data Memory. • 32 Bi-directional and individually addressable I/O lines. • Two 16 bit timer/counters. • Full Duplex UART. • 6-source / 5-vector interrupt structure with priority levels. • Onchip clock oscillator.
  26. 26. DENSITY BASED TRAFFIC CONTROL SYSTEM Now you may be wondering about the non mentioning of memory space meant for the program storage, the most important part of any embedded controller. Originally this 8031 architecture was introduced with onchip, one time programmable version of Program Memory of size 4K X 8. Intel delivered all these microcontrollers (8051) with users program fused inside the device. 8051 DERIVATIVES Along the way, this 8031 architecture gained enviable market acceptance. Many semiconductor manufacturers started either manufacturing the 8031 devices as such (Intel was liberal in giving away license to whoever asked) or developing a new kind of microcontrollers based on 8031 core architecture.Manufacturers modified the basic 8031 architecture and added many new peripheral functions to make them attractive to the designers.Because of the rush, electronic community started getting a varietyof 8031 based devices with range of options. To beat thecompetition, manufacturers developed different microcontrollerswith many unique features.These parts are popularly known as 8031 Derivatives. Almost everydecent manufacturer boasted of having an 8031 basedmicrocontroller in the line card.
  27. 27. DENSITY BASED TRAFFIC CONTROL SYSTEMFirst major manufacturer was the Philips who brought out morethan 40-50 derivatives with a variety of I/O options, memorycombinations, and peripheral functions. Devices became availablein regular DIP and SMD packages. With the basic 8031 core, Philipsported high capacity Program Memory (upto 32K/64K), its patentedI2C interface bus, 8/10 bit Analog to Digital Converters, CAN Bus,Capture and Compare registers, Watch dog timer, PWM facilitiesand etc. More I/O ports (as many as eight ports), additionaltimer/counter, second serial port was also made available in Philipsdevices.Apart from all these, Philips developed many consumer devicesmeant for telecom, computer and TV applications. A smart cardcontroller was also developed by incorporating a cryptographicengine. So Philips clearly established itself as the market leader in8031 derivatives and still caters to this segment.Then came Dallas semiconductor. Dallas redesigned the 8031architecture and eliminated waste clock cycles of original core andmade all instructions executed in less clock cycles (maximum of 4)which has traditionally taken upto 12 clock cycles. So, came thebirth of High speed 8031 Derivatives.Dallas also maintained the same device pin out configurations toenable the user get upto 3X performance by replacing slower partswith a Dallas device. So, existing compiled code started running
  28. 28. DENSITY BASED TRAFFIC CONTROL SYSTEMfaster without any modification. These days, you can find Dallasdevices giving upto 50 MIPS (Million Instructions Per Second).Apart from this, Dallas introduced additional Serial port, Watch DogTimer, Precision Reset Circuitry, Real Time Clock, Power FailMonitor in the 8031 devices. Also a second data pointer, moreonchip RAM space and more interrupt lines were also madeavailable.Dallas semiconductor also has got a range of securemicrocontrollers based on 8031 core. This microcontroller familyuses non volatile RAM to keep both program and data. Because ofthis RAM, the controller gives the In System Reprogrammability.Dallas has combined this microcontroller, SRAM and lithium cell ina single pack. This device guarantees 10+ years of data retention inthe RAM area. This 8031 also boasts the tamper proof securityfeatures like Real Time Memory Encryption, user selected 48 bitEncryption key, memory contents, security lock and the facility tohide interrupt vector table. As you can agree, this particular 8031device has found a niche market in banking and security relatedapplications.Atmel Corporation is the another major semiconductormanufacturer who introduced many flash memory based 8031derivatives at a competitive cost. Atmel used its expertise in flashmemory technology into the basic 8031 core and brought out
  29. 29. DENSITY BASED TRAFFIC CONTROL SYSTEMmicrocontrollers with a variety of flash memory options and fewdevices also carry In System Reprogramming facility. You canprogram/reprogram this microcontroller after soldering the devicein the target board. If this programming facility is embedded in thesystem software, then the tasks like remote calibration, onsitesystem upgradation become as easy as sending your data/programin a floppy disk or by internet. Atmel devices sport security lock toits flash memory to protect the contents from the prying eyes.Meantime, Intel itself tried to cash in the popularity of this 8031architecture and introduced improved versions of microcontrollers:80151 and 80251 families. These devices sport 16 bit architectureusing 8031 core and unfortunately these devices have not becomeas popular as 8031.Even after many years of introduction, 8031core is still going strong in 8 bit arena.PIN DIAGRAM OF GENERAL PURPOSE MICROCONTROLLER
  30. 30. DENSITY BASED TRAFFIC CONTROL SYSTEMALE/PROG: Address Latch Enable output pulse for latching the lowbyte of the address during accesses to external memory. ALE isemitted at a constant rate of 1/6 of the oscillator frequency, forexternal timing or clocking purposes, even when there are noaccesses to external memory. (However, one ALE pulse is skippedduring each access to external Data Memory.) This pin is also theprogram pulse input (PROG) during EPROM programming.PSEN: Program Store Enable is the read strobe to external ProgramMemory. When the device is executing out of external Program
  31. 31. DENSITY BASED TRAFFIC CONTROL SYSTEMMemory, PSEN is activated twice each machine cycle (except thattwo PSEN activations are skipped during accesses to external DataMemory). PSEN is not activated when the device is executing out ofinternal Program Memory.EA/VPP: When EA is held high the CPU executes out of internalProgram Memory (unless the Program Counter exceeds 0FFFH inthe 80C51). Holding EA low forces the CPU to execute out ofexternal memory regardless of the Program Counter value. In the80C31, EA must be externally wired low. In the EPROM devices,this pin also receives the programming supply voltage (VPP) duringEPROM programming.XTAL1: Input to the inverting oscillator amplifier.XTAL2: Output from the inverting oscillator amplifier.Port 0: Port 0 is an 8-bit open drain bidirectional port. As an opendrain output port, it can sink eight LS TTL loads. Port 0 pins thathave 1s written to them float, and in that state will function as highimpedance inputs. Port 0 is also the multiplexed low-order addressand data bus during accesses to external memory. In thisapplication it uses strong internal pullups when emitting 1s. Port 0emits code bytes during program verification. In this application,external pullups are required.Port 1: Port 1 is an 8-bit bidirectional I/O port with internalpullups. Port 1 pins that have 1s written to them are pulled high by
  32. 32. DENSITY BASED TRAFFIC CONTROL SYSTEMthe internal pullups, and in that state can be used as inputs. Asinputs, port 1 pins that are externally being pulled low will sourcecurrent because of the internal pullups.Port 2: Port 2 is an 8-bit bidirectional I/O port with internalpullups. Port 2 emits the high-order address byte during accessesto external memory that use 16-bit addresses. In this application, ituses the strong internal pullups when emitting 1s.Port 3: . Port 3 is an 8-bit bidirectional I/O port with internalpullups. It also serves the functions of various special features ofthe 80C51 Family as follows:Port Pin Alternate FunctionP3.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)
  33. 33. DENSITY BASED TRAFFIC CONTROL SYSTEMVCC: -Supply voltageVSS: -Circuit ground potentialAll four ports in the 80C51 are bidirectional. Each consists of alatch (Special Function Registers P0 through P3), an output driver,and an input buffer. The output drivers of Ports 0 and 2, and theinput buffers of Port 0, are used in accesses to external memory. Inthis application, Port 0 outputs the low byte of the external memoryaddress, time-multiplexed with the byte being written or read. Port2 outputs the high byte of the external memory address when theaddress is 16 bits wide. Otherwise, the Port 2 pins continue to emitthe P2 SFR content.All the Port 3 pins are multifunctional. They are not only port pins,but also serve the functions of various special features as listedbelow:Port Pin Alternate FunctionP3.0 RxD (serial input port)P3.1 TxD (serial output port)P3.2 INT0 (external interrupt)P3.3 INT1 (external interrupt)P3.4 T0 (Timer/Counter 0 external input)
  34. 34. DENSITY BASED TRAFFIC CONTROL SYSTEMP3.5 T1 (Timer/Counter 1 external input)P3.6 WR (external Data Memory write strobe)P3.7 RD (external Data Memory read strobe)MEMORY ORGANISATIONThe alternate functions can only be activated if the correspondingbit latch in the port SFR contains a 1. Otherwise the port pinremains at 0.All 80C51 devices have separate address spaces forprogram and data memory, as shown in Figures 1 and 2. Thelogical separation of program and data memory allows the datamemory to be accessed by 8-bit addresses, which can be quicklystored and manipulated by an 8-bit CPU. Nevertheless, 16-bit datamemory addresses can also be generated through the DPTRregister.Program memory (ROM, EPROM) can only be read, not written to.There can be up to 64k bytes of program memory. In the 80C51, thelowest 4k bytes of program are on-chip. In the ROMless versions, allprogram memory is external. The read strobe for external programmemory is the PSEN (program store enable). Data Memory (RAM)occupies a separate address space from Program Memory. In the80C51, the lowest 128 bytes of data memory are on-chip. Up to 64kbytes of external RAM can be addressed in the external DataMemory space. In the ROMless version, the lowest 128 bytes are
  35. 35. DENSITY BASED TRAFFIC CONTROL SYSTEMon-chip. The CPU generates read and write signals, RD and WR, asneeded during external Data Memory accesses.External Program Memory and external Data Memory may becombined if desired by applying the RD and PSEN signals to theinputs of an AND gate and using the output of the gate as the readstrobe to the external Program/Data memory.BASIC REGISTERSA number of 8052 registers can be considered "basic." Very littlecan be done without them and a detailed explanation of each one iswarranted to make sure the reader understands these registersbefore getting into more complicated areas of development.The Accumulator If youve worked with any other assemblylanguage you will be familiar with the concept of an accumulatorregister.The Accumulator, as its name suggests, is used as a generalregister to accumulate the results of a large number of instructions.It can hold an 8-bit (1-byte) value and is the most versatile registerthe 8052 has due to the sheer number of instructions that makeuse of the accumulator. More than half of the 8052s 255instructions manipulate or use the Accumulator in some way. Forexample, if you want to add the number 10 and 20, the resulting 30will be stored in the Accumulator. Once you have a value in the
  36. 36. DENSITY BASED TRAFFIC CONTROL SYSTEMAccumulator you may continue processing the value or you maystore it in another register or in memory.The "R" Registers The "R" registers are sets of eight registers thatare named R0, R1, through R7. These registers are used asauxiliary registers in many operations. To continue with the aboveexample, perhaps you are adding 10 and 20. The original number10 may be stored in the Accumulator whereas the value 20 may bestored in, say, register R4. To process the addition you wouldexecute the command: ADD A,R4After executing this instruction the Accumulator will contain thevalue 30. You may think of the "R" registers as very importantauxiliary, or "helper", registers. The Accumulator alone would notbe very useful if it were not for these "R" registers.The "R" registers are also used to store values temporarily. Forexample, letís say you want to add the values in R1 and R2 togetherand then subtract the values of R3 and R4. One way to do thiswould be: MOV A,R3 ;Move the value of R3 to accumulator ADD A,R4 ;Add the value of R4 MOV R5,A ;Store the result in R5 MOV A,R1 ;Move the value of R1 to Acc
  37. 37. DENSITY BASED TRAFFIC CONTROL SYSTEM ADD A,R2 ;Add the value of R2 with A SUBB A,R5 ;Subtract the R5 (which has R3+R4)As you can see, we used R5 to temporarily hold the sum of R3 andR4. Of course, this isnt the most efficient way to calculate (R1+R2) -(R3 +R4) but it does illustrate the use of the "R" registers as a wayto store values temporarily.As mentioned earlier, there are four sets of "R" registers-registerbank 0, 1, 2, and 3. When the 8052 is first powered up, registerbank 0 (addresses 00h through 07h) is used by default. In thiscase, for example, R4 is the same as Internal RAM address 04h.However, your program may instruct the 8052 to use one of thealternate register banks; i.e., register banks 1, 2, or 3. In this case,R4 will no longer be the same as Internal RAM address 04h. Forexample, if your program instructs the 8052 to use register bank 1,register R4 will now be synonymous with Internal RAM address0Ch. If you select register bank 2, R4 is synonymous with 14h, andif you select register bank 3 it is synonymous with address 1Ch.The concept of register banks adds a great level of flexibility to the8052, especially when dealing with interrupts (well talk aboutinterrupts later). However, always remember that the register banksreally reside in the first 32 bytes of Internal RAM.The B Register The "B" register is very similar to the Accumulatorin the sense that it may hold an 8-bit (1-byte) value. The "B" register
  38. 38. DENSITY BASED TRAFFIC CONTROL SYSTEMis only used implicitly by two 8052 instructions: MUL AB and DIVAB. Thus, if you want to quickly and easily multiply or divide A byanother number, you may store the other number in "B" and makeuse of these two instructions.Aside from the MUL and DIV instructions, the "B" register are oftenused as yet another temporary storage register much like a ninth"R" register.The Program Counter The Program Counter (PC) is a 2-byteaddress that tells the 8052 where the next instruction to execute isfound in memory. When the 8052 is initialized PC always starts at0000h and is incremented each time an instruction is executed. Itis important to note that PC isnt always incremented by one. Sincesome instructions are 2 or 3 bytes in length the PC will beincremented by 2 or 3 in these cases.The Program Counter is special in that there is no way to directlymodify its value. That is to say, you cant do something likePC=2430h. On the other hand, if you execute LJMP 2430h youveeffectively accomplished the same thing.It is also interesting to note that while you may change the value ofPC (by executing a jump instruction, etc.) there is no way to readthe value of PC. That is to say, there is no way to ask the 8052"What address are you about to execute?" As it turns out, this is notcompletely true: There is one trick that may be used to determinethe current value of PC. This trick will be covered in a later chapter.
  39. 39. DENSITY BASED TRAFFIC CONTROL SYSTEMThe Data Pointer The Data Pointer (DPTR) is the 8052ís onlyuser-accessible 16-bit (2-byte) register. The Accumulator, "R"registers, and "B" register are all 1-byte values. The PC justdescribed is a 16-bit value but isnt directly user-accessible as aworking register.DPTR, as the name suggests, is used to point to data. It is used bya number of commands that allow the 8052 to access externalmemory. When the 8052 accesses external memory it accesses thememory at the address indicated by DPTR.While DPTR is most often used to point to data in external memoryor code memory, many developers take advantage of the fact thatits the only true 16-bit register available. It is often used to store 2-byte values that have nothing to do with memory locations.The Stack Pointer The Stack Pointer, like all registers exceptDPTR and PC, may hold an 8-bit (1-byte) value. The Stack Pointer isused to indicate where the next value to be removed from the stackshould be taken from.When you push a value onto the stack, the 8052 first incrementsthe value of SP and then stores the value at the resulting memorylocation. When you pop a value off the stack, the 8052 returns thevalue from the memory location indicated by SP, and thendecrements the value of SP.
  40. 40. DENSITY BASED TRAFFIC CONTROL SYSTEMThis order of operation is important. When the 8052 is initialized SPwill be initialized to 07h. If you immediately push a value onto thestack, the value will be stored in Internal RAM address 08h. Thismakes sense taking into account what was mentioned twoparagraphs above: First the 8051 will increment the value of SP(from 07h to 08h) and then will store the pushed value at thatmemory address (08h).ADDRESSING MODESThe addressing modes in the 80C51 instruction set are as follows:Direct Addressing In direct addressing the operand is specified byan 8-bit address field in the instruction. Only internal Data RAMand SFRs can be directly addressed.Indirect Addressing In indirect addressing the instructionspecifies a register which contains the address of the operand. Bothinternal and external RAM can be indirectly addressed. The addressregister for 8-bit addresses can be R0 or R1 of the selected bank, orthe Stack Pointer. The address register for 16-bit addresses canonly be the 16-bit “data pointer” register, DPTR.Register Instructions The register banks, containing registers R0through R7, can be accessed by certain instructions which carry a3-bit register specification within the opcode of the instruction.Instructions that access the registers this way are code efficient,since this mode eliminates an address byte. When the instruction is
  41. 41. DENSITY BASED TRAFFIC CONTROL SYSTEMexecuted, one of the eight registers in the selected bank is accessed.One of four banks is selected at execution time by the two bankselect bits in the PSW.Register-Specific Instructions Some instructions are specific to acertain register. For example, some instructions always operate onthe Accumulator, or Data Pointer, etc., so no address byte is neededto point to it. The opcode itself does that. Instructions that refer tothe Accumulator as A assemble as accumulator specific opcodes.Immediate Constants The value of a constant can follow the opcodein Program Memory. For example,MOV A, #100loads the Accumulator with the decimal number 100. The samenumber could be specified in hex digits as 64H.Indexed AddressingOnly program Memory can be accessed with indexed addressing,and it can only be read. This addressing mode is intended forreading look-up tables in Program Memory A 16-bit base register(either DPTR or the Program Counter) points to the base of thetable, and the Accumulator is set up with the table entry number.The address of the table entry in Program Memory is formed byadding the Accumulator data to the base pointer. Another type ofindexed addressing is used in the “case jump” instruction. In this
  42. 42. DENSITY BASED TRAFFIC CONTROL SYSTEMcase the destination address of a jump instruction is computed asthe sum of the base pointer and the Accumulator data…CHAPTER 3AT89S52 MICROCONTROLLER
  43. 43. DENSITY BASED TRAFFIC CONTROL SYSTEMDescriptionThe AT89S52 is a low-power, high-performance CMOS 8-bitmicrocontroller with 8K bytes of in system programmable Flashmemory. The device is manufactured using Atmel’s high-densitynonvolatile memory technology and is compatible with the industry-standard 80C51 instruction set and pinout. The on-chip Flashallows the program memory to be reprogrammed in-system or by aconventional nonvolatile memory programmer. By combining aversatile 8-bit CPU with in-system programmable Flash on amonolithic chip, the Atmel AT89S52 is a powerful microcontrollerwhich provides a highly-flexible and cost-effective solution to many
  44. 44. DENSITY BASED TRAFFIC CONTROL SYSTEMembedded control applications.The AT89S52 provides the followingstandard features: 8K bytes of Flash, 256 bytes of RAM, 32 I/Olines, Watchdog timer, two data pointers, three 16-bittimer/counters, a six-vector two-level interrupt architecture, a fullduplex serial port, on-chip oscillator, and clock circuitry. Inaddition, the AT89S52 is designed with static logic for operationdown to zero frequency and supports two software selectable powersaving modes. The Idle Mode stops the CPU while allowing the RAM,timer/counters, serial port, and interrupt system to continuefunctioning. The Power-down mode saves the RAM contents butfreezes the oscillator, disabling all other chip functions until thenext interrupt or hardware reset.Features• Compatible with MCS-51® Products• 8K Bytes of In-System Programmable (ISP) Flash Memory– Endurance: 1000 Write/Erase Cycles• 4.0V to 5.5V Operating Range• Fully Static Operation: 0 Hz to 33 MHz• Three-level Program Memory Lock• 256 x 8-bit Internal RAM
  45. 45. DENSITY BASED TRAFFIC CONTROL SYSTEM• 32 Programmable I/O Lines• Three 16-bit Timer/Counters• Eight Interrupt Sources• Full Duplex UART Serial Channel• Low-power Idle and Power-down Modes• Interrupt Recovery from Power-down Mode• Watchdog Timer• Dual Data Pointer• Power-off Flag• Fast Programming Time• Flexible ISP Programming (Byte and Page Mode)
  46. 46. DENSITY BASED TRAFFIC CONTROL SYSTEM
  47. 47. DENSITY BASED TRAFFIC CONTROL SYSTEM
  48. 48. DENSITY BASED TRAFFIC CONTROL SYSTEM PinDescriptionVCC Supply voltage.GND Ground.
  49. 49. DENSITY BASED TRAFFIC CONTROL SYSTEMPort 0 Port 0 is an 8-bit open drain bidirectional I/O port. As anoutput port, each pin can sinkeight TTL inputs. When 1s arewritten to port 0 pins, the pins can be used as highimpedanceinputs.Port 0 can also be configured to be the multiplexed low-orderaddress/data bus during accesses to external program and datamemory. In this mode, P0 has internal pull-ups. Port 0 also receivesthe code bytes during Flash programming and outputs the codebytes during program verification. External pull-ups are requiredduring program verification.Port 1 Port 1 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 1 output buffers can sink/source four TTL inputs.When 1s are written to Port 1 pins, they are pulled high by theinternal pull-ups and can be used as inputs. As inputs, Port 1 pinsthat are externally being pulled low will source current (IIL) becauseof the internal pull-ups. In addition, P1.0 and P1.1 can beconfigured to be the timer/counter 2 external count input (P1.0/T2)and the timer/counter 2 trigger input (P1.1/T2EX), respectively, asshown in the following table. Port 1 also receives the low-orderaddress bytes during Flash programming and verification.
  50. 50. DENSITY BASED TRAFFIC CONTROL SYSTEMPort 2 Port 2 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 2 output buffers can sink/source four TTL inputs.When 1s are written to Port 2 pins, they are pulled high by theinternal pull-ups and can be used as inputs. As inputs, Port 2 pinsthat are externally being pulled low will source current (IIL) becauseof the internal pull-ups. Port 2 emits the high-order address byteduring fetches from external program memory and during accessesto external data memory that use 16-bit addresses (MOVX @ DPTR).In this application, Port 2 uses strong internal pull-ups whenemitting 1s. During accesses to external data memory that use 8-bitaddresses (MOVX @ RI), Port 2 emits the contents of the P2 SpecialFunction Register. Port 2 also receives the high-order address bitsand some control signals during Flash programming andverification.Port 3 Port 3 is an 8-bit bidirectional I/O port with internal pull-ups. The Port 3 output buffers can sink/source four TTL inputs.When 1s are written to Port 3 pins, they are pulled high by theinternal pull-ups and can be used as inputs. As inputs, Port 3 pinsthat are externally being pulled low will source current (IIL) because
  51. 51. DENSITY BASED TRAFFIC CONTROL SYSTEMof the pull-ups. Port 3 receives some control signals for Flashprogramming and verification. Port 3 also serves the functions ofvarious special features of the AT89S52, as shown in the followingtable.RST Reset input. A high on this pin for two machine cycles whilethe oscillator is running resets the device. This pin drives high for98 oscillator periods after the Watchdog times out. The DISRTO bitin SFR AUXR (address 8EH) can be used to disable this feature. Inthe default state of bit DISRTO, the RESET HIGH out feature isenabled.
  52. 52. DENSITY BASED TRAFFIC CONTROL SYSTEMALE/PROG Address Latch Enable (ALE) is an output pulse forlatching the low byte of the address during accesses to externalmemory. This pin is also the program pulse input (PROG) duringFlash programming. In normal operation, ALE is emitted at aconstant rate of 1/6 the oscillator frequency and may be used forexternal timing or clocking purposes. Note, however, that one ALEpulse is skipped during each access to external data memory. Ifdesired, ALE operation can be disabled by setting bit 0 of SFRlocation 8EH. With the bit set, ALE is active only during a MOVX orMOVC instruction. Otherwise, the pin is weakly pulled high. Settingthe ALE-disable bit has no effect if the microcontroller is in externalexecution mode.PSEN Program Store Enable (PSEN) is the read strobe to externalprogram memory.When the AT89S52 is executing code fromexternal program memory, PSEN is activated twice each machinecycle, except that two PSEN activations are skipped during eachaccess to external data memory.EA/VPP External Access Enable. EA must be strapped to GND inorder to enable the device to fetch code from external programmemory locations starting at 0000H up to FFFFH.Note, however,that if lock bit 1 is programmed, EA will be internally latched onreset. EA should be strapped to VCC for internal program
  53. 53. DENSITY BASED TRAFFIC CONTROL SYSTEMexecutions. This pin also receives the 12-volt programming enablevoltage (VPP) during Flash programming.XTAL1 Input to the inverting oscillator amplifier and input to theinternal clock operating circuit.XTAL2 Output from the inverting oscillator amplifier.Special Function RegistersA map of the on-chip memory area called the Special FunctionRegister (SFR) space isshown in Table 1. Note that not all of the addresses are occupied,and unoccupied addresses may not be implemented on the chip.Read accesses to these addresses will in general return randomdata, and write accesses will have an indeterminate effect.Usersoftware should not write 1s to these unlisted locations, since theymay be used in Future products to invoke new features. In thatcase, the reset or inactive values of the new bits will always be 0.Timer 2 Registers: Control and status bits are contained inregisters T2CON (shown in Table 2) and T2MOD (shown in Table 6)for Timer 2. The register pair (RCAP2H,RCAP2L) are theCapture/Reload registers for Timer 2 in 16-bit capture mode or 16-bit auto-reload mode.
  54. 54. DENSITY BASED TRAFFIC CONTROL SYSTEMInterrupt Registers: The individual interrupt enable bits are in theIE register. Two priorities can be set for each of the six interruptsources in the IP register.
  55. 55. DENSITY BASED TRAFFIC CONTROL SYSTEM
  56. 56. DENSITY BASED TRAFFIC CONTROL SYSTEMDual Data Pointer Registers: To facilitate accessing both internaland external data memory, two banks of 16-bit Data PointerRegisters are provided: DP0 at SFR address locations 82H-83H andDP1 at 84H-85H. Bit DPS = 0 in SFR AUXR1 selects DP0 and DPS =1 selects DP1. The user should ALWAYS initialize the DPS bit to theappropriate value before accessing the respective Data PointerRegister. Power Off Flag: The Power Off Flag (POF) is located at bit 4(PCON.4) in the PCON SFR. POF is set to “1” during power up. Itcan be set and rest under software control and is not affected byreset.
  57. 57. DENSITY BASED TRAFFIC CONTROL SYSTEMMemory Organization MCS-51 devices have a separate addressspace for Program and Data Memory. Up to 64K bytes each ofexternal Program and Data Memory can be addressed. ProgramMemory If the EA pin is connected to GND, all program fetches aredirected to external memory. On the AT89S52, if EA is connected toVCC, program fetches to addresses 0000H through 1FFFH aredirected to internal memory and fetches to addresses 2000Hthrough FFFFH are to external memory. Data Memory The AT89S52implements 256 bytes of on-chip RAM. The upper 128 bytes occupya parallel address space to the Special Function Registers. Thismeans that the upper 128 bytes have the same addresses as theSFR space but are physically separate from SFR space.When an instruction accesses an internal location above address7FH, the address mode used in the instruction specifies whetherthe CPU accesses the upper 128 bytes
  58. 58. DENSITY BASED TRAFFIC CONTROL SYSTEMof RAM or the SFR space. Instructions which use direct addressingaccess the SFR space. 9 1919B–MICRO–11/03 For example, thefollowing direct addressing instruction accesses the SFR at location0A0H (which is P2).MOV 0A0H, #dataInstructions that use indirect addressing access the upper 128bytes of RAM. For example, the following indirect addressinginstruction, where R0 contains 0A0H, accesses the data byte ataddress 0A0H, rather than P2 (whose address is 0A0H).MOV @R0, #dataNote that stack operations are examples of indirect addressing, sothe upper 128 bytes of data RAM are available as stack space.Watchdog Timer(One-time Enabled with Reset-out) The WDT isintended as a recovery method in situations where the CPU may besubjected to software upsets. The WDT consists of a 14-bit counterand the WatchdogTimer Reset (WDTRST) SFR. The WDT is defaulted to disable fromexiting reset. To enable the WDT, a user must write 01EH and0E1H in sequence to the WDTRST register (SFR location 0A6H).When the WDT is enabled, it will increment every machine cyclewhile the oscillator is running. The WDT timeout period isdependent on the external clock frequency. There is no way to
  59. 59. DENSITY BASED TRAFFIC CONTROL SYSTEMdisable the WDT except through reset (either hardware reset orWDT overflow reset). When WDT overflows, it will drive an outputRESET HIGH pulse at the RST pin.Using the WDT To enable the WDT, a user must write 01EH and0E1H in sequence to the WDTRST register (SFR location 0A6H).When the WDT is enabled, the user needs to service it by writing01EH and 0E1H to WDTRST to avoid a WDT overflow. The 14-bitcounter overflows when it reaches 16383 (3FFFH), and this willreset the device. When the WDT is enabled, it will increment everymachine cycle while the oscillator is running. This means the usermust reset the WDT at least every 16383 machine cycles. To resetthe WDT the user must write 01EH and 0E1H to WDTRST.WDTRST is a write-only register. The WDT counter cannot be reador written. When WDT overflows, it will generate an output RESETpulse at the RST pin. The RESET pulse duration is 98xTOSC, whereTOSC = 1/FOSC. To make the best use of the WDT, it should beserviced in those sections of code that will periodically be executedwithin the time required to prevent a WDT reset.WDT During Powerdown and IdleIn Power-down mode the oscillator stops, which means the WDTalso stops. While in Power-down mode, the user does not need toservice the WDT. There are two methods of exiting Power-downmode: by a hardware reset or via a level-activated external interruptwhich is enabled prior to entering Power-down mode. When Power-
  60. 60. DENSITY BASED TRAFFIC CONTROL SYSTEMdown is exited with hardware reset, servicing the WDT should occuras it normally does whenever the AT89S52 is reset. Exiting Power-down with an interrupt is significantly different. The interrupt isheld low long enough for the oscillator to stabilize. When theinterrupt is brought high, the interrupt is serviced. To prevent theWDT from resetting the device while the interrupt pin is held low,the WDT is not started until the interrupt is pulled high.It is suggested that the WDT be reset during the interrupt servicefor the interrupt used to exit Power-down mode. To ensure that theWDT does not overflow within a few states of exiting Power-down, itis best to reset the WDT just before entering Power-down mode.Before going into the IDLE mode, the WDIDLE bit in SFR AUXR isused to determine whether the WDT continues to count if enabled.The WDT keeps counting during IDLE(WDIDLE bit = 0) as the default state. To prevent the WDT fromresetting the AT89S52 while in IDLE mode, the user should alwaysset up a timer that will periodically exitIDLE, service the WDT, and reenter IDLE mode.With WDIDLE bit enabled, the WDT will stop to count in IDLE modeand resumes the count upon exit from IDLE. UART The UART inthe AT89S52 operates the same way as the UART in the AT89C51and AT89C52. For further information on the UART operation, referto the ATMEL Web site
  61. 61. DENSITY BASED TRAFFIC CONTROL SYSTEM(http://www.atmel.com). From the home page, select “Products”,then “8051-ArchitectureFlash Microcontroller”, then “Product Overview”.Timer 0 and 1 Timer 0 and Timer 1 in the AT89S52 operate thesame way as Timer 0 and Timer 1 in the AT89C51 and AT89C52.For further information on the timers” operation, refer to theATMEL Web site (http://www.atmel.com). From the home page,select “Products”, then“8051-Architecture Flash Microcontroller”, then “Product Overview”.Timer 2 Timer 2 is a 16-bit Timer/Counter that can operate aseither a timer or an event counter. The type of operation is selectedby bit C/T2 in the SFR T2CON (shown in Table 2). Timer 2 hasthree operating modes: capture, auto-reload (up or down counting),and baud rate generator. The modes are selected by bits in T2CON,as shown in Table 5.Timer 2 consists of two 8-bit registers, TH2 and TL2. In the Timerfunction, the TL2 register is incremented every machine cycle. Sincea machine cycle consists of 12 oscillator periods, the count rate is1/12 of the oscillator frequency. In the Counter function, theregister is incremented in response to a 1-to-0 transition at itscorresponding external input pin, T2. In this function, the externalinput is sampled during S5P2 of every machine cycle. When thesamples show a high in one cycle and a low in the next cycle, the
  62. 62. DENSITY BASED TRAFFIC CONTROL SYSTEMcount is incremented. The new count value appears in the registerduring S3P1 of the cycle following the one in which the transitionwas detected. Since two machine cycles (24 oscillator periods) arerequired to recognize a 1-to-0 transition, the maximum count rateis 1/24 of the oscillator frequency. To ensure that a given level issampled at least once before it changes, the level should be held forat least one full machine cycle.Capture Mode In the capture mode, two options are selected by bitEXEN2 in T2CON. If EXEN2 = 0, Timer 2 is a 16-bit timer orcounter which upon overflow sets bit TF2 in T2CON. This bit canthen be used to generate an interrupt. If EXEN2 = 1, Timer 2performs the same operation, but a 1-to-0 transition at externalinput T2EX also causes the current value in TH2 and TL2 to becaptured into RCAP2H and RCAP2L, respectively. In addition, thetransition at T2EX causes bit EXF2 in T2CON to be set. The EXF2bit, like TF2, cangenerate an interrupt. The capture mode is illustrated in Figure 1.Auto-reload (Up or Down Counter)Timer 2 can be programmed to count up or down when configuredin its 16-bit autoreload mode. This feature is invoked by the DCEN(Down Counter Enable) bit located in the SFR T2MOD (see Table 6).Upon reset, the DCEN bit is set to 0 so that timer 2 will default tocount up. When DCEN is set, Timer 2 can count up or down,depending on the value of the T2EX pin.
  63. 63. DENSITY BASED TRAFFIC CONTROL SYSTEMFigure 2 shows Timer 2 automatically counting up when DCEN = 0.In this mode, two options are selected by bit EXEN2 in T2CON. IfEXEN2 = 0, Timer 2 counts up to 0FFFFH and then sets the TF2 bitupon overflow. The overflow also causes the timer registers to bereloaded with the 16-bit value in RCAP2H and RCAP2L. The valuesin
  64. 64. DENSITY BASED TRAFFIC CONTROL SYSTEMTimer in Capture ModeRCAP2H and RCAP2L are preset by software.If EXEN2 = 1, a 16-bit reload can be triggered either by an overflowor by a 1-to-0 transition at external input T2EX. This transition alsosets the EXF2 bit. Both the TF2 and EXF2 bits can generate aninterrupt if enabled.Setting the DCEN bit enables Timer 2 to count up or down, asshown in Figure 2. In this mode, the T2EX pin controls thedirection of the count. A logic 1 at T2EX makes Timer 2 count up.The timer will overflow at 0FFFFH and set the TF2 bit. This overflowalso causes the 16-bit value in RCAP2H and RCAP2L to be reloadedinto the timer registers, TH2 and TL2, respectively. A logic 0 atT2EX makes Timer 2 count down. The timer underflows when TH2and TL2 equal the values stored in RCAP2H and RCAP2L. Theunderflow sets the TF2 bit and causes 0FFFFH to be reloaded intothe timer registers.The EXF2 bit toggles whenever Timer 2 overflows or underflows andcan be used as a 17th bit of resolution. In this operating mode,EXF2 does not flag an interrupt.----------------------------------------------------------- =
  65. 65. DENSITY BASED TRAFFIC CONTROL SYSTEM
  66. 66. DENSITY BASED TRAFFIC CONTROL SYSTEMBaud Rate Generator Timer 2 is selected as the baud rate generatorby setting TCLK and/or RCLK in T2CON (Table 2). Note that thebaud rates for transmit and receive can be different if Timer 2 isused for the receiver or transmitter and Timer 1 is used for theother function. Setting RCLK and/or TCLK puts Timer 2 into itsbaud rate generator mode, as shown in Figure 4.The baud rate generator mode is similar to the auto-reload mode, inthat a rollover inTH2 causes the Timer 2 registers to be reloaded with the 16-bitvalue in registersRCAP2H and RCAP2L, which are preset by software.The baud rates in Modes 1 and 3 are determined by Timer 2’soverflow rate according tothe following equation.
  67. 67. DENSITY BASED TRAFFIC CONTROL SYSTEMThe Timer can be configured for either timer or counter operation.In most applications, it is configured for timer operation (CP/T2 =0). The timer operation is different for Timer 2 when it is used as abaud rate generator. Normally, as a timer, it increments everymachine cycle (at 1/12 the oscillator frequency). As a baud rategenerator, however, it increments every state time (at 1/2 theoscillator frequency). The baud rate formula is given below.where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2Ltaken as a 16-bit unsigned integer.Timer 2 as a baud rate generator is shown in Figure 4. This figure isvalid only if RCLK or TCLK = 1 in T2CON. Note that a rollover inTH2 does not set TF2 and will not generate an interrupt. Note too,that if EXEN2 is set, a 1-to-0 transition in T2EX will set EXF2 butwill not cause a reload from (RCAP2H, RCAP2L) to (TH2, TL2). Thus,when Timer 2 is in use as a baud rate generator, T2EX can be usedas an extra external interrupt. Note that when Timer 2 is running(TR2 = 1) as a timer in the baud rate generator mode, TH2 or TL2should not be read from or written to. Under these conditions, theTimer is incremented every state time, and the results of a read orwrite may not be accurate. The RCAP2 registers may be read butshould not be written to, because a write might overlap a reload and
  68. 68. DENSITY BASED TRAFFIC CONTROL SYSTEMcause write and/or reload errors. The timer should be turned off(clear TR2) before accessing the Timer 2 or RCAP2 registers.Modes 1 and 3 Baud Rates= Timer 2 Overflowrate/16÷÷ The Timer can be configured for either timer or counteroperation. In most applications, it is configured for timer operation(CP/T2 = 0). The timer operation is different for Timer 2 when it isused as a baud rate generator. Normally, as a timer, it incrementsevery machine cycle (at 1/12 the oscillator frequency). As a baudrate generator, however, it increments every state time (at 1/2 theoscillator frequency). The baud rate formula isgiven below.where (RCAP2H, RCAP2L) is the content of RCAP2H and RCAP2Ltaken as a 16-bit
  69. 69. DENSITY BASED TRAFFIC CONTROL SYSTEMunsigned integer.Timer 2 as a baud rate generator is shown in Figure 4. This figure isvalid only if RCLKor TCLK = 1 in T2CON. Note that a rollover in TH2 does not set TF2and will not generatean interrupt. Note too, that if EXEN2 is set, a 1-to-0 transition inT2EX will set EXF2 but will not cause a reload from (RCAP2H,RCAP2L) to (TH2, TL2). Thus, when Timer 2is in use as a baud rategenerator, T2EX can be used as an extra external interrupt. Notethat when Timer 2 is running (TR2 = 1) as a timer in the baud rategenerator mode, TH2 or TL2 should not be read from or written to.Under these conditions, the Timer is incremented every state time,and the results of a read or write may not be accurate. The RCAP2registers may be read but should not be written to, because a writemightoverlap a reload and cause write and/or reload errors. The timershould be turned off (clear TR2) before accessing the Timer 2 orRCAP2 registers.
  70. 70. DENSITY BASED TRAFFIC CONTROL SYSTEMProgrammableClock OutA 50% duty cycle clock can be programmed to come out on P1.0, asshown in Figure 5. This pin, besides being a regular I/O pin, hastwo alternate functions. It can be programmed to input the externalclock for Timer/Counter 2 or to output a 50% duty cycle clockranging from 61 Hz to 4 MHz (for a 16-MHz operating frequency). Toconfigure the Timer/Counter 2 as a clock generator, bit C/T2(T2CON.1) must be cleared and bit T2OE (T2MOD.1) must be set.Bit TR2 (T2CON.2) starts and stops the timer.The clock-out frequency depends on the oscillator frequency andthe reload value of
  71. 71. DENSITY BASED TRAFFIC CONTROL SYSTEMTimer 2 capture registers (RCAP2H, RCAP2L), as shown in thefollowing equation.In the clock-out mode, Timer 2 roll-overs will not generate aninterrupt. This behavior issimilar to when Timer 2 is used as a baud-rate generator. It ispossible to use Timer 2 as a baud-rate generator and a clockgenerator simultaneously. Note, however, that the baud-rate andclock-out frequencies cannot be determined independently from oneanother since they both use RCAP2H and RCAP2L.
  72. 72. DENSITY BASED TRAFFIC CONTROL SYSTEMInterrupts The AT89S52 has a total of six interrupt vectors: twoexternal interrupts (INT0 and INT1), three timer interrupts (Timers0, 1, and 2), and the serial port interrupt. These interrupts are allshown in Figure 6.Each of these interrupt sources can be individually enabled ordisabled by setting or clearing a bit in Special Function Register IE.IE also contains a global disable bit, EA, which disables allinterrupts at once.Note that Table 5 shows that bit position IE.6 is unimplemented.User software should not write a 1 to this bit position, since it maybe used in future AT89 products. Timer 2 interrupt is generated bythe logical OR of bits TF2 and EXF2 in register T2CON. Neither ofthese flags is cleared by hardware when the service routine isvectored to. In fact, the service routine may have to determinewhether it was TF2 or EXF2 that generated the interrupt, and thatbit will have to be cleared in software. The Timer 0 and Timer 1flags, TF0 and TF1, are set at S5P2 of the cycle in which the timersoverflow. The values are then polled by the circuitry in the nextcycle. However, the Timer 2 flag, TF2, is set at S2P2 and is polled inthe same cycle in which the timer overflows.
  73. 73. DENSITY BASED TRAFFIC CONTROL SYSTEMOscillatorCharacteristics
  74. 74. DENSITY BASED TRAFFIC CONTROL SYSTEMXTAL1 and XTAL2 are the input and output, respectively, of aninverting amplifier that can be configured for use as an on-chiposcillator, as shown in Figure 7. Either a quartz crystal or ceramicresonator may be used. To drive the device from an external clocksource, XTAL2 should be left unconnected while XTAL1 is driven, asshown in Figure 8. There are no requirements on the duty cycle ofthe external clock signal, since the input to the internal clockingcircuitry is through a divide-by-two flip-flop, but minimum andmaximum voltage high and low time specifications must beobserved.Idle Mode In idle mode, the CPU puts itself to sleep while all the on-chip peripherals remain active. The mode is invoked by software.The content of the on-chip RAM and all the specialfunctions registers remain unchanged during this mode. The idlemode can be terminated by any enabled interrupt or by a hardwarereset. Note that when idle mode is terminated by a hardware reset,the device normally resumes program execution from where it leftoff, up to two machine cycles before the internal reset algorithmtakes control. On-chip hardware inhibits access to internal RAM inthis event, but access to the port pins is not inhibited. To eliminatethe possibility of an unexpected write to a port pin when idle modeis terminated by a reset, the instructionfollowing the one that invokes idle mode should not write to a portpin or to external memory.
  75. 75. DENSITY BASED TRAFFIC CONTROL SYSTEMPower-down Mode In the Power-down mode, the oscillator isstopped, and the instruction that invokes Power-down is the lastinstruction executed. The on-chip RAM and Special FunctionRegisters retain their values until the Power-down mode isterminated. Exit from Powerdown mode can be initiated either by ahardware reset or by an enabled external interrupt.Reset redefines the SFRs but does not change the on-chip RAM. Thereset should not be activated before VCC is restored to its normaloperating level and must be held active long enough to allow theoscillator to restart and stabilize.
  76. 76. DENSITY BASED TRAFFIC CONTROL SYSTEM
  77. 77. DENSITY BASED TRAFFIC CONTROL SYSTEMProgram MemoryLock BitsThe AT89S52 has three lock bits that can be left unprogrammed (U)or can be programmed(P) to obtain the additional features listed in the following table.
  78. 78. DENSITY BASED TRAFFIC CONTROL SYSTEMWhen lock bit 1 is programmed, the logic level at the EA pin issampled and latched during reset. If the device is powered upwithout a reset, the latch initializes to a random value and holdsthat value until reset is activated. The latched value of EA mustagree with the current logic level at that pin in order for the deviceto function properly.Programming the Flash – Parallel ModeThe AT89S52 is shipped with the on-chip Flash memory arrayready to be programmed.The programming interface needs a high-voltage (12-volt) programenable signal and is compatible with conventional third-party Flashor EPROM programmers.The AT89S52 code memory array is programmed byte-by-byte.Programming Algorithm: Before programming the AT89S52, theaddress, data, and control signals should be set up according to theFlash programming mode table andFigures 13 and 14. To program the AT89S52, take the followingsteps:1. Input the desired memory location on the address lines.2. Input the appropriate data byte on the data lines.3. Activate the correct combination of control signals.
  79. 79. DENSITY BASED TRAFFIC CONTROL SYSTEM4. Raise EA/VPP to 12V.5. Pulse ALE/PROG once to program a byte in the Flash array orthe lock bits. The byte-write cycle is self-timed and typically takesno more than 50 µs. Repeat steps 1 through 5, changing theaddress and data for the entire array or until the end of the objectfile is reached.Data Polling: The AT89S52 features Data Polling to indicate the endof a byte writecycle. During a write cycle, an attempted read of the last bytewritten will result in the complement of the written data on P0.7.Once the write cycle has been completed, true data is valid on alloutputs, and the next cycle may begin. Data Polling may begin anytime after a write cycle has been initiated.Ready/Busy: The progress of byte programming can also bemonitored by the RDY/BSY output signal. P3.0 is pulled low afterALE goes high during programming to indicate BUSY. P3.0 is pulledhigh again when programming is done to indicate READY.Program Verify: If lock bits LB1 and LB2 have not beenprogrammed, the programmed code data can be read back via theaddress and data lines for verification. The status of the individuallock bits can be verified directly by reading them back.Reading the Signature Bytes: The signature bytes are read by thesame procedure as a normal verification of locations 000H, 100H,
  80. 80. DENSITY BASED TRAFFIC CONTROL SYSTEMand 200H, except that P3.6 and P3.7 must be pulled to a logic low.The values returned are as follows.(000H) = 1EH indicates manufactured by Atmel(100H) = 52H indicates AT89S52(200H) = 06HChip Erase: In the parallel programming mode, a chip eraseoperation is initiated by using the proper combination of controlsignals and by pulsing ALE/PROG low for a duration of 200 ns -500 ns. In the serial programming mode, a chip erase operation isinitiated by issuing the Chip Erase instruction. In this mode, chiperase is self-timed and takes about 500 ms. During chip erase, aserial read from any address location will return 00H at the dataoutput.Programming the Flash – Serial ModeThe Code memory array can be programmed using the serial ISPinterface while RST is pulled to VCC. The serial interface consists ofpins SCK, MOSI (input) and MISO (output).After RST is set high, the Programming Enable instruction needs tobe executed first before other operations can be executed. Before areprogramming sequence can occur, a Chip Erase operation isrequired. The Chip Erase operation turns the content of everymemory location in the Code array into FFH. Either an external
  81. 81. DENSITY BASED TRAFFIC CONTROL SYSTEMsystem clock can be supplied at pin XTAL1 or a crystal needs to beconnected across pins XTAL1 and XTAL2. The maximum serialclock (SCK) frequency should be less than 1/16 of the crystalfrequency. With a 33 MHz oscillator clock, the maximum SCKfrequency is 2 MHz.Serial ProgrammingAlgorithmTo program and verify the AT89S52 in the serial programmingmode, the following sequence is recommended:1. Power-up sequence:Apply power between VCC and GND pins.Set RST pin to “H”.If a crystal is not connected across pins XTAL1and XTAL2, apply a 3 MHz to33 MHz clock to XTAL1 pin and waitfor at least 10 milliseconds.2. Enable serial programming by sending the Programming Enableserial instruction to pin MOSI/P1.5. The frequency of the shift clocksupplied at pin SCK/P1.7 needs to be less than the CPU clock atXTAL1 divided by 16.3. The Code array is programmed one byte at a time in either theByte or Page mode. The write cycle is self-timed and typically takesless than 0.5 ms at 5V.
  82. 82. DENSITY BASED TRAFFIC CONTROL SYSTEM4. Any memory location can be verified by using the Readinstruction which returns the content at the selected address atserial output MISO/P1.6.5. At the end of a programming session, RST can be set low tocommence normal device operation.Power-off sequence (if needed):Set XTAL1 to “L” (if a crystal is not used).Set RST to “L”.Turn VCC power off.Data Polling: The Data Polling feature is also available in the serialmode. In this mode,during a write cycle an attempted read of thelast byte written will result in the complement of the MSB of theserial output byte on MISO.
  83. 83. DENSITY BASED TRAFFIC CONTROL SYSTEM
  84. 84. DENSITY BASED TRAFFIC CONTROL SYSTEM
  85. 85. DENSITY BASED TRAFFIC CONTROL SYSTEM
  86. 86. DENSITY BASED TRAFFIC CONTROL SYSTEMFlash Programming and Verification Waveforms – Serial ModeFigure 13.Serial Programming Waveforms
  87. 87. DENSITY BASED TRAFFIC CONTROL SYSTEM
  88. 88. DENSITY BASED TRAFFIC CONTROL SYSTEM
  89. 89. DENSITY BASED TRAFFIC CONTROL SYSTEMCHAPTER 4INTERFACING DEVICES
  90. 90. DENSITY BASED TRAFFIC CONTROL SYSTEMRS232 (serial port).RS-232 (Recommended Standard - 232) is a telecommunicationsstandard for binary serial communications between devices. Itsupplies the roadmap for the way devices speak to each other usingserial ports. The devices are commonly referred to as a DTE (dataterminal equipment) and DCE (data communications equipment);for example, a computer and modem, respectively.RS232 is the most known serial port used in transmitting the datain communication and interface. Even though serial port is harderto program than the parallel port, this is the most effective methodin which the data transmission requires less wires that yields to theless cost. The RS232 is the communication line which enables thedata transmission by only using three wire links. The three linksprovides ‘transmit’, ‘receive’ and common ground...The ‘transmit’ and ‘receive’ line on this connecter send and receivedata between the computers. As the name indicates, the data istransmitted serially. The two pins are TXD & RXD. There are otherlines on this port as RTS, CTS, DSR, DTR, and RTS, RI. The ‘1’ and‘0’ are the data which defines a voltage level of 3V to 25V and -3V to-25V respectively.he electrical characteristics of the serial port as per the EIA(Electronics Industry Association) RS232C Standard specifies amaximum baud rate of 20,000bps, which is slow compared to
  91. 91. DENSITY BASED TRAFFIC CONTROL SYSTEM today’s standard speed. For this reason, we have chosen the new RS-232D Standard, which was recently released. The RS-232D has existed in two types. i.e., D-TYPE 25 pin connector and D-TYPE 9 pin connector, which are male connectors on the back of the PC. You need a female connector on your communication from Host to Guest computer. The pin outs of both D-9 & D-25 are show belowD-Type-9 D-Type-25 Pin outs Functionpin no. pin no. 3 2 RD Receive Data (Serial data input) 2 3 TD Transmit Data (Serial data output) 7 4 RTS Request to send (acknowledge to modem that UART is ready to exchange data 8 5 CTS Clear to send (i.e.; modem is ready to exchang data) 6 6 DSR Data ready state (UART establishes a link) 5 7 SG Signal ground 1 8 DCD Data Carrier detect (This line is active when modem detects a carrier 4 20 DTR Data Terminal Ready.
  92. 92. DENSITY BASED TRAFFIC CONTROL SYSTEM9 22 RI Ring Indicator (Becomes active when modem detects ringing signal from PSTN Rs232 When communicating with various micro processors one needs to convert the RS232 levels down to lower levels, typically 3.3 or 5.0 Volts. Here is a cheap and simple way to do that. Serial RS-232
  93. 93. DENSITY BASED TRAFFIC CONTROL SYSTEM(V.24) communication works with voltages -15V to +15V for highand low. On the other hand, TTL logic operates between 0V and+5V . Modern low power consumption logic operates in the range of0V and +3.3V or even lower.RS-232 TTL Logic-15V … -3V +2V … +5V High+3V … +15V 0V … +0.8V Low Thus the RS-232 signal levels are far too high TTL electronics,and the negative RS-232 voltage for high can’t be handled at all bycomputer logic. To receive serial data from an RS-232 interface thevoltage has to be reduced. Also the low and high voltage level hasto be inverted. This level converter uses a Max232 and fivecapacitors. The max232 is quite cheap (less than 5 dollars) or ifyoure lucky you can get a free sample from Maxim.The MAX232from Maxim was the first IC which in one package contains thenecessary drivers and receivers to adapt the RS-232 signal voltagelevels to TTL logic. It became popular, because it just needs onevoltage (+5V or +3.3V) and generates the necessary RS-232 voltagelevels. MAX 232 PIN DIAGRAM +---/---+1 -|C1+ Vcc|- 162 -|V+ gnd|- 153 -|C1- T1O|- 144 -|C2+ R1I|- 13
  94. 94. DENSITY BASED TRAFFIC CONTROL SYSTEM5 -|C2- R1O|- 126 -|V- T1I|- 117 -|T2O T2I|- 108 -|R2I R2O|- 9 +--------+RS232 INTERFACED TO MAX 232 J2 C1 U3 1uf 9 5 16 8 4 13 12 P 3 .0 R X D 7 3 T1O U T 8 R 1 IN R 1O U T 9 VCC 6 2 R 2 IN R 2O U T 1 10 14 T1O U T TXD P 3 .1 11 T 2 IN T1O U T 7 C4 T 1 IN T2O U T 5V 1 3 C 1+ C . 51 u f 0 4 C 1- 5 C 2+ C6 C 2- 0 .1 u f 2 0 .1 u f 6 V+ GND V- C7 M A X3232 15 0 .1 u fRs232 is 9 pin db connector,only three pins of this are used ie 2,3,5the transmit pin of rs232 is connected to rx pin of microcontrollerMax232 interfaced to microcontroller
  95. 95. DENSITY BASED TRAFFIC CONTROL SYSTEM.MAX232 is connected to the microcontroller as shown in the figureabove 11, 12 pin are connected to the 10 and 11 pin ie transmitand receive pin of microcontroller LED’S :
  96. 96. DENSITY BASED TRAFFIC CONTROL SYSTEM Fig:19 LED’s interfacing LED (light emitting diode) color is characterized by the wavelength it emits. The peak emission wavelength differs according to the energy released during recombination. This energy differs according to the LED material used. Mixed crystals of GaP & GaAs are used. By varying the mixing ratio “X”, different luminous colors from red to yellow are obtained. LEDs can typically draw up to 30mA.A current limiting resistor is mandatory to protect both the microcontroller & LED. Even connecting a led through a resistor is not advisable in case of 8051.A NPN or a PNP transistor may be used. This way even higher currents can be used. Ohms law can be used to calculate the value of the current limiting resistor , i.e I=V/R.
  97. 97. DENSITY BASED TRAFFIC CONTROL SYSTEMREGULATED POWER SUPPLY A variable regulated power supply, also called a variable benchpower supply, is one where you can continuously adjust the outputvoltage to your requirements. Varying the output of the powersupply is the recommended way to test a project after having doublechecked parts placement against circuit drawings and the partsplacement guide.This type of regulation is ideal for having a simple variable benchpower supply. Actually this is quite important because one of thefirst projects a hobbyist should undertake is the construction of avariable regulated power supply. While a dedicated supply is quitehandy e.g. 5V or 12V, its much handier to have a variable supplyon hand, especially for testing.Most digital logic circuits and processors need a 5 volt powersupply. To use these parts we need to build a regulated 5 voltsource. Usually you start with an unregulated power To make a 5volt power supply, we use a LM7805 voltage regulator IC (IntegratedCircuit). The IC is shown below.
  98. 98. DENSITY BASED TRAFFIC CONTROL SYSTEMThe LM7805 is simple to use. You simply connect the positive leadof your unregulated DC power supply (anything from 9VDC to24VDC) to the Input pin, connect the negative lead to the Commonpin and then when you turn on the power, you get a 5 volt supplyfrom the Output pin.CIRCUIT FEATURES • Brief description of operation: Gives out well regulated +5V output, output current capability of 100 mA • Circuit protection: Built-in overheating protection shuts down output when regulator IC gets too hot • Circuit complexity: Very simple and easy to build • Circuit performance: Very stable +5V output voltage, reliable operation
  99. 99. DENSITY BASED TRAFFIC CONTROL SYSTEM • Availability of components: Easy to get, uses only very common basic components • Design testing: Based on datasheet example circuit, I have used this circuit succesfully as part of many electronics projects • Applications: Part of electronics devices, small laboratory power supply • Power supply voltage: Unreglated DC 8-18V power supply • Power supply current: Needed output current + 5 mA • Component costs: Few dollars for the electronics components + the input transformer costBLOCK DIAGRAM
  100. 100. DENSITY BASED TRAFFIC CONTROL SYSTEMEXAMPLE CIRCUIT DIAGRAM: RESET
  101. 101. DENSITY BASED TRAFFIC CONTROL SYSTEM The pin 9 of the microcontroller 8051 is the RESET pin. Upon applying a high pulse to this pin, the micro controller will reset and terminate all activities. This is often called as power-on reset. Activating a power-on reset will cause all the values in the registers to be lost. It will set program counter to all 0’s. the reset can be given by either power-on reset circuit or by using a momentary switch. RESET value of some 8051 registers: Registe Reset r value (hex) PC 0000 DPTR 0000 ACC 00 PSW 00 SP 07 B 00 P0-P3 FF Table:10 Reset values table
  102. 102. DENSITY BASED TRAFFIC CONTROL SYSTEMPOWER SUPPLY Power supply is an important part of operation of the Microcontroller. Microcontroller operates at +5v DC and also for other ICs and displays.INTRODUCTION TO ORCAD(SCHEMATIC DESIGN TOOL)OrCAD is a software tool suite used primarily for electronic designautomation. The software is used mainly to create electronic printsfor manufacturing of printed circuit boards, by electronic designengineers and electronic technicians to manufacture electronicschematics and diagrams, and for their simulation.The name OrCAD is a portmanteau, reflecting the softwaresorigins: Oregon + CAD.The OrCAD product line is fully owned by Cadence Design Systems.The latest iteration has the ability to maintain a database ofavailable integrated circuits. This database may be updated by theuser by downloading packages from component manufacturers,such as Analog Devices or Texas Instruments.
  103. 103. DENSITY BASED TRAFFIC CONTROL SYSTEMThe Cadence OrCAD product line includes affordable, high-performance PCB design tools that boost productivity for smallerdesign teams and individual PCB designers.To stay competitive in todays market, engineers must take a designfrom engineering through manufacturing with shorter design cyclesand faster time to market. To be successful, you need a set ofpowerful, intuitive, and integrated tools that work seamlessly acrossthe entire design flow.Cadence® OrCAD® personal productivity tools (including Cadence®PSpice®) have a long history of addressing these demands.Designed to boost productivity for smaller design teams andindividual PCB designers, OrCAD PCB design suites grow with yourneeds and technology challenges. The powerful, tightly integratedPCB design suites include design capture, librarian tools, a PCBeditor, an auto/interactive router, and optional analog and mixed-signal simulator.The affordable, high-performance OrCAD product line is easily
  104. 104. DENSITY BASED TRAFFIC CONTROL SYSTEMscalable with the full complement of Cadence® Allegro® PCBsolutions.The OrCAD product line is supported by a worldwide network ofCadence Channel Partners. For sales, technical support, andtraining inquiries please visit the global Cadence Channel Partnerlisting to find a partner in your region. CHAPTER 5PROJECT CIRCUITRY

×