Anda di halaman 1dari 77

1

ABSTRACT

This project deals with the control of traffic for an ambulance, it analyses the
number of vehicles passing in every track in order to the intelligent for existing
traffic light controller and through GSM it sends message to the user. In the present,
it is seen that lot of time is getting wasted due to fixed time limit which is flexible in
lanes with more traffic density and also it is problem for emergency cases like
ambulance. Due to wastage of time there may be loss. Now by this project we can
save time of the people by continuously monitoring the vehicles passing on the
road. This monitoring is done thought 24 hours in a timeslot of 15 to 30 s after
every time slot.

The monitoring task is performed by based on the IR sensors. IR Transmitter


is placed over the ambulance. IR Receivers placed in four sides of traffic lights.
When the vehicle crosses the target location the receiver receives IR signal it will
interrupt the Micro controller and it stop all Green signals and on Red signals at the
same time it will on green signal at the ambulance side to allow the ambulance to
move without waiting in signals. After ambulance gone microcontroller reset and
works in normal function. Also these IR pairs linked to the GSM modem sends a
message to the user about the density of the traffic on respected sides.
Title of the project : Microcontroller based intelligent ambulance

traffic controller and Navigation

Domain : Embedded Systems Design

Software : Embedded C, Keil c,

Microcontroller : AT89c52

Power Supply : +5V, 500mA Regulated Power Supply

Display : LED 5mm, 16 X 2 LCD

Crystal : 11.0592MHz

Communication Device : IR sensors, GSM modem

Applications : Traffic Signals

1
2

CONTENTS

Chapters

1. Introduction
2. Overview Embedded Systems
2.1 What Is System?
2.2 Embedded System
2.3 Life Cycle
2.4 Software Design and Working of Embedded Systems
3. Block diagram and its brief description
3.1 Block Diagrams
3.2 Circuit description
3.3IC’s
3.31 AT 89c52
3.32 ULN 2008
3.33 555 Timer
3.4 Infrared led’s
3.5 Power supply description
3.6 Transistors
3.7 Resistors & Capacitor
4. Software Description and Project Code
4.1 Software Description
4.2 Project Code
5.Advantages & Limitations

6. Applications

7. Conclusion and further scope

2
3

Introduction
This project deals with the control of traffic for an ambulance, it analyses the
number of vehicles passing in every track in order to the intelligent for existing
traffic light controller and sending message to the user. In the present, it is seen that
lot of time is getting wasted due to fixed time limit which is flexible in lanes with
more traffic density and also it is problem for emergency cases like ambulance. Due
to wastage of time there may be loss. Now by this project we can save time of the
people by continuously monitoring the vehicles passing on the road. This
monitoring is done thought 24 hours in a timeslot of 15 to 30 s after every time slot.

The monitoring task is performed by based on the IR sensors. IR Transmitter


is placed over the ambulance. IR Receivers placed in four sides of traffic lights.
When the vehicle crosses the target location the receiver receives IR signal it will
interrupt the Micro controller and it stop all Green signals and on Red signals at the
same time it will on green signal at the ambulance side to allow the ambulance to
move without waiting in signals. After ambulance gone microcontroller reset and
works in normal function.

Title of the project : Microcontroller based intelligent ambulance

traffic controller.

Domain : Embedded Systems Design

Software : Embedded C, Keil c,

Microcontroller : AT89c52

Power Supply : +5V, 500mA Regulated Power Supply

Display : LED 5mm, 16 X 2 LCD

Crystal : 11.0592MHz

Communication Device : IR sensors & GSM modem

Applications : Traffic Signals,

3
4

Overview Embedded Systems


2.1 What Is A System?

A Systems Is Something That Maintains Its Existence And Functions


As A Whole Through The Interaction Of Its Parts. E.G. Body, Mankind, Access
Control, Etc

A System Is A Part Of The World That A Person Or Group Of Persons


During Some Time Interval And For Some Purpose Choose To Regard As A
Whole, Consisting Of Interrelated Components, Each Component Characterized By
Properties That Are Selected As Being Relevant To The Purpose.

System Constituents

2.2 Embedded System:

We Can Define An Embedded System As “A Computing Device, Built In

To A Device That Is Not A Computer, And Meant For Doing Specific Computing

Tasks”.

An Embedded System Is A Special-Purpose Computer System Usually Built Into A


Environment Connected To Systems Through Sensors , Actuators And Other I/O

4
5

Interfaces.Embedded System Must Meet Timing & Other Constraints Imposed On


It By Environment

Typical Embedded System


Technically, There Are Prevalent And Common Characteristics Of
Embedded Systems. From A Programmer's Perspective The Following Components
Are Minimum: Central Processing Unit (Cpu), Random Access Memory (Ram),
Programmable Read Only Memory (Prom) Or Erasable Prom (Eprom), And
Input/Output (I/O) Space.

Micro-Processor:
The Cpu Is A Unit That Centrally Fetches And Processes A Set Of General
Purpose Instructions. The Cpu Instruction Set Includes Instructions For Data
Transfer Operations, Alu Operations, Stack Operations, I/P &O/P Operations And
Program Control Sequencing And Supervising Operations. Any Cpu Must Process
The Following Basic Functionality Units:

1. A Control Unit To Fetch And Control The Sequential Processing Of Given


Commands Or Instruction And For Communicating With The Rest Of The System.

2. An Alu For The Arithmetic And Logic Operations On The Bytes Or Words. It
May Be Capable Of Processing 8,16,32or 64-Bit Words At An Instant.

5
6

3. A Microprocessor Is A Single Vlsi Chip That Has A Chip And May Also Have
Some Other Units That Are Additionally Present And That Result In Faster
Processing Of Instructions.

Microcontroller:
A Microcontroller Is A Single Chip Vlsi Unit (Also Called Microcomputer)
Which Though Having Limited Computational Capabilities Posses An Enhanced
I/P, O/P Capabilities And A Number Of On-Chip Functional Units Micro-
Controllers Are Particularly Suited For Use In Embedded Systems For Real Time
Applications With On-Chip Program Memory And Devices.

2.3 Life Cycle


Requirements
Finalize the Functional Requirement of the System That Has To Be Implemented

Analysis:
Analyze the Requirements and Finalise the System Requirements

Design:

6
7

Based On The Requirements Design The System.

Hardware :
Proteus
Software

Implementation:
Based On The Hardware Design Make The Layout Of The Pcb And Design The
Routing
Get The Pcb Fabricated
Mount The Components On To The Pcb

Programming:
Use The Designated Tools For Programming The Microcontroller Or Processor
Whichever Is Selected
Atmel
Kiel ‘C’- Compiler
Uc Flash Programmer

Microchip :
Mplab Ide
Icd2
Atmel
GSM
Jtag / Flash Programmer

Testing/Debugging:

Hardware Debugging
Software Debugging
Functionality Test

7
8

Packaging/Implementation
Mount The Module Into The Designed Enclosure
Install The Designed System In The Required Application Area

The Essence
An Embedded
System Is A

8
9

Microcontroller-Based, Software Driven, Reliable, Real-Time Control System,


Autonomous, Or Human Or Network Interactive, Operating On Diverse Physical
Variables And In Diverse Environments And Sold Into A Competitive And Cost
Conscious Market.

2.4 Software Design and Working of Embedded Systems:


In The Design Of The Software, It Simply Has A Loop Called
Control Loop. The Loop Calls Subroutines. Each Subroutine Manages A Part Of
The Hardware Or Software. Interrupts Generally Set Flags, Or Update Counters
That Are Read By The Rest Of The Software.
A Simple Api Disables And Enables Interrupts. Done Right, It Handles Nested
Calls In Nested Subroutines, And Restores The Preceding Interrupt State In The
Outermost Enable. This Is One Of The Simplest Methods Of Creating An
Exokernel. There Is Some Sort Of Subroutine In The Loop To Manage A List Of
Software Timers, Using A Periodic Real Time Interrupt. When A
Timer Expires, An Associated Subroutine Is Run, Or Flag Is Set. Any Expected
Hardware Event Should Be Backed-Up With A Software Timer.
Hardware Events Fail About Once In A Trillion Times. State Machines May Be
Implemented With A Function-Pointer Per State-Machine (In C++, C Or Assembly,
Anyway). A Change Of State Stores A Different Function Into The Pointer. The
Function Pointer Is Executed Every Time The Loop Runs. Many Designers Read

9
10

Each Io Device Once Per Loop, And Storing The Result So The Logic Acts On
Consistent Values.

3.1BLOCK DIAGRAM
BLOCK DIAGRAM FOR TRAFFIC CONTROLLER By
AMBULANCE

10
11

3.2Circuitdiagrams
3.2.1 Power Supply Circuit:

3.2.2 Control Circuit:

11
12

3.2.3 IR Tx CKT

3.2.4 IR Rx CKT

12
13

3.2.5 WORKING:

The working of the circuit mainly comprises of four sections. They are:
1. Power Supply Circuit
2. Control Circuit
3. IR Transmitter
4. IR Receiver
1. Regulated Power Supply:
The power supply circuit comprises of a Transformer, Rectifier,
Filter (Smoothing) & Regulator.
• The Transformer used is a 12v, 1A step-down transformer which is used for
reducing the single phase AC supply of 230v to 12v. This is done so because the
rectifier which we are using cannot withstand for such high currents and voltages.
• The Rectifier comprises of four diodes which is called as full wave bridge
rectifier. A rectifier is a device, which consists of diodes, is used for converting
alternating current into direct current.
• The filter section comprises of a Capacitor which is used for reducing the
harmonics/ripple content present if any in the circuit after rectification process. This
is done so because the output of rectifier is pulsating DC.
• A voltage regulator is an electrical regulator designed to automatically
maintain a constant voltage level.
2. Control Circuit:
• The control circuit comprises of a microcontroller, relay driver and LED’s, max232
and GSM. The microcontroller is the heart of the circuit. This takes the inputs and
gives the respective output according to the command given to it.
• The input from the controller comes from IR receiver circuit. According to the
input the controller activates the relays through relay driver. And hence for the
information to be given to the person/ambulance is done by making automatically
ON of Lights and sending a message to the respective person about the intensity of
traffic through GSM.

13
14

• The message is sent through GSM via serial communication i.e.;max232. This
follows a protocol called as RS232 through which serial communication between
devices is done. Accordingly as per the intensity of the traffic on respective side ,
the GSM modem sends a message to the user.
• When the ambulance is arriving at a signal, the green light is given automatically
through the communication between IR transmitter and IR receiver. When the
communication between IR transmitter and receiver is going on then there will be
green signal given automatically as the transmitter circuit is connected to the
microcontroller.
3. IR Transmitter:
• The supply to the transmitter is given through a 9v battery.
• The transmitter circuit consists of 555 timer and IR transmitter.
• The IR transmitter continuously transmits the rays.
• The 555 timer will be astable mode of operation.
4. IR Receiver:
• The supply to the transmitter is given through a 9v battery.
• The receiver circuit consists of 555 timer and IR receiver.
• The IR receiver continuously checks out for the IR transmitter rays.
• The 555 timer will be monostable mode of operation.
• When these rays are detected by the IR receiver, then the signal is passed
to microcontroller and then the controller makes the necessary action to
be taken i.e., it will make green lights ON and leaves the traffic of that
particular side where ambulance is present.

3.31MICRO CONTROLLERS(AT89c52)

14
15

Microprocessors vs. Microcontrollers:

• Microprocessors are single-chip CPUs used in microcomputers.

• Microcontrollers and microprocessors are different in three main aspects:


hardware architecture, applications, and instruction set features.

• Hardware architecture: A microprocessor is a single chip CPU while a


microcontroller is a single IC contains a CPU and much of remaining circuitry of a
complete computer (e.g., RAM, ROM, serial interface, parallel interface, timer,
interrupt handling circuit).

• Applications: Microprocessors are commonly used as a CPU in computers while


microcontrollers are found in small, minimum component designs performing
control oriented activities.

• Microprocessor instruction sets are processing Intensive.

• Their instructions operate on nibbles, bytes, words, or even double words.

• Addressing modes provide access to large arrays of data using pointers and
offsets.

• They have instructions to set and clear individual bits and perform bit operations.

• They have instructions for input/output operations, event timing, enabling and
setting priority levels for interrupts caused by external stimuli.

• Processing power of a microcontroller is much less than a microprocessor.

Difference between 8051 and 8052:

15
16

The 8052 microcontroller is the 8051's "big brother." It is a slightly more powerful
microcontroller, sporting a number of additional features which the developer may
make use of:

• 256 bytes of Internal RAM (compared to 128 in the standard 8051).


• A third 16-bit timer, capable of a number of new operation modes and 16-bit
reloads.
• Additional SFRs to support the functionality offered by the third timer.

AT89S52:

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
• 256K Internal RAM
• 32 Programmable I/O Lines
• 3 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

16
17

DESCRIPTION OF MICROCONTROLLER 89S52:

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


micro controller with 8Kbytes 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 micro controller. 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
one monolithic chip; the Atmel AT89c52 is a powerful micro controller,
which provides a highly flexible and cost-effective solution to many
embedded control applications.

ARCHITECTURE OF MICROCONTROLLER (89S52)

17
18

The AT89S52 provides the following standard features: 8K


bytes of Flash, 256 bytes of RAM, 32 I/O lines, Watchdog timer, two
data pointers, three 16-bit timer/counters, full duplex serial port, on-chip
oscillator, and clock circuitry. In addition, the AT89S52 is designed
with static logic for perationdown to zero frequency and supports two
software selectable power saving modes. The Idle Mode stops the CPU
while allowing the RAM timer/counters, serial port, and interrupt
system to continue functioning. The Power-down mode saves the RAM
contents but freezes the oscillator, disabling all other chip functions
until the next interrupt
Or hardware reset.

18
19

PIN DESCRIPTION OF MICROCONTROLLER 89C52


VCC: Supply voltage.
GND: Ground.
Port 0:
Port 0 is an 8-bit open drain bi-directional I/O port. As an output
port, each pin can sink eight TTL inputs. When 1sare written to port 0
pins, the pins can be used as high impedance inputs. Port 0 can also be
configured to be the multiplexed low order address/data bus during
accesses to external program and data memory. In this mode, P0 has
internal pull-ups. Port 0 also receives the code bytes during Flash
programming and outputs the code bytes during program verification.
External pull-ups are required during program verification
Port 1
Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 1
Output buffers can sink/source four TTL inputs. When 1s are written to Port 1
pins, they are pulled high by the internal pull-ups and can be used as inputs. In
addition, P1.0 and P1.1 can be configured to be the timer/counter 2 external
count input

(P1.0/T2) and the timer/counter 2 trigger input P1.1/T2EX),


respectively, as shown in the following table. Port 1 also receives the
low-order address bytes during Flash programming and verification.

19
20

Port : 2
Port 2 is an 8-bit bi-directional 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 the internal pull-ups and
can be used as inputs. Port 2 emits the high-order address byte during
fetches from external program memory and during accesses to external
data memory that use 16-bit addresses (MOVX @DPTR). In this
application, Port 2 uses strong internal pull-ups when emitting 1s.
During accesses to external data memory that use 8-bit addresses
(MOVX @ RI), Port 2emits the contents of the P2 Special Function
Register. Port 2 also receives the high-order address bits and some
control signals during Flash programming and verification.
Port : 3
Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port 3
output buffers can sink/source four TTL inputs. When 1s are writt 1s are written to
Port 3 pins, they are pulled high by the internal pull-ups and can be used as inputs.
As inputs, Port 3 pins that are externally being pulled low will source current (IIL)
because of the pull-ups. Port 3 also serves the functions of various special features
of the AT89S52, as shown in the following table.
Port 3 also receives some control signals for Flash programming
And verification.

RST Reset input. A high on this pin for two machine cycles while
the oscillator is running resets the device.

ALE/PROG

20
21

Address Latch Enable (ALE) is an output pulse for latching the low byte of the
address during accesses to external memory. This pin is also the program pulse
input (PROG) during Flash programming. In normal operation, ALE is emitted
at a constant rate of1/6 the oscillator frequency and may be used for external
timing or clocking purposes. Note, however, that one ALE pulse is skipped
during each access to external data Memory. If desired, ALE operation can be
disabled by setting bit 0 of SFR location
8EH. With the bit set, ALE is active only during a MOVX or MOVC
instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-
disable bit has no effect if the micro controller is in external execution
mode.

PSEN :
Program Store Enable (PSEN) is the read strobe to external progra
m memory. When the AT89S52 is executing code from external
program memory, PSEN is activated twice each machine cycle, except
that two PSEN activations are skipped during each access to external
data memory.

EA/VPP :
External Access Enable. EA must be strapped to GND in order to
enable the device to fetch code from external program memory
locations starting at 0000H up to FFFFH.Note, however, that if lock bit
1 is programmed, EA will be internally latched on reset. A should be
strapped to VCC for internal program executions. This pin also receives
the 12-voltProgramming enables voltage (VPP) during Flash
programming.

XTAL1 :
Input to the inverting oscillator amplifier and input to the internal clock
operating circuit.

XTAL2 : Output from the inverting oscillator amplifier.


Oscillator Characteristics

21
22

XTAL1 and XTAL2 are the input and output, respectively, of an


inverting amplifier that can be configured for use as an on-chip
oscillator, as shown in Figure 1. Either a quartz crystal or ceramic
resonator may be used. To drive the device from an External clock
source, XTAL2 should be left unconnected while XTAL1 is driven, as
shown in Figure 2.

Figure 1. Oscillator Connections

Special Function Register (SFR) Memory: -


Special Function Registers (SFR s) are areas of memory that
control specific functionality of the 8051 processor. For example, four
SFRs permit access to the 8051’s 32 input/output lines. Another SFR
allows the user to set the serial baud rate, control and access timers, and
configure the 8051’s interrupt system.

The Accumulator: The Accumulator, as its name suggests is used


as a general register to accumulate the results of a large number of
instructions. It can hold 8-bit (1-byte) value and is the most versatile
register.

22
23

The “R” registers: The “R” registers are a set of eight registers that
are named R0, R1. Etc up to R7. These registers are used as auxiliary
registers in many operations.
The “B” registers: The “B” register is very similar to the
accumulator in the sense that it may hold an 8-bit (1-byte) value. Two
only uses the “B” register 8051 instructions: MUL AB and DIV AB.
The Data Pointer: The Data pointer (DPTR) is the 8051’s only user
accessible 16-bit (2Bytes) register. The accumulator, “R” registers are
all 1-Byte values. DPTR, as the name suggests, is used to point to data.
It is used by a number of commands, which allow the 8051 to access
external memory.
THE PROGRAM COUNTER AND STACK POINTER:
The program counter (PC) is a 2-byte address, which tells
the 8051 where the next instruction to execute is found in memory. The
stack pointer like all registers except DPTR and PC may hold an 8-bit (1-
Byte) value

ADDRESSING MODES:
An “addressing mode” refers that you are addressing a given
memory location. In summary, the addressing modes are as follows,
with an example of each:
Each of these addressing modes provides important
flexibility.
Immediate Addressing MOV A, #20 H
Direct Addressing MOV A, 30 H
Indirect Addressing MOV A, @R0
Indexed Addressing
a. External Direct MOVX A, @DPTR
b. Code In direct MOVC A, @A+DPTR

23
24

Immediate Addressing:
Immediate addressing is so named because the value to
be stored in memory immediately follows the operation code in
memory. That is to say, the instruction itself dictates what value will be
stored in memory. For example, the instruction:
MOV A, #20H:
This instruction uses immediate Addressing because the
accumulator will be loaded with the value that immediately follows in
this case 20(hexadecimal). Immediate addressing is very fast since the
value to be loaded is included in the instruction. However, since the
value to be loaded is fixed at compile-time it is not very flexible.

Direct Addressing:
Direct addressing is so named because the value to be
stored in memory is obtained by directly retrieving it from another
memory location.
For example:
MOV A, 30h
This instruction will read the data out of internal RAM address
30(hexadecimal) and store it in the Accumulator. Direct addressing is
generally fast since, although the value to be loaded isn’t included in the
instruction, it is quickly accessible since it is stored in the 8051’s
internal RAM. It is also much more flexible than Immediate Addressing
since the value to be loaded is whatever is found at the given address
which may variable.

Also it is important to note that when using direct addressing


any instruction that refers to an address between 00h and 7Fh is
referring to the SFR control registers that control the 8051 micro
controller itself.

Indirect Addressing:
Indirect addressing is a very powerful addressing mode, which
in many cases provides an exceptional level of flexibility. Indirect

24
25

addressing is also the only way to access the extra 128 bytes of internal
RAM found on the 8052. Indirect addressing appears as follows:

MOV A, @R0:

This instruction causes the 8051 to analyze Special Function


Register (SFR) Memory:
Special Function Registers (SFRs) are areas of memory that control
specific functionality of the 8051 processor. For example, four SFRs
permit access to the 8051’s 32 input/output lines. Another SFR allows
the user to set the serial baud rate, control and access timers, and
configure the 8051’s interrupt system.
Timer 2 Registers:
Control and status bits are contained in registers T2CON and
T2MOD for Timer 2 . The register pair (RCAP2H , RCAP2L) are the
Capture / Reload registers for Timer 2 in 16-bit capture mode or 16-bit
auto-reload mode .

25
26

Article I. Interrupt Registers:


Article II. The individual interrupt enable bits are in the IE registe . Two
priorities can be set for each of the six interrupt sources in the IP register.
Article III.

Article IV. Timer 2


Article V. Timer 2 is a 16-bit Timer / Counter that can operate as either
a timer or an event counter. The type of operation is selected by bit C/T2 in
Article VI. the SFR T2CON . Timer 2 has three operating Modes :
capture , auto-reload ( up or down Counting ) , and baud rate generator . The
modes are selected by bits in T2CON . Timer 2 consists of two 8-bit
registers , TH2 and TL2 . In the Timer function , the TL2 register is
incremented every machine cycle . Since a machine cycle consists

26
27

Article VII. of 12 oscillator periods, the count rate is 1/12 of the oscillator
frequency.In the Counter function , the register is incremented in response
to a 1-to-0 transition at its corresponding external input pin , T2 .When the
samples show a high in one cycle and a low in the next cycle, the count is
incremented . Since two machine cycles (24 Oscillator periods ) are required to
recognize 1-to-0 transition , the maximum count rate is 1 / 24 of the
oscillator frequency . To ensure that a given level is sampled at least once
before it changes , the level should be held for atleast one full machine
cycle .
Article VIII. Capture Mode
Article IX. In the capture mode , two options are selected by bit EXEN2
in T2CON . If EXEN2 = 0, Timer 2 is a 16-bit timer or counter which upon
overflow sets bit TF2 in T2CON . This bit can then be used to generate an
interrupt . If EXEN2 = 1 , Timer 2 performs the same operation , but a 1-to-0
transition at external input T2EX also causes the current value in TH2
and TL2 to be captured into RCAP2H and RCAP2L , respectively
Article X. Auto-reload (Up or Down Counter)
Article XI. Timer 2 can be programmed to count up or down when
configured in its 16-bit auto-reload mode. This feature is invoked by the
DCEN
(Down Counter Enable) bit located in the SFR T2MOD . Upon reset , the
DCEN bit is set to 0 so that timer 2 will default to count up.
When DCEN is set , Timer 2 can count up or down , depending on the value
of the T2EX pin . In this mode , two options are selected by bit EXEN2 in
T2CON . If EXEN2 = 0 , Timer 2 counts up to 0FFFFH and then sets the
TF2 bit upon overflow . If EXEN2 = 1 , a 16-bit

27
28

Article XII. reload can be triggered either by an overflow or by a 1-to-0


transition at external input T2EX.
Article XIII. Baud Rate Generator
Article XIV. Timer 2 is selected as the baud rate generator by setting
TCLK and/or RCLK in T2CON . Note that the baud rates for transmit and
receive can be different if Timer 2 is used for the receiver or transmitter
and Timer 1 is used for the other function .The baud rates in Modes 1 and 3
aredetermined by Timer 2’s overflow rate according to the following equation
.
Article XV. Modes 1 and 3 Baud Rates =Timer 2 Overflow Rate
Article XVI. 16
Article XVII.
Article XVIII. The timer operation is different for Timer 2 when it is used as
a baud rate generator .Normally ,as a timer , it increments every machine cycle
(at 1/12 the oscillator frequency).As a baud rate generator , however, it
increments every state time ( at 1/2 the oscillator frequency ) .
Article XIX. Timer 0
Timer 0 functions as either a timer or event counter in four modes of
operation . Timer 0 is controlled by the four lower bits of the TMOD
register and bits 0, 1, 4 and 5 of the TCON register

28
29

Article XX. Mode 0 ( 13-bit Timer)


Article XXI. Mode 0 configures timer 0 as a 13-bit timer which is set
up as an 8-bit timer (TH0 register) with a modulo 32 prescaler
implemented with the lower five bits of the TL0 register . The upper three
bits of TL0 register are indeterminate and should be ignored . Prescaler
overflow increments the TH0 register.
Article XXII. Mode 1 ( 16-bit Timer )
Article XXIII. Mode 1 is the same as Mode 0, except that the
Timer register is being run with all 16 bits . Mode 1 configures timer 0
as a 16-bit timer with the TH0 and TL0 registers connected in
cascade . The selected input increments the TL0 register .
Article XXIV. Mode 2 (8-bit Timer with Auto-Reload)
Article XXV. Mode 2 configures timer 0 as an 8-bit timer ( TL0 register )
that automatically reloads from the TH0 register . TL0 overflow sets TF0
flag in the TCON register and reloads TL0 with the contents of
TH0 , which is preset by software .
Article XXVI. Mode 3 ( Two 8-bit Timers )Mode 3 configures timer 0
so that registers TL0 and TH0 operate as separate 8-bit timers. This mode
is provided for applications requiring an additional 8-bit timer or counter .
Article XXVII.
Article XXVIII. Timer 1
Article XXIX. Timer 1 is identical to timer 0 , except for mode 3 ,
which is a hold-count mode .
Article XXX. Mode 3 ( Halt )
Article XXXI. Placing Timer 1 in mode 3 causes it to halt and hold its
count . This can be used to halt Timer 1 when TR1 run control bit is
not available i.e. , when Timer 0 is in mode 3 .
Article XXXII. Baud Rates :

29
30

Article XXXIII. The baud rate in Mode 0 is fixed. The baud


rate in Mode 2 depends on the value of bit SMOD in Special Functio
Register PCON. If SMOD = 0 (which is its value on reset), the baud rate is
1/64 the oscillator frequency . If SMOD = 1, the baud rate is 1/32 the
oscillator frequency. In the 89S52 , the baud rates in Modes 1 and 3 are
determined by the Timer 1 overflow rate. In case of Timer 2 , these
baud rates can be determined by Timer 1 , or by Timer 2 , or by both
(one for transmit and the other for receive ).
Article XXXIV.
Article XXXV. TCON REGISTER :Timer/counter Control Register

30
31

Article XXXVI. TMOD REGISTER: Timer/Counter 0 and 1 Modes

3.32ULN 2803A

ULN are used to interfacing between microcontroller and the led’s


Because the can not work with out them.The ULN2801A-ULN2805Aeach contain
eight dar-lington transistors with common emitters and integral suppression diodes
for inductive loads. Each darlington features a peak load current rating of 600mA
(500mA continuous) and can withstand at least 50V in the off state. Outputsmay be
paralleled for higher current capability. Five versions are available to simplify
interfacing to standard logic families : the ULN2801A is designed for general
purpose applications with a current limit resistor ; the ULN2802Ahas a 10.5kΩ
input resistor and zener for 14-25V PMOS ; the ULN2803A has a 2.7kΩ input
resistor for 5V TTL and CMOS ; the ULN2804A has a 10.5kΩ input resistor for 6-
15V CMOS and the ULN2805A is designed to sink a minimum of 350mA for
standard and Schottky TTL where higher output current is required. All types are
supplied in a 18-lead plastic DIP with a copperlead from and featurethe
convenientinputopposite-output pinout to simplify board layout.

31
32

3.33 555 TIMER

555 is used for producing a clock (square wave) at


a desired frequency. It can be used in various ways
like the astable mode, monostable mode etc. Here,
we deal with the astable operation of 555. Astable
mode ensures that the 555 is self-triggered & so, it
acts as a multi-vibrator.
Let us look into the working of 555 in astable
mode:

These are the


connections
needed to make the 555 chip run in the
‘astable’ mode. The pin numbers are given in
circles.

Note the right-most side of the figure, and


consider all the connections with the pins as
‘open-circuits’. Ignore the rest of the circuit
for a while.

32
33

D1 -
Circuit Connections to be made

This over-familiar circuit will majestically


jump up. The Vc1 is the driving signal for
this 555, connected at PIN 6, which is the
THRESHOLD PIN. As soon as Vc1
reaches ⅔Vcc, then the output at PIN 3
goes low, and the capacitor starts
discharging, via PIN 7 with Rb as the
Resistor and ground as the other terminal.
(Refer to the first image to see how it
MIGHT happen.) When it reaches ⅓Vcc,
the output at PIN 3 goes high, and the
DISCHARGE PIN’s connection with
ground is broken. The capacitor again
starts charging, and the cycle is repeated.
You need not bother yourself with how
the
Circuit is broken or established.

This graph gives the OUTPUT at PIN 3


and the input voltage at PIN 7.

D3- Output

D4- Internal Working of the 555


This is the internal working of the 555 timer. The chip derives its name from the
three R’s on the top of the image, they all are 5 kΩ. Hence, the name 555.

33
34

Now, let us see how we can set the 555 to work at the desired frequency by
selecting the right combination of resistances & capacitances. Using the convention
as in D1,
From circuit analysis & mathematics, it can be obtained that:
Frequency = 1.44/{(RA + 2RB) * C1}

Also, 555 can produce waves with duty cycle else than the 50 % cycle. The desired
duty cycle can be worked out by using the result:
Duty Cycle = (RA + RB) * 100/ (RA + 2RB)
where duty cycle= Ratio of time period when the output is 1 to the time
period when the output is 0

34
35

3.4(IR) INFRARED TECHNOLOGY

Introduction:
Technically known as "infrared radiation", infrared light is part of the
electromagnetic spectrum located just below the red portion of normal visible light
– the opposite end to ultraviolet. Although invisible, infrared follows the same
principles as regular light and can be reflected or pass through transparent objects,
such as glass. Infrared remote controls use this invisible light as a form of
communications between themselves and home theater equipment, all of which
have infrared receivers positioned on the front. Essentially, each time you press a
button on a remote, a small infrared diode at the front of the remote beams out
pulses of light at high speed to all of your equipment. When the equipment
recognizes the signal as its own, it responds to the command.

But much like a flashlight, infrared light can be focused or diffused, weak or
strong. The type and number of emitters can affect the possible angles and range
your remote control can be used from. Better remotes can be used up to thirty feet
away and from almost any angle, while poorer remotes must be aimed carefully at
the device being controlled.

The light our eyes see is but a small part of a broad spectrum of
electromagnetic radiation. On the immediate high energy side of the visible
spectrum lies the ultraviolet, and on the low energy side is the infrared. The portion
of the infrared region most useful for analysis of organic compounds is not
immediately adjacent to the visible spectrum, but is that having a wavelength range
from 2,500 to 16,000 nm, with a corresponding frequency range from 1.9*1013 to
1.2*1014 Hz.( From http://hyperphysics.phy-astr.gsu.edu/hbase/ems3.html : the
frequency of infrared ranges from 0.003 - 4 x 10 14 Hz or about 300 gigahertz to 400
terahertz.).

35
36

Infrared imaging is used extensively for both military and civilian purposes.
Military applications include target acquisition, surveillance, night vision, homing
and tracking. Non-military uses include thermal efficiency analysis, remote
temperature sensing, short-ranged wireless communication, spectroscopy, and
weather forecasting. Infrared astronomy uses sensor-equipped telescopes to
penetrate dusty regions of space, such as molecular clouds; detect cool objects such
as planets, and to view highly red-shifted objects from the early days of the universe

IR LED QED234:

FEATURES:
• Wave length is 940 nm
• Chip material =GaAs with AlGaAs window
• Package type: T-1 3/4 (5mm lens diameter)
• Matched Photo sensor: QSD122/123/124
• Medium Emission Angle, 40°
• High Output Power
• Package material and color: Clear, untainted, plastic
• Ideal for remote control applications

36
37

Emitter/Detector Alignment:

Good alignment of the emitter and detector is important for good operation,
especially if the gap is large. This can be done with a piece of string stretched
between and in line with LED and phototransistor. A length of dowel or stiff wire
could be used to set the alignment. Another method that can be used for longer
distances is a laser pointer shone through one of the mounting holes.

For best results the height of the "beam" should be at coupler height and at an
angle across the tracks. The emitter could also be mounted above the track with the
phototransistor placed between the rails in locations such as hidden yards. Placing
the emitter and detector at an angle would again be helpful.

Emitter/Detector Alignment Methods

37
38

A sample infrared remote controle setup:

Infrared Receiver (Pickup)


This device picks up the infrared signal from your remote control just like a
TV or VCR. It encodes the infrared signal into a signal suitable for transmission.
Receivers must be located in the room you wish to use the remote control. The wire
from the receiver to the connecting block needs at least three available conductors
and can be several hundred feet long. Both quad wire and category 5wire work fine.
See our IR receivers here.

Connecting Block
This is simply a place for all the parts to plug in or connect to. Connecting
blocks are usually classified based on the number of outputs (how many IR emitters
can connect to the block) Amplified connecting blocks can generally support more
outputs. All connecting blocks can support many IR receivers wired in parallel.
Connecting blocks are usually located near the equipment that is to be controlled,
along with the power supply and emitters. See our connecting blocks here.

38
39

Infrared Emitters
IR Emitters generally "stick" onto the front of the device you want to
control. Therefore you need one emitter for each device. "Dual" emitters
have two emitters and one plug, so they only take up one jack of the connecting
block. "Blink" emitters blink visibly as well as infrared, so they are easier to
troubleshoot. All emitters come with long cords and extra double-stick tape. "Blast"
style emitters, where one emitter blinks into several devices, are usually less reliable
but can be used when the environment is tightly controlled and

Applications:

• Infrared Filters

• Night vision

• Thermograph

• Other imaging

• Tracking

• Heating

• Communications

• Spectroscopy

• Meteorology

• Climatology

• Astronomy

• Art history

• Biological systems

• Photobiomodulation

39
40

• Health hazard

Article XXXVII. Light-emitting diode (LED)

A light-emitting diode (LED) (pronounced, or just /lɛd/), is an electronic


light source. The LED was first invented in Russia in the 1920s, and introduced in
America as a practical electronic component in 1962. Oleg Vladimirovich Losev
was a radio technician who noticed that diodes used in radio receivers emitted light
when current was passed through them. In 1927, he published details in a Russian
journal of the first ever LED.

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.

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.

LEDs present many advantages over traditional light sources including lower
energy consumption, longer lifetime, improved robustness, smaller size and faster
switching. However, they are relatively expensive and require more precise current
and heat management than traditional light sources.

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.

40
41

(a) Application-specific variations

Flashing LEDs are used as attention seeking indicators without requiring external
electronics. Flashing LEDs resemble standard LEDs but they contain an integrated
multivibrator circuit inside which causes the LED to flash with a typical period of
one second. In diffused lens LEDs this is visible as a small black dot. Most flashing
LEDs emit light of a single color, but more sophisticated devices can flash between
multiple colors and even fade through a color sequence using RGB color mix

• Bi-color LEDs are actually two different LEDs in one case. It consists of
two dies connected to the same two leads but in opposite directions. Current
flow in one direction produces one color, and current in the opposite
direction produces the other color. Alternating the two colors with sufficient
frequency causes the appearance of a blended third color. For example, a
red/green LED operated in this fashion will color blend to produce a yellow
appearance.

• Tri-color LEDs are two LEDs in one case, but the two LEDs are connected
to separate leads so that the two LEDs can be controlled independently and
lit simultaneously. A three-lead arrangement is typical with one common
lead (anode or cathode).

41
42

• RGB LEDs contain red, green and blue emitters, generally using a four-wire
connection with one common lead (anode or cathode).

• Alphanumeric LED displays are available in seven-segment and starburst


format. Seven-segment displays handle all numbers and a limited set of
letters. Starburst displays can display all letters. Seven-segment LED
displays were in widespread use in the 1970s and 1980s, but increasing use
of liquid crystal displays, with their lower power consumption and greater
display flexibility, has reduced the popularity of numeric and alphanumeric
LED displays.

(b) Advantages
• Efficiency LEDs produce more light per watt than incandescent bulbs.
• 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.
• Size: LEDs can be very small (smaller than 2 mm2and are easily populated
onto printed circuit boards.
• 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.
• Dimming: LEDs can very easily be dimmed either by Pulse-width
modulation or lowering the forward current.
• Cool light: In contrast to most light sources, LEDs radiate very little heat in
the form of IR that can cause damage to sensitive objects or fabrics. Wasted
energy is dispersed as heat through the base of the LED.
• Slow failure: LEDs mostly fail by dimming over time, rather than the
abrupt burn-out of incandescent bulbs.
• 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 10,000 to 15,000

42
43

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.
• Focus: The solid package of the LED can be designed to focus its light.
Incandescent and fluorescent sources often require an external reflector to
collect light and direct it in a usable manner.
• Toxicity: LEDs do not contain mercury, unlike fluorescent lamps.

(c) Disadvantages
• High initial price: LEDs are currently more expensive, price per lumen, on
an initial capital cost basis, than most conventional lighting technologies.
The additional expense partially stems from the relatively low lumen output
and the drive circuitry and power supplies needed. However, when
considering the total cost of ownership (including energy and maintenance
costs), LEDs far surpass incandescent or halogen sources and begin to
threaten compact fluorescent lamps.
• 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. This is especially important when considering
automotive, medical, and military applications where the device must
operate over a large range of temperatures, and is required to have a low
failure rate.
• 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. The spike at
460 nm and dip at 500 nm can cause the color of objects to be perceived
differently under cool-white LED illumination than sunlight or incandescent
sources, due to metamerism, red surfaces being rendered particularly badly

43
44

by typical phosphor based cool-white LEDs. 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. This is contrasted with lasers, which can
produce beams with divergences of 0.2 degrees or less.
• Blue Hazard: There is increasing concern that blue LEDs and cool-white
LEDs are now capable of exceeding safe limits of the so-called blue-light
hazard as defined in eye safety specifications such as ANSI/IESNA RP-
27.1-05: Recommended Practice for Photobiological Safety for Lamp and
Lamp Systems.
• Blue pollution: Because cool-white LEDs (i.e., LEDs with high color
temperature) emit much more blue light than conventional outdoor light
sources such as high-pressure sodium lamps, the strong wavelength
dependence of Rayleigh scattering means that cool-white LEDs can cause
more light pollution than other light sources. It is therefore very important
that cool-white LEDs are fully shielded when used outdoors. Compared to
low-pressure sodium lamps, which emit at 589.3 nm, the 460 nm emission
spike of cool-white and blue LEDs is scattered about 2.7 times more by the
Earth's atmosphere. Cool-white LEDs should not be used for outdoor
lighting near astronomical observatories.

44
45

3.5 REGULATED POWER SUPPLY

Description :

A variable regulated power supply, also called a


variable bench power supply, is one where you can continuously
adjust the output voltage to your requirements. Varying the
output of the power supply is the recommended way to test a
project after having double checked parts placement against
circuit drawings and the parts placement guide. This type of
regulation is ideal for having a simple variable bench power
supply. Actually this is quite important because one of the first
projects a hobbyist should undertake is the construction of a
variable regulated power supply. While a dedicated supply is quite
handy e.g. 5V or 12V, it's much handier to have a variable supply
on hand, especially for testing. Most digital logic circuits and
processors need a 5 volt power supply. To use these parts we
need to build a regulated 5 volt source. Usually you start with an
unregulated power supply ranging from 9 volts to 24 volts DC (A
12 volt power supply is included with the Beginner Kit and the
Microcontroller Beginner Kit.). To make a 5 volt power supply, we
use a LM7805 voltage regulator IC .

45
46

The LM7805 is simple to use. You simply connect the


positive lead of your unregulated DC power supply (anything from
9VDC to 24VDC) to the Input pin, connect the negative lead to the
Common pin and then when you turn on the power, you get a 5
volt supply from 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
• Availability of components: Easy to get, uses only very
common basic components
• Design testing: Based on datasheet example circuit, I
have used this circuit successfully as part of many electronics
projects

46
47

• Block Diagram:

Circuit Diagram:

47
48

Basic Power Supply Circuit:


Above is the circuit of a basic unregulated dc power
supply. A bridge rectifier D1 to D4 rectifies the ac from the
transformer secondary, which may also be a block rectifier such as
WO4 or even four individual diodes such as 1N4004 types. (See
later re rectifier ratings).
The principal advantage of a bridge rectifier is you do not
need a centre tap on the secondary of the transformer. A further
but significant advantage is that the ripple frequency at the output
is twice the line frequency (i.e. 50 Hz or 60 Hz) and makes
filtering somewhat easier.
As a design example consider we wanted a small
unregulated bench supply for our projects. Here we will go for a
voltage of about 12 - 13V at a maximum output current (IL) of
500ma (0.5A). Maximum ripple will be 2.5% and load regulation is
5%.
Now the RMS secondary voltage (primary is whatever is
consistent with your area) for our power transformer T1 must be
our desired output Vo PLUS the voltage drops across D2 and D4 (2
* 0.7V) divided by 1.414.
This means that Vsec = [13V + 1.4V] / 1.414 which equals about
10.2V. Depending on the VA rating of your transformer, the
secondary voltage will vary considerably in accordance with the
applied load. The secondary voltage on a transformer advertised
as say 20VA will be much greater if the secondary is only lightly
loaded.
If we accept the 2.5% ripple as adequate for our purposes
then at 13V this becomes 13 * 0.025 = 0.325 Vrms. The peak to
peak value is 2.828 times this value. Vrip = 0.325V X 2.828 =
0.92 V and this value is required to calculate the value of C1. Also

48
49

required for this calculation is the time interval for charging


pulses. If you are on a 60Hz system it it 1/ (2 * 60) = 0.008333
which is 8.33 milliseconds. For a 50Hz system it is 0.01 sec or 10
milliseconds.
Remember the tolerance of the type of capacitor used here
is very loose. The important thing to be aware of is the voltage
rating should be at least 13V X 1.414 or 18.33. Here you would
use at least the standard 25V or higher (absolutely not 16V).With
our rectifier diodes or bridge they should have a PIV rating of
2.828 times the Vsec or at least 29V. Don't search for this rating
because it doesn't exist. Use the next highest standard or even
higher. The current rating should be at least twice the load
current maximum i.e. 2 X 0.5A or 1A. A good type to use would be
1N4004, 1N4006 or 1N4008 types.
These are rated 1 Amp at 400PIV, 600PIV and 1000PIV
respectively. Always be on the lookout for the higher voltage ones
when they are on special.
IC Voltage Regulators

Voltage regulators comprise a class of widely used ICs.


Regulator IC units contain the circuitry for reference source,
comparator amplifier, control device, and overload protection all in
a single IC. Although the internal construction of the IC is
somewhat different from that described for discrete voltage
regulator circuits, the external operation is much the same. IC
units provide regulation of either a fixed positive voltage, a fixed
negative voltage, or an adjustably set voltage.

A power supply can be built using a transformer connected


to the ac supply line to step the ac voltage to desired amplitude,
then rectifying that ac voltage, filtering with a capacitor and RC
filter, if desired, and finally regulating the dc voltage using an IC

49
50

regulator. The regulators can be selected for operation with load


currents from hundreds of mill amperes to tens of amperes,
corresponding to power ratings from mill watts to tens of watts.

Three-Terminal Voltage Regulators:


Fixed Positive Voltage Regulators:

Vin IN OUT
78XX
Vout
GND
C1 C2

Fig shows the basic connection of a three-terminal voltage


regulator IC to a load. The fixed voltage regulator has an
unregulated dc input voltage, Vi, applied to one input terminal, a
regulated output dc voltage, Vo, from a second terminal, with the
third terminal connected to ground. While the input voltage may
vary over some permissible voltage range, and the output load
may vary over some acceptable range, the output voltage remains
constant within specified voltage variation limits. A table of
positive voltage regulated ICs is provided in table. For a selected
regulator, IC device specifications list a voltage range over which
the input voltage can vary to maintain a regulated output voltage
over a range of load current. The specifications also list the
amount of output voltage change resulting from a change in load
current (load regulation) or in input voltage (line regulation).

50
51

TABLE: Positive Voltage Regulators in 7800 series

IC No. Output voltage(v) Maximum input


voltage(v)

7805 +5
7806 +6 35V
7808 +8
7810 +10
7812 +12
7815 +15
7818 +18
7824 +24 40V

51
52

3.6 Transistors
Transistors amplify current, for
example they can be used to amplify the small output current
from a logic IC so that it can operate a lamp, relay or other
high current device. In many circuits a resistor is used to
convert the changing current to a changing voltage, so the
transistor is being used to
amplify voltage.
A transistor may be used as a switch (either fully on with maximum current, or fully
off with no current) and as an amplifier (always partly on). The amount of current
amplification is called the current gain, symbol hFE.
For further information please see the Transistor Circuits page.

Types of transistor

There are two types of standard transistors, NPN and


PNP, with different circuit symbols. The letters refer
to the layers of semiconductor material used to make
the transistor. Most transistors used today are NPN
because this is the easiest type to make from silicon. If
you are new to electronics it is best to start by learning Transistor circuit symbols
how to use NPN transistors.

The leads are labelled base (B), collector (C) and emitter (E).
These terms refer to the internal operation of a transistor but they are not much help in understanding
how a transistor is used, so just treat them as labels!

A Darlington pair is two transistors connected


together to give a very high current gain.

In addition to standard (bipolar junction)


transistors, there are field-effect transistors
which are usually referred to as FETs. They
have different circuit symbols and properties
and they are not (yet) covered by this page.

Connecting

52

Transistor leads for some common case styles.


53

Transistors have three leads which must be connected the correct way round. Please
take care with this because a wrongly connected transistor may be damaged
instantly when you switch on.

If you are lucky the orientation of the transistor will be clear from the PCB or
stripboard layout diagram, otherwise you will need to refer to a supplier's catalogue
to identify the leads.

The drawings on the right show the leads for some of the most common case styles.

Please note that transistor lead diagrams show the view from below with the leads
towards you. This is the opposite of IC (chip) pin diagrams which show the view
from above.

Heat sinks :
Waste heat is produced in transistors due
to the current flowing through them. Heat sinks Heat sink
are needed for power transistors because they
pass large currents. If you find that a transistor is Photograph © Rapid Electronics
becoming too hot to touch it certainly needs a heat sink! The heat sink helps
to dissipate (remove) the heat by transferring it to the surrounding air.

For further information please see the Heat sinks page.

Testing a transistor:
Transistors
can be damaged by
heat when soldering
or
by misuse in a circuit. If you
suspect that a transistor may
be damaged there are two
easy ways to test it:

(i) 1. Testing with a multimeter Testing an NPN transistor


Use a multimeter or a simple tester (battery,
resistor and LED) to check each pair of leads for conduction. Set a digital
multimeter to diode test and an analogue multimeter to a low resistance range.

Test each pair of leads both ways (six tests in total):

• The base-emitter (BE) junction should behave like a diode and conduct one
way only.
• The base-collector (BC) junction should behave like a diode and conduct
one way only.

53
54

• The collector-emitter (CE) should not


conduct either way.

The diagram shows how the junctions behave in


an NPN transistor. The diodes are reversed in a
PNP transistor but the same test procedure can be
used.

(ii) 2. Testing in a simple switching


circuit
Connect the transistor into the circuit shown on A simple switching circuit
the right which uses the transistor as a switch. to test an NPN transistor
The supply voltage is not critical, anything
between 5 and 12V is suitable. This circuit can be quickly built on breadboard for
example. Take care to include the 10k resistor in the base connection or you will
destroy the transistor as you test it!

If the transistor is OK the LED should light when the switch is pressed and not light
when the switch is released.

To test a PNP transistor use the same circuit but reverse the LED and the supply
voltage.

Some multimeters have a 'transistor test' function which provides a known base
current and measures the collector current so as to display the transistor's DC
current gain hFE.

Transistor codes :
There are three main series of transistor codes used in the UK:

• Codes beginning with B (or A), for example BC108, BC478


The first letter B is for silicon, A is for germanium (rarely used now). The second letter
indicates the type; for example C means low power audio frequency; D means high power
audio frequency; F means low power high frequency. The rest of the code identifies the
particular transistor. There is no obvious logic to the numbering system. Sometimes a letter
is added to the end (eg BC108C) to identify a special version of the main type, for example
a higher current gain or a different case style. If a project specifies a higher gain version
(BC108C) it must be used, but if the general code is given (BC108) any transistor with that
code is suitable.
• Codes beginning with TIP, for example TIP31A
TIP refers to the manufacturer: Texas Instruments Power transistor. The letter at the end
identifies versions with different voltage ratings.

54
55

• Codes beginning with 2N, for example 2N3053


The initial '2N' identifies the part as a transistor and the rest of the code identifies the
particular transistor. There is no obvious logic to the numbering system.

Choosing a transistor
Most projects will specify a particular transistor, but if necessary you can usually
substitute an equivalent transistor from the wide range available. The most
important properties to look for are the maximum collector current IC and the
current gain hFE. To make selection easier most suppliers group their transistors in
categories determined either by their typical use or maximum power rating.

To make a final choice you will need to consult the tables of technical data which
are normally provided in catalogues. They contain a great deal of useful information
but they can be difficult to understand if you are not familiar with the abbreviations
used. The table below shows the most important technical data for some popular
transistors, tables in catalogues and reference books will usually show additional
information but this is unlikely to be useful unless you are experienced. The
quantities shown in the table are explained below.

NPN transistors
Category
Case IC VCE hFE Ptot Possible
Code Structure (typical
style max. max. min. max. substitutes
use)
Audio, low
BC107 NPN TO18 100mA 45V 110 300mW power BC182 BC547

General
BC108C
BC108 NPN TO18 100mA 20V 110 300mW purpose, low BC183 BC548
power
General
BC108C NPN TO18 100mA 20V 420 600mW purpose, low
power
Audio (low
BC109 NPN TO18 200mA 20V 200 300mW noise), low BC184 BC549
power
General
BC107
BC182 NPN TO92C 100mA 50V 100 350mW purpose, low
BC182L
power
General
BC182L NPN TO92A 100mA 50V 100 350mW purpose, low BC107 BC182
power
Audio, low
BC547B NPN TO92C 100mA 45V 200 500mW power BC107B

General
BC548B NPN TO92C 100mA 30V 220 500mW purpose, low BC108B
power
Audio (low
BC549B NPN TO92C 100mA 30V 240 625mW noise), low BC109
power
2N3053 NPN TO39 700mA 40V 50 500mW General BFY51
purpose, low

55
56

power
General
purpose,
BFY51 NPN TO39 1A 30V 40 800mW medium
BC639
power
General
purpose,
BC639 NPN TO92A 1A 80V 40 800mW medium
BFY51
power
General
TIP29A NPN TO220 1A 60V 40 30W purpose, high
power
General
TIP31C
TIP31A NPN TO220 3A 60V 10 40W purpose, high
TIP41A
power
General
TIP31A
TIP31C NPN TO220 3A 100V 10 40W purpose, high
TIP41A
power
General
TIP41A NPN TO220 6A 60V 15 65W purpose, high
power
General
2N3055 NPN TO3 15A 60V 20 117W purpose, high
power
Please note: the data in this table was compiled from several sources which are not entirely consistent!
Most of the discrepancies are minor, but please consult information from your supplier if you require
precise data.
PNP transistors
Category
Case IC VCE hFE Ptot Possible
Code Structure (typical
style max. max. min. max. substitutes
use)
Audio, low
BC177 PNP TO18 100mA 45V 125 300mW power BC477

General
BC178 PNP TO18 200mA 25V 120 600mW purpose, low BC478
power
Audio (low
BC179 PNP TO18 200mA 20V 180 600mW noise), low
power
Audio, low
BC477 PNP TO18 150mA 80V 125 360mW power BC177

General
BC478 PNP TO18 150mA 40V 125 360mW purpose, low BC178
power
General
TIP32A PNP TO220 3A 60V 25 40W purpose, high TIP32C
power
General
TIP32C PNP TO220 3A 100V 10 40W purpose, high TIP32A
power
Please note: the data in this table was compiled from several sources which are not entirely consistent!
Most of the discrepancies are minor, but please consult information from your supplier if you require

56
57

precise data.

Structure This shows the type of transistor, NPN or PNP. The polarities of the two
types are different, so if you are looking for a substitute it must be the
same type.
Case style There is a diagram showing the leads for some of the most common
case styles in the Connecting section above. This information is also
available in suppliers' catalogues.
IC max. Maximum collector current.
VCE max. Maximum voltage across the collector-emitter junction.
You can ignore this rating in low voltage circuits.

hFE This is the current gain (strictly the DC current gain). The guaranteed
minimum value is given because the actual value varies from transistor
to transistor - even for those of the same type! Note that current gain is
just a number so it has no units.
The gain is often quoted at a particular collector current IC which is usually in the
middle of the transistor's range, for example '100@20mA' means the gain is at least
100 at 20mA. Sometimes minimum and maximum values are given. Since the gain is
roughly constant for various currents but it varies from transistor to transistor this
detail is only really of interest to experts.
Why hFE? It is one of a whole series of parameters for transistors, each with their own
symbol. There are too many to explain here.

Ptot max. Maximum total power which can be developed in the transistor, note
that a heat sink will be required to achieve the maximum rating. This
rating is important for transistors operating as amplifiers, the power is
roughly IC × VCE. For transistors operating as switches the maximum
collector current (IC max.) is more important.

3.7Resistors& Capacitors

Resistors:

57
58

The resistor's function is to reduce the flow of electric current.


This symbol is used to indicate a resistor in a circuit diagram, known as a
schematic.
Resistance value is designated in units called the "Ohm." A 1000 Ohm resistor is
typically shown as 1K-Ohm ( kilo Ohm ), and 1000 K-Ohms is written as 1M-Ohm
( megohm ).

There are two classes of resistors; fixed resistors and the variable resistors. They
are also classified according to the material from which they are made. The typical
resistor is made of either carbon film or metal film. There are other types as well,
but these are the most common.
The resistance value of the resistor is not the only thing to consider when selecting a
resistor for use in a circuit. The "tolerance" and the electric power ratings of the
resistor are also important.
The tolerance of a resistor denotes how close it is to the actual rated resistence
value. For example, a ±5% tolerance would indicate a resistor that is within ±5% of
the specified resistance value.
The power rating indicates how much power the resistor can safely tolerate. Just
like you wouldn't use a 6 volt flashlight lamp to replace a burned out light in your
house, you wouldn't use a 1/8 watt resistor when you should be using a 1/2 watt
resistor.

The maximum rated power of the resistor is specified in Watts.


Power is calculated using the square of the current ( I2 ) x the resistance value ( R )
of the resistor. If the maximum rating of the resistor is exceeded, it will become
extremely hot, and even burn.
Resistors in electronic circuits are typicaly rated 1/8W, 1/4W, and 1/2W. 1/8W is
almost always used in signal circuit applications.
When powering a light emitting diode, a comparatively large current flows through
the resistor, so you need to consider the power rating of the resistor you choose.

Color code resistor's

58
59

Color code ariations

Three band resistors


Very long ago, back in the 20th century, it was assumed that all resistors were 20 %,
or worse, and thus didn't need any tolerance marking. Also, since the tolerance was
so wide there was no need for more than two significant digits. These resistors are
in the E3 or E6 series. If you stumble on one of these, call your local museum.

Four band resistors


Mankind eventually learned to manufacture 10 % or even 5 % resistors and a
tolerance marking had to be invented. There were still no need for more than two
significant digits, and therefore four color bands did the trick. These resistors
typically are in the E12 and E24 series.

Five band resistors


Engineers' appetite for precision led to the development of 2 % and 1 % or better
resistors, and in order to keep the logarithmically constant difference between
consecutive resistance values another significant digit had to be employed. But
engineers also developed tools to paint tinier color bands, so that was not a problem.
These resistors belong to the E48, E96 and E192 series.

59
60

Section XXXVII.2 Six band resistors

Now that tolerances were in the sub-percent region, another factor had to be
accounted for, namely temperature coefficient. Well, why not just throw in yet
another color band? Good idea. Here it is.

There are also other uses of the sixth color band, for instance quality codes. These
are, however, not well standardized and are therefore not part of the color code
calculator.

Capacitor
Electronic capacitors are one of the most widely
used electronic components. These electronic capacitors only
allow alternating or changing signals to pass through them,
and as a result they find applications in many different areas of electronic circuit
design. There are a wide variety of types of capacitor including electrolytic,
ceramic, tantalum, plastic, sliver mica, and many more. Each capacitor type has its
own advantages and disadvantages can be used in different applications.

The choice of the correct capacitor type can have a major impact on any circuit. The
differences between the different types of capacitor can mean that the circuit may
not work correctly if the correct type of capacitor is not used. Accordingly a
summary of the different types of capacitor is given below, and further descriptions
of a variety of capacitor types can be reached through the related articles menu on
the left hand side of the page below the main menu.

4.1 SOFTWARE DESCRIPTION

1. Click on the Keil uVision Icon on Desktop


2. The following fig will appear

60
61

3. Click on the Project menu from the title bar


4. Then Click on New Project

5. Save the Project by typing suitable project name with no extension in u r


own folder sited in either C:\ or D:\

61
62

6. Then Click on Save button above.


7. Select the component for u r project. i.e. Atmel……
8. Click on the + Symbol beside of Atmel

9. Select AT89C51 as shown below

62
63

10. Then Click on “OK”


11. The Following fig will appear

12. Then Click either YES or NO………mostly “NO”

13. Now your project is ready to USE


14. Now double click on the Target1, you would get another option “Source
group 1” as shown in next page.

63
64

15. Click on the file option from menu bar and select “new”

16. The next screen will be as shown in next page, and just maximize it by
double clicking on its blue boarder.

64
65

17. Now start writing program in either in “C” or “ASM”


18. For a program written in Assembly, then save it with extension “. asm”
and for “C” based program save it with extension “ .C”

19. Now right click on Source group 1 and click on “Add files to Group
Source”

65
66

20. Now you will get another window, on which by default “C” files will
appear.

21. Now select as per your file extension given while saving the file
22. Click only one time on option “ADD”
23. Now Press function key F7 to compile. Any error will appear if so
happen.

66
67

24. If the file contains no error, then press Control+F5 simultaneously.


25. The new window is as follows

26. Then Click “OK”


27. Now Click on the Peripherals from menu bar, and check your required
port as shown in fig below

67
68

28. Drag the port a side and click in the program file.

29. Now keep Pressing function key “F11” slowly and observe.
You are running your program successfully

68
69

4.2 Project Code

org 0000h
ljmp main ;main program

ORG 000BH
ljmp timer_0

org 0030h
main:
clr ie.7
mov a,#00h
mov p0,a ;data to ports=0
mov p1,a
mov p2,a

mov 50h,a ;0.25 counter


mov 51h,a ;0.25 counter

setb p1.0 ;R1 LED ON


setb p1.3 ;R2 LED ON
setb p1.6 ;R3 LED ON
setb p2.1 ;R4 LED ON

setb p3.7
setb p3.6
setb p3.5
setb p3.4
acall delay
clr p1.0 ;R1 LED OFF
setb p1.2 ;G1 LED ON

setb 00
clr 01
clr 02
clr 03
clr 04

mov tmod,#01h ;timer 0 mode 1


mov tl0,#00h
mov th0,#00h ;timer is loaded
with 0000
mov ie,#10000011b ;timer 0 interrupt
setb tr0

69
70

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAIN PROGRAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
loop_inf:
jb p3.7,next1
setb 00
setb 04
clr 01
clr 02
clr 03
sjmp next_out
;;;;;;;;;;;;;;;;;;;;;;;;;;;;
next1:
jb p3.6,next2
setb 01
setb 04
clr 00
clr 02
clr 03
sjmp next_out
;;;;;;;;;;;;;;;;;;;;;;;;;;;
next2:
jb p3.5,next3
setb 02
setb 04
clr 00
clr 01
clr 03
sjmp next_out
;;;;;;;;;;;;;;;;;;;;;;;;;;;
next3:
jb p3.4,next_out
setb 03
setb 04
clr 00
clr 01
clr 02
sjmp next_out
;;;;;;;;;;;;;;;;;;;;;;;;;;
next_out:
clr 04
sjmp loop_inf
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;timer 0 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
timer_0:
clr tr0
CLR IE.7

jb 04,out_siren

INC 50h
mov a,50h

70
71

CJNE a,#02H,OUT_ID
MOV 50h,#00h
out_siren:
jb 00,first
jb 01,second
jb 02,third
jb 03,fourth
ljmp OUT_ID
;;;;;;;;;;;;;;
first:
clr p1.2 ;G1 LED off
setb p1.1 ;Y1 LED ON
acall delay
clr p1.1
setb p1.0 ;R1 LED ON

clr p1.3 ;R2 LED OFF


setb p1.5 ;G2 LED ON
clr 00
setb 01
ljmp OUT_ID
;;;;;;;;;;;;;;;;
second:
clr p1.5 ;G2 LED off
setb p1.4 ;Y2 LED ON
acall delay
clr p1.4
setb p1.3 ;R2 LED ON

clr p1.6 ;R3 LED OFF


setb p2.0 ;G3 LED ON
clr 01
setb 02
ljmp OUT_ID
;;;;;;;;;;;;;;;;;
third:
clr p2.0 ;G3 LED off
setb p1.7 ;Y3 LED ON
acall delay
clr p1.7
setb p1.6 ;R3 LED ON

clr p2.1 ;R4 LED OFF


setb p2.3 ;G4 LED ON
clr 02
setb 03
ljmp OUT_ID
;;;;;;;;;;;;;;;;;
fourth:
clr p2.3 ;G4 LED off

71
72

setb p2.2 ;Y4 LED ON


acall delay
clr p2.2
setb p2.1 ;R4 LED ON

clr p1.0 ;R1 LED OFF


setb p1.2 ;G1 LED ON
clr 03
setb 00

OUT_ID:
mov th0,#00h
mov tl0,#01h
mov ie,#10000011b
SETB TR0
RETI
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

delay1: mov 70h,#0ffh


mov 71h,#0fh
loop_2:
djnz 70h,loop_2
djnz 71h,loop_2
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
delay: mov 70h,#0ffh
mov 71h,#0ffh
mov 72h,#05h
loop_1:
djnz 70h,loop_1
djnz 71h,loop_1
djnz 72h,loop_1
ret
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Advantages

72
73

 Resistance to external disturbances such as vibration, infrared


radiation, ambient noise, and EMI radiation.

 Reduce the traffic intensity

 High signaling control


 Less affected by target materials and surfaces, and not affected by
color. Solid-state units have virtually unlimited, maintenance free
life. Can detect small objects over long operating distances.
 Reduction in time taken by the user to reach a particular.

LIMITATIONS

 COST

 BANDWIDTH

 EFFICIENCY COST
 COMPLEXITY

73
74

Applications

 Ambulance
 VIPs vehicles

74
75

CONCLUSION

The project “Microcontroller based intelligent ambulance traffic controller and

Navigation” has been successfully designed and tested. Integrating features of all

the hardware components used have developed it. Presence of every module has

been reasoned out and placed carefully thus contributing to the best working of the

unit.

Secondly, using highly advanced IC’s and with the help of growing technology the
project has been successfully implemented.

75
76

FUTURE SCOPE

This system is a rapidly growing field and there are new and improved

strategies popping up all the time. For the most part these systems are all built

around the same basic structure, a central box that monitors several detectors and

perimeter guards and sounds an alarm when any of them are triggered.

This system is best for guiding the perimeter of a house or a business

center the points where an intruder would enter the building. In this system IR

sensor is used to detect the intrusion. Similarly the vibration and temperature

sensors recognize vibration disturbances and accidental fires respectively.

This project provides an efficient and economical security system.

This system finds applications in industries, banks and homes.

Incorporating the features discussed below can further enhance the system

1. This system can detect intrusion only at discrete points. This system

detection feature can be extended to scanning a complete area. Thus the

intrusion into the building can be detected with much more efficiently.

2. The redialing feature can also be incorporated such that if the call is

not put forward the first time, the auto dialer will dial the same number

until the call is successfully completed.

3. A pre-recorded voice message can delivered to the owner notifying

him about the intrusion into the premises.

4. The addition of the above discussed advancements certainly builds this

project into a much flexible and reliable security system.

76
77

BIBLIOGRAPHY

1. The 8051 Microcontroller and Embedded Systems By Muhammad Ali Mazidi

2. Fundamentals Of Embedded Software By Daniel W Lewis

3..www.howsstuffworks.com

4. www.alldatasheets.com

5. www.electronicsforu.com

6. www.knowledgebase.com

7.www.8051 projectsinfo.com

8.Datasheets of Microcontroller AT89C52

9. Datasheets of 555 timer

10. Datasheets of TSAL 6200

11. Datasheets of TSOP 1356

12. Datasheets of BC 547

13. Datasheets of DTMF Generator UM 95089

77

Anda mungkin juga menyukai