Sei sulla pagina 1di 117







1. Abbreviations
2. Abstract
3. Introduction 5
a. Biometric
i. What is Biometrics?
ii. Why go for Biometrics
iii. Why finger Print Biometric
iv. FP Patterns
4. Block Diagram
5. Block Diagram Explanation 12
6. Schematic
7. Schematic Explanation
8. Hardware Components
a. Microcontroller
19 2

b. FP scanner
c. MAX-232
e. Power Supply
f. LCD
g. Buzzer
h. Keypad
i. Locker system
i. DC motors
ii. H-Bridge
9. Circuit description 92
10. Software Concepts 94
c. Embedded C
11. Result 108
12. Future Scope 109
13. Conclusion 110
14. Bibliography 111 3


ACC Accumulator
B B register
PSW Program status word
SP Stack pointer
DPTR Data pointer 2 bytes
DPL Low byte
DPH High byte
P0 Port0
P1 Port1
P2 Port2
P3 Port3
IP Interrupt priority control
IE Interrupt enable control
TMOD Timer/counter mode control
TCON Timer/counter control
T2CON Timer/counter 2 control
T2MOD Timer/counter mode2 control
TH0 Timer/counter 0high byte
TL0 Timer/counter 0 low byte
TH1 Timer/counter 1 high byte
TL1 Timer/counter 1 low byte
TH2 Timer/counter 2 high byte
TL2 Timer/counter 2 low byte
SCON Serial control
SBUF Serial data buffer
PCON Power control
RPS Regulated Power Supply
FP Finger Print 5


An embedded system is a special-purpose system in which the computer is

completely encapsulated by or dedicated to the device or system it controls. Unlike a
general-purpose computer, such as a personal computer, an embedded system
performs one or a few pre-defined tasks, usually with very specific requirements.
Since the system is dedicated to specific tasks, design engineers can optimize it,
reducing the size and cost of the product. Embedded systems are often mass-
produced, benefiting from economies of scale.

What is Biometrics?
The study of automated identification, by use of physical or behavioral

Physical vs. Behavioral:

• Physical
– Fingerprint
– Iris
– Ear
– Face
– Retina
– Hands
• Behavioral
– Signature
– Walking gait 6

– Typing patterns
• Both
– Voice

Why go for Biometrics?

 Authentication – the process of verifying that a user requesting a

network resource is who he, she, or it claims to be, and vice versa.
 Conventional authentication methods
• something that you have – key, magnetic card or
• something that you know – PIN or password
 Biometric authentication uses personal features
• something that you are

Biometrics has no risk of
• Forgetting it
• Loosing it
• Getting it stolen
• Getting it copied
• Being used by anyone else.

Essential Properties of a Biometric 7

• Universal
– Everyone should have the characteristic
• Uniqueness
– No two persons have the same characteristic
• Permanence
– Characteristic should be unchangeable
• Collectability
– Characteristic must be measurable

Biometric System Process Flow 8

Pattern Recognition

• Description and classification of measurements taken from

physical or mental processes
• Examination of pattern characteristics
• Formulation of the recognition system
• Important part of any biometric system

Why Fingerprint biometry?

 High Universality
 A majority of the population (>96%) have legible
 More than the number of people who possess passports,
license and IDs
 High Distinctiveness
 Even identical twins have different fingerprints (most
biometrics fail)
 Individuality of fingerprints established through empirical
 High Permanence
 Fingerprints are formed in the fetal stage and remain
structurally unchanged through out life.
 High Performance
 One of the most accurate forms of biometrics available
 Best trade off between convenience and security
 High Acceptability 9

 Fingerprint acquisition is non intrusive. Requires no training.

• Uniqueness
• Surety over the Cards and Keypads
• Against to Cards Duplication, misplacement and
improper disclosure of password
• No excuses for RF/Magnetic Cards forget ness
• No need to further invest on the Cards Cost
• No need to further manage the Cards Writing Devices

Fingerprint Patterns
• Loops
– Ridge lines enter from one side and curve around to exit
from the same side
– 60-65% of population
• Whorls
– Rounded or circular ridge pattern
– 30-35% of population
• Arches
– Ridge lines enter from one side of print and exit out the other
– 5% of population 10 11


LCD Display
Power supply


Key pad
Finger X
Print 2
Module 3
2 12


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.

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.

Finger Print Scanner:

A fingerprint sensor is an electronic device used to capture a digital image of

the fingerprint pattern. The captured image is called a live scan. This live scan is 13

digitally processed to create a biometric template (a collection of extracted features)

which is stored and used for matching.
It supports wide range of fingerprint sensor interoperability giving you a
freedom to select suitable sensor that most fits to your application. Furthermore, the
fingerprint data for enrollment and verification are compatible among different
sensors, even if they are based on different technologies. This feature of unification
presents application manufacturers and system integrators with much more flexibility
than ever before.

MAX- 232

To allow compatibility among data communication equipment made by various

manufactures, an interfacing standard called RS232 was set by the Electronic
Industries Association (EIA).This RS-232 standard is used in PCs and numerous
types of equipment .However, since the standard was set long before the advent of the
TTL logic family, its input and output voltage levels are not TTL compatible. In RS-
232 ,a 1 is represented by -3 to -25V,while a 0 bit is +3 to +25V,making -3 to +3
undefined. For this reason, to connect any RS-232 to a microcontroller system we
must use voltage converters such as MAX232 to convert the TTL logic levels to the
RS-232 voltage levels and vice versa.

So here we are using this MAX-232 to have compatibility between the Finger Print
Scanner and microcontroller.


A Micro controller consists of a powerful CPU tightly coupled with memory

RAM, ROM or EPROM), various I / O features such as Serial ports, Parallel Ports,
Timer/Counters, Interrupt Controller, Data Acquisition interfaces-Analog to Digital
Converter (ADC), Digital to Analog Converter (ADC), everything integrated onto a
single Silicon Chip. 14

It does not mean that any micro controller should have all the above said
features on chip, Depending on the need and area of application for which it is
designed, The ON-CHIP features present in it may or may not include all the
individual section said above.
Any microcomputer system requires memory to store a sequence of
instructions making up a program, parallel port or serial port for communicating with
an external system, timer / counter for control purposes like generating time delays,
Baud rate for the serial port, apart from the controlling unit called the Central
Processing Unit

In this project we are using two types of keypads, one is the matrix keypad and the
other is the normal key for selecting the mode of operation.
Here we are doing all the transactions regarding bank like deposit, withdraw, etc. for
this transactions and for entering the password we are using the 4X4 Matrix keypad.
Using the normal keypad we are going to select the mode which we are going to


This is the widely used output device to indicate the status. Here the transaction
details are clearly displayed on the LCD.


This is the output device which we are using to indicate the unauthorized person.


Here we are demonstrating a DC motor as the Locker for the authorized persons in
the Locker system mode. 15


This is the additional memory which we are using for the storage of the data for a
particular person.


Schematic Explanation:

This schematic explanation includes the detailed pin connections of every

device with the microcontroller.
Let us see the pin connections of each and every device with the
microcontroller in detail.

Power Supply:

The main aim of this power supply is to convert the 230V AC into 5V DC in order to
give supply for the TTL or CMOS devices.
In this process we are using a step down transformer, a bridge rectifier, a smoothing
circuit and the RPS.
At the primary of the transformer we are giving the 230V AC supply. The
secondary is connected to the opposite terminals of the Bridge rectifier as the input.
From other set of opposite terminals we are taking the output to the rectifier.
The bridge rectifier converts the AC coming from the secondary of the
transformer into pulsating DC. The output of this rectifier is further given to the
smoother circuit which is capacitor in our project.
The smoothing circuit eliminates the ripples from the pulsating DC and gives
the pure DC to the RPS to get a constant DC voltage.
The RPS regulates the voltage as per our requirement.

LCD module:

This module is used to display the status of voter and the competitor.
This module consists of 8 data lines D0 – D7, which are connected to the 8 pins of
port0 (P0). 18

Additionally this module is having 3 control lines namely RS, RW and EN, which are
connected to the port2 higher pins P2.7, P2.6 and P2.5 respectively.
And the supply connections are given from the Power supply output 7805 to the VCC
and VSS pins of the LCD.

Finger Print Scanner:

The finger print scanner which we are using in this project supports the RS-232
standard voltage levels where as our microcontroller supports TTL logic levels. To
interface this finger print scanner with the microcontroller we require a level
converter which is MAX-232 here.

The connections from finger print scanner are:

The transmission line is connected to RS-232 input section and the receiver line is
connected to the RS-232 output section on the MAX-232 IC to convert these voltage
levels into TTL standards. And the concerned TTL logic levels are connected to the
microcontroller TXD and the RXD lines.
Scan key:

To enable the microcontroller to read the finger print present at the scanner we are
using a scan key. After placing the finger on the scanner press this scan key to follow
the further process.
Mode Keys:
The mode keys concerned to different modes are connected as:
Locker key is connected to P3.4
Passport verification key is connected to P3.5 and
The ATM mode key is connected to P3.6.

The connections regarding this Keypad are given to Port1 entirely because it is a 4 X
4 matrix keypad.

Locker system:

The locker system which is a motor here is connected to P2.2 and P2.3 through H-
Bridge, which is used to rotate the motor in bi-direction.


The data pin and the clock pin of this PROM SDA and SCL are connected to P2.0 and
P2.1 respectively.
Here the buzzer is connected to P3.3 to indicate the wrong transaction or the wrong
passport. 20


1. Microcontroller
2. Finger print scanner
3. MAX-232
5. Power supply
6. LCD module
7. Buzzer
8. Matrix Keypad
9. Locker system


A Micro controller consists of a powerful CPU tightly coupled with memory
RAM, ROM or EPROM), various I / O features such as Serial ports, Parallel Ports, 21

Timer/Counters, Interrupt Controller, Data Acquisition interfaces-Analog to Digital

Converter (ADC), Digital to Analog Converter (ADC), everything integrated onto a
single Silicon Chip.

It does not mean that any micro controller should have all the above said
features on chip, Depending on the need and area of application for which it is
designed, The ON-CHIP features present in it may or may not include all the
individual section said above.
Any microcomputer system requires memory to store a sequence of
instructions making up a program, parallel port or serial port for communicating with
an external system, timer / counter for control purposes like generating time delays,
Baud rate for the serial port, apart from the controlling unit called the Central
Processing Unit

In 1981,Intel corporation introduced an 8 bit microcontroller called the 8051.This

microcontroller had 128 bytes of RAM,4K bytes of on-chip ROM, two timers, one
serial port, and 4 ports(each 8-bits wide)all on single chip. At that time it was also
referred to as a “system on a chip”.
The 8051 is an 8-bit processor, meaning that the CPU can
work on only 8-bits of data at a time. Data larger than 8-bits has to be broken into 8-
bit pieces to be processed by the CPU. The 8051 can have a maximum of 64K bytes
of ROM; many manufacturers have put only 4Kbytes on chip.



The major Features of 8-bit Micro controller ATMEL 89C51:

• 8 Bit CPU optimized for control applications 22

• Extensive Boolean processing (Single - bit Logic) Capabilities.

• On - Chip Flash Program Memory
• On - Chip Data RAM
• Bi-directional and Individually Addressable I/O Lines
• Multiple 16-Bit Timer/Counters
• Full Duplex UART
• Multiple Source / Vector / Priority Interrupt Structure
• On - Chip Oscillator and Clock circuitry.
• On - Chip EEPROM

Figure.1 Block Diagram






Fig.1: Oscillator Connection.

The P89C51 provides the following standard features: 4K bytes of Flash, 128
bytes of RAM, 32 I/O lines, two 16-bit timer/counters, five vector two-level interrupt
architecture, a full duplex serial port, and on-chip oscillator and clock circuitry. In
addition, the P89C51 is designed with static logic for operation down 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 hardware reset. 24

Memory Organization




EA = 0 EA = 1

External External



Fig.3 Memory Structure of the 8051. 25

Memory Organization
Program Memory
Figure 4 shows a map of the lower part of the program memory. After
reset, the CPU begins execution from location 0000H. As shown in fig.4, each
interrupt is assigned a fixed location in program memory. The interrupt causes the
CPU to jump to that location, where it executes the service routine. External Interrupt
0, for example, is assigned to location 0003H. If External Interrupt 0 is used, its
service routine must begin at location 0003H. If the interrupt is not used, its service
location is available as general purpose. 26




8 bytes



Fig. 4 Program Memory.

Program memory addresses are always 16 bits wide, even though the actual amount o
program memory used may be less than 64Kbytes. External program execution
sacrifices two of the 8-bit ports, P0 and P2, to the function of addressing the program

Data Memory

The right half of Figure 3 shows the internal and external data memory spaces
available on Philips Flash microcontrollers. Fig.6 shows a hardware configuration for
accessing up to 2K bytes of external RAM. In this case, the CPU executes from
internal flash. Port0 serves as a multiplexed address/data bus to the RAM, and 3 lines
of Port 2 are used to page the RAM. The CPU generates RD and WR signals as
needed during external RAM accesses. You can assign up to 64K bytes of external 27

data memory. External data memory addresses can be either 1 or 2bytes wide. One-
byte addresses are often used in conjunction with one or more other I/O lines to page
the RAM, as shown in Fig.6. Two-byte addresses can also be used, in which case the
high address byte is emitted at Port2.

7FH 80H
128 ADDRESSING Status and control
AND DIRECT Special bits
00 function Timers
Fig.5 Internal Data Memory. Stack pointer

Internal data memory addresses are always 1 byte wide, which implies an
address space of only 256bytes. However, the addressing modes for internal RAM can
infact accommodate 384 bytes. Direct addresses higher than 7FH access one memory
space and indirect addresses higher than 7FH access a different memory space. Thus,
Figure.7 shows the Upper 128 and SFR space occupying the same block of addresses,
80H through FFH, although they are physically separate entities. Figure.8 shows how
the lower 128 bytes of RAM are mapped. The lowest 32 bytes are grouped into 4
banks of 8 registers. Program instructions call out these registers as R0 through R7.
Two bits in the Program Status Word (PSW) select which register bank is in use. This
architecture allows more efficient use of code space, since register instructions are
shorter than instructions that use direct addressing. 28

Fig.6 the lower 128 bytes of Internal RAM

The next 16 bytes above the register banks form a block of bit-addressable memory
space. The microcontroller instruction set includes a wide selection of single-bit
instructions, and these instructions can directly address the 128 bits in this area. These
bit addresses are 00H through 7FH. All of the bytes in the Lower 128 can be accessed
by either direct or indirect addressing.

In the CPU, registers are used to store information temporarily. That
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 registers are 8–bit registers. In the 8051
there is only one data type: 8bits. The 8bits of a register are should in the diagram
from the MSB(most significant bit) D7 to the LSB(least significant bit)D0. With an
8-bit data type, any data larger than 8bits must be broken into 8-bit chunks before it is
processed. Since there are a large number of registers in the 8051, we will
concentrate on some of the widely used general-purpose registers and cover special
registers in future chapters. 29

D7 D6 D5 D4 D3 D2 D1 D0

The most widely used registers of the 8051 are A (accumulator), B, R0, R1,
R2, R3, R4, R5, R6, R7, DPTR (data pointer), and PC (program counter). All of the
above registers are 8-bits, except DPTR and the program counter. The accumulator,
register A, is used for all arithmetic and logic instructions.

SFRs (Special Function Registers)

Among the registers R0-R7 are part of the 128 bytes of RAM memory . what
about registers A,B, PSW, and DPTR? Do they also have addresses? The answer is
yes. In the 8051, registers A, B, PSW and DPTR are part of the group of registers
commonly referred to as SFR (special function registers). There are many special
function registers and they are widely used. The SFR can be accessed by the names
(which is much easier) or by their addresses. For example, register A has address
E0h, and register B has been ignited the address F0H, as shown in table.

Symbol Name Address

ACC Accumulator 0E0H
B B register 0F0H
PSW Program status word 0D0H
SP Stack pointer 81H
DPTR Data pointer 2 bytes
DPL Low byte 82H
DPH High byte 83H
P0 Port0 80H
P1 Port1 90H
P2 Port2 0A0H
P3 Port3 0B0H
IP Interrupt priority control 0B8H
IE Interrupt enable control 0A8H
TMOD Timer/counter mode control 89H
TCON Timer/counter control 88H
T2CON Timer/counter 2 control 0C8H
T2MOD Timer/counter mode2 control 0C9H
TH0 Timer/counter 0high byte 8CH
TL0 Timer/counter 0 low byte 8AH 30

TH1 Timer/counter 1 high byte 8DH

TL1 Timer/counter 1 low byte 8BH
TH2 Timer/counter 2 high byte 0CDH
TL2 Timer/counter 2 low byte 0CCH
RCAP2H T/C 2 capture register high byte 0CBH
RCAP2L T/C 2 capture register low byte 0CAH
SCON Serial control 98H
SBUF Serial data buffer 99H
PCON Power control 87H


Pin Diagram of AT89C51

Pin Description
Pin 40 provides supply voltage to the chip. The voltage source is +5v.
GND Pin 20 is the ground.

Ports 0, 1, 2 and 3
As shown in pin diagram, the four ports P0, P1, P2, and P3 each use of 8 pins,
making the 8-bit ports. All the ports upon Reset are configured as input, since P0-P3
have FFH on them. 32

Port 0
Port 0 occupies a total of 8 pins (pins 32-33). It can be used for input or
output. Port0 is also designated as AD0-AD7, allowing it to be used for both address
and data. When connecting an 8051/31 to an external memory, port 0 provides both
address and data. The 8051 multiplexes address and data through port 0 to save pins.
ALE=0, it provides data D0-D7, but when ALE=1, it has address A0-A7. Therefore,
ALE is used for de-multiplexing address and data with the help of a 74LS373 latch.
In the 8051-based systems where there is no external memory connection, the pins of
P0 must be connected externally to a 10k –ohm pull-up resistor. This is due to the
fact that P0 is an Open drain, Unlike P1, P2, P3. Open drain is a term used for MOS
chips in the same way that open collector is used for TTL chips. In many systems
using the 8751, 89C51, or DS89C4x0 chips, we normally connect P0 to pull-up
resistors. With external pull-up resistors connected to P0, it can be used as a simple
I/O port, just like P1 and P2. In contrast to Port 0, ports p1, p2, and p3 do not need
any pull-up resistors since they already have pull-up resistors internally. Upon reset,
ports p1, p2, ad p3 are configured as input ports.

Port 1
Port 1 occupies a total of 8-pins (pins1-8). It can be used as input or output.
In contrast to port 0, this port does not need any pull-up resistors since it already has
pull-up resistors internally. Upon reset, port1 is configured as an input port.
Port 2
Port 2 occupies a total 8 pins (pins 21-28). It can be used as input or output.
However, in 8031-based systems, port2 is also designated as A8-A15, indicating its
dual function. Since an 8051/31 is capable of accessing 64K bytes of external
memory, it needs a path for the 16 bits of the address. While P0 provides the lower 8
bits via A0-A7, it is the job of p2 is used for the upper 8 bits of the 16-bit address, and
it cannot be used for I/O. Just like P1, port 2 does not need any pull-up resistors since
it already has pull-up resistors internally. Upon reset, port2 is configured as an input

Port 3 33

Port 3 occupies a total of 8 pins (pins 10-17). It can be used as input or output. P3
does not need any pull-up resistors, just as P1 and P2 did not. Although Port 3 is
configured as an input port upon reset, this is not the way it is most commonly used.
Port 3 has the additional function of providing some extremely important signals such
as interrupts. The below table provides these alternate functions of P3. This is
information applies to both 8051 and 8031 chips.

Alternate Functions of PORT3

Port 3 also receives some control signals for Flash programming and verification.

Reset input. A high on this pin for two machine cycles while the oscillator is running
resets the device.
Prior to each reading from external memory, the microcontroller will set the
lower address byte (A0-A7) on P0 and immediately after that activates the output
ALE. Upon receiving signal from the ALE pin, the external register (74HCT373 or
74HCT375 circuit is usually embedded) memorizes the state of P0 and uses it as an
address for memory chip. In the second part of the microcontroller’s machine cycle, a
signal on this pin stops being emitted and P0 is used now for data transmission (Data
Bus). In this way, by means of only one additional (and cheap) integrated circuit, data 34

multiplexing from the port is performed. This port at the same time used for data and
address transmission.

Program Store Enable is the read strobe to external program memory. When the
AT89C51 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.
External Access. 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. EA
should be strapped to VCC for internal program executions. This pin also receives
the 12-volt programming enable voltage (VPP) during Flash programming, for parts
that require 12-volt VPP.
The 8051 has an on-chip oscillator but requires an external clock to run it.
Most often a quartz crystal oscillator is connected to inputs XTAL1 (pin19) and
XTAL2 (pin18). The quartz crystal oscillator connected to XTAL1 and XTAL2 also
needs two capacitors of 30pf value. One side of each capacitor is connected to the
ground as shown in fig1.
It must be noted that there are various speeds of the 8051 family. Speed refers
to the maximum oscillator frequency connected to XTAL. For example, a 12-MHz
chip must be connected to a crystal with 12 MHz frequency of no more than 20 MHz.
When the 8051 is connected to a crystal oscillator and is powered up, we can observe
the frequency on the XTAL2 pin using the oscilloscope.
If you decide to use a frequency source other than a crystal oscillator, such as
a TTL oscillator, it will be connected to XTAL1; XTAL2 is left unconnected. As
shown in fig2. 35

Fig(1) XTAL connection to 8051 fig2. XTAL connection to an External clock


Tab 6.2.2 Status of External Pins


On-chip timing/counting facility has proved the capabilities of the

microcontroller for implementing the real time application. These includes pulse
counting, frequency measurement, pulse width measurement, baud rate generation,
etc,. Having sufficient number of timer/counters may be a need in a certain design
application. The 8051 has two timers/counters. They can be used either as timers to
generate a time delay or as counters to count events happening outside the 36

microcontroller. Let discuss how these timers are used to generate time delays and we
will also discuss how they are been used as event counters.


Both Timer 0 and Timer 1 are 16 bits wide. Since the 8051 has an 8-bit
architecture, each 16-bit timer is accessed as two separate registers of low byte and
high byte.


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 the high byte register is referred to
as TH0(Timer 0 high byte).These register can be accessed like any other register, such
as A,B,R0,R1,R2,etc.for example, the instruction ”MOV TL0, #4F”moves the value
4FH into TL0,the low byte of Timer 0.These registers can also be read like any other

D15 D14 D13 D12 D11 D10 D9 D8 D7 D6 D5 D4 D3 D2 D1 D0



Timer 1 is also 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 n the
same way as the register of Timer 0.

TMOD (timer mode) REGISTER

Both timers 0 and 1 use the same register, called TMOD, to set the various
timer operation modes. TMOD is an 8-bit register in which the lower 4 bits are set
aside for Timer 0 and the upper 4 bits for Timer each case; the lower 2 bits are
used to set the timer mode and the upper 2 bits to specify the operation.

TCON Register:
TCON controls the timer/counter operations. The lower four bits of TCON cater to
interrupt functions, but the upper four bits are for timer operations. The details of the
TCON register are shown below.


TF1 TR1 TF0 TR0 IE1 IT1 IE0 IT0 38

Serial Communication:

Computers can transfer data in two ways: parallel and serial. In

parallel data transfers, often 8 or more lines (wire conductors) are used to transfer data
to a device that is only a few feet away. Examples of parallel transfers are printers
and hard disks; each uses cables with many wire strips. Although in such cases a lot
of data can be transferred in a short amount of time by using many wires in parallel,
the distance cannot be great. To transfer to a device located many meters away, the
serial method is used. In serial communication, the data is sent one bit at a time, in
contrast to parallel communication, in which the data is sent a byte or more at a time.
Serial communication of the 8051 is the topic of this chapter. The 8051 has serial
communication capability built into it, there by making possible fast data transfer
using only a few wires.
Serial data communication uses two methods, asynchronous and synchronous.
The synchronous method transfers a block of data at a time, while the asynchronous
method transfers a single byte at a time.
The 8051 transfers and receives data serially at many different baud rates. The
baud rate in the 8051 is programmable. This is done with the help of Timer1. The
8051 divides the crystal frequency by 12 to get the machine cycle frequency. In the
case of XTAL=11.0592MHZ, the machine cycle frequency is 921.6 KHz
(11.0592MHz/12=921.6KHz). The 8051’s serial communication UART circuitry
divides the machine cycle frequency of 921.6 kHz divided by 32 once more before it
is used by Timer 1 to set the Baud rate.
SBUF register
SBUF is an 8-bit register used solely for serial communication in the
8051. For a byte of data to be transferred via the TXD line, it must be placed in the
SBUF register. Similarly, SBUF holds the byte of data when it is received by the
8051’s RXD line. SBUF can be accessed like any other register in the 8051.
SCON (serial control) register
The SCON register is an 8-bit register used to program the start bit, stop bit,
and data bits of data framing, among other things. 39

The following describes various bits of the SCON register.



Internal timer stages are as fallows

Divided by X box can be replaced with T1 timer so that by changing the value of
timer we can obtain the required baud rate.
Let XClk = 11.0592 MHz
Baud Rate = (XClk / 12 / 16 / 2 / X)

For attaining 9600 baud Rate,

X can be calculated as
= 11.0592 x 106 / 12 / 16 / 2 / 9600
= 3
So set the 2’s Complement of 3 in Timer 1 so that we can achieve 9600 baud rates.

Note: Assuming 8-bit Auto reload mode and 8-bit variable baud rate modes.
Doubling the baud rate in the 8051: 40

There are two ways to increase the baud rate to data transfer in the 8051.
1. Use a higher- frequency crystal.
2. Change a bit in the PCON register, shown below.


- - -

Option1 is not feasible in many situations since the system crystal is fixed.
Importantly, it is not feasible because the new crystal may not be compatible
with the IBM PC serial COM port’s baud rate. Therefore, we will explore option2.
there is a software way to double the baud rate of the 8051 while the crystal frequency
is fixed. This is done with the register called PCON (power control). The PCON
register is an 8-bit register. Of the 8 bits, some are unused, and some are used for the
power control capability of the 8051. The bit that is used for the serial communication
is D7, the SMOD (serial mode) bit. When the 8051 is powered up, D7 (SMOD) of
this PCON register is zero. We can set it to high by software and thereby double the
baud rate.

A single microcontroller can serve several devices. There are two ways to do that:


In polling the microcontroller continuously monitors the status of a given device;

when the status condition is met, it performs the service .After that, it moves on to 41

monitor the next device until each one is serviced. Although polling can monitor the
status of several devices and serve each of them as certain condition are met.


In the interrupts method, whenever any device needs its service, the device notifies
the microcontroller by sending it an interrupts signal. Upon receiving an interrupt
signal, the microcontroller interrupts whatever it is doing and serves the device. The
program associated with the interrupts is called the interrupt service routine (ISR).or
interrupt handler.

Six Interrupts in the 8051:

In reality, only five interrupts are available to the user in the 8051, but many
manufacturers’ data sheets state that there are six interrupts since they include reset
.the six interrupts in the 8051 are allocated as above.
1. Reset. When the reset pin is activated, the 8051 jumps to address location
0000.this is the power-up reset.
2. Two interrupts are set aside for the timers: one for Timer 0 and one for Timer
1.Memory location 000BH and 001BH in the interrupt vector table belong to
Timer 0 and Timer 1, respectively.
3. Two interrupts are set aside for hardware external harder interrupts. Pin
number 12(P3.2) and 13(P3.3) in port 3 are for the external hardware
interrupts INT0 and INT1,respectively.These external interrupts are also
referred to as EX1 and EX2.Memory location 0003H and 0013H in the
interrupt vector table are assigned to INT0 and INT1, respectively.
4. Serial communication has a single interrupt that belongs to both receive and
transmit. The interrupt vector table location 0023H belongs to this interrupt. 42

Interrupt Enable Register

D7 D6 D5 D4 D3 D2 D1 D0

EA -- ET2 ES ET1 EX1 ET0 EX0

Interrupt priority upon rest:

When the 8051 is powered up, the priorities are assigned according to the below table.
in the below table we see, for example, that if external hardware interrupts 0 and 1 are
activated at the same time, external interrupt 0 (INT0) is responded to first. Only after
INT0 has been serviced is INT1 serviced, since INT1 has the lower priority. In reality,
the priority scheme in the table is nothing but an internal polling sequence in which
the 8051 polls the interrupts in the sequence listed in the below table and responds

8051/52 Interrupt Priority upon Reset

Highest to Lowest Priority

External Interrupt 0 (INT0)

Timer Interrupt 0 (TF0)
External Interrupt 1 (INT1)
Timer Interrupt 1 (TF1)
Serial Communication (RI+TI)
Timer 2(8052 only) TF2 43

Setting interrupts priority with the IP register

We can alter the sequence of above Table by assigning a higher priority to any one of
the interrupts. This is done by programming a register called IP (interrupt
priority).below diagram shows the bits of IP register. Upon power-up reset, the IP
register contain all 0s, making the priority sequence based on the above table. To give
a higher priority to any of the interrupt, we make the corresponding bit in the IP
register high.

D7 D0

-- -- PT2 PS PT1 PX1 PT0 PX0 44



A fingerprint sensor is an electronic device used to capture a digital image of

the fingerprint pattern. The captured image is called a live scan. This live scan is
digitally processed to create a biometric template (a collection of extracted features)
which is stored and used for matching.

General Descriptions 45

FIM30 is an evolutionary standalone fingerprint recognition module consisted of optic

sensor and processing board. As CPU and highly upgraded algorithm are embedded
into a module, it provides high recognition ratio even to small size, wet, dry, calloused
fingerprint. High speed 1: N identification and 1: N verification.

FIM 30 has functions of fingerprint enrollment, identification, partial and entire

deletion and reset in a single board, it does not require connection with a separate PC,
thereby offering convenient development environment.

Off-line functionality stores logs on the equipment memory (up to 100 fingerprints)
and it’s identified using search engine from the internal algorithm.

Evolutionary standalone fingerprint recognition module FIM30 is ideal for on-line

applications, because allows ASCII commands to manage the device from the host.

On-line functionality, fingerprints to verify (1:1) or identify (1: N) can be stored on

non volatile memory, or be sent by RS-232 port.


• On-line and off-line fingerprint identification incorporated

• Identification rate 1:1 and 1:N; FAR: 1/100.000 y FRR: 1/1.000
• Algorithm and high hardness optical sensor
• It provides high recognition ratio even to small size, wet, dry, calloused
• Fast acquisition of difficult finger types under virtually any condition.
• Memory capacity for 100 fingerprints
• Memory events: up to 2,000 authentications
• Access host can be protected by fingerprint or password
• It offers convenient development environment.
• Two communication ports: RS-232 or host ( on-line applications )
• ASCII protocol
• Supply voltage: 5V
• Small size and robust durability, it has longer life span. 46

This FIM 3030 is going to have the Optical Sensor to Enroll and Identify the Finger

Optical sensor

Optical fingerprint imaging involves capturing a digital image of the print

using visible light. This type of sensor is, in essence, a specialized digital camera. The
top layer of the sensor, where the finger is placed, is known as the touch surface.
Beneath this layer is a light-emitting phosphor layer which illuminates the surface of
the finger. The light reflected from the finger passes through the phosphor layer to an
array of solid state pixels (a charge-coupled device) which captures a visual image of
the fingerprint. A scratched or dirty touch surface can cause a bad image of the
fingerprint. A disadvantage of this type of sensor is the fact that the imaging
capabilities are affected by the quality of skin on the finger. For instance, a dirty or
marked finger is difficult to image properly. Also, it is possible for an individual to
erode the outer layer of skin on the fingertips to the point where the fingerprint is no
longer visible. It can also be easily fooled by an image of a fingerprint if not coupled
with a "live finger" detector. However, unlike capacitive sensors, this sensor
technology is not susceptible to electrostatic discharge damage.

Target Application

 Door-lock system
 Safe Box
 Simple Access Controller
 Vehicle Control
 ATM ,And more 47

Block Diagram

RS-232C communication data consist of 8-bit data, no parity, 1-bit start-bit and 1-bit

Here this FIM 3030 supports the serial communication protocol which is RS-232. we
are interfacing serially by converting the TTL logic into RS-232 standards and vice

For this hardware interfacing we are using MAX-232 as a level converter for reading
and writing data.

MAX-232: 48


Serial RS-232 (V.24) communication works with voltages (-15V ... -3V
for high [sic]) and +3V ... +15V for low [sic]) which are not compatible with normal
computer logic voltages. On the other hand, classic TTL computer logic operates
between 0V ... +5V (roughly 0V ... +0.8V for low, +2V ... +5V for high). Modern
low-power logic operates in the range of 0V ... +3.3V or even lower.

So, the maximum RS-232 signal levels are far too high for computer logic electronics,
and the negative RS-232 voltage for high . Therefore, to receive serial data from an
RS-232 interface the voltage has to be reduced, and the low and high voltage level
inverted. In the other direction (sending data from some logic over RS-232) the low
logic voltage has to be "bumped up", and a negative voltage has to be generated, too.

Logic Voltages

All this can be done with conventional analog electronics, e.g. a particular power
supply and a couple of transistors or the once popular 1488 (transmitter) and 1489
(receiver) ICs. However, since more than a decade it has become standard in amateur
electronics to do the necessary signal level conversion with an integrated circuit (IC)
from the MAX232 family (typically a MAX232A or some clone). In fact, it is hard to
find some

The MAX232 & MAX232A

The MAX 232 translates RS232 voltages to TTL voltages. RS232 represent a binary 1
or HI anywhere between –3V to –12V, a zero logic or LOW, between 3V and 12V.
TTL in the other hand responds to 0 to 2.1V as logic zero and 2.8V to 5V as a HI. The
MAX 232 provides voltage translation so the TTL PIC 16F84 can understand the
messages sent to it from the computer. A serial cable is also provided to connect the
MAX232 to the PC and jumper cables to connect the MAX232 to the micro
controller. 49

The MAX232 from Maxim was the first IC which in one package contains the
necessary drivers (two) and receivers (also two), to adapt the RS-232 signal voltage
levels to TTL logic. It became popular, because it just needs one voltage (+5V) and
generates the necessary RS-232 voltage levels (approx. -10V and +10V) internally.
This greatly simplified the design of circuitry. Circuitry designers no longer need to
design and build a power supply with three voltages (e.g. -12V, +5V, and +12V), but
could just provide one +5V power supply, e.g. with the help of a simple 78x05
voltage converter.

MAX232 (A) DIP Package

DIP Package of MAX 232A

A Typical Application

The MAX232 (A) has two receivers (converts from RS-232 to TTL voltage levels)
and two drivers (converts from TTL logic to RS-232 voltage levels). This means only
two of the RS-232 signals can be converted in each direction.

There are not enough drivers/receivers in the MAX232 to also connect the DTR,
DSR, and DCD signals. Usually these signals can be omitted when e.g.
communicating with a PC's serial interface. If the DTE really requires these signals 50

either a second MAX232 is needed, or some other IC from the MAX232 family can
be used (if it can be found in consumer electronic shops at all). An alternative for
DTR/DSR is also given below.

Maxim's data sheet explains the MAX232 family in great detail, including the pin
configuration and how to connect such an IC to external circuitry. This information
can be used as-is in own design to get a working RS-232 interface. Maxim's data just
misses one critical piece of information: How exactly to connect the RS-232 signals
to the IC. So here is one possible example:

MAX232 to RS232 DB9 Connection as a DCE

MAX232 Pin Nbr. MAX232 Pin Name Signal Voltage DB9 Pin
7 T2out CTS RS-232 7
8 R2in RTS RS-232 8
9 R2out RTS TTL n/a
10 T2in CTS TTL n/a
11 T1in TX TTL n/a
12 R1out RX TTL n/a
13 R1in RX RS-232 2
14 T1out TX RS-232 3
15 GND GND 0 5

Connections between MAX 232 & RS 232

In addition one can directly wire DTR (DB9 pin 4) to DSR (DB9 pin 6) without going
through any circuitry. This gives automatic (brain dead) DSR acknowledgement of an
incoming DTR signal.

Sometimes pin 6 of the MAX232 is hard wired to DCD (DB9 pin 1). This is not
recommended. Pin 6 is the raw output of the voltage pump and inverter for the -10V
voltage. Drawing currents from the pin leads to a rapid breakdown of the voltage, and 51

as a consequence to a breakdown of the output voltage of the two RS-232 drivers. It is

better to use software which doesn't care about DCD, but does hardware-handshaking
via CTS/RTS only. The circuitry is completed by connecting five capacitors to the IC
as it follows. The MAX232 needs 1.0µF capacitors, the MAX232A needs 0.1µF
capacitors. MAX232 clones show similar differences. It is recommended to consult
the corresponding data sheet. At least 16V capacitor types should be used. If
electrolytic or tantalic capacitors are used, the polarity has to be observed. The first
pin as listed in the following table is always where the plus pole of the capacitor
should be connected to. External Capacitors The 5V power supply is connected
to+5V: Pin 16 GND: Pin 15

MAX232(A) external Capacitors

Capacitor + Pin - Pin Remark
C1 1 3
C2 4 5
C3 2 16
This looks non-intuitive, but because pin 6 is
C4 GND 6 on -10V, GND gets the + connector, and not the
C5 16 GND

Drawbacks of MAX232:
 The MAX-232 chip receives data from the receiver, and converts it to the
standard RS-232 data format that can be read in by a serial port on a personal
computer or workstation.

 For the RS-232 interface, a standard MAX232 chip is used for level
conversion. Both use the on chip USART and thus the same firmware.

If you wanted to do a general RS-232 connection, you could take a bunch of long
wires and solder them directly to the electronic circuits of the equipment you are
using, but this tends to make a big mess and often those solder connections tend to
break and other problems can develop. To deal with these issues, and to make it easier
to setup or take down equipment, some standard connectors have been developed that
is commonly found on most equipment using the RS-232 standards

EEPROM (24C02):

• Low power CMOS
— Active current less than 2 mA
— Standby current less than 8 mA
• Hardware writes protection
— Write control pin
• Internally organized as 256 x 8
• Two-wire serial interface
— Bidirectional data transfer protocol
• 8-Byte page-write mode
— Minimized total write time per byte
• Automatic word address incrementing
— Sequential register read
• Self-timed write cycle
— Maximum write cycle time of 10 ms
• 400 KHz Compatibility
Endurance: 1, 000,000 cycles per byte
• 8-pin PDIP, TSSOP, MSOP or SOIC packages
• Filtered inputs for noise suppression

The IS24C02 is a low cost 2,048-bit serial EEPROM. It is fabricated using ISSI’s
advanced CMOS EEPROM technology and operates from a single supply. The 53

IS24C02 is internally organized as a 256 x 8 memory bank. The IS24C02 features a

serial interface and software protocol allowing operation on a simple 2-wire bus. Up
to eight IS24C02s may be connected to the 2-wire bus by programming the A0, A1,
and A2 inputs.


A0-A2 Address Inputs
SDA Serial Data I/O
SCL Serial Clock Input
WC Write Control Input
VCC Power
GND Ground

A0, A1, and A2 - The address inputs are used to set the least significant three bits of
the slave address. These inputs may be tied HIGH or LOW, or they may be actively
driven. These inputs allow up to eight IS24C02 devices to be connected together on
the bus. When left floating, A0,
A1 and A2 are pulled to ground. The default values are zeros.

Serial Data (SDA) - The SDA pin is a bidirectional pin used to transfer data into and
out of the device. Data may change only when SCL is LOW. It is an open-drain
output, and may be wire ORed with any number of open-drain or open-collector
outputs. 54

Serial Clock (SCL) - The SCL input is used to clock all data into and out of the
device. In the WRITE mode, data must remain stable when SCL is HIGH. In the
READ mode, data is clocked out on the falling edge of SCL.

Write Control (WC) - The Write Control input is used to disable any attempt to write
to the memory. When HIGH, the memory is protected; when LOW, the write function
is normal. The part can be read independent of the state of WC pin. When not
connected, this pin will be pulled LOW.


The IS24C02 is designed for applications requiring high endurance write cycles and
unlimited read cycles. It provides 10 years of secure data retention, with or without
power applied, after the execution of 1,000,000 write cycles.

The IS24C02 is ideal for high volume applications requiring low power and low
density storage. This device uses a low-cost, space-saving 8-pin plastic package.
Candidate applications include robotics, alarm devices, electronic locks, meters and

The IS24C02 features a SERIAL communication, and supports bidirectional data
transmission protocol allowing operation on a simple two-wire bus between the
different devices connected somewhere on the system bus. The two-wire bus is
defined as a serial data line (SDA), and a serial clock line (SCL).

The protocol defines any device that sends data onto the SDA bus as a transmitter,
and the receiving device as a receiver. The device controlling the data transmission is 55

named MASTER device, and the controlled device is named SLAVE device. In all
cases, the IS24C02 will be a slave device, since it never initiates any data transfers.
Up to eight IS24C02 can be connected to the bus. Device's physical address inputs A0-A2
must be connected to either VCC or GND. When left floating, A0, A1 and A2 are
pulled to ground. The default values are zeros.

Following a START condition, the MASTER (transmitter) device must initiate the
“Device Addressing Byte” including device type identifier, device address, and a read
or write operation to select a slave device (receiver) connected to the system bus. The
receiver will then respond with an Acknowledge by pulling the SDA line LOW. The
Acknowledge is used to indicate successful data transfers. The transmitting device
will release the data bus (SDA goes HIGH) after transmitting eight bits (one data bit
is transferred at the falling edge of each clock cycle). During the ninth clock cycle, the
receiver will pull the SDA line LOW to acknowledge the transmitter that it received
the eight bits of data.


START and STOP Conditions

Both SDA and SCL lines remain HIGH when the SDA bus is not busy. A HIGH-to-
LOW transition of SDA line, while SCL is HIGH, is defined as the START condition.
A LOW to- High transition of SDA line, while SCL is HIGH, is defined as the STOP

Data Validity Protocol 56

One data bit is transferred during each clock cycle. The data on the SDA line must
remain stable during the HIGH period of the clock cycle, because changes on SDA
line during the SCL HIGH period will be interpreted as START or STOP control

Device Addressing Byte Definitions

The most significant four bits of Device Addressing Byte (Bit 7 to Bit 4) are defined
as the device type identifier. For IS24C02, this is fixed as 1010. The next three
significant address bits (Bit 3 to Bit 1) address a particular device. Up to eight
IS24C02 devices can be connected on the bus.
These eight addresses are defined by the state of the A0, A1, and A2 inputs. The last
bit Bit 0 defines the write or read operation to be performed. When set to “1”, a
READ operation is selected; when set to “0” a WRITE operation is selected.

Byte Write 57

For a WRITE operation, the IS24C02 requires another 8-bit data word address
following the Device Addressing Byte and Acknowledgement. This data word
address provides access to any one of the 256 data words of device's memory array.

Upon receipt of the data word address, the IS24C02 responds with an Acknowledge
on SDA, and waits for the next 8-bit data word, then again responding with an
Acknowledge. The master device terminates the Byte Write Operation by generating a
STOP condition; afterward the IS24C02 begins the internal WRITE cycle to the
nonvolatile memory array. Refer to Write Cycle Timing. All inputs are disabled
during this write cycle and the device will not respond to any requests from the

Page Write
The IS24C02 is capable of 8-byte page- WRITE operation. A page-WRITE is
initiated in the same manner as a byte write, but instead of terminating the internal
write cycle after the first data word is transferred, the master device can transmit up to
7 more words. After the receipt of each data word, the IS24C02 responds immediately
with an Acknowledge on SDA line, and the four lower order data word address bits
are internally incremented by one while the four higher order bits of the data word
address remain constant. If the master device should transmit more than 8 words,
prior to issuing the STOP condition, the address counter will “roll over,” and the
previously written data will be overwritten. All inputs are disabled until completion of
the internal WRITE cycle.

Acknowledge Polling
Once the internal write cycle has started and the IS24C02 inputs are disabled,
acknowledge polling can be initiated. This involves sending a start condition followed
by the Device Addressing Byte. The read/write bit is representation of the operation 58

desired. Only if the internal write cycle has been completed will the IS24C02 respond
with acknowledge on the SDA bus allowing the read or write sequence to continue.

READ operations are initiated in the same manner as WRITE operations, except that
the read/write bit of the device addressing byte is set to “1”. There are three READ
operation options: current address read, random address read and sequential read.
Current Address Read
The IS24C02 contains an internal address counter which maintains the address of the
last data word accessed, incremented by one. For example, if the previous operation
either a read or write operation addressed to the address location n, the internal
address counter would increment to address location n+1. When the IS24C02 receives
the Device Addressing Byte with a READ operation (read/write bit set to “1”), it will
respond an Acknowledge and transmit the 8-bit data word stored at address location
n+1. If the Current Address READ operation only accesses a single byte of data, the
master device terminates the Current Address READ operation by pulling
Acknowledge HIGH (lack of Acknowledge) indicating the last data word to be read,
followed by a STOP condition.

Random Access Read

Random Address READ operation allows the master device to access any memory
location in a random fashion. This operation involves a two-step process. First, the
master device generates a START condition and initiates Device Addressing Byte
with a dummy WRITE operation (read/write bit sets to “0”), followed by the address 59

of the data word the master device is to READ. This procedure stores the desired
address of data word to the internal address counter of the IS24C02.

After the data word address Acknowledge is received by the master device, the master
device now initiates a CURRENT ADDRESS READ by sending Device Addressing
Byte with a READ operation (read/write bit sets to “1”). The IS24C02 responds with
an Acknowledge and transmits the eight data bits stored at the address location where
the master device is to READ. At this point, the master device terminates the
operation by pulling Acknowledge HIGH (lack of Acknowledge) indicating the last
data word to be read, followed by a STOP condition.

Sequential Read
Sequential Reads can be initiated as either a Current Address Read or Random
Address Read. The first data word is transmitted as with the other byte read modes,
the master device now responds with an ACKnowledge indicating that it requires
additional data from the IS24C02. The IS24C02 continues to output data for each
ACKnowledge received. the master device terminates the sequential READ operation
by pulling ACKnowledge HIGH (lack of ACKnowledge) indicating the last data word
to be read, followed by a STOP condition.

The data output is sequential; with the data from address n followed by the date from
address n+1 ... etc. The address-counter increments by one automatically, allowing
the entire memory contents to be serially read during sequential read operation. When
the memory address boundary (address 255) is reached, the address counter “rolls
over” to address 0, and the IS24C02 continues to output data for each Acknowledge
received. 60



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 .To make a 5 volt
power supply, we use a LM7805 voltage regulator IC (Integrated Circuit). The IC is
shown below. 61

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
succesfully as part of many electronics projects
Applications: Part of electronics devices, small laboratory power supply
Power supply voltage: Unreglated DC 8-18V power supply
Power supply current: Needed output current + 5 mA
Component costs: Few dollars for the electronics components + the input
transformer cost. 62


This 5V dc acts as Vcc to the microcontroller. The excess voltage is dissipated as

heat via an Aluminum heat sink attached to the voltage regulator.


power supply—A device for the conversion of available power of one set of
characteristics to meet specified requirements. Typical application of power supplies
includes converting raw input power to a controlled or stabilized voltage and/or
current for the operation of electronic equipment.

Power supplies belong to the field of power electronics, the use of

electronics for the control and conversion of electrical power. A power supply is
sometimes called a power converter and the process is called power conversion. It is 63

also sometimes called a power conditioner and the process is called power

There are many types of power supplies. Most are designed to convert
high voltage AC mains electricity to a suitable low voltage supply for electronics
circuits and other devices. A power supply can be broken down into a series of
blocks, each of which performs a particular function. The power supplies used in our
project, Digital Control of Three-Phase Induction Motor are +5V and+12V.

These power supplies can be designed by a simple circuit

arrangement consisting of bridge rectifier (here we used diodes connected in bridge
arrangement called the Diode Bridge), Capacitive or inductive filter, regulator (7812
for +12V and 7805 for +5V), resistor and Light Emitting Diode (LED) and
transformer. The purpose of each component in the power supply design circuit
shown in the schematic (drawn using Express SCH) is described below:


Transformer is basically a one that transforms. A device used to transfer electric

energy from one circuit to another, especially a pair of multiply wound, inductively
coupled wire coils that affect such a transfer with a change in voltage, current, phase,
or other electric characteristic. In other words Transformers convert AC electricity
from one voltage to another with little loss of power.

Transformers work only with AC and this is one of the reasons why mains electricity
is AC. If the output voltage of a transformer is greater than the input voltage, it is
called a step-up transformer. If the output voltage of a transformer is less than the
input voltage it is called a step-down transformer. Most power supplies use a step-
down transformer to reduce the dangerously high mains voltage (230V in UK) to a
safer low voltage. 64

The input coil is called the primary and the output coil is called the secondary. There
is no electrical connection between the two coils; instead they are linked by an
alternating magnetic field created in the soft-iron core of the transformer. The two
lines in the middle of the circuit symbol shown below represent the core Transformers
waste very little power so the power out is (almost) equal to the power in. Note that as
voltage is stepped down current is stepped up.

The ratio of the number of turns on each coil, called the turns ratio, determines the
ratio of the voltages. A step-down transformer has a large number of turns on its
primary (input) coil, which is connected to the high voltage mains supply, and a small
number of turns on its secondary (output) coil to give a low output voltage. 65

Turns Ratio = Vp / Vs = Np / Ns and

Power Out = Power In i.e., Vs * Is =Vp * Ip

Where, Vp =Primary (input) voltage

Np =Number of turns on primary coil

Ip =Primary (input) current

Vs =Secondary (output) voltage

Ns =Number of turns on secondary coil

Is =Secondary (output) current

Uses of transformers

• Electric power transmission over long distances. The simplicity, reliability, and
economy of conversion of voltages by stationary transformers were the principal
factor in the selection of alternating current power transmission.

• High-voltage direct-current HVDC power transmission systems. Large, specially

constructed power transformers are used for electric arc furnaces used in steel
making. 66

• Rotating transformers are designed so that one winding turns while the other
remains stationary. These can pass power or radio signals from a stationary
mounting to a rotating mechanism, or radar antenna.

• Sliding transformers can pass power or signals from a stationary mounting to a

moving part such as a machine tool head. See linear variable differential

• Some rotary transformers are precisely constructed in order to measure distances

or angles. Usually they have a single primary and two or more secondaries, and
electronic circuits measure the different amplitudes of the currents in the
secondaries. See synchro and resolver.

• Small transformers are often used to isolate and link different parts of radio
receivers and audio amplifiers, converting high current low voltage circuits to low
current high voltage, or vice versa. See electronics and impedance matching. See
also isolation transformer and repeating coil.

• Balanced-to-unbalanced conversion. A special type of transformer called a balun

is used in radio and audio circuits to convert between balanced circuits and
unbalanced transmission lines such as antenna down leads. A balanced line is one
in which the two conductors (signal and return) have the same impedance to
ground: twisted pair and "balanced twin" are examples. Unbalanced lines include
coaxial cable sand strip-line traces on printed circuit boards. A similar use is for
connecting the "single ended" input stages of an amplifier to the high-powered
"push-pull" output stage.

Center tap transformers:

In electronics, a center tap is a wire that is connected to a point half way along one of
the windings of a transformer, inductor or a resistor. Center taps are sometimes used
on inductors for the coupling of signals, although most tapings are not at the center
but usually near one end. In the case of resistors, tapping is usually done only with
potentiometers, and center tapping is just a special case of normal operation of these


Rectification is a process of conversion of AC to DC. Here, the AC of transformer

output is given to the rectifier input, which converts it to DC output. Basically, bridge
rectifiers or diodes arranged in bridge called Diode arrangement are used for power
supply design.

A bridge rectifier makes use of four diodes in a bridge arrangement to achieve full-
wave rectification. This is a widely used configuration, both with individual diodes
wired as shown and with single component bridges where the diode bridge is wired

Current Flow in the Bridge Rectifier 68

For both positive and negative swings of the transformer, there is a forward path
through the diode bridge. Both conduction paths cause current to flow in the same
direction through the load resistor, accomplishing full-wave rectification.

While one set of diodes is forward biased, the other set is reversing biased and
effectively eliminated from the circuit.

Diode Bridge:

A diode bridge is an arrangement of four diodes connected in a bridge circuit as

shown below, that provides the same polarity of output voltage for any polarity of the
input voltage. When used in its most common application, for conversion of
alternating current (AC) input into direct current (DC) output, it is known as a bridge
rectifier. The diagram describes a diode-bridge design known as a full-wave rectifier
or Graetz circuit. This design can be used to rectify single phase AC when

No transformer center tap is available. 69

The essential feature of this arrangement is that for both polarities of the voltage at the
bridge input, the polarity of the output is constant. When the input connected at the
left corner of the diamond is positive with respect to the one connected at the right
hand corner, current flows to the right along the upper colored path to the output, and
returns to the input supply via the lower one.

When the right hand corner is positive relative to the left hand corner, current flows
along the upper colored path and returns to the supply via the lower colored path. 70

AC, half-wave and full wave rectified signals

In each case, the upper right output remains positive with respect to the lower right
one. Since this is true whether the input is AC or DC, this circuit not only produces
DC power when supplied with AC power: it also can provide what is sometimes
called "reverse polarity protection". That is, it permits normal functioning when
batteries are installed backwards or DC input-power supply wiring "has its wires
crossed" (and protects the circuitry it powers against damage that might occur without
this circuit in place).

Prior to availability of integrated electronics, such a bridge rectifier was always

constructed from discrete components. Since about 1950, a single four-terminal
component containing the four diodes connected in the bridge configuration became a
standard commercial component and is now available with various voltage and
current ratings.


A capacitor is a device that stores energy in the electric field created between a pair of
conductors on which equal but opposite electric charges have been placed. A
capacitor is occasionally referred to using the older term condenser. 71

A capacitor consists of two electrodes or plates, each of which stores an opposite

charge. These two plates are conductive and are separated by an insulator or
dielectric. The charge is stored at the surface of the plates, at the boundary with the
dielectric. Because each plate stores an equal but opposite charge, the total charge in
the capacitor is always zero.

The capacitor's capacitance (C) is a measure of the amount of charge (Q) stored on
each plate for a given potential difference or voltage (V) which appears between the

In SI units, a capacitor has a capacitance of one farad when one coulomb of charge
causes a potential difference of one volt across the plates. Since the farad is a very
large unit, values of capacitors are usually expressed in microfarads (µF), nanofarads
(nF) or Pico farads (pF).

The capacitance is proportional to the surface area of the conducting plate and
inversely proportional to the distance between the plates. It is also proportional to the
permittivity of the dielectric (that is, non-conducting) substance that separates the
plates.The capacitance of a parallel-plate capacitor is given by:

Where ε is the permittivity of the dielectric, A is the area of the plates and d is the
spacing between them.

Capacitors are commonly used in power supplies where they smooth the output of a
full or half wave rectifier. They can also be used in charge pump circuits as the energy
storage element in the generation of higher voltages than the input voltage.

Capacitors are connected in parallel with the power circuits of most electronic devices
and larger systems (such as factories) to shunt away and conceal current fluctuations 72

from the primary power source to provide a "clean" power supply for signal or control
circuits. Audio equipment, for example, uses several capacitors in this way, to shunt
away power line hum before it gets into the signal circuitry. The capacitors act as a
local reserve for the DC power source, and bypass Ac currents from the power supply.

Capacitors are used in power factor correction. Such capacitors often come as three
capacitors connected as a three phase load. Usually, the values of these capacitors are
given not in farads but rather as a reactive power in volt-amperes reactive (VAr). The
purpose is to match the inductive loading of machinery which contains motors, to
make the load appear to be mostly resistive.

Capacitors are also used in parallel to interrupt units of a high-voltage circuit breaker
in order to distribute the voltage between these units. In this case they are called
grading capacitors. In schematic diagrams, a capacitor used primarily for DC charge
storage is often drawn vertically in circuit diagrams with the lower, more negative,
plate drawn as an arc. The straight plate indicates the positive terminal of the device;
if it is polarized Non-polarized electrolytic capacitors used for signal filtering are
typically drawn with two curved plates. Other non-polarized capacitors are drawn
with two straight plates.

Non-polarized fixed capacitor

A non-polarized ("non polar") capacitor is a type of capacitor that has no implicit

polarity -- it can be connected either way in a circuit. Ceramic, mica and some
electrolytic capacitors are non-polarized. You'll also sometimes hear people call them
"bipolar" capacitors. 73

Polarized fixed capacitor

A polarized ("polar") capacitor is a type of capacitor that has implicit polarity -- it can
only be connected one way in a circuit. The positive lead is shown on the schematic
(and often on the capacitor) with a little "+" symbol. The negative lead is generally
not shown on the schematic, but may be marked on the capacitor with a bar or "-"
symbol. Polarized capacitors are generally electrolytes.

The simple capacitor filter is the most basic type of power supply filter. The
application of the simple capacitor filter is very limited. It is sometimes used on
extremely high-voltage, low-current power supplies for cathode ray and similar
electron tubes, which require very little load current from the supply. The capacitor
filter is also used where the power-supply ripple frequency is not critical; this
frequency can be relatively high.


A regulator converts varying input voltage and produces a constant "regulated"

output voltage.

The linear regulator is the basic building block of nearly every

power supply used in electronics. The IC linear regulator is so easy to use that it is
virtually foolproof, and so inexpensive that it is usually one of the cheapest
components in an electronic assembly. A linear regulator operates by using a voltage-
controlled current source to force a fixed voltage to appear at the regulator output
terminal. Series every electronic circuit is designed to operate off of some supply
voltage, which is usually assumed to be constant. A voltage regulator provides this
constant DC output voltage and contains circuitry that continuously holds the output
voltage at the design value regardless of changes in load current or input voltage (this
assumes that the load current and input voltage are within the specified operating
range for the part).

Voltage regulators are available in a variety of outputs, typically 5

volts, 9 volts and 12 volts. The last two digits in the name indicate the output voltage.
The "LM78XX" series of voltage regulators are designed for positive input. For
applications requiring negative input the "LM79XX" is used.

Name Voltage
LM7805 + 5 volts
LM7809 + 9 volts
LM7812 + 12 volts
LM7905 - 5 volts
LM7909 - 9 volts
LM7912 - 12 volts 75


A liquid crystal display (LCD) is a thin, flat display device made up of any
number of color or monochrome pixels arrayed in front of a light source or reflector. Each
pixel consists of a column of liquid crystal molecules suspended between two transparent
electrodes, and two polarizing filters, the axes of polarity of which are perpendicular to
each other. Without the liquid crystals between them, light passing through one would be
blocked by the other. The liquid crystal twists the polarization of light entering one filter
to allow it to pass through the other. 76

Many microcontroller devices use 'smart LCD' displays to output visual

information. LCD displays designed around Hitachi's LCD HD44780 module, are
inexpensive, easy to use, and it is even possible to produce a readout using the 8x80
pixels of the display. They have a standard ASCII set of characters and mathematical
For an 8-bit data bus, the display requires a +5V supply plus 11 I/O lines. For a 4-
bit data bus it only requires the supply lines plus seven extra lines. When the LCD display
is not enabled, data lines are tri-state and they do not interfere with the operation of the
Data can be placed at any location on the LCD. For 16×2 LCD, the address locations are:

Address locations for a 2x16 line LCD


The LCD also requires 3 control lines from the microcontroller:
1) Enable (E)
This line allows access to the display through R/W and RS lines. When this line is low,
the LCD is disabled and ignores signals from R/W and RS. When (E) line is high, the
LCD checks the state of the two control lines and responds accordingly.
2) Read/Write (R/W)
This line determines the direction of data between the LCD and microcontroller. When it
is low, data is written to the LCD. When it is high, data is read from the LCD.
3) Register select (RS)
With the help of this line, the LCD interprets the type of data on data lines. When it is
low, an instruction is being written to the LCD. When it is high, a character is being
written to the LCD.

Logic status on control lines:

•E - 0 Access to LCD disabled
- 1 Access to LCD enabled
• R/W - 0 Writing data to LCD 77

- 1 Reading data from LCD

• RS - 0 Instructions
- 1 Character

Writing and reading the data from the LCD:

Writing data to the LCD is done in several steps:
1) Set R/W bit to low
2) Set RS bit to logic 0 or 1 (instruction or character)
3) Set data to data lines (if it is writing)
4) Set E line to high
5) Set E line to low
Read data from data lines (if it is reading):
1) Set R/W bit to high
2) Set RS bit to logic 0 or 1 (instruction or character)
3) Set data to data lines (if it is writing)
4) Set E line to high
5) Set E line to low

Most LCDs with 1 controller has 14 Pins and LCDs with 2 controller has 16 Pins
(Two pins are extra in both for back-light LED connections).

Pin diagram of 2x16 line LCD 78

Pin description of the LCD

A buzzer or beeper is a signaling device, usually electronic, typically used in
automobiles, household appliances such as a microwave oven, or game shows. It most
commonly consists of a number of switches or sensors connected to a control unit that
determines if and which button was pushed or a preset time has lapsed, and usually
illuminates a light on the appropriate button or control panel, and sounds a warning in
the form of a continuous or intermittent buzzing or beeping sound. Initially this device 79

was based on an electromechanical system which was identical to an electric bell

without the metal gong (which makes the ringing noise). Often these units were
anchored to a wall or ceiling and used the ceiling or wall as a sounding board.
Another implementation with some AC-connected devices was to implement a circuit
to make the AC current into a noise loud enough to drive a loudspeaker and hook this
circuit up to a cheap 8-ohm speaker. Nowadays, it is more popular to use a ceramic-
based piezoelectric sounder like a Sonalert which makes a high-pitched tone. Usually
these were hooked up to "driver" circuits, which varied the pitch of the sound or
pulsed the sound on and off.

Electronic symbol for buzzer.

Metal disk with piezoelectric disk attached, as found in a buzzer

In game shows it is also known as a "lockout system," because when one person
signals ("buzzes in"), all others are locked out from signalling.Several game shows
have large buzzer buttons which are identified as "plungers".

The word "buzzer" comes from the rasping noise that buzzers made when they were
electromechanical devices, operated from stepped-down AC line voltage at 50 or 60 80

cycles. Other sounds commonly used to indicate that a button has been pressed are a
ring or a beep.


Keyboards and LCDs are the most widely used input/output devices of the 8051, and
a basic understanding of them is essential. In this section, we first discuss keyboard
fundamentals, along with key press and key detection mechanisms, Then we show
how a keyboard is interfaced to an 8051.

Interfacing the Keyboard to the 8051

At the lowest level, keyboards are organized in a matrix of rows and columns. The
CPU accesses both rows and column through ports; therefore, with two 8-bit ports, an
8*8 matrix of keys can be connected to a microprocessor. When a key pressed, a row
and column make a connect; otherwise, there is no connection between row and
column. In IBM PC keyboards, a single micro controller (consisting of
microprocessor, RAM and EPROM, and several ports all on a single chip) takes care
of software and hardware interfacing of keyboard. In such systems it is the function of
programs stored in the EPROM of micro controller to scan the keys continuously,
identify which one has been activated, and present it to the motherboard. In this
section we look at the mechanism by which the 8051 scans and identifies the key.

Scanning and identifying the key

Figure13.5 shows a 4*4 matrix connected to two ports. The rows are connected to an
output port and the columns are connected to an input port. If no key has been
pressed, reading the input port will yield 1s for all columns since they are all
connected to high (Vcc) If all the rows are grounded and a key is pressed, one of the
columns will have 0 since the key pressed provides the path to ground. It is the
function of the micro controller to scan the keyboard continuously to detect and
identify the key pressed. How it is done is explained next. 82

Grounding rows and reading columns

To detect a pressed key, the micro controller grounds all rows by providing 0 to the
output latch, and then it reads the columns. If the data read from the columns is D3-
D0=1111, no key has been pressed and the process continues until a key press is
detected. However, if one of the column bits has a zero, this means that a key press
has occurred. For example, if D3-D0=1101, this means that a key in the D1 column
has been pressed. After a key press is detected, the micro controller will go through
the process of identifying the key. Starting with the top row, the micro controller
grounds it by providing a low to row D0 only; then it reads the columns. If the data
read is all1s, no key in that row is activated and the process is moved to the next row.
It grounds the next row, reads the columns, and checks for any zero. This process
continues until the row is identified. After identification of the row in which the key
has been pressed, the next task is to find out which column the pressed key belongs to. 83

This should be easy since the microcontroller knows at any time which row and
column are being accessed.

Assembly language program for detection and identification of key activation is given
below. In this program, it is assumed that P1 and P2 are initialized as output and
input, respectively. Program13.1 goes through the following four major stages:

1. To make sure that the preceding key has been released, 0s are output to all rows at
once, and the columns are read and checked repeatedly until all the columns are high.
When all columns are found to be high, the program waits for a short amount of time
before it goes to the next stage of waiting for a key to be pressed.

2) To see if any key is pressed, the columns are scanned over and over in an infinite
loop until one of them has a 0 on it. Remember that the output latches connected to
rows still have their initial zeros (provided in stage 1), making them grounded. After
the key press detection, it waits 20ms for the bounce and then scans the columns
again. This serves two functions: (a) it ensures that the first key press detection was
not an erroneous one due to spike noise, and(b) the 20ms delay prevents the same key
press from being interpreted as a multiple key press. If after the 20-ms delay the key
is still pressed, it goes to the next stage to detect which row it belongs to; otherwise, it
goes back into the loop to detect a real key press

3) To detect which row the key press belongs to, it grounds one row at a time,
reading the columns each time. If it finds that all columns are high, this means that the
key press cannot belong to that row; therefore, it grounds the next row and continues
until it finds the row the key press belongs to. Upon finding the row that the key press
belongs to, it sets up the starting address for the look-up table holding the scan codes
(or the ASCII value) for that row and goes to the next stage to identify the key.
4) To identify the key press, it rotates the column bits, one bit at a time, into the
carry flag and checks to see if it is low. Upon finding the zero, it pulls out the ASCII
code for that key from the look-up table; Otherwise, it increments the pointer to point
to the next element of the look-up table. 84

While the key press detection is standard for all keyboards, the process for
determining which key is pressed varies. The look-up table method shown in program
can be modified to work with any matrix up to 8*8.

There are IC chips such as National Semiconductors MM74C923 that incorporate

keyboard scanning and decoding all in one chip. Such chips use combinations of
counters and logic gates (No micro controller).


The keypad is the most widely used input device for microcontroller. Here we
are having two different sets of keypads one for entering the password and the other
for electing a person.

Any way here we are using a momentary NO switch which is open by default. When
ever we are pressing a key the concerned circuit will be closed and the resultant value
will be read by microcontroller and depends on our program the controller will takes
the further actions.

Schematic of momentary NO switch 85

DC Motor
DC motors are configured in many types and sizes, including brush
less, servo, and gear motor types. A motor consists of a rotor and a permanent
magnetic field stator. The magnetic field is maintained using either permanent
magnets or electromagnetic windings. DC motors are most commonly used in
variable speed and torque.
Motion and controls cover a wide range of components that in some
way are used to generate and/or control motion. Areas within this category include
bearings and bushings, clutches and brakes, controls and drives, drive components,
encoders and resolves, Integrated motion control, limit switches, linear actuators,
linear and rotary motion components, linear position sensing, motors (both AC and
DC motors), orientation position sensing, pneumatics and pneumatic components,
positioning stages, slides and guides, power transmission (mechanical), seals, slip

Motors are the devices that provide the actual speed and torque in a
drive system. This family includes AC motor types (single and multiphase motors,
universal, servo motors, induction, synchronous, and gear motor) and DC motors
(brush less, servo motor, and gear motor) as well as linear, stepper and air motors, and
motor contactors and starters.
In any electric motor, operation is based on simple electromagnetism.
A current-carrying conductor generates a magnetic field; when this is then placed in
an external magnetic field, it will experience a force proportional to the current in the
conductor, and to the strength of the external magnetic field. As you are well aware of
from playing with magnets as a kid, opposite (North and South) polarities attract,
while like polarities (North and North, South and South) repel. The internal
configuration of a DC motor is designed to harness the magnetic interaction between 86

a current-carrying conductor and an external magnetic field to generate rotational


Let's start by looking at a simple 2-pole DC electric motor (here red

represents a magnet or winding with a "North" polarization, while green represents a
magnet or winding with a "South" polarization).

Every DC motor has six basic parts -- axle, rotor (a.k.a., armature), stator,
commutator, field magnet(s), and brushes. In most common DC motors (and all that
Beamers will see), the external magnetic field is produced by high-strength permanent
magnets1. The stator is the stationary part of the motor -- this includes the motor
casing, as well as two or more permanent magnet pole pieces. The rotor (together with
the axle and attached commutator) rotates with respect to the stator. The rotor consists
of windings (generally on a core), the windings being electrically connected to the
commutator. The above diagram shows a common motor layout -- with the rotor
inside the stator (field) magnets.

The geometry of the brushes, commutator contacts, and rotor windings are
such that when power is applied, the polarities of the energized winding and the stator
magnet(s) are misaligned, and the rotor will rotate until it is almost aligned with the
stator's field magnets. As the rotor reaches alignment, the brushes move to the next
commutator contacts, and energize the next winding. Given our example two-pole
motor, the rotation reverses the direction of current through the rotor winding, leading
to a "flip" of the rotor's magnetic field, and driving it to continue rotating. 87

In real life, though, DC motors will always have more than two poles
(three is a very common number). In particular, this avoids "dead spots" in the
commutator. You can imagine how with our example two-pole motor, if the rotor is
exactly at the middle of its rotation (perfectly aligned with the field magnets), it will
get "stuck" there. Meanwhile, with a two-pole motor, there is a moment where the
commutator shorts out the power supply (i.e., both brushes touch both commutator
contacts simultaneously). This would be bad for the power supply, waste energy, and
damage motor components as well. Yet another disadvantage of such a simple motor
is that it would exhibit a high amount of torque” ripple" (the amount of torque it could
produce is cyclic with the position of the rotor).

So since most small DC motors are of a three-pole design, let's tinker with
the workings of one via an interactive animation (JavaScript required):

You'll notice a few things from this -- namely, one pole is fully energized
at a time (but two others are "partially" energized). As each brush transitions from one
commutator contact to the next, one coil's field will rapidly collapse, as the next coil's
field will rapidly charge up (this occurs within a few microsecond). We'll see more 88

about the effects of this later, but in the meantime you can see that this is a direct
result of the coil windings' series wiring:

There's probably no better way to see how an average dc motor is put together,
than by just opening one up. Unfortunately this is tedious work, as well as requiring
the destruction of a perfectly good motor. This is a basic 3-pole dc motor, with 2
brushes and three commutator contacts. 89


DC motors are typically controlled by using a transistor

configuration called an "H-bridge". This consists of a minimum of four mechanical or
solid-state switches, such as two NPN and two PNP transistors. One NPN and one
PNP transistor are activated at a time. Both NPN and PNP transistors can be activated
to cause a short across the motor terminals, which can be useful for slowing down the
motor from the back EMF it creates.

Basic Theory

H-bridge. Sometimes called a "full bridge" the H-bridge is so named because it has
four switching elements at the "corners" of the H and the motor forms the cross bar.

The key fact to note is that there are, in theory, four switching elements within the
bridge. These four elements are often called, high side left, high side right, low side
right, and low side left (when traversing in clockwise order).

The switches are turned on in pairs, either high left and lower right, or lower left and
high right, but never both switches on the same "side" of the bridge. If both switches
on one side of a bridge are turned on it creates a short circuit between the battery plus
and battery minus terminals. If the bridge is sufficiently powerful it will absorb that
load and your batteries will simply drain quickly. Usually however the switches in
question melt.

To power the motor, you turn on two switches that are diagonally opposed. In the
picture to the right, imagine that the high side left and low side right switches are
turned on.

The current flows and the motor begins to turn in a "positive" direction. Turn on the
high side right and low side left switches, then Current flows the other direction
through the motor and the motor turns in the opposite direction. 91

Actually it is just that simple, the tricky part comes in when you decide what to use
for switches. Anything that can carry a current will work, from four SPST switches,
one DPDT switch, relays, transistors, to enhancement mode power MOSFETs.

One more topic in the basic theory section, quadrants. If each switch can be controlled
independently then you can do some interesting things with the bridge, some folks
call such a bridge a "four quadrant device" (4QD get it?). If you built it out of a single
DPDT relay, you can really only control forward or reverse. You can build a small
truth table that tells you for each of the switch's states, what the bridge will do. As
each switch has one of two states, and there are four switches, there are 16 possible
states. However, since any state that turns both switches on one side on is "bad"
(smoke issues forth: P), there are in fact only four useful states (the four quadrants)
where the transistors are turned on.

High Side Left High Side Right Low Side Left Low Side Right Quadrant Description
On Off Off On Forward Running
Off On On Off Backward Running
On On Off Off Braking
Off Off On On Braking

The last two rows describe a maneuver where you "short circuit" the motor which
causes the motors generator effect to work against itself. The turning motor generates
a voltage which tries to force the motor to turn the opposite direction. This causes the
motor to rapidly stop spinning and is called "braking" on a lot of H-bridge designs.

Of course there is also the state where all the transistors are turned off. In this case the
motor coasts freely if it was spinning and does nothing if it was doing nothing. 92


1. Using Relays:

A simple implementation of an H Bridge using four SPST relays is shown.

Terminal A is High Side Left, Terminal B is High Side Right, Terminal C is
Low Side Left and Terminal D is Low Side Right. The logic followed is
according to the table above.

Warning: Never turn on A and C or B and D at the same time. This will lead
to a short circuit of the battery and will lead to failure of the relays due to the
large current.

2. Using Transistors: 93

We can better control our motor by using transistors or Field Effect

Transistors (FETs). Most of what we have discussed about the relays H-Bridge
is true of these circuits. See the diagram showing how they are connected. You
should add diodes across the transistors to catch the back voltage that is
generated by the motor's coil when the power is switched on and off. This fly
back voltage can be many times higher than the supply voltage!

For information on building an H-Bridge using Transistors, have a look here.

Warning: If you don't use diodes, you could burn out your transistors. Also the
same warning as in the diode case. Don't turn on A and C or B and D at the
same time.

Transistors, being a semiconductor device, will have some resistance, which

causes them to get hot when conducting much current. This is called not being
able to sink or source very much power, i.e.: Not able to provide much current
from ground or from plus voltage.

Mosfets are much more efficient, they can provide much more current and not
get as hot. They usually have the fly back diodes built in so you don't need the
diodes anymore. This helps guard against fly back voltage frying your ICs.

To use Mosfets in an H-Bridge, you need P-Channel Mosfets on top because

they can "source" power, and N-Channel Mosfets on the bottom because then
can "sink" power. 94

It is important that the four quadrants of the H-Bridge circuits be turned on

and off properly. When there is a path between the positive and ground side of
the H-Bridge, other than through the motor, a condition exists called "shoot
through". This is basically a direct short of the power supply and can cause
semiconductors to become ballistic, in circuits with large currents flowing.
There are H-bridge chips available that are much easier, and safer, to use than
designing your own H-Bridge circuit.


This section describes the flow of the project from time to time and the
internal operation of the circuit.

• Up on the power on, the microcontroller initializes the finger print

module, LCD, keypad, and the Locker system to their initial states as
stated in the program which is loaded into the microcontroller.
• Before starting the actual operation here we have to specify the mode
which we are using like ATM or Locker or for PASSPORT
• After pressing any one of the keys specified the controller initializes to
that particular mode.
• In any one of the modes, the FP module is waiting for a finger print to
be scanned and when we place the finger and press the scan key a low
logic will be read by that pin and controller starts comparison among
the finger prints available in the data base with the present finger print.
• ATM mode: If the match found then the controller enables the matrix
keypad which further enables the process of transactions 95

• During each key press the concerned port pin of the controller reads a
logic low signal to indicate a particular operation as specified.
• If any one of he option key like DEPOSIT, WITHDRAW, MINI,
pressed the concerned data will automatically stored in the external
memory through the SDA line through which controller is going to
access the information of the users.
• Locker mode: If the match found then the controller enables the
matrix keypad which further enables the locker system operation.
• PASSPORT verification: If the match found then the controller gets
the information of the particular person and will be displayed on the

• If the match not found in the data base then the keypad and the locker
are remain in the disabled state and it will be indicated.
• All these process while transactions or any fault will be displayed on
the LCD to which microcontroller sends the data through the data lines
(D0 – D7). 96


The software used for this project is:

• Embedded C


Keil uVision is what the software we are using for the programming. In this software
editor we are writing the program in any of the languages like ASM or Embedded C.

µVision3 Overview

The µVision3 IDE is a Windows-based software development platform that combines

a robust editor, project manager, and makes facility. µVision3 integrates all tools
including the C compiler, macro assembler, linker/locator, and HEX file generator.
µVision3 helps expedite the development process of your embedded applications by
providing the following:

 Full-featured source code editor,

 Device database for configuring the development tool setting,

 Project manager for creating and maintaining your projects,

 Integrated make facility for assembling, compiling, and linking your

embedded applications,

 Dialogs for all development tool settings,

 True integrated source-level Debugger with high-speed CPU and peripheral


 Advanced GDI interface for software debugging in the target hardware and for
connection to Keil ULINK,

 Flash programming utility for downloading the application program into Flash

 Links to development tools manuals, device datasheets & user’s guides.

The µVision3 IDE offers numerous features and advantages that help you quickly and
successfully develop embedded applications. They are easy to use and are guaranteed
to help you achieve your design goals. 98


• The µVision3 Simulator is the only debugger that completely simulates all
on-chip peripherals
• The µVision3 Device Database automatically configures the development
tools for the target microcontroller.
• Identical Target Debugger and Simulator User Interface.
• µVision3 incorporates project manager, editor, and debugger in a single


• Write and test application code before production hardware is available.

Investigate different hardware configurations to optimize the hardware design.
• Sophisticated systems can be accurately simulated by adding your own
peripheral drivers.
• Mistakes in tool settings are practically eliminated and tool configuration time
is minimized.
• The same tool can be used for debugging and programming. No extra
configuration time required.
• Accelerates application development. While editing, you may configure
debugger features. While debugging, you may make source code

Steps to Create a PROJECT: 99

µVision3 includes a project manager which makes it easy to design

applications for an ARM based microcontroller. You need to perform the following
steps to create a new project:

• Select the Toolset (only required for ARM Projects).

• Create Project File and Select CPU.
• Project Workspace - Books.
• Create New Source Files.
• Add Source Files to the Project.
• Create File Groups.
• Set Tool Options for Target Hardware.
• Configure the CPU Startup Code.
• Build Project and Generate Application Program Code.
• Create a HEX File for PROM Programming.

The detailed description to create a project will be discussed with snap shots below
for better understanding the tool.


1. Click on the Keil uVision Icon on Desktop

2. The following fig will appear 100

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:\ 101

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 102

9. Select AT89C51 as shown below

10. Then Click on “OK”

11. The Following fig will appear

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

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.

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

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

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” 105

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

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

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

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

25. The new window is as follows

26. Then Click “OK” 108

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

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

29. Now keep Pressing function key “F11” slowly and observe.

30. You are running your program successfully 109

Express PCB is the software tool which consists two functionalities one regarding the
Circuit designing and the other for PCB designing.
Here we are using Express SCH for designing the circuit regarding the project.

Take a few minutes to acquaint yourself with the Express SCH program's display.
You will notice that there are two toolbars, one along the top and another along the
left side. At the bottom of the display is a status bar.

Drawing a Schematic
Express SCH is a very easy to use Windows application for drawing schematics.
While not required, we suggest that you draw a schematic for your circuit before
designing the PC board. By linking the schematic to the PCB, you will save time
designing and be less likely to make mistakes. You will also discover that the user
interface for Express SCH and Express PCB is so similar that after spending the few
minutes to learn one, the other will already be familiar. 110

Embedded C:

What is an embedded system?

An embedded system is an application that contains at least one programmable
computer and which is used by individuals who are, in the main, unaware that the
system is computer-based.

Which programming language should you use?

Having decided to use an 8051 processor as the basis of your embedded system,
the next key decision that needs to be made is the choice of programming language. In
order to identify a suitable language for embedded systems, we might begin by
making the following observations:
• Computers (such as microcontroller, microprocessor or DSP chips) only
accept instructions in ‘machine code’ (‘object codes’). Machine code is, by
definition, in the language of the computer, rather than that of the
programmer. Interpretation of the code by the programmer is difficult and
error prone.
• All software, whether in assembly, C, C++, Java or Ada must ultimately be
translated into machine code in order to be executed by the computer.
• Embedded processors – like the 8051 – have limited processor power and very
limited memory available: the language used must be efficient.
• The language chosen should be in common use.

Summary of C language Features:

It is ‘mid-level’, with ‘high-level’ features (such as support for functions and

modules), and ‘low-level’ features (such as good access to hardware via pointers).
• It is very efficient. 111

• It is popular and well understood.

• Even desktop developers who have used only Java or C++ can soon
understand C syntax.
• Good, well-proven compilers are available for every embedded processor (8-
bit to 32-bit or more).

Basic C program structure:

//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
//Basic blank C program that does nothing
// Includes
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#include <reg51.h> // SFR declarations
Void main (void)
While (1);
Body of the loop // Infinite loop
} // match the braces 112


After selecting the mode of operation, the optical sensor takes the finger print and
compares with the previously stored database. If the present finger prints matches
with any one of the previously stored data then the controller sends a signal to enable
the keypad.
For each key press a low logic value will be present at the concerned pin of the
microcontroller and by reading this value the controller will do the further actions as
specified in the program. The concerned transaction by the user is loaded in the
external memory in this case what we are using is EEPROM of 2K bytes at a
particular location in the memory.
All these functions which are performed by the user are simultaneously
displayed on the LCD. In case any of the finger print is not matched with the data the
Locker system is not opened and the Keypad is not enabled at all by giving the
indication in the form of buzzer. 113


1. The performance of the system can be further improved in terms of operating

speed, memory capacity by using the advanced controllers.
2. The storage memory of the particular user can be increased by interfacing the
controller to the PC for all these transactions.
3. The device can be made to perform better by providing the power supply with
the help of Battery to reduce the requirement of main AC supply.
4. A speaking voice alarm used to indicate the unauthorized person accessing the
ATM and the Locker system and to indicate the wrong Passport.
5. The system can be made to communicate with modems or mobile phones to
alert the user on every transaction in the ATM mode and to alert the
authorities in the Passport verification mode. 114


A step by step approach in designing the microcontroller based system for securing
the transactions of the user and providing the security for the locker system and even
more for the PASSPORT verification using a finger print scanner has been followed.
The result obtained in providing the security is quite reliable in all the three modes.

The system has successfully overcome some of the aspects existing with the present
technologies, by the use of finger print Biometric as the authentication Technology. 115


The 8051 Micro controller and Embedded Systems

-Muhammad Ali Mazidi

Janice Gillispie Mazidi

The 8051 Micro controller Architecture, Programming & Applications

-Kenneth J.Ayala

Fundamentals Of Micro processors and Micro computers


Micro processor Architecture, Programming & Applications

-Ramesh S. Gaonkar 116

Electronic Components

-D.V. Prasad

WEB Resources: 117