+ All Categories
Home > Documents > Traffic Density Based Light Intensity Controller

Traffic Density Based Light Intensity Controller

Date post: 10-Apr-2015
Category:
Upload: swethakv
View: 3,250 times
Download: 4 times
Share this document with a friend
88
Transcript
Page 1: Traffic Density Based Light Intensity Controller
Page 2: Traffic Density Based Light Intensity Controller

Contents:

Abstract Embedded Systems Introduction to microcontroller IR sensors LED Software Implementation Program Conclusion

Page 3: Traffic Density Based Light Intensity Controller

Traffic density based light intensity controller

Domain : Embedded systems

Software : Embedded C, Keil, Proload

Microcontroller : AT89S52

Power Supply : +9V, 500mA Regulated Power

Crystal : 11.0592MHZ

Transmitter : Infra red LED

Receiver : LDR

Developed By : Indian Engineering Corporation

Components required:

1. Infra red transmitters

2. Infra red receivers

3. Micro controller AT89S52

Page 4: Traffic Density Based Light Intensity Controller

OBJECTIVE:

The main objective of the project is to save the power by developing a system which controls the intensity of street lights depending upon the traffic density on the road. Mostly the traffic density will be more in some peak times only and in the remaining times the density will be very less in such time the power can be saved by reducing the intensity of light. If the density is more the intensity of the street light will be maximum otherwise intensity will be minimum. For this application we are developing this system.

MOTIVATION:

Everywhere, throughout the world, the street lights will be turned on from 6

pm at evening to 5 am at morning. Throughout these twelve hours of time, the

traffic will be more at some times and less at remaining time. Whenever the traffic

is less i.e., the density of traffic is less, there is no need to street lights to be glow at

maximum intensity. A minimum level of intensity of lights is enough to see the

roads. Hence to reduce the power consumption, whenever the traffic density is

less, we are developing this system.

To develope the above system we are using Embedded systems.

Design:

Mostly the roads are one way, so, it will be easy to calculate the no. of vehicles entering into a particular length of road and also that are leaving the road. By this we can also calculate the total no. of vehicles that are present in particular length of the road. For this we are using IR sensor. When an vehicle is entered on to the road the sensor detects the vehicle. If the total no. of vehicles detected by the sensor is maximum, then this will be indicated that the density of traffic is

Page 5: Traffic Density Based Light Intensity Controller

maximum, and then this will be indicated that the density of traffic is maximum, minimum, otherwise.

In the peak times of traffic, there is no need to check the count of vehicles for a long time, to change the light intensity, since there will be more traffic for a long time. And in non-peak times the light intensity will be less and there is a need to check the count of vehicles for short time intervals, because there may be a sudden change in traffic density hence the count of vehicles will be taken at short durations of time intervals.

Embedded Systems

Definition of an Embedded System

Embedded system is defined as, for a particular/specific application

implementing the software code to interact directly with that particular hardware

what we built. Software is used for providing features and flexibility, Hardware =

{Processors, ASICs, Memory...} is used for Performance (& sometimes security)

There are many definitions of embedded system but all of these can be

combined into a single concept. An embedded system is a special purpose

computer system that is used for particular task.

Characteristics of Embedded Systems

Embedded computing systems generally exhibit rich functionality—

complex functionality is usually the reason for introducing CPUs into the design.

However, they also exhibit many non-functional requirements that make the task

especially challenging:

• Real-time deadlines that will cause system failure if not met;

• Multi-rate operation;

Page 6: Traffic Density Based Light Intensity Controller

Application Software

Operating System

H/W

• In many cases, low power consumption;

• Low manufacturing cost, which often means limited code size.

Workstation programmers often concentrate on functionality. They may

consider the performance characteristics of a few computational kernels of their

software, but rarely analyze the total application. They almost never consider

power consumption and manufacturing cost. The need to juggle all these

requirements makes embedded system programming very challenging and is the

reason why embedded system designers need to understand computer architecture.

Overview of an Embedded System Architecture

Every Embedded system consists of a custom-built hardware built around a

central processing unit. This hardware also contains memory chips onto which the

software is loaded.

Page 7: Traffic Density Based Light Intensity Controller

The operating system runs above the hardware and the application software

runs above the operating system. The same architecture is applicable to any

computer including desktop computer. However these are significant differences. It

is not compulsory to have an operating system in every embedded system. For

small applications such as remote control units, air conditioners, toys etc.

In general we are having Microprocessor and Microcontroller based

Embedded systems.

1. Micro Processor: - are for general purpose eg: our personal computer

2. Micro Controller: - are for specific applications, because of cheaper cost we will go for these

MICROCONTROLLER VERSUS MICROPROCESSOR

A system designer using a general-purpose microprocessor such as the

Pentium or the 68040 must add RAM, ROM, I/O ports, and timers externally to

make them functional. Although the addition of external RAM, ROM, and I/O

ports makes these systems bulkier and much more expensive, they have the

advantage of versatility such that the designer can decide on the amount of RAM,

ROM and I/O ports needed to fit the task at hand.

A Microcontroller has a CPU (a microprocessor) in addition to a fixed

amount of RAM, ROM, I/O ports, and a timer all on a single chip. In other words,

the processor, the RAM, ROM, I/O ports and the timer are all embedded together

on one chip; therefore, the designer 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 ports in

Page 8: Traffic Density Based Light Intensity Controller

Microcontrollers makes them ideal for many applications in which cost and in

space are critical.

Page 9: Traffic Density Based Light Intensity Controller

Embedded systems are based on the concept of the microcontroller, a single

integrated circuit that contains all the technology required to run an application.

INTRODUCTION TO 8051

Intel Corporation introduced an 8 bit micro controller called the 8051 in

1981. While the time of introduction, Intel was given some specific features and

particular name as MCS-51

Micro controller is a chip through which we can connect many other devices

and also those are controlled by the program the program which burn into that

chip.

Microcontrollers make integrated systems possible by combining several

features together into what is effectively a complete computer on a chip, including:

Page 10: Traffic Density Based Light Intensity Controller

* Central Processing Unit

* Input/Output interfaces (such as serial ports)

* Peripherals (such as timers)

* ROM, EEPROM or Flash memory for program storage

* RAM for data storage

* Clock generator

By integrating all of these features into a single chip it is possible to greatly

reduce the number of chips and wiring necessary to control an electronic device,

dramatically reducing its complexity, size and cost.

* Size & Weight: Microcontrollers are designed to deliver maximum performance

for minimum size and weight. A centralized on-board computer system would

greatly outweigh a collection of microcontrollers.

* Efficiency: Microcontrollers are designed to perform repeated functions for long

periods of time without failing or requiring service.

AT89S52 MICROCONTROLLER

The AT89S52 is a low-power, high-performance CMOS 8-bit

microcontroller with 8K bytes of in-system programmable Flash memory. The

device is manufactured using Atmel’s high-density nonvolatile memory

technology and is compatible with the industry-standard 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-bit CPU with in-system programmable Flash on a monolithic chip, the

Atmel AT89S52 is a powerful microcontroller which provides a highly-flexible

and cost-effective solution to many embedded control applications.

Page 11: Traffic Density Based Light Intensity Controller

AT89S52

Page 12: Traffic Density Based Light Intensity Controller

Fig: Architecture of 89S52

AT89S52 Architecture consists of these specific features:

8 bit CPU with registers A (Accumulator) and B

16 bit Program Counter(PC) and Data Pointer (DPTR)

8 bit Program Status Word (PSW)

8 bit Stack Pointer (SP)

Internal ROM of 8k

Internal RAM of 128 bytes

Four Register banks each containing eight registers

Page 13: Traffic Density Based Light Intensity Controller

Sixteen bytes, which may be addressed at the bit level

Eighty bytes of general purpose data memory

32 I/O pins arranged as four 8-bit ports: P0,P1,P2,P3

Two 16-bit Timers/Counters: T0 and T1

Full duplex serial data Receiver/Transmitter : SBUF

Control Registers: TCON, TMOD, SCON, SMOD, PCON, IP and IE.

Two external and three internal interrupt sources.

Oscillator and Clock circuits.

8051 PIN CONFIGURATION

Features:-

Page 14: Traffic Density Based Light Intensity Controller

ROM ---- 4 K bytes of Memory

RAM ----- 128 bytes

Timers------2

4 ports --- 32 I/O ports (each 8 bit wide)

Interrupts-----6

Serial port-----1

All on a single chip

Pin Description

Pin (1- 8) Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull ups.

Port 1 pins that have 1s written to them are pulled high by the internal pull ups, and

in that state can be used as inputs. As inputs, port 1 pins that are externally being

pulled low will source current because of the internal pull ups.

Alternate Functions of Port 1 used for In system Programmable

P.5 MOSI --------- Instruction Input

P.6 MISO ---------- Data Output

P.7 SCK ----------- Clk in

Pin 9 Reset:

RESET is an active High input When RESET is set to High, 8051 goes back to the power on state. The 8051 is reset by holding the RST high for at least two machine cycles and then returning it low. Initially charging of capacitor makes RST High, when capacitor charges fully it blocks DC.

Page 15: Traffic Density Based Light Intensity Controller

Pin (10 – 17) Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull ups.

It also serves the functions of various special features of the 80C51 Family as

follows:

Port 3 Pins Alternate Functions

P3.0- RxD (serial input port)

P3.1 -TxD (serial output port)

P3.2 -INT0 (external interrupt 0)

P3.3- INT1 (external interrupt 1)

P3.4 -T0 (timer 0 external input)

P3.5 -T1 (timer 1 external input)

P3.6 -WR (external data memory write strobe)

P3.7 -RD (external data memory read strobe)

Pin 18 XTAL1: Input to the inverting oscillator amplifier.

Crystal Oscillator

Page 16: Traffic Density Based Light Intensity Controller

The 8051 uses the crystal for precisely that: to synchronize it’s operation.

Effectively, the 8051 operates using what are called "machine cycles." A single

machine cycle is the minimum amount of time in which a single 8051 instruction

can be executed. Although many instructions take multiple cycles.  8051 has an on-

chip oscillator. It needs an external crystal that decides the operating frequency of

the 8051. The crystal is connected to pins 18 and 19 with stabilizing capacitors. 12

MHz (11.059MHz) crystal is often used and the capacitance ranges from 20pF to

40pF.

A cycle is, in reality, 12 pulses of the crystal. That is to say, if an instruction

takes one machine cycle to execute, it will take 12 pulses of the crystal to execute.

Since we know the we can calculate how many instruction cycles the 8051 can

execute per second:

11,059,000 / 12 = 921,583

11.0592 MHz crystals are often used because it can be divided to give you exact

clock rates for most of the common baud rates for the UART, especially for the

higher speeds (9600, 19200).

Pin 19 XTAL2: Output from the inverting oscillator amplifier.

Page 17: Traffic Density Based Light Intensity Controller

Pin 20 VSS : Circuit ground potential

Pin (21 – 28) Port 2 : Port 2 is an 8-bit bidirectional I/O port with internal pull

ups. Port 2 emits the high-order address byte during accesses to external memory

that use 16-bit addresses. In this application, it uses the strong internal pull ups

when emitting 1s.

Pin 29 PSEN: Program Store Enable is the read strobe to external Program

Memory. When the device is executing out of external Program Memory, PSEN is

activated twice each machine cycle (except that two PSEN activations are skipped

during accesses to external Data Memory). PSEN is not activated when the device

is executing out of internal Program Memory.

Pin 30 ALE/PROG: Address Latch Enable output pulse for latching the low byte

of the address during accesses to external memory. ALE is emitted at a constant

rate of 1/6 of the oscillator frequency, for external timing or clocking purposes,

even when there are no accesses to external memory. (However, one ALE pulse is

skipped during each access to external Data Memory.) This pin is also the program

pulse input (PROG) during EPROM programming.

Pin 31 EA/VPP: When EA is held high the CPU executes out of internal Program

Memory. Holding EA low forces the CPU to execute out of external memory

regardless of the Program Counter value. In the 80C31, EA must be externally

wired low. In the EPROM devices, this pin also receives the programming supply

voltage (VPP) during EPROM programming.

Pin (32 – 39) Port 0: Port 0 is an 8-bit open drain bidirectional port. As an open

drain output port, it can sink eight LS TTL loads. Port 0 pins that have 1s written to

them float, and in that state will function as high impedance inputs. Port 0 is also

the multiplexed low-order address and data bus during accesses to external

Page 18: Traffic Density Based Light Intensity Controller

memory. In this application it uses strong internal pull ups when emitting 1s. Port 0

emits code bytes during program verification. In this application, external pull ups

are required.

Pin 40 Vcc : Supply voltage

REGISTERS

8051 is a collection of 8 and 16 bit registers and 8 bit memory locations.

These registers and memory locations can be made to operate using the software

instructions. The program instructions control the registers and digital data paths

that are contained inside the 8051, as well as memory locations that are located

outside the 8051.

Register are used to store information temporarily, while the information

could be a byte of data to be processed, or an address pointing to the data to be

fetched. The vast majority of 8051 register are 8-bit registers.

Generally there are two types of registers. They are General purpose Registers

(GPR’s) and Special Function Registers (SFR’s)

TIMER/COUNTERS

The Atmel 80C51 Microcontrollers implement two general purpose, 16-bit

timers/ counters. They can be used either as timers to generate a time delay or as a

counter to count events happening outside the microcontroller. The microcontroller

has two 16-bit wide timers. They are identified as Timer 0 and Timer 1, and can be

independently configured to operate in a variety of modes as a timer or as an event

counter. When operating as a timer, the timer/counter runs for a programmed

length of time, and then issues an interrupt request. When operating as a counter,

the timer/counter counts negative transitions on an external pin. After a preset

Page 19: Traffic Density Based Light Intensity Controller

number of counts, the counter issues an interrupt request. Register pairs (TH0,

TL0), (TH1, TL1), and (TH2, TL2) are the 16-bit counting registers for

Timer/Counters 0, 1, and 2, respectively.

Timer 0 Register

The 16-bit register of Timer 0 is accessed as low byte and high byte. The

low byte register is called TL0 (Timer 0 low byte) and high byte register is referred

to as TH0 (Timer 0 high byte). These registers can be accessed like any other

register, such as A,B,R0,R1,R2,etc.

Timer 1 Register

Timer 1 is also 16-bits, and its 16-bit register is split into two bytes, referred

to as TL1 (Timer 1 low byte) and TH1 (Timer 1 high byte). These registers are

accessible in the same way as the registers of timer 0.

TMOD Register (timer mode)

TMOD: Timer/Counter Mode Control Register

Not Bit Addressable.

Timer 1 Timer 0

GATE : When TRx (in TCON) is set and GATE=1, Timer/CounterX

will run only while INTx pin is high (hardware control). When

GATE=0, Timer/Counter will run only while TRx=1

(software control).

Page 20: Traffic Density Based Light Intensity Controller

C/T : Timer or Counter selector. Cleared for Timer operation (input

from internal system clock). Set for Counter operation (input

from TX input pin).

M1 : Mode selector bit.

M0 : Mode selector bit.

M1 M0 Mode Operating Mode

0 0 0 13-bit Timer (8048 compatible) (TH1)

0 1 1 16-bit Timer/Counter

0 1 2 8-bit Auto-Reload Timer/Counter (TL1).

Reloaded from TH1 at overflow.

1 1 3 Timer 1 halted. Retains count.

1 1 3 (Timer 1) Timer/Counter 1 stopped.

TCON: Timer/Counter Control Register

Bit Addressable.

The upper four bits are used to store the TF and TR bits of both timers 0 and 1.

The lower four bits are set aside for controlling the interrupt pins.

Page 21: Traffic Density Based Light Intensity Controller

TF1 : Timer1 overflow flag. Set by hardware when the Timer/Counter 1

overflows. Cleared by hardware as processor vectors to the interrupt

service routine.

TR1 : Timer 1 run control bit. Set/cleared by software to turn

Timer/Counter 1 ON/OFF.

TF0 : Timer0 overflow flag. Set by hardware when the Timer/Counter 0

overflows. Cleared by hardware as processor vectors to the service

routine.

TR0 : Timer 0 run control bit. Set/cleared by software to turn

Timer/Counter 0 ON/OFF.

IE1 : External Interrupt 1 edge flag. Set by hardware when External

interrupt edge is detected. Cleared by hardware when interrupt is

processed.

IT1 : Interrupt 1 type control bit. Set/cleared by software to specify

falling edge/low level triggered External Interrupt.

IE0 : External Interrupt 0 edge flag. Set by hardware when External

Interrupt edge is detected. Cleared by hardware when interrupt is

processed.

IT0 : Interrupt 0-type control bit. Set/cleared by software to specify

falling edge/low level triggered External Interrupt.

2.5 SERIAL COMMUNICATION

Page 22: Traffic Density Based Light Intensity Controller

The 8051 serial port is full duplex. In other words, it can transmit and receive

data at the same time. Unlike any other register in the 8051, SBUF is in fact two

distinct registers - the write-only register and the read-only register. Transmitted data

is sent out from the write-only register while received data is stored in the read-only

register. There are two separate data lines, one for transmission (TXD) and one for

reception (RXD). Therefore, the serial port can be transmitting data down the TXD

line while it is at the same time receiving data on the RXD line.   The TXD line is pin

11 of the microcontroller (P3.1) while the RXD line is on pin 10 (P3.0)

Serial data communication uses two methods, asynchronous and

synchronous. The synchronous method transfers a block of data (characters) at a time,

while the asynchronous method transfers a single byte at a time. It is possible to write

software to use either of these methods, but the programs can be tedious and long. For

this reason, there are special IC chips made by many manufacturers for serial data

communications. These chips can be commonly referred to as UART (Universal

Asynchronous Receiver-transmitter) and USART (Universal Synchronous

Asynchronous Receiver-Transmitter). The 8051 chip has a built-in UART.

Asynchronous Serial Communication and Data Framing

Start Bits and Stop Bits  

In the asynchronous method is character is placed between start and stop

bits, this is called data framing. In asynchronous communication, at least two extra

bits are transmitted with the data word; a start bit and a stop bit. Therefore, if the

transmitter is using an 8-bit system, the actual number of bits transmitted per word is

ten.   In most protocols the start bit is logic 0 while the stop bit is logic 1. Therefore,

when no data is being sent the data line is continuously HIGH.   The receiver waits for

a 1 to 0 transition. In other words, it awaits a transition from the stop bit (no data) to

Page 23: Traffic Density Based Light Intensity Controller

XTAL oscillator

÷ 12÷ 32

By UART

Machine cycle frequency

28800 Hz

To timer 1 To set the Baud rate

921.6 kHz

11.0592 MHz

Timer 1

the start bit (logic 0). Once this transition occurs the receiver knows a data byte will

follow.   Since it knows the data rate (because it is defined in the protocol) it uses the

same clock as frequency as that used by the transmitter and reads the correct number

of bits and stores them in a register. For example, if the protocol determines the word

size as eight bits, once the receiver sees a start bit it reads the next eight bits and

places them in a buffer. Once the data word has been read the receiver checks to see if

the next bit is a stop bit, signifying the end of the data. If the next bit is not logic 1

then something went wrong with the transmission and the receiver dumps the data.   If

the stop bit was received the receiver waits for the next data word, i.e., it waits for a 1

to 0 transition.

Baud Rates in the 8051

XTAL = 11.0592 MHz

The frequency of system clock = 11.0592 MHz / 12 = 921.6 kHz

The frequency sent to timer 1 = 921.6 kHz/ 32 = 28,800 Hz

Goes out first

Page 24: Traffic Density Based Light Intensity Controller

(a) 28,800 / 3 = 9600 where -3 = FD (hex) is loaded into TH1

(b) 28,800 / 12 = 2400 where -12 = F4 (hex) is loaded into TH1

(c) 28,800 / 24 = 1200 where -24 = E8 (hex) is loaded into TH1

INTERRUPTS :

An interrupt is a special feature which allows the 8051 to provide the

illusion of "multi-tasking," although in reality the 8051 is only doing one thing at a

time. The word "interrupt" can often be substituted with the word "event."

An interrupt is triggered whenever a corresponding event occurs. When the

event occurs, the 8051 temporarily puts "on hold" the normal execution of the

program and executes a special section of code referred to as an interrupt handler.

The interrupt handler performs whatever special functions are required to handle

the event and then returns control to the 8051 at which point program execution

continues as if it had never been interrupted.

Interrupt Service Routine:

For every interrupt, there must be an interrupt service routine (ISR). Or

interrupt handler. When an interrupt is invoked, the microcontroller runs the

interrupt service routine. For every interrupt, there is a fixed location in memory

that holds the address of its ISR. The group of memory locations set aside to hold

the addresses of the ISRs is called interrupt vector table.

Six Interrupts in 8051

Page 25: Traffic Density Based Light Intensity Controller

1. Reset : When the reset pin is activated, the 8051 jumps to address location 0000

2. Two interrupts are set aside for the timers: one for the Timer 0 and one for Timer1.

3. Two interrupts are set aside for hardware external interrupts : one for INT0 and one for INT1

4. Serial communication has a single interrupt that belongs to both receive and transmit.

Enabling Interrupt (IE) Register

All interrupt are disabled after reset .

We can enable and disable them bye IE

EA IE.7 If EA=0, disables all interrupts, no interrupt is acknowledged

If EA=1, each interrupt source is individually enabled or disabled by setting or clearing its enable bit.

-- IE.6 Not implemented, reserved for future use.

ET2 IE.5 Enables or disables Timer2 overflow or capture interrupt

(8052 only)

ES IE.4 Enables or disables the serial port interrupt.

ET1 IE.3 Enables or disables Timer 1 overflow interrupt.

EX1 IE.2 Enables or disables external interrupt 1.

ET0 IE.1 Enables or disables Timer 0 overflow interrupt.

EX0 IE.0 Enables or disables external interrupt 0.

EA -- ET2 ES ET1 EX1 ET0 EX0

Page 26: Traffic Density Based Light Intensity Controller

Interrupt Priority (IP) Register

0= lower priority, 1= higher priority, reset IP=00H

Lower priority ISR can be interrupted by a high priority interrupt.

A high priority ISR can not be interrupted.

Low-priority interrupt wait until 8051 has finished servicing the high-priority interrupt.

-- -- PT2 PS PT1 PX1 PT0 PX0

-- IP.7 Reserved

-- IP.6 Reserved

PT2 IP.5 Timer2 interrupt priority bit (8052 only)

PS IP.4 serial port interrupt priority bit.

PT1 IP.3 Timer 1 interrupt priority bit.

PX1 IP.2 external interrupt 1 priority bit.

PT0 IP.1 Timer 0 interrupt priority bit.

PX0 IP.0 external interrupt 0 priority bit.

Page 27: Traffic Density Based Light Intensity Controller

Building a Power Supply

Most of the circuits in Electronics need a smooth DC power supply in order to function correctly.  Some other circuits, particularly those using digital ICs, also need their power supply to be regulated.  In this article and the articles that follow in this series you will learn the meaning of terms such as 'smoothing' and 'regulation' and find out how to build a simple power supply for your circuits.

What is AC and DC?

A representation of an Alternating Current (AC) supply is shown in figure 1.  The voltage (and current) alternates between positive and negative over time and the resulting waveform shape is a sine wave.  In the case of the UK mains supply, the frequency of this sine wave is 50Hz, or 50 cycles per second.

A Direct Current (DC) supply, shown in figure 2, stays at a fixed, regular, voltage all of the time, like the voltage from a battery.  A DC supply is needed by most circuits as a constant reference voltage.  Also, some components would be damaged by the negative half-cycles of an AC supply.

Page 28: Traffic Density Based Light Intensity Controller

The Parts of a Power Supply

Figure 3 shows a block diagram of a power supply system which converts a 230V AC mains supply (230V is the UK mains voltage) into a regulated 5V DC supply.

A simple power supply circuit that includes each of these blocks in given in figure 4.  The following articles in this series look at each block of the power supply in detail, but if you just want to build a 5V regulated power supply without understanding how it works, you can follow the instructions later in this article.

Page 29: Traffic Density Based Light Intensity Controller

Building the 5V Regulated Power Supply

Figure 5 gives a stripboard layout for the 5V regulated power supply shown in figure 4.  The layout does not include the transformer block, so the input to the board needs to be 7 - 35V AC from a suitable transformer.  The layout includes space for two optional 2-way screw terminal blocks to make connecting up the power supply easier.

If the input voltage is 9V AC, you will be able to draw 1A from the power supply.  For the maximum input voltage of 35V you will be able to draw 0.1A.

Page 30: Traffic Density Based Light Intensity Controller

Construction

1. Cut a piece of stripboard to 13 tracks x 35 columns (assuming the use of the 50mm heatsink given).

2. Drill four 1.5mm holes for the thick legs of the terminal blocks, two 2mm holes for the thick legs of the fuse holder, and two 3mm holes for the heatsink and 7805 bolts.

3. Fit the four wire links.4. Fit the four 1N4001 diodes, taking care that the polarity of each one is

correct.5. Fit the two 0.01μF and the single 470μF capacitors.  Ensure that the polarity

of the 470μF capacitor is correct.  The leads will be marked with '+' or '-'.6. Fit the two terminal blocks.7. Fit the fuse holder and insert the fuse.  Clip the cover over the fuse holder.8. Bolt the heatsink to the board.9. Bend the leads of the 7805 and position it.  Bolt it into place before

soldering the leads to the board.10.Cut the copper tracks where an X is shown.  Cut any tracks under the

heatsink that might short out the 7805 or other stripboard tracks.11.Connect up a 7V - 35V AC power supply and test the circuit by placing

a volt meter across the DC Output terminals.  The voltage should read approximately 5V DC.

The Transformer

Page 31: Traffic Density Based Light Intensity Controller

A suitable ready-built mains power supply unit, such as those used to control model trains, will include a transformer.  I wouldn't recommend building your own due to the safety considerations when dealing with mains voltages.  If such a unit does not incorporate smoothing, rectification, and regulation, then you will need to build these blocks as described in part 1 of this series

If the unit does not have a fuse or a cut-out on the output of the transformer, you will also need to add a fuse of an appropriate rating.  This fuse is in addition

to the mains fuse in the unit's plug and is needed to protect the low voltage winding of the transformer and any circuits you connect to it.

Although we won't be building the transformer block of our 5V regulated power supply, it is interesting to know how it works

How Transformers Work

A transformer consists of two coils (often called 'windings') linked by an iron core, as shown in figure 1. There is no electrical connection between the coils, instead they are linked by a magnetic field created in the core.

Transformers are used to convert electricity from one voltage to another with minimal loss of power. They only work with AC (alternating current) because they require a changing magnetic field to be created in their core. Transformers can increase voltage (step-up) as well as reduce voltage (step-down).

Page 32: Traffic Density Based Light Intensity Controller

Alternating current flowing in the primary (input) coil creates a continually changing magnetic field in the iron core. This field also passes through the secondary (output) coil and the changing strength of the magnetic field induces an alternating voltage in the secondary coil. If the secondary coil is connected to a load the induced voltage will make an induced current flow. The correct term for the induced voltage is 'induced electromotive force' which is usually abbreviated to induced e.m.f.

The iron core is laminated to prevent 'eddy currents' flowing in the core. These are currents produced by the alternating magnetic field inducing a small voltage in the core, just like that induced in the secondary coil. Eddy currents waste power by needlessly heating up the core but they are reduced to a negligible amount by laminating the iron because this increases the electrical resistance of the core without affecting its magnetic properties.

Transformers have two great advantages over other methods of changing voltage:

1. They provide total electrical isolation between the input and output, so they can be safely used to reduce the high voltage of the mains supply.

2. Almost no power is wasted in a transformer. They have a high efficiency (power out / power in) of 95% or more.

The Rectifier

The purpose of a rectifier is to convert an AC waveform into a DC waveform.  There are two different rectification circuits, known as 'half-wave' and 'full-wave' rectifiers.  Both use components called diodes to convert AC into DC.

A diode is a device which only allows current to flow through it in one direction.  In this direction, the diode is said to be 'forward-biased' and the only effect on the signal is that there will be a voltage loss of around 0.7V.  In the opposite direction, the diode is said to be 'reverse-biased' and no current will flow though it.

Page 33: Traffic Density Based Light Intensity Controller

The Half-wave RectifierThe half-wave rectifier is the simplest type of rectifier since it only uses one

diode, as shown in figure 1.

Figure 2 shows the AC input waveform to this circuit and the resulting output.  As you can see, when the AC input is positive, the diode is forward-biased and lets the current through.  When the AC input is negative, the diode is reverse-biased and the diode does not let any current through, meaning the output is 0V.  Because there is a 0.7V voltage loss across the diode, the peak output voltage will be 0.7V less than Vs.

Page 34: Traffic Density Based Light Intensity Controller

While the output of the half-wave rectifier is DC (it is all positive), it would not be suitable as a power supply for a circuit.  Firstly, the output voltage continually varies between 0V and Vs-0.7V, and secondly, for half the time there is no output at all. 

The Full-wave Rectifier

The circuit in figure 3 addresses the second of these problems since at no time is the output voltage 0V.  This time four diodes are arranged so that both the positive and negative parts of the AC waveform are converted to DC.  The resulting waveform is shown in figure 4.

Page 35: Traffic Density Based Light Intensity Controller

When the AC input is positive, diodes A and B are forward-biased, while diodes C and D are reverse-biased.  When the AC input is negative, the opposite is true - diodes C and D are forward-biased, while diodes A and B are reverse-biased.

One disadvantage of the full-wave rectifier is that there is a voltage loss of 1.4V across the diodes.  Why not 2.8V as there are four diodes?  Remember that only two of the diodes are passing current at any one time!

While the full-wave rectifier is an improvement on the half-wave rectifier, its output still isn't suitable as a power supply for most circuits since the output voltage still varies between 0V and Vs-1.4V.  So, if you put 12V AC in, you will 10.6V DC out.

The Regulator

Page 36: Traffic Density Based Light Intensity Controller

While there are many circuits that will tolerate a smoothed power supply, some must have a completely regular supply with no ripple voltage.  This article discusses regulator ICs which can provide this regular power supply.

The 78xx Series of Regulators

There are many types of regulator IC and each type will have different pin-outs and will need to be connected up slightly differently.  Therefore, this article will only look at one of the common ranges of regulator, the 78xx series.

There are seven regulators in the 78xx series, and each can pass up to 1A to any connected circuit.  There are also regulators with similar type numbers that can pass a higher or lower current, as shown in the table below.  In addition, variable regulators are available, as are regulators that can provide negative regulation voltages for circuits that require them.

Type Number

   Regulation Voltage

   Maximum Current

   Minimum Input Voltage

78L05 +5V 0.1A +7V

78L12 +12V 0.1A +14.5V

78L15 +15V 0.1A +17.5V

Ripple VoltageIf you are using a regulator after the smoothing block of the power supply,

then you shouldn't need to worry about the ripple voltage, since the whole point of using a regulator is to get a stable, accurate, known voltage for your circuits! 

Page 37: Traffic Density Based Light Intensity Controller

However, if the ripple voltage is too large and the input voltage to the regulator falls below the regulated voltage of the regulator, then of course the regulator will not be able to produce the correct regulated voltage.  In fact, the input voltage to a regulator should usually be at least 2V above the regulated voltage.  In our power supply circuit, the input to the 7805 regulator is around 12V, and the regulation voltage is 5V, so there is plenty of headroom.  The maximum input voltage to any 78xx regulator is 30V.

78xx Pin-outThe 78xx, 78Mxx, and 78Sxx regulators all have the pin-out shown in the

left of figure 1 and are normally supplied in a case style known as TO-220.  The 78Lxx series, shown in the right of figure 1, also has the same pin-out but has a case style known as TO-92.  They are all connected to the rest of the power supply in the same way, as shown in figure 2.

HeatsinksIn use, a regulator IC will get quite hot, so a heatsink will need to be

attached to it to dissipate the heat.  The type of heatsink you choose depends on

Page 38: Traffic Density Based Light Intensity Controller

the regulator's case style, the amount of heat it must dissipate, and the way in which you wish to mount it.

IR SENSOR:-

IR remote controls use wavelengths between 850 - 950nm. At this short

wavelength, the light is invisible to the human eye, but a domestic camcorder can

actually view this portion of the electromagnetic spectrum. Viewed with a

camcorder, an IR LED appears to change brightness.

All remote controls use an encoded series of pulses, of which there are

thousands of combinations. The light output intensity varies with each remote

control, remotes working at 4.5V DC generally will provide a stronger light output

than a 3V dc control. Also, as the photodiode in this project has a peak light

response at 850nm, it will receive a stronger signal from controls

operating closer to this wavelength. The photodiode will actually respond to IR

wavelengths from 400nm to 1100nm, so all remote controls should be compatible.

A sensor is a type of transducer, or mechanism that responds to a type of

energy by producing another type of energy signal, usually electrical. They are

either direct indicating (an electrical meter) or are paired with an indicator (perhaps

indirectly through an analog to digital converter, a computer and a display) so that

the value sensed is translated for human understanding. Types of sensors include

electromagnetic, chemical, biological and acoustic. Aside from other applications,

Page 39: Traffic Density Based Light Intensity Controller

sensors are heavily used in medicine, industry & robotics.

In order to act as an effectual sensor, the following guidelines must be met:

the sensor should be sensitive to the measured property

the sensor should be insensitive to any other property

the sensor should not influence the measured property

In theory, when the sensor is working perfectly, the output signal of a sensor

is exactly proportional to the value of the property it is meant to measure. The gain

is then defined as the ratio between output signal and measured property. For

example, if a sensor measures temperature and has an actual voltage output, the

gain is a constant with the unit.

When the sensor is not perfect, various deviations can occur, including gain

error, long term drift, and noise. These and other deviations can be classified as

systematic, or random, errors. Systematic deviations may be compensated for by

means of some kind of calibration strategy. Noise is an example of a random error

that can be reduced by signal processing, such as filtering, usually at the expense

of the dynamic behavior of the sensor.

A sensor network is a computer network of spatially distributed devices using

sensors to monitor conditions (such as temperature, sound, vibration, pressure,

motion or pollutants) at a variety of locations. Usually the devices are small and

inexpensive, allowing them to be produced and deployed in large numbers; this

constrains their resources in terms of energy, memory, and computational speed

and bandwidth. Each device is equipped with a radio transceiver, a small micro

controller, and an energy source, most commonly a battery. The devices work off

each other to deliver data to the computer which has been set up to monitor the

information. Sensor networks involve three areas: sensing, communications, and

Page 40: Traffic Density Based Light Intensity Controller

computation (hardware, software, algorithms). They are applied in many areas,

such as video surveillance, traffic monitoring, home monitoring and

manufacturing.

Technical specifications:-

Supply : 5V

Power consumption : 0.4 to 1.0 mA

Min. IR radiation : 0.35 mW/m2 typ.

Angle of detection : 90

Dimensions of the casing (mm) : 12.5 x 10 x Thickness 5.8

Temperature range : 25 C to +85

Astable 555 Oscillator

Page 41: Traffic Density Based Light Intensity Controller

The 555 OscillatorWe can connect the 555 timer IC in its Astable mode to produce a very

stable 555 Oscillator circuit for generating highly accurate free running waveforms whose output frequency can be adjusted by means of an externally connected RC tank circuit consisting of just two resistors and a capacitor.

The 555 Oscillator is another type of relaxation oscillator for generating stabilized square wave output waveforms of either a fixed frequency of up to 500kHz or of varying duty cycles from 50 to 100%. In order to get the 555 Oscillator to operate as an Astable Multivibrator, it is necessary to continuously re-trigger the 555 IC after each and every timing cycle. This is basically achieved by connecting the Trigger input (pin 2) and the Threshold input (pin 6) together,

Page 42: Traffic Density Based Light Intensity Controller

thereby allowing the device to act as an astable oscillator. Then the 555 Oscillator has no stable states as it continuously switches from one state to the other.

In the 555 Oscillator above, pin 2 and pin 6 are connected together allowing the circuit to re-trigger itself on each and every cycle allowing it to operate as a free running oscillator. During each cycle capacitor, C charges up through both timing resistors, R1 and R2 but discharges itself only through resistor, R2 as the other side of R2 is connected to the Discharge terminal, pin 7. Then the capacitor charges up to 2/3Vcc (the upper comparator limit) which is determined by the 0.693(R1+R2)C combination and discharges itself down to 1/3Vcc (the lower comparator limit) determined by the 0.693(R2.C) combination. This results in an output waveform whose voltage level is approximately equal to Vcc - 1.5V and whose output "ON" and "OFF" time periods are determined by the capacitor and resistors combinations. The individual times required to complete one charge and discharge cycle of the output is therefore given as:

Astable 555 Oscillator Charge and Discharge Times:

 

Where, R is in Ω's and C in Farads.

When connected as an Astable Multivibrator, the output from the 555 Oscillator will continue indefinitely charging and discharging between 2/3Vcc and 1/3Vcc until the power supply is removed. As with the Monostable Multivibrator these charge and discharge times and therefore the frequency are independent of the supply voltage.

The duration of one full cycle is therefore equal to the sum of the two individual times that the capacitor charges and discharges added together and is given as:

555 Oscillator Total Time Period:

Page 43: Traffic Density Based Light Intensity Controller

 

The output frequency of oscillations can be found by inverting the equation above for the total cycle time giving a final equation for the output frequency of an Astable 555 Oscillator as:

555 Oscillator Frequency Equation

 

Transmitter circuit:-

Page 44: Traffic Density Based Light Intensity Controller

For maximum effect, over 60 milliamps pulses through the infrared LED. Adjust R3 as appropriate for your use and LED specifications.

When calculating current through the resistor, don't forget to first subtract the voltage drop across the LED and transistor. Let's say the LED uses 1.8 V (1.6 V to 2.2 V wouldn't be unheard of). Let's say the collector-emitter drop of the transistor uses 0.2 V.

5 V (total) - 1.8 V (LED) - 0.2 V (transistor) = 3 V remaining to drop across the resistor.

3 V / 47 ohms is about 64 mA. Because there's only one path, the current going through the resistor must be the same as what's going through the LED.Now for the other trick: the word "pulses". The LED is only on half the time because it is blinking. If you use an ohmmeter, the average current is 32 mA (half).Aside: The LED heats up faster than it cools off. As such, it's not possible to drive 100 mA through a 50 mA LED even though the average current is half. Depending on ambient temperatures, it's usually safe to drive only 125% or 133% of rated maximum at 50% duty. With smaller duty cycles and frequent pauses, it's possible to drive a lot more current in very short bursts.

Theoretical frequency can be calculated by:

f= 1/(1.4 RC)

where f is frequency in kilohertz, R is resistance in kilohms, and C is capacitance in microfarads.

38 kilohertz = 1/(1.4 * 18.7969 kilohms * 0.001 microfarads)

Page 45: Traffic Density Based Light Intensity Controller

IR sensor TSOP 1738:

Receiver circuit :

Description:-

The TSOP1738 Series are miniaturized receivers for infrared

remote control systems. PIN diode and preamplifier are assembled on lead frame,

the epoxy package is designed as IR filter. The demodulated output signal can

directly be decoded by a microprocessor. TSOP1738 is the standard IR remote

control receiver series, supporting all major transmission codes.

Page 46: Traffic Density Based Light Intensity Controller

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 ( 5 V output (active at level 0)).

Low power consumption.

High immunity against ambient light.

Continuous data transmission possible (up to 2400 bps).

Suitable burst length:-10 cycles/burst.

Receives and amplifies the infrared signal without any external component.

38 kHz integrated oscillator.

High sensitivity.

Improved shielding against electrical field interference.

Applications: infrared remote control.

Suitable Data Format:-

The circuit of the TSOP1738 is designed in that way that unexpected output

pulses due to noise or disturbance signals are avoided. A band pass filter, an

integrator stage and an automatic gain control are used to suppress such

disturbances. The distinguishing mark between data signal and disturbance signal

are carrier frequency, burst length and duty cycle. The data signal should fulfill the

following condition:-

Carrier frequency should be close to center frequency of the band pass (e.g.

38 kHz).

Page 47: Traffic Density Based Light Intensity Controller

Burst length should be 10 cycles/burst or longer.

After each burst which is between 10 cycles and 70cycles a gap time of at

least 14 cycles is necessary.

For each burst, which is longer than 1.8ms, a corresponding gap time is

necessary at some time in the data stream.

This gap time should have at least same length as the burst.

Up to 1400 short bursts per second can be received continuously.

Some examples for suitable data format are:-

NEC Code,

Toshiba Micom Format,

Sharp Code,

RC5 Code,

RC6 Code,

R–2000 Code,

Sony Format (SIRCS).

When a disturbance signal is applied to the TSOP17_ _, it can still receive

the data signal. However the sensitivity is reduced to that level that no unexpected

pulses will occur. Some examples for such disturbance signals which are

suppressed by the TSOP1738 are:-

DC light (e.g. from tungsten bulb or sunlight)

Continuous signal at 38 kHz or at any other frequency signals from

fluorescent lamps

Page 48: Traffic Density Based Light Intensity Controller

LIGHT-EMITTING DIODE:

A light-emitting diode(LED) is an electronic light source. LEDs are based on the semiconductor diode. When the diode is forward biased (switched on), electrons are able to recombine with holes and energy is released in the form of light. This effect is called electroluminescence and the color of the light is determined by the energy gap of the semiconductor. The LED is usually small in area (less than 1 mm2) with integrated optical components to shape its radiation pattern and assist in reflection. All early devices emitted low-intensity red light, but modern LEDs are available across the visible, ultraviolet and infra red wavelengths, with very high brightness.

Page 49: Traffic Density Based Light Intensity Controller

Fig: parts of led Fig: inner working of an led

Like a normal diode, the LED consists of a chip of semiconducting material impregnated, or doped with impurities to create a p-n junction. As in other diodes, current flows easily from the p-side, or anode, to the n-side, or cathode, but not in the reverse direction. Charge-carriers—electrons and holes—flow into the junction from electrodes with different voltages. When an electron meets a hole, it falls into a lower energy level, and releases energy in the form of a photon.

LEDs are usually built on an n-type substrate, with an electrode attached to the p-type layer deposited on its surface. P-type substrates, while

Fig: Electronic symbol of an LED

Page 50: Traffic Density Based Light Intensity Controller

less common, occur as well. Many commercial LEDs, especially GaN/InGaN, also use sapphire substrate.

Most materials used for LED production have very high refractive indices. This means that much light will be reflected back in to the material at the material/air surface interface. Therefore light extraction in LEDs is an important aspect of LED production, subject to much research and development.

LED parameters

Apart from the LED colour, there are several other specifications and parameters that can be seen in the specification sheets.

Angle:   This is the width of the beam of light produced by the LED and measured in degrees

Intensity:   The output or brightness of the LED is also a key performance parameter. The actual light output is measured in mcd or milli-candela for a particular current.

Wavelength: The wavelength refers to the wavelength of the light emitted from the LED. It is measured in nanometres (nm) and obviously the wavelength will govern the actual colour. In most cases it is sufficient just to refer to the colour.

Current Consumption:   The amount of current to be consumed by the LED is an important parameter for the circuit design. While the level of current is normally stated in the data sheets, for ordinary indicator LED lamps used in many electronics projects a figure of 20 mA is taken as standard, especially if no figure is mentioned.

Types

Page 51: Traffic Density Based Light Intensity Controller

LEDs are produced in a variety of shapes and sizes. The 5 mm cylindrical package (red, fifth from the left) is the most common, estimated at 80% of world production. The color of the plastic lens is often the same as the actual color of light emitted, but not always. For instance, purple plastic is often used for infrared LEDs, and most blue devices have clear housings.

LED connections

Like any diode LEDs must be fitted into a circuit with the correct orientation. To operate, a LED must have current flowing through it, and this can only happen if it is forward biased. In the reverse direction no current will flow. Also if a LED has a high reverse voltage placed across it, then it can easily blow.

The two connections for a LED are denoted by a for the anode which is positive (+), and K for the cathode which is negative (-).For the small indicator LED lamps that are often used in electronics equipment and electronics projects the cathode (k) usually has a shorter lead and there may a slight flat on the body of cylindrical LEDs. Sometimes it is possible to see inside the LED and again the cathode normally has the larger electrode.

Advantages

Efficiency: LEDs produce more light per watt than incandescent bulbs. C

Color: LEDs can emit light of an intended color without the use of color filters that traditional lighting methods require. This is more efficient and can lower initial costs.

On/Off time: LEDs light up very quickly. A typical red indicator LED will achieve full brightness in microseconds. LEDs used in communications devices can have even faster response times.

Cycling: LEDs are ideal for use in applications that are subject to frequent on-off cycling, unlike fluorescent lamps that burn out more quickly when cycled frequently, or HID lamps that require a long time before restarting.

Lifetime: LEDs can have a relatively long useful life. One report estimates 35,000 to 50,000 hours of useful life, though time to complete failure may be longer.Fluorescent tubes typically are rated at about

Page 52: Traffic Density Based Light Intensity Controller

10,000 to 15,000 hours, depending partly on the conditions of use, and incandescent light bulbs at 1,000–2,000 hours.

Shock resistance: LEDs, being solid state components, are difficult to damage with external shock, unlike fluorescent and incandescent bulbs which are fragile.

Disadvantages

Temperature dependence: LED performance largely depends on the ambient temperature of the operating environment. Over-driving the LED in high ambient temperatures may result in overheating of the LED package, eventually leading to device failure. Adequate heat-sinking is required to maintain long life.

Voltage sensitivity: LEDs must be supplied with the voltage above the threshold and a current below the rating. This can involve series resistors or current-regulated power supplies.

Light quality: Most cool-white LEDs have spectra that differ significantly from a black body radiator like the sun or an incandescent light. However, the color rendering properties of common fluorescent lamps are often inferior to what is now available in state-of-art white LEDs.

Area light source: LEDs do not approximate a “point source” of light, but rather a lambertian distribution. So LEDs are difficult to use in applications requiring a spherical light field. LEDs are not capable of providing divergence below a few degrees.

Applications

Applications of LEDs are diverse. They are used as low-energy indicators but also for replacements for traditional light sources in general lighting and automotive lighting. The compact size of LEDs has allowed new text and video displays and sensors to be developed, while their high switching rates are useful in communications technology.

The first commercial LEDs were commonly used as replacements for incandescent indicators, and in seven-segment displays, first in expensive equipment such as laboratory and electronics test equipment, then later in such appliances as TVs, radios, telephones, calculators, and even watches.

Page 53: Traffic Density Based Light Intensity Controller

The many application of LEDs are very diverse but fall into three major categories: Visual signal application where the light goes more or less directly from the LED to the human eye, to convey a message or meaning. Illumination where LED light is reflected from object to give visual response of these objects. Finally LEDs are also used to generate light for measuring and interacting with processes that do not involve the human visual system.

Indicators and signs:

LED digital display that can display 4 digits along with points.

Traffic light using LED

LED lights used as Street lights

Page 54: Traffic Density Based Light Intensity Controller

A large LED display behind a disc jockey.

LED s using as lights at shopping malls

The low energy consumption, low maintenance and small size of modern LEDs has led to applications as status indicators and displays on a variety of equipment and installations. Large area LED displays are used as stadium displays and as dynamic decorative displays. Thin, lightweight message displays are used at airports and railway stations, and as destination displays for trains, buses, trams, and ferries.

Because of their long life and fast switching times, LEDs have been used for automotive high-mounted brake lights and truck and bus brake lights and turn signals for some time, but many high-end vehicles are now starting to use LEDs for their entire rear light clusters. The use of LEDs also has styling advantages

Page 55: Traffic Density Based Light Intensity Controller

because LEDs are capable of forming much thinner lights than incandescent lamps with parabolic reflectors.

Sustainable Lighting

Efficient lighting is needed for sustainable architecture. A 13 watt LED lamp produces 450 to 650 lumens which is equivalent to a standard 40 watt incandescent bulb. A standard 40 W incandescent bulb has an expected lifespan of 1,000 hours while an LED can continue to operate with reduced efficiency for more than 50,000 hours, 50 times longer than the incandescent bulb.

LEDs are also non-toxic unlike the more popular energy efficient bulb option: the compact florescent a.k.a. CFL which contains traces of harmful mercury. While the amount of mercury in a CFL is small, introducing less into the environment is preferable.

LEDs have also been used as a medium quality voltage reference in electronic circuits. The forward voltage drop (e.g., about 1.7 V for a normal red LED) can be used instead of a Zener diode in low-voltage regulators. Although LED forward voltage is much more current-dependent than a good Zener, Zener diodes are not widely available below voltages of about 3 V.

LED elements tend to be small and can be placed with high density over flat or even shaped substrates (PCBs etc) so that bright and homogeneous sources can be designed which direct light from tightly controlled directions on inspected parts. This can often be obtained with small, inexpensive lenses and diffusers, helping to achieve high light densities with control over lighting levels and homogeneity. LED sources can be shaped in several configurations (spot lights for reflective illumination; ring lights for coaxial illumination; back lights for contour illumination; linear assemblies; flat, large format panels; dome sources for diffused, omnidirectional illumination).

These Leds now a days using at every where for many applications. Group of LEDs are using now a days instead of bulbs or lights in real time.

Page 56: Traffic Density Based Light Intensity Controller

Software Implementation:

Life cycle of a microcontroller project

Before passing to the next part of the tutorial, is important to have a general idea of the steps that are followed to realize a project, from the very beginning when you get an idea to the very end when you finalize your project.

As you can see in figure 1.5.A, after you settle on the choice of your project in the 'brain storming' part, its imperative to imagine how it can be implemented from the hardware point of view, before passing to the programming phase, because programming is much more flexible than the hardware design. In other words, you start by designing the hardware, then you work on the programming while taking in consideration the eventual constraints imposed by the hardware design.

Page 57: Traffic Density Based Light Intensity Controller

Figure 1.5.A

The hardware design includes all the aspects of the electronic connections between other devices, like the compatibility of the voltage levels, or the required number of pins, etc...

After you're done with a first version of your program, you can transfer it to the microcontroller mounted on the board that you realized already, resulting in a first prototype. The transfer of the code is done using a special device called 'burner' or 'programmer' that connect to the computer, reads the HEX file generated by the compiler, and sends it to the 'program memory' of the microcontroller. The prototype will be used to test your project, correct eventual errors and enhance its performance, tacking in account the famous rule that states that any project never works the first time, at least it does not work as you expected!

Your project will always stay in the prototyping cycle, even if you decide that it is functioning correctly, simply because perfect machines or inventions do not exist, so there is always some room for little changes and updates.

From the C program to the machine language

The C source code is very high level language, meaning that it is far from being at the base level of the machine language that can be executed by a processor. This machine language is basically just zero's and one's and is written in Hexadecimal format, that why they are called HEX files.

Page 58: Traffic Density Based Light Intensity Controller

There are several types of HEX files; we are going to produce machine code in the INTEL HEX-80 format, since this is the output of the KEIL IDE that we are going to use. Figure 2.1.A shows that to convert a C program to machine language, it takes several steps depending on the tool you are using, however, the main idea is to produce a HEX file at the end. This HEX file will be then used by the 'burner' to write every byte of data at the appropriate place in the EEPROM of the 89S52.

figure 2.1.A

Using the KEIL environment

KEIL uVision is the name of a software dedicated to the development and testing of a family of microcontrollers based on 8051 technology, like the 89S52 which we are going to use along this tutorial.

Using Proload Software:

This Proload software is used to dump the hexcode file created by KEIL copiler in the system into the Microcontroller ,which we are using in the project.

PROGRAM:

#include<reg51.h> /*include the library file for 8051*/

Page 59: Traffic Density Based Light Intensity Controller

sfr led = 0x80; /*declare a name for port 0*/

sbit IR=P2^1; /*name for pin P2.1*/

sbit test = P2^0; /*name for P2.0*/

unsigned char i=0; /*declaring a global variable i*/

void timer(void) interrupt 1 /*interrupt service routine for timer0

interrupt*/

{

TR0 = 0; /*stop Timer0 */

TH0 = 0x00; /*load hexadecimal value 00 in to TH0*/

TL0 = 0x00; /*load hexadecimal value 00 in to TL0*/

i = i+1; /*increment i by 1*/

test = ~test; /*compliment pin "test"*/

TF0 = 0; /*clear timer0 flag*/

TR0 = 1; /*start timer 0*/

}

void delay(void) /*delay function */

{

int i,j; /*declare variables i and j*/

for(i=0;i<=10;i++) /*for loop for 10 times*/

for(j=0;j<=1000;j++); /*another loop which rotates for 1000 times*/

}

Page 60: Traffic Density Based Light Intensity Controller

void main(void) /*start of main program*/

{

Unsigned int a=0; /*declare an int type of variable*/

TMOD = 0x01; /*set timer 0 in mode 1*/

TH0 = 0x00; /*load hexadecimal value 00 in to TH0*/

TL0 = 0x00; /*load hexadecimal value 00 in to TL0*/

TR0 = 1; /*start timer 0*/

IE = 0x82; /*load 10000010 value in IE register*/

test = 0; /*clear test pin*/

led = 0x00; /*make all pins of port0 to 0*/

IR = 1; /*make IR pin as input*/

while(1) /*entering in to a continuous while loop*/

{

peak: IE = 0x82; /*load 10000010 value in IE register*/

while(i<=150) /*while loop for 150 times timer interrupt

generated*/

{

if(IR==0) /*if IR sensor detects obstacle*/

{

delay(); /*calls the delay function*/

a=a+1; /*if vehicle passes count increases*/

}

Page 61: Traffic Density Based Light Intensity Controller

}

IE =0x00; /*disables all interrupts*/

if(a>=30) /*if density is more than 30*/

{

led = 0x0F; /*turn on all the lights */

a=0; /*clear the variable a*/

i=0; /*clear the variable i*/

goto peak; /*go to the lable "peak"*/

}

else if(a<=10) /*if density is less than 10*/

{

led = 0x03 ; /*turn on only two lights*/

a=0; /*clear the variable a*/

i=0; /*clear the variable i*/

goto nonpeak; /*go to the lable "nonpeak"*/

}

nonpeak: IE = 0x82;

while(i<=50)

{

if(IR==0)

{

delay();

a=a+1;

Page 62: Traffic Density Based Light Intensity Controller

}

}

IE =0x00;

if(a>=15)

{

led = 0x0F;

a=0;

i=0;

goto peak;

}

else if(a<=10)

{

led = 0x03;

a=0;

i=0;

goto nonpeak;

}

}

}

BLOCK DIAGRAM:

Page 63: Traffic Density Based Light Intensity Controller

AT89S52 IR Rx IR Tx

Power supply

Line driver

light

light

light

OPERATION OF THE PROJECT:

An IR Sensor will be having an IR transmitter, and IR receiver. The IR Transmitter will transmit the IR rays, if these are not received by IR Receiver. Then it will be noticed that an obstacle will be detected on the path of IR rays. This indicaton will be given as input to the micro controller. Whenever, this happens, the micro controller will increment the count of the no. of vehicles that are detected by IR sensors.

The total value of count of no. Of vehicles will be used to decide the light intensity of the street light. When the traffic is more i.e., at peak levels, the count of no. Of vehicles will be maximum, hence the lights will glow with maximum intensity. The count will be checked for every 10 seconds at maximum level of traffic. When the traffic is less i.e., at non-peak level of traffic, the count of no. of

Page 64: Traffic Density Based Light Intensity Controller

vehicles will be less, this will be taken as input to control the intensity of lights and hence, the lights will glow with minimum intensity. Here, i.e., at non peak levels, the count will be checked for every 4 seconds of time.

APPLICTIONS:

This system is mainly designed, to apply this in real time power saving applications in street lights, to reduce the power consumption unnecessarily.

ADVANTAGES:

Here, in this system we are using the IR sensors and array of Led’s, interfaced with a micro controller. Very less no. of components are using here, occupies less space and hence in real time application easily applicable very efficiently.

DRAW BACK:

Whenever the vehicles pass with very high speed on the road, the JR Sensor can’t detect the vehicles, the reason is that the JR ray breakdown in its path can’t be identified.

Remedy: Whenever we use high strengthened IR Sensors which produce high quality of IR rays, if the received voltage level is by IR receiver has minute change. Then the original voltage value that has to be received, also can be identified

CONCLUSION:

The “Traffic Density Based Light Intensity Controller”has been developed by integrating all the hardware components and software embedded using Keil software and Proload.

FUTURE ENHANCEMENT:

Page 65: Traffic Density Based Light Intensity Controller

The “traffic density based light intensity controller” is developed for reducing the power consumption and to save it. However it can be enhanced in such a way that, by calculating the particular time intervals and by interfacing integrated real time clock to micro controller, we can change the intensity of the lights time to time.

In another way, by calculating the percentage of Carbon Monoxide (CO) released by vehicles in particular area, we can measure the traffic density present in that area and with respect to that we can change the intensity of the lights.

For the above project, by using Relays we can control normal lights which are operating with ac voltage(230v).


Recommended