Anda di halaman 1dari 66

CHAPTER 1

INTRODUCTION

1.1.

AIM
Safety of human life while travelling in car by adding enhancements

1.2.

INTRODUCTION:
Now a days increasing of transportation system in daily life has made
tremendous changes in security of travelling. Travelling in the night time is a difficult job
as the in-proper lighting system on highway lines, roads. If the vehicle travelling in
congested type of roads (Like small town road), accident may occur due to insufficient
lighting system. This project aims in safe guarding the life, prevention of accidents and to
safe guard the human life. So the project name has titled as AUTOMATION OF CAR
ADD ON FEATURES. The microcontroller scans the position of the car doors. If any
door is not locked properly, the microcontroller senses and displays the particular door is
not locked properly. This helps a lot for safe journey.
This project is facilitated with automatic dim and dip, depending on the light
intensity of the opposite vehicle, the car light will be go lower beam, once the vehicle
passes it automatically goes to higher beam.
The technical aspects will be discussed in detail in the later chapters.

1.3.

BLOCK DIAGRAM

DOOR
SENSORS

16X2 LCD

AT
R.P.S

89S52

CRYSTAL

Fig1: Block Diagram of Car Door Sensing System

HIGH
HIGH BEAM
BEAM
LIGHTS
LIGHTS

LDR

AMPLIFIE
R CIRCUIT

SPDT
RELAY
LOW
LOW BEAM
BEAM
LIGHTS
LIGHTS

Fig2: Block Diagram of Dim & Dip of Car Light Control System

1.4.

BLOCK DIAGRAM EXPLANATION OF DIM AND DIP CAR LIGHT


CONTROL SYSTEM

1.4.1. LDR
The LDR senses the light intensity of the opposite vehicle and
makes the vehicle head lights to operate in lower beam and as
the vehicle passes, it automatically the light goes to high beam.

1.4.2. AMPLIFYING CIRCUIT


The amplifier consists of two NPN transistors. These are
interfaced as darlington pair amplifier. The output of the
amplifier is fed to relay.

1.4.3. RELAY
It is an electromagnetic switch, with the help of relay contacts,
a low beam and high beam lights are operated.

1.5.

BLOCK DIAGRAM EXPLANATION OF CAR DOOR SENSING SYSTEM.

1.5.1. DOOR SENSORS


Here SPDT manual relays are used which are also called
as limiting switches. When car door is properly closed,
the microcontroller gets a digital signal of active high (1)
and if door is not open, the microcontroller gets a digital
signal of active low (0).

1.5.2. MICROCONTROLLER
In

this

project

AT 89s52

version

of

ATMEL

microcontroller is used which has a significant features


of 8KB of Flash ROM, 256 bytes of static RAM, 40-Pin
DIP Package, 8 bit microcontroller, 2 16 bit timers/
counters, 8 interrupts and serial port. It has a unique
feature that it supports ISP Protocol.

1.5.3. LCD
A 16x2 LCD (Liquid Crystal Display) is used to display
the different characters. It support alphanumeric and
punctuations. It can take 8 bit/ 4 bit of data from
Microcontroller to display the text. The data which it
has taken converts into ASCII code.

1.5.4. RPS
Regulated power supply gives constant and continues voltage. It takes house hold supply
voltage (230v) as input and converts into +9v, +6v, +5v using various converters.

1.5.5. CRYSTAL:
A quartz crystal provides clock pulses oscillations, hence it
is called Crystal Oscillator. Here 11.0592 MHz External
crystal oscillator is used to speed up the execution of
program.

CHAPTER 2
CIRCUIT DIAGRAMS
2.1.

CIRCUIT DIAGRAM DIP AND DIM SENSING CIRCUIT

2.2.

CIRCUIT DIAGRAM DURING NO OPPSITE VEHICLE

2.3.

CIRCUIT DIAGRAM DURING NO OPPSITE VEHICLE

2.4.

WORKING OF DIP AND DIM SENSING CIRCUIT


When the light falls on the LDR, the resistance of the LDR decreases, therefore the

current starts flowing through it and provides base bias to the transistor T1. And the transistor
T1 goes to the saturation, then the current starts flowing through T1 and the voltage drop across
the resistor R2 provides the biasing to the switching transistor T2, as transistor T2 conducts and
energizes the Relays. The output is taken with the help of relay contacts, and applied to the high
beam and low beam lights.
When there is no vehicle coming opposite, the intensity of light decreases and the
resistances of LDR increases and therefore no biasing voltage to the transistor T1 and the
transistor T1 & T2 does not conduct and goes to saturation cutt-off region and the two Relays
will be de-energized. With the help of Relay contacts a dc voltage of 9V is provided to the high
beam light.

2.5.

CIRCUIT DIAGRAM OF CAR DOOR SENSOR INTERFACING WITH MCU

2.6.

CIRCUIT
DIAGRAM
OF CAR
DOOR
SENSORS
WHEN ALL ARE CLOSED

2.7.

CIRCUIT DIAGRAM OF CAR DOOR SENSORS WHEN DOOR IS UNLOCKED

2.8.

WORKING PROCEDURE

The project is designed to identify the unlocked door of a car. It is developed with
embedded system platform. ATMEL microcontroller such as AT89s52 is interfaced with car
door sensors such as limiting switches. These switches acts input device and input data is
given to microcontroller. The limiting switches are connected to Port 1 (P1.0, P1.1, P1.2,
P1.3). All the switches are commonly connected to Vcc, hence when door is closed an active

low signal is fed to microcontroller. If door is unlocked properly, an active high signal
produced and is fed to microcontroller. When microcontroller receives active high signal
from a particular port pin say P1.0, microcontroller gives active high out to buzzer. So the
buzzer gives alarm which will alert the car driver. Simultaneously 4 bit of data is given to
LCD. The LCD converts the 4-bit as per ASCII code system and displays the representative
character.
The buzzer is interfaced with P1.7. LCD is interfaced with Port 2 as 4 bit mode of data bus.

CHAPTER III
EMBEDDED SYSTEMS
3.1 INTRODUCTION TO EMBEDDED SYSTEMS
Each day, our lives become more dependent on 'embedded systems', digital information
technology that is embedded in our environment. More than 98% of processors applied today are
in embedded systems, and are no longer visible to the customer as 'computers' in the ordinary

sense. 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. The increasing use of PC hardware
is one of the most important developments in high-end embedded systems in recent years.
Hardware costs of high-end systems have dropped dramatically as a result of this trend, making
feasible some projects which previously would not have been done because of the high cost of
non-PC-based embedded hardware. But software choices for the embedded PC platform are not
nearly as attractive as the hardware.
Typically, an embedded system is housed on a single microprocessor board with the
programs stored in ROM. Virtually all appliances that have a digital interface -- watches,
microwaves, VCRs, cars -- utilize embedded systems. Some embedded systems include an
operating system, but many are so specialized that the entire logic can be implemented as a
single program.
Physically, Embedded Systems range from portable devices such as digital watches and
MP3 players, to large stationary installations like traffic lights, factory controllers, or the systems
controlling nuclear power plants.
In terms of complexity embedded systems can range from very simple with a single
microcontroller chip, to very complex with multiple units, peripherals and networks mounted
inside a large chassis or enclosure.
Definition of an Embedded System
Embedded system is defined as, for a particular/specific application implementing the
software code to interact directly with that particular hardware what we built. Software is used
for providing features and flexibility, hardware = {processors, asics, memory,...} Is used for
performance (& sometimes security)

(or)
An embedded system is a special-purpose computer system designed to perform one or a
few dedicated functions, often with real-time computing constraints. It is usually embedded as
part of a complete device including hardware and mechanical parts. In contrast, a generalpurpose computer, such as a personal computer, can do many different tasks depending on
programming.
(or)
An embedded system is a single-purpose computer built into a larger system for the
purposes of controlling and monitoring the system. A specialized computer system that is part of
a larger system or machine.
There are many definitions of embedded system but all of these can be combined into a
single concept. An embedded system is a special purpose computer system that is used for
particular task.
Features of Embedded Systems
The versatility of the embedded computer system lends itself to utility in all kinds of
enterprises, from the simplification of deliverable products to a reduction in costs in their
development and manufacture. Complex systems with rich functionality employ special
operating systems that take into account major characteristics of embedded systems. Embedded
operating systems have minimized footprint and may follow real-time operating system
specifics.
The special computers system is usually less powerful than general-purpose systems,
although some expectations do exist where embedded systems are very powerful and
complicated. Usually a low power consumption CPU with a limited amount of memory is used
in embedded systems. Many embedded systems use very small operating systems; most of these
provide very limited operating system capabilities.

Since the embedded system is dedicated to specific tasks, design engineers can optimize
it, reducing the size and cost of the product, or increasing the reliability and performance. Some
embedded systems are mass-produced, benefiting from economies of scale.
Some embedded systems have to operate in extreme environment conditions such as very
high temperature & humidity.
For high volume systems such as portable music players or mobile phones, minimizing
cost is usually the primary design consideration. Engineers typically select hardware that is just
good enough to implement the necessary functions.
For low volume or prototype embedded systems, general purpose computers may be
adapted by limiting the programs or by replacing the operating system with a real-time operating
system.
CHARACTERISTICS OF EMBEDDED SYSTEMS
Embedded computing systems generally exhibit rich functionalitycomplex functionality is
usually the reason for introducing cpus into the design. However, they also exhibit many nonfunctional requirements that make the task especially challenging:
Real-time deadlines that will cause system failure if not met;
Multi-rate operation;
In many cases, low power consumption;
Low manufacturing cost, which often means limited code size.
Workstation programmers often concentrate on functionality. They may consider the
performance characteristics of a few computational kernels of their software, but rarely analyze
the total application. They almost never consider power consumption and manufacturing cost.
The need to juggle all these requirements makes embedded system programming very
challenging and is the reason why embedded system designers need to understand computer
architecture.
Overview of an Embedded System Architecture

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


processing unit. This hardware also contains memory chips onto which the software is loaded.

Application Software
Operating
System
H/W

The operating system runs above the hardware and the application software runs above
the operating system. The same architecture is applicable to any computer including desktop
computer. However these are significant differences. It is not compulsory to have an operating
system in every embedded system. For small applications such as remote control units, air
conditioners, toys etc.

Applications of Embedded Systems


Some of the most common embedded systems used in everyday life are
Small embedded controllers:

8-bit cpus dominate, simple or no operating system


(e.g., thermostats)
Control systems:
often use dsp chip for control computations
(e.g., automotive engine control)
Distributed embedded control: mixture of large and small nodes on a real-time
embedded networks
(e.g., cars, elevators, factory automation)
System on chip:
asic design tailored to application area
(e.g., consumer electronics, set-top boxes)

Network equipment:
Critical systems:
Signal processing:
Robotics:
Computer peripherals:
Wireless systems:
Embedded pcs:
Command and control:

emphasis on data movement/packet flow


(e.g., network switches; telephone switches)
safety and mission critical computing
(e.g., pacemakers, automatic trains)
often use dsp chips for vision, audio, or other signal
processing (e.g., face recognition)
uses various types of embedded computing (especially
vision and control) (e.g., autonomous vehicles)
disk drives, keyboards, laser printers, etc.
wireless network-connected sensor networks and
motes to gather and report information
palmtop and small form factor pcs embedded into
equipment
often huge military systems and systems of systems
(e.g., a fleet of warships with interconnected
computers)

Home appliances, intercom, telephones, security systems, garage door openers, answering
machines, fax machines, home computers, tvs, cable tv tuner, vcr, camcorder, remote controls,
video games, cellular phones, musical instruments, sewing machines, lighting control, paging,
camera, pinball machines, toys, exercise equipment
Office telephones, computers, security systems, fax machines, microwave, copier, laser printer,
color printer, paging
Auto trip computer, engine control, air bag, abs, instrumentation, security system, transmission
control, entertainment, climate control, cellular phone, keyless entry

Types of embedded systems


Based on functionality and performance embedded systems categorized as 4 types
1. Stand alone embedded systems
2. Real time embedded systems
3. Networked information appliances
4. Mobile devices
1.Stand alone embedded systems:As the name implies, stand alone systems work in stand alone mode. They take i/p,
process them and produce the desire o/p. The i/p can be an electrical signal from transducer or
temperature signal or commands from human being. The o/p can be electrical signal to drive

another system an led or lcd display


Ex digital camera, microwave oven, cd player, air conditioner etc
2.Real time embedded systems:In this type of an embedded system a specific work has to be complete in a particular
period of time.
Hard real time systems:- embedded real time used in missiles
Soft real time systems:- dvd players
3.Networked information appliances:Embedded systems that are provided with n/w interfaces and accessed by n/w's such as
local area n/w or internet are called network information appliances
Ex a web camera is connected to the internet. Camera can send pictures in real time to any
computers connected to the internet
4. Mobile devices:Actually it is a combination of both VLSI and Embedded system Mobile devices such as
mobile phone, personal digital assistants, smart phones etc are special category of embedded
systems

3.2 INTRODUCTION TO MICROCONTROLLER


Based on the processor side embedded systems is mainly divided into 3 types
1. Micro processor : - are for general purpose eg: our personal computer
2. Micro controller:- are for specific applications, because of cheaper cost we will go for these
3. Dsp ( digital signal processor ):- are for high and sensitive application purpose

MICROCONTROLLER VERSUS MICROPROCESSOR


A system designer using a general-purpose microprocessor such as the pentium or the
68040 must add ram, rom, i/o ports, and timers externally to make them functional. Although the

addition of external ram, rom, and i/o ports makes these systems bulkier and much more
expensive, they have the advantage of versatility such that the designer can decide on the amount
of ram, rom and i/o ports needed to fit the task at hand.
A Microcontroller has a CPU (a microprocessor) in addition to a fixed amount of RAM,
ROM, I/O ports, and a timer all on a single chip. In other words, the processor, the RAM, ROM,
I/O ports and the timer are all embedded together on one chip; therefore, the designer cannot add
any external memory, I/O ports, or timer to it. The fixed amount of on-chip ROM, RAM, and
number of I/O ports in Microcontrollers makes them ideal for many applications in which cost
and space are critical.

CPU platform:
Embedded processors can be broken into two distinct categories: microprocessors (P)
and microcontrollers (C). Microcontrollers have built-in peripherals on the chip, reducing size
of the system.
There are many different CPU architectures used in embedded designs such as ARM,
MIPS, Coldfire/68k, PowerPC, x86, PIC, 8051, Atmel AVR, Renesas H8, SH, V850, FR-V,
M32R, Z80, Z8, etc. This in contrast to the desktop computer market, which is currently limited
to just a few competing architectures.

PC/104 and PC/104+ are a typical base for small, low-volume embedded and ruggedized
system design. These often use DOS, Linux, NetBSD, or an embedded real-time operating
system such as QNX or VxWorks.
A common configuration for very-high-volume embedded systems is the system on a
chip (SoC), an application-specific integrated circuit (ASIC), for which the CPU core was
purchased and added as part of the chip design. A related scheme is to use a field-programmable
gate array (FPGA), and program it with all the logic, including the CPU.
Embedded systems are based on the concept of the microcontroller, a single integrated
circuit that contains all the technology required to run an application. Microcontrollers make
integrated systems possible by combining several features together into what is effectively a
complete

computer

on

chip,

including:

*CentralProcessingUnit
*Input/Outputinterfaces(suchasserialports)
*Peripherals(suchastimers)
*ROM,EEPROM(or)Flashmemoryforprogramstorage
*RAMfordatastorage
*Clockgenerator

By integrating all of these features into a single chip it is possible to greatly reduce the
number of chips and wiring necessary to control an electronic device, dramatically reducing its
complexity, size and cost.
* Size & Weight: Microcontrollers are designed to deliver maximum performance for minimum
size and weight. A centralized on-board computer system would greatly outweigh a collection of
microcontrollers.
* Efficiency: Microcontrollers are designed to perform repeated functions for long periods of
time without failing or requiring service.
MICRO CONTROLLER: It is a chip through which we can connect many other devices and
also those are controlled by the program the program which burn into that chip

3.3 INTRODUCTION TO 8051


Intel corporation introduced an 8 bit micro controller called the 8051 in 1981. While the
time of introduction, intel was given some specific features and particular name as

mcs-51

FEATURES:ROM ---- 4 K BYTES OF MEMORY


RAM ----- 128 BYTES
TIMERS------2
4 PORTS --- 32 I/O PORTS ( EACH 8 BIT WIDE )
INTERRUPTS-----6
SERIAL PORT-----1
ALL ON A SINGLE CHIP
Many semiconductor manufacturers started either manufacturing the 8051 devices as
such (Intel was liberal in giving away license to whoever asked) or developing a new kind of
microcontrollers based on 8051 core architecture. Manufacturers modified the basic 8051
architecture and added many new peripheral functions to make them attractive to the designers.
After that so many industries are come into picture to introduce 8051 again wit some
extra features. This has led to many versions of the 8051 with different speeds and amounts of
on-chip rom marketed by more manufactures those are
DALLAS ------ DS4700

ZILOG---------Z
MOTROLLA
FREESCALE
ATMEL ------- AT89C51/52, AT89S51/52
PHILLIPS ----- P89C51RD2FN

Before these industries came into picture 8051 chips are made with cmos technology. Atmel was
introduced with isp (in system programming)

IN SYSTEM PROGRAMMING (ISP):IN-SYSTEM PROGRAMMING (ISP) is the ability of some programmable logic devices,
microcontrollers, and other programmable electronic chips to be programmed while installed in a
complete system, rather than requiring the chip to be programmed prior to installing it into the
system. (or) in-system programming is a valuable feature that allows system firmware to be
upgraded without disassembling the embedded system to physically replace memory. Most
maxim 8051-based microcontrollers can be reprogrammed from a pc or laptop via an
inexpensive rs-232 serial interface and a few logic gates
The primary advantage of this feature is that it allows manufacturers of electronic devices to
integrate programming and testing into a single production phase, rather than requiring a separate
programming stage prior to assembling the system. This may allow manufacturers to program
the chips in their own system's production line instead of buying preprogrammed chips from a
manufacturer or distributor, making it feasible to apply code or design changes in the middle of a
production run.

3.4 AT89S52 MICROCONTROLLER


The AT89S52 is a low-power, high-performance cmos 8-bit microcontroller with 8k bytes
of in-system programmable flash memory. The device is manufactured using atmels high-

density nonvolatile memory technology and is compatible with the industry-standard 80c51
instruction set and pin out. The on-chip flash allows the program memory to be reprogrammed
in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit
cpu with in-system programmable flash on a monolithic chip, the atmel at89s52 is a powerful
microcontroller which provides a highly-flexible and cost-effective solution to many embedded
control applications.

3.5. AT89S52 PIN DIAGRAM

AT89S52 ARCHITECTURE CONSISTS OF THESE SPECIFIC FEATURES:

8 BIT CPU WITH REGISTERS A (ACCUMULATOR) AND B


16 BIT PROGRAM COUNTER(PC) AND DATA POINTER (DPTR)
8 BIT PROGRAM STATUS WORD (PSW)
8 BIT STACK POINTER (SP)
INTERNAL ROM OF 8K
INTERNAL RAM OF 128 BYTES

FOUR REGISTER BANKS EACH CONTAINING EIGHT REGISTERS

SIXTEEN BYTES, WHICH MAY BE ADDRESSED AT THE BIT LEVEL

EIGHTY BYTES OF GENERAL PURPOSE DATA MEMORY

32 I/O PINS ARRANGED AS FOUR 8-BIT PORTS: P0,P1,P2,P3


TWO 16-BIT TIMERS/COUNTERS: T0 AND T1
FULL DUPLEX SERIAL DATA RECEIVER/TRANSMITTER : SBUF
CONTROL REGISTERS: TCON, TMOD, SCON, SMOD, PCON, IP AND IE.
TWO EXTERNAL AND THREE INTERNAL INTERRUPT SOURCES.
OSCILLATOR AND CLOCK CIRCUITS.

3.6. PIN DESCRIPTION


Pin ( 32 39 ) Port 0: Port 0 is an 8-bit open drain bidirectional port. As an open drain output
port, it can sink eight LS TTL loads. Port 0 pins that have 1s written to them float, and in that
state will function as high impedance inputs. Port 0 is also the multiplexed low-order address and
data bus during accesses to external memory. In this application it uses strong internal pull ups
when emitting 1s. Port 0 emits code bytes during program verification. In this application,
external pull ups are required.
Pin ( 1- 8 ) Port 1: Port 1 is an 8-bit bidirectional I/O port with internal pull ups. Port 1 pins that
have 1s written to them are pulled high by the internal pull ups, and in that state can be used as

inputs. As inputs, port 1 pins that are externally being pulled low will source current because of
the internal pull ups.
Alternate Functions of Port 1 used for In system Programmable
P.5

MOSI --------- Instruction Input

P.6

MISO ---------- Data Output

P.7

SCK ----------- Clk in

Pin ( 21 28 ) Port 2:

Port 2 is an 8-bit bidirectional I/O port with internal pull ups. Port 2

emits the high-order address byte during accesses to external memory that use 16-bit addresses.
In this application, it uses the strong internal pull ups when emitting 1s.
Pin (10 17) Port 3: Port 3 is an 8-bit bidirectional I/O port with internal pull ups. It also serves
the functions of various special features of the 80C51 Family as follows:
Port Pin Alternate Function
P3.0- RxD (serial input port)
P3.1 -TxD (serial output port)
P3.2 -INT0 (external interrupt 0)
P3.3- INT1 (external interrupt 1)
P3.4 -T0 (timer 0 external input)
P3.5 -T1 (timer 1 external input)
P3.6 -WR (external data memory write strobe)
P3.7 -RD (external data memory read strobe)

Pin 40 VCC: -Supply voltage


Pin 20 VSS: -Circuit ground potential
Pin 29 PSEN: Program Store Enable is the read strobe to external Program Memory. When the
device is executing out of external Program Memory, PSEN is activated twice each machine
cycle (except that two PSEN activations are skipped during accesses to external Data Memory).
PSEN is not activated when the device is executing out of internal Program Memory.
Pin 30 ALE/PROG: Address Latch Enable output pulse for latching the low byte of the address
during accesses to external memory. ALE is emitted at a constant rate of 1/6 of the oscillator
frequency, for external timing or clocking purposes, even when there are no accesses to external
memory. (However, one ALE pulse is skipped during each access to external Data Memory.)
This pin is also the program pulse input (PROG) during EPROM programming.
Pin 31 EA/VPP: When EA is held high the CPU executes out of internal Program Memory.
Holding EA low forces the CPU to execute out of external memory regardless of the Program
Counter value. In the 80C31, EA must be externally wired low. In the EPROM devices, this pin
also receives the programming supply voltage (VPP) during EPROM programming.
Pin 18 XTAL1: Input to the inverting oscillator amplifier.
Pin 19 XTAL2: Output from the inverting oscillator amplifier.

3.7. REGISTERS
8051 is a collection of 8 and 16 bit registers and 8 bit memory locations. These registers
and memory locations can be made to operate using the software instructions. The program
instructions control the registers and digital data paths that are contained inside the 8051, as well
as memory locations that are located outside the 8051.
Register are used to store information temporarily, while the information could be a byte
of data to be processed, or an address pointing to the data to be fetched. The vast majority of
8051 register are 8-bit registers.

Generally there are two types of registers. They are general purpose registers (gprs) and special
function registers (sfrs)
GENERAL PURPOSE REGISTER
The 8 bits of a register are shown from msb d7 to the lsb d0. With an 8-bit data type, any
data larger than 8 bits must be broken into 8-bit chunks before it is processed.

The most widely used registers A (accumulator)


for all arithmetic and logic instructions
B, R0, R1, R2, R3, R4, R5, R6, R7
dptr (data pointer), and pc (program counter)
16 bit General Purpose Register are Data Pointer (DPTR) and Program Counter (PC)
The program counter points to the address of the next instruction to be executed. Dptr. As the
name suggests, is used to point the data. It is used by a number of commands which allows the
microcontroller to access external memory. When the microcontroller access external memory it
will access at the address indicated by DPTR.

There are 128 bytes of RAM in the 8051


The 128 bytes are divided into three different groups as follows:
1) A total of 32 bytes from locations 00 to 1f hex are set aside for register banks and the stack
2) A total of 16 bytes from locations 20h to 2fh are set aside for bit-addressable read/write
memory
3) A total of 80 bytes from locations 30h to 7fh are used for read and write storage, called scratch
pad

Special Function Registers


The program status word (PSW)
PSW register, also referred to as the flag register, is an 8 bit register only 6 bits are used these
four are cy (carry), ac (auxiliary carry), p (parity), and ov (overflow)
They are called conditional flags, meaning that they indicate some conditions that resulted after
an instruction was executed. The psw3 and psw4 are designed as rs0 and rs1, and are used to
change the bank. The two unused bits are user-definable

3.8. TIMER/COUNTERS
The atmel 80c51 microcontrollers implement two general purpose, 16-bit timers/
counters. They can be used either as timers to generate a time delay or as a counter to count
events happening outside the microcontroller. The microcontroller has two 16-bit wide timers.
They are identified as timer 0 and timer 1, and can be independently configured to operate in a
variety of modes as a timer or as an event counter. When operating as a timer, the timer/counter
runs for a programmed length of time, then issues an interrupt request. When operating as a
counter, the timer/counter counts negative transitions on an external pin. After a preset number of

counts, the counter issues an interrupt request. Register pairs (th0, tl0), (th1, tl1), and (th2, tl2)
are the 16-bit counting registers for timer/counters 0, 1, and 2, respectively.

TIMER 0 REGISTER
The 16-bit register of timer 0 is accessed as low byte and high byte. the low byte register
is called tl0 (timer 0 low byte) and high byte register is referred to as th0 (timer 0 high byte).
these registers can be accessed like any other register, such as A,B,R0,R1,R2,etc.
TIMER 1 REGISTER
Timer 1 is also 16-bits, and its 16-bit register is split into two bytes, referred to as TL1
( Timer 1 low byte ) and TH1 ( Timer 1 high byte ). These registers are accessible in the same
way as the registers of timer 0.
TMOD Register (timer mode)
TMOD: TIMER/COUNTER MODE CONTROL REGISTER.
NOT BIT ADDRESSABLE.

TIMER 1
GATE

TIMER 0
When TRx (in TCON) is set and GATE=1, Timer/CounterX will run only
while INTx pin is high (hardware control). When GATE=0, Timer/Counter
will run only while TRx=1 (software control).

C/T

Timer or counter selector. Cleared for timer operation (input from internal
system clock). Set for counter operation

M1

Mode Selector Bit.

M0

Mode Selector Bit.

(input from tx input pin).

M1

M0

MODE

OPERATING MODE

13-Bit Timer (8048 Compatible) (Th1)

16-Bit Timer/Counter

8-bit auto-reload timer/counter (tl1).


Reloaded from th1 at overflow.

Timer 1 halted. Retains count.

(Timer 1) Timer/Counter 1 stopped.

TCON: TIMER/COUNTER CONTROL REGISTER


BIT ADDRESSABLE.

The upper four bits are used to


store the TF and

The lower 4 bits are set aside for


controlling the interrupt bits

TR bits of both timer 0 and 1

TF1

Timer1 overflow flag. Set by hardware when the timer/counter 1 overflows.


Cleared by hardware as processor vectors to the interrupt service routine.

TR1

Timer 1 run control bit. Set/cleared by software to turn timer/counter 1


on/off.

TF0

Timer0 overflow flag. Set by hardware when the timer/counter 0

overflows.

Cleared by hardware as processor vectors to the service routine.


TR0

Timer 0 run control bit. Set/cleared by software to turn timer/counter 0 on/off.

IE1

External interrupt 1 edge flag. Set by hardware when external interrupt edge is
detected. Cleared by hardware when interrupt is processed.

IT1

Interrupt 1 type control bit. Set/cleared by software to specify falling edge/low


level triggered External Interrupt.

IE0

External interrupt 0 edge flag. set by hardware when external interrupt edge is
detected. Cleared by hardware when interrupt is processed.

IT0

Interrupt 0-type control bit. Set/cleared by software to specify falling edge/low


level triggered external interrupt.

3.9. SERIAL COMMUNICATION


The 8051 serial port is full duplex. In other words, it can transmit and receive data at the same
time. Unlike any other register in the 8051, sbuf is in fact two distinct registers - the write-only
register and the read-only register. Transmitted data is sent out from the write-only register while
received data is stored in the read-only register. There are two separate data lines, one for
transmission (txd) and one for reception (rxd). Therefore, the serial port can be transmitting data
down the txd line while it is at the same time receiving data on the rxd line. The txd line is pin 11 of
the microcontroller (p3.1) while the rxd line is on pin 10 (p3.0)
Serial data communication uses two methods, asynchronous and synchronous. The synchronous
method transfers a block of data (characters) at a time, while the asynchronous method transfers a
single byte at a time. It is possible to write software to use either of these methods, but the programs
can be tedious and long. For this reason, there are special ic chips made by many manufacturers for
serial data communications. These chips can be commonly referred to as uart (universal
asynchronous receiver-transmitter) and USART ( universal synchronous asynchronous receivertransmitter). The 8051 chip has a built-in UART.

ASYNCHRONOUS SERIAL COMMUNICATION AND DATA FRAMING


START BITS AND STOP BITS

In the asynchronous method is character is placed between start and stop bits, this is called data
framing. In asynchronous communication, at least two extra bits are transmitted with the data word;
a start bit and a stop bit. Therefore, if the transmitter is using an 8-bit system, the actual number of
bits transmitted per word is ten. In most protocols the start bit is a logic 0 while the stop bit is logic
1. Therefore, when no data is being sent the data line is continuously high. The receiver waits for a
1 to 0 transition. In other words, it awaits a transition from the stop bit (no data) to the start bit (logic
0). Once this transition occurs the receiver knows a data byte will follow. Since it knows the data
rate (because it is defined in the protocol) it uses the same clock as frequency as that used by the
transmitter and reads the correct number of bits and stores them in a register. For example, if the
protocol determines the word size as eight bits, once the receiver sees a start bit it reads the next
eight bits and places them in a buffer. Once the data word has been read the receiver checks to see if
the next bit is a stop bit, signifying the end of the data. If the next bit is not a logic 1 then something
went wrong with the transmission and the receiver dumps the data. If the stop bit was received the
receiver waits for the next data word, ie; it waits for a 1 to 0 transition.

Goes out first


Baud Rates in the 8051

11.0592
MHz

XTAL
oscillat
or

Machine
cycle
12 frequency
921.6
kHz

28800
Hz
Timer 1
To
timer
1
By UART
To set the
Baud rate

32

XTAL = 11.0592 MHz:


The frequency of system clock = 11.0592 MHz / 12 = 921.6 kHz
The frequency sent to timer 1 = 921.6 kHz/ 32 = 28,800 Hz
(a) 28,800 / 3 = 9600

where -3 = FD (hex) is loaded into TH1

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


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

SBUF
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 8051s rxd line. SBUF can be accessed like any
other register in the 8051.
The moment a byte is written into sbuf, it is framed with the start and stop bits and transferred
serially via the txd pin. Similarly, when the bits are received serially via rxd, the 8051 deframes
it by eliminating the stop and start bits, making a byte out of the data received, and then placing
it in the SBUF.

DATA TRANSMISSION: Transmission of serial data bits begins anytime data is written to sbuf. " TI " (SCON) set
to 1 when data has been transmitted and signifies that " SBUF " is empty and that another data
byte can be sent.
DATA RECEPTION: Reception of serial data will begin if the receive enable bit (ren) in scon is set to ' 1 ' for
all modes. For mode ' 0 ' only ri must be cleared to 0. Receiver interrupt flag ' ri ' (in scon) is set
after data has been received in all modes. Setting of ' ren ' bit is a direct program control that
limits the reception of unexpected data.

SCON ( SERIAL CONTROL ) REGISTER


SM0

SM1

SM2

REN

TB8

RB8

TI

RI

Mode 0: Serial data enters and exits through RxD. TxD outputs the shift clock. 8 bits are
transmitted/received (LSB first). The baud rate is fixed at 1/12 the oscillator frequency.
Mode 1: 10 bits are transmitted (through txd) or received (through rxd): a start bit (0), 8 data bits
(lsb first), and a stop bit (1). On receive, the stop bit goes into rb8 in special function register
scon. The baud rate is variable.
Mode 2: 11 bits are transmitted (through txd) or received (through rxd): start bit (0), 8 data bits
(lsb first), a programmable 9th data bit, and a stop bit (1). On transmit, the 9th data bit (tb8 in
scon) can be assigned the value of 0 or 1. Or, for example, the parity bit (p, in the psw) could be
moved into tb8. On receive, the 9th data bit goes into rb8 in special function register scon, while
the stop bit is ignored. The baud rate is programmable to either 1/32 or 1/64 the oscillator
frequency.
Mode 3: 11 bits are transmitted (through txd) or received (through rxd): a start bit (0), 8 data bits
(lsb first), a programmable 9th data bit, and a stop bit (1). In fact, mode 3 is the same as mode 2
in all respects except baud rate. The baud rate in mode 3 is variable. In all four modes,
transmission is initiated by any instruction that uses sbuf as a destination register. Reception is
initiated in mode 0 by the condition ri = 0 and ren = 1. Reception is initiated in the other modes
by the incoming start bit if ren = 1.
SM2 enables the multiprocessor communication feature in modes 2 and 3. In mode 2 or 3, if sm2
is set to 1, then rl will not be activated if the received 9th data bit (rb8) is 0. In mode 1, if sm2=1
then ri will not be activated if a valid stop bit was not received. In mode 0, sm2 should be 0.

REN enables serial reception. Set by software to enable reception. Clear by software to disable
reception.
TB8 the 9th data bit that will be transmitted in modes 2 and 3. Set or clear by software as
desired.
RB8 in modes 2 and 3, is the 9th data bit that was received. In mode 1, it sm2=0, rb8 is the stop
bit that was received. In mode 0, rb8 is not used.

TI (Transmit Interrupt)
This is an extremely important flag bit in the scon register. When the 8051 finishes the transfer of
the 8-bit character it raises the ti flag to indicate that it is ready to transfer another byte. The ti bit
is raised at the beginning of the stop bit.
RI (Receive Interrupt)
This is an extremely important flag bit in the scon register. When the 8051 receives data
serially via rxd, it gets rid of the start and stop bits and places the byte in the sbuf register. Then it
raises the ri flag bit to indicate that a byte has been received and chould be picked up before it is
lost.
INTERRUPTS
An interrupt is a special feature which allows the 8051 to provide the illusion of "multitasking," although in reality the 8051 is only doing one thing at a time. The word "interrupt" can
often be substituted with the word "event."
An interrupt is triggered whenever a corresponding event occurs. When the event occurs,
the 8051 temporarily puts "on hold" the normal execution of the program and executes a special
section of code referred to as an interrupt handler. The interrupt handler performs whatever
special functions are required to handle the event and then returns control to the 8051 at which
point program execution continues as if it had never been interrupted.

Interrupt Service Routine


For every interrupt, there must be an interrupt service routine (ISR). Or interrupt handler.
When an interrupt is invoked, the microcontroller runs the interrupt service routine. For every
interrupt, there is a fixed location in memory that holds the address of its ISR. The group of
memory locations set aside to hold the addresses of the ISRs is called interrupt vector table.

Six Interrupts in 8051


1. Reset : When the reset pin is activated, the 8051 jumps to address location 0000
2. Two interrupts are set aside for the timers: one for the Timer 0 and one for Timer1.
3. Two interrupts are set aside for hardware external interrupts : one for INT0 and one for
INT1
4. Serial communication has a single interrupt that belongs to both receive and transmit.
Enabling Interrupt (IE) Register
All interrupt are disabled after reset
We can enable and disable them bye IE
EA
EA

-IE.7

ET2

ES

ET1

EX1

ET0

EX0

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


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

--

IE.6

Not implemented, reserved for future use.

ET2

IE.5

Enables or disables Timer2 overflow or capture interrupt


(8052 only)

ES

IE.4

Enables or disables the serial port interrupt.

ET1

IE.3

Enables or disables Timer 1 overflow interrupt.

EX1

IE.2

Enables or disables external interrupt 1.

ET0

IE.1

Enables or disables Timer 0 overflow interrupt.

EX0

IE.0

Enables or disables external interrupt 0.

Interrupt Priority (IP) Register


0= lower priority, 1= higher priority, reset IP=00H
Lower priority ISR can be interrupted by a high priority interrupt.
A high priority ISR can not be interrupted.
Low-priority interrupt wait until 8051 has finished servicing the high-priority interrupt.

--

--

PT2

PS

PT1

PX1

--

IP.7

Reserved

--

IP.6

Reserved

PT2

IP.5

Timer2 interrupt priority bit (8052 only)

PS

IP.4

serial port interrupt priority bit.

PT1

IP.3

Timer 1 interrupt priority bit.

PX1

IP.2

external interrupt 1 priority bit.

PT0

IP.1

Timer 0 interrupt priority bit.

PT0

PX0

PX0

IP.0

external interrupt 0 priority bit.

3.10. BASIC REQUIRMENT


The following are the basic five requirements of microcontroller
1. Power Supply
2. Crystal Oscillator
3. Reset
4. SIP Resistor
5. Resistor for EA Pin
3.10.1. REGULATED POWER SUPPLY
In mains-supplied electronic systems the ac input voltage must be converted into a dc voltage
with the right value and degree of stabilization. The common dc voltages that are required to
power up the devices are generally in the range of 3 vdc to 30 vdc. Typically the fixed types of
dc voltages are 5v, 9v, 12v, 15v and 18v dc.

POWER SUPPLY MODULES:

STEP DOWN TRANSFORMER


BRIDGE RECTIFIER WITH FILTER
VOLTAGE REGULATORS

TRANSFORMER
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. step-up
transformers increase voltage, step-down transformers reduce voltage.

A step down power transformer is used to step down the ac voltage from the line voltage
of 110 VAC or 220 VAC i.e, it converts higher voltage at the input side to a lower voltage at the
output.

RECTIFIER
There are several ways of connecting diodes to make a rectifier to convert ac to dc. The
bridge rectifier is the most important and it produces full-wave varying dc
BRIDGE RECTIFIER

OUTPUT: FULL-WAVE VARYING DC

Alternate pairs of diodes conduct, changing over (using all the ac wave) the connections so the
alternating directions of ac are converted to the one direction of dc.
FILTER
Filtering is performed by a large value electrolytic capacitor connected across the DC supply to
act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier
is falling. The diagram shows the unfiltered varying DC (dotted line) and the filtered DC (solid
line).
The capacitor charges quickly near the peak of the varying DC, and then discharges as it
supplies current to the output. Typically 1000 f capacitor is used

REGULATOR
This is a simple dc regulated supply project using 7805 voltage regulator to obtain a variable dc
voltage range from 5v to 15v

Pin out of the 7805 regulator ic.


1. Unregulated voltage in
2. Ground
3. Regulated voltage out

If you need other voltages than +5v, you can modify the circuit by replacing the 7805 chips with
another regulator with different output voltage from regulator 78xx chip family. the last numbers
in the the chip code tells the output voltage. remember that the input voltage must be at least 3v
greater than regulator output voltage ot otherwise the regulator does not work well.

CIRCUIT DIAGRAM OF POWER SUPPLY


The power supply consists of a 9-0-9 step down transformer. a bridge rectifier is used to rectify
and convert ac to dc. a 1000uf capacitor is used to filter the ripples and the output is connected to

7805 voltage regulator. this comprises the power supply for the entire circuit. vcc is connected to
pin 40 the power supply of microcontroller.

3.11. CRYSTAL OSCILLATOR


The 8051 uses the crystal for precisely that: to
synchronize its operation. effectively, the 8051
operates using what are called "machine cycles."

single machine cycle is the minimum amount of

time

in which a single 8051 instruction can be


executed. Although many instructions take multiple cycles. 8051 has an on-chip oscillator. it
needs an external crystal that decides the operating frequency of the 8051. the crystal is
connected to pins 18 and 19 with stabilizing capacitors. 12MHz (11.059mhz) crystal is often
used and the capacitance ranges from 20pf to 40pf.

A cycle is, in reality, 12 pulses of the crystal. that is to


say, if an instruction takes one machine cycle to
execute, it will take 12 pulses of the crystal to execute.
since we know the we can calculate how many
instruction cycles the 8051 can execute per second:
11,059,000 / 12 = 921,583
11.0592 mhz crystals are often used because it can be
divided to give you exact clock rates for most of the
common baud rates for the uart, especially for the
higher speeds (9600, 19200).

3.12. RESET

Reset is an active high input when reset is set to high, 8051 goes back to the power on state.the
8051 is reset by holding the rst high for at least two machine cycles and then returning it low.
initially charging of capacitor makes rst high, when capacitor charges fully it blocks dc.

SIP Resistor
Sip Resistor is a single in pack Resistor (i.e.,) 8 resistors connected in series. Basically SIP
resistor is a 9 pin connector first pin is for power supply to the entire 8 resistors in SIP.
Generally SIP Resistor is used to close the open drain connections of Port 0.

CHAPTER 4
HARDWARE IMPLEMENTATION

4.1. LDR SENSOR (LIGHT DEPENDENT RESISTOR )


An LDR is an input transducer (sensor) which converts brightness (light) to resistance. It is
made from cadmium sulphide (CdS) and the resistance decreases as the brightness of light falling
on the LDR increases. LDRs or Light Dependent Resistors are very useful especially in
light/dark sensor circuits. Normally the resistance of an LDR is very high, sometimes as high as
1000 000 ohms, but when they are illuminated with light resistance drops dramatically.
A multimeter can be used to find the resistance in darkness and bright light, these are the typical
results for a standard LDR:

Darkness: maximum resistance, about 1M .

Very bright light: minimum resistance, about 100 .

For many years the standard LDR has been the ORP12, now the NORPS12, which is about
13mm diameter. Miniature LDRs are also available and their diameter is about 5mm.
An LDR may be connected either way round and no special precautions are required when
soldering.

CIRCUIT SYMBOL

The animation opposite shows that when the torch is turned on, the resistance of the LDR falls,
allowing current to pass through it.

This is an example of a light sensor circuit :

When the light level is low the resistance of the LDR is high. This prevents current from flowing
to the base of the transistors. Consequently the LED does not light.
However, when light shines onto the LDR its resistance falls and current flows into the base of
the first transistor and then the second transistor. The LED lights.
The preset resistor can be turned up or down to increase or decrease resistance, in this way it can
make the circuit more or less sensitive.

4.2. TRANSISTORS

Transistors amplify current, for example they can be used to amplify the small output
current from a logic IC so that it can operate a lamp, relay or other high current device. In many
circuits a resistor is used to convert the changing current to a changing voltage, so the transistor
is being used to amplify voltage.

A transistor may be used as a switch (either fully on with maximum current, or fully off
with no current) and as an amplifier (always partly on).
The amount of current amplification is called the current gain, symbol hFE

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

Transistor circuit symbols

The

leads

are

labeled

base

(B),

collector

(C)

and

emitter

(E).

These terms refer to the internal operation of a transistor but they are not much help in
understanding how a transistor is used, so just treat them as labels!
A Darlington pair is two transistors connected together to give a very high current gain.
In addition to standard (bipolar junction)
transistors,

there

are

field-effect

transistors which are usually referred to


as FETs.

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

Structure

This shows the type of transistor, NPN or PNP. The polarities of the two
types are different, so if you are looking for a substitute it must be the
same type.

Case style

There is a diagram showing the leads for some of the most common case
styles in the Connecting section above. This information is also available
in suppliers' catalogues.

IC max.

Maximum collector current.

VCE max.

Maximum

voltage

across

the

collector-emitter

junction.

You can ignore this rating in low voltage circuits.


hFE

This is the current gain (strictly the DC current gain). The guaranteed
minimum value is given because the actual value varies from transistor to
transistor - even for those of the same type! Note that current gain is just a
number

so

it

has

no

units.

The gain is often quoted at a particular collector current IC which is usually


in the middle of the transistor's range, for example '100@20mA' means the
gain is at least 100 at 20mA. Sometimes minimum and maximum values
are given. Since the gain is roughly constant for various currents but it
varies from transistor to transistor this detail is only really of interest to
experts.
Why hFE? It is one of a whole series of parameters for transistors, each
with their own symbol. There are too many to explain here.

Ptot max.

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

Category

This shows the typical use for the transistor, it is a good starting point
when looking for a substitute. Catalogues may have separate tables for
different categories.

Possible substitutes These are transistors with similar electrical properties which will be
suitable substitutes in most circuits. However, they may have a different

case style so you will need to take care when placing them on the circuit
board.

4.3. RELAY
A relay is an electrically operated switch. Current flowing through the coil of the relay creates a
magnetic field which attracts a lever and changes the switch contacts. The coil current can be on
or off so relays have two switch positions and most have double throw (changeover) switch
contacts as shown in the diagram.
Relays allow one circuit to switch a second circuit which can be completely separate from the
first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains
circuit. There is no electrical connection inside the relay between the two circuits, the link is
magnetic and mechanical.
The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be
as much as 100mA for relays designed to operate from lower voltages. Most ICs (chips) cannot
provide this current and a transistor is usually used to amplify the small IC current to the larger
value required for the relay coil. The maximum output current for the popular 555 timer IC is
200mA so these devices can supply relay coils directly without amplification.
Relays are usually SPDT or DPDT but they can have many more sets of switch contacts, for
example relays with 4 sets of changeover contacts are readily available. For further information
about switch contacts and the terms used to describe them please see the page on switches.
Most relays are designed for PCB mounting but you can solder wires directly to the pins
providing you take care to avoid melting the plastic case of the relay.
The supplier's catalogue should show you the relay's connections. The coil will be obvious and it
may be connected either way round. Relay coils produce brief high voltage 'spikes' when they
are switched off and this can destroy transistors and ICs in the circuit. To prevent damage you
must connect a protection diode across the relay coil.

The animated picture shows a working relay with its coil and switch contacts. You can see a
lever on the left being attracted by magnetism when the coil is switched on. This lever moves the
switch contacts. There is one set of contacts (SPDT) in the foreground and another behind them,
making the relay DPDT.

SPDT Relay

Circuit symbol

The relay's switch connections are usually labelled COM, NC and NO:

COM = Common, always connect to this, it is the moving part of the switch.

NC = Normally Closed, COM is connected to this when the relay coil is off.

NO = Normally Open, COM is connected to this when the relay coil is on.

Connect to COM and NO if you want the switched circuit to be on when the relay coil is
on.

Connect to COM and NC if you want the switched circuit to be on when the relay coil is
off.

4.4. CAPACITOR
Function
Capacitors store electric charge. They are used with resistors in timing circuits because it takes
time for a capacitor to fill with charge. They are used to smooth varying DC supplies by acting as
a reservoir of charge. They are also used in filter circuits because capacitors easily pass AC
(changing) signals but they block DC (constant) signals.
Capacitance
This is a measure of a capacitor's ability to store charge. A large capacitance means that more
charge can be stored. Capacitance is measured in farads, symbol F. However 1F is very large, so
prefixes are used to show the smaller values.
Three prefixes (multipliers) are used, (micro), n (nano) and p (pico):

means 10-6 (millionth), so 1000000F = 1F

n means 10-9 (thousand-millionth), so 1000nF = 1F

p means 10-12 (million-millionth), so 1000pF = 1nF

Capacitor values can be very difficult to find because there are many types of capacitor with
different labelling systems!
There are many types of capacitor but they can be split into two groups, polarised and
unpolarised. Each group has its own circuit symbol.

Polarized capacitors (large values, 1F +)

Examples:

Circuit symbol:

Electrolytic Capacitors
Electrolytic capacitors are polarized and they must be connected the correct way round, at
least one of their leads will be marked + or -. They are not damaged by heat when soldering.
There are two designs of electrolytic capacitors; axial where the leads are attached to each end
(220F in picture) and radial where both leads are at the same end (10F in picture). Radial
capacitors tend to be a little smaller and they stand upright on the circuit board.
It is easy to find the value of electrolytic capacitors because they are clearly printed with their
capacitance and voltage rating. The voltage rating can be quite low (6V for example) and it
should always be checked when selecting an electrolytic capacitor. If the project parts list does
not specify a voltage, choose a capacitor with a rating which is greater than the project's power
supply voltage. 25V is a sensible minimum for most battery circuits.

Unpolarised capacitors (small values, up to 1F)

Examples:

Circuit symbol:

Small value capacitors are un-polarized and may be connected either way round. They are not
damaged by heat when soldering, except for one unusual type (polystyrene). They have high
voltage ratings of at least 50V, usually 250V or so. It can be difficult to find the values of these
small capacitors because there are many types of them and several different labeling systems!
Many small value capacitors have their value printed but without a multiplier, so
you need to use experience to work out what the multiplier should be!
For example 0.1 means 0.1F = 100nF.
Sometimes

the

multiplier

is

used

in

place

of

the

For example: 4n7 means 4.7nF.


Capacitor Number Code
A number code is often used on small capacitors where printing is difficult:

the 1st number is the 1st digit,

the 2nd number is the 2nd digit,

the 3rd number is the number of zeros to give the capacitance in pF.

Ignore any letters - they just indicate tolerance and voltage rating.

For example: 102 means 1000pF = 1nF (not 102pF!)


For example: 472J means 4700pF = 4.7nF (J means 5% tolerance).

4.5. LIGHT EMITTING DIODES (LEDS)

Example:

Circuit symbol:

decimal

point:

Function
LEDs emit light when an electric current passes through them.
Connecting and soldering
LEDs must be connected the correct way round, the diagram may be labelled
a or + for anode and k or - for cathode (yes, it really is k, not c, for cathode!).
The cathode is the short lead and there may be a slight flat on the body of
round LEDs. If you can see inside the LED the cathode is the larger electrode (but this is not an
official identification method).
LEDs can be damaged by heat when soldering, but the risk is small unless you are very slow. No
special precautions are needed for soldering most LEDs.
Testing an LED
Never connect an LED directly to a battery or power supply!
It will be destroyed almost instantly because too much current will pass
through and burn it out.
LEDs must have a resistor in series to limit the current to a safe value,
for quick testing purposes a 1k

resistor is suitable for most LEDs if your supply voltage is 12V

or less. Remember to connect the LED the correct way round!

For an accurate value please see Calculating an LED resistor value below.
Colours of LEDs

LEDs are available in red, orange, amber, yellow,


green, blue and white. Blue and white LEDs are
much more expensive than the other colours.
The colour of an LED is determined by the
semiconductor material, not by the colouring of
the 'package' (the plastic body). LEDs of all colours are available in uncoloured packages which
may be diffused (milky) or clear (often described as 'water clear'). The coloured packages are
also available as diffused (the standard type) or transparent.
Calculating an LED resistor value
An LED must have a resistor connected in series to limit the
current through the LED, otherwise it will burn out almost
instantly.
The resistor value, R is given by:

R = (V S - V L ) / I
VS = supply voltage
VL = LED voltage (usually 2V, but 4V for blue and white LEDs)
I = LED current (e.g. 10mA = 0.01A, or 20mA = 0.02A)
Make sure the LED current you choose is less than the maximum permitted and convert the
current to amps (A) so the calculation will give the resistor value in ohms ( ).
To convert mA to A divide the current in mA by 1000 because 1mA = 0.001A.
If the calculated value is not available choose the nearest standard resistor value which is
greater, so that the current will be a little less than you chose. In fact you may wish to choose a
greater resistor value to reduce the current (to increase battery life for example) but this will
make the LED less bright.

For example
If
The supply voltage VS = 9V,
Red LED (VL = 2V),
Requiring a current I = 20mA = 0.020A,

R = (9V - 2V) / 0.02A = 350 , so choose 390

(the nearest standard value which is greater).

4.6. RESISTORS

Example:

Circuit symbol:

Function

The

Resistor

Colour Code
Resistors restrict the flow of electric current, for example a resistor is placed
in series with a light-emitting diode (LED) to limit the current passing

Colour Number

through the LED.

Black

Connecting and soldering

Brown 1

Resistors may be connected either way round. They are not damaged by heat
when soldering.

Red

Orange 3
Yellow 4

Resistor values - the resistor colour code

Green

Blue

Violet

Grey

White

Resistance

is

is

quite

1k

= 1000

Resistor

measured
small
1M

values

so

in

ohms,

resistor

= 1000000
are

the

symbol

values

are

for

often

ohm

is

an

omega

given

in

and

.
M .

normally

shown

using

coloured

bands.

Each colour represents a number as shown in the table.


Most resistors have 4 bands:

The first band gives the first digit.

The second band gives the second digit.

The third band indicates the number of zeros.

The fourth band is used to shows the tolerance (precision) of the resistor, this may be
ignored for almost all circuits but further details are given below.

This
So

resistor
its

has

red
value

On circuit diagrams the

(2),

violet
is

(7),

yellow

270000

(4

zeros)
=

and
270

is usually omitted and the value is written 270K.

gold

bands.
k .

4.7.

LCD DESCRIPTION:

LCD operation

In recent years the LCD is finding widespread wide spread use replacing LED (seven
segments LED or other multi segment LED). This is due to the following reasons:

1.

The declining prices of LCD.

2.

The ability to display numbers, characters, and graphics. This is in contrast to LED,
which are limited to numbers and a few characters.

3.

Incorporation of a refreshing controller into the LDC, thereby relieving the CPU of the
task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU (or in
some other way) to keep displaying the data.

4.

Ease of programming for characters and graphics.

4.7.1. LCD Pin Descriptions


The LCD discussed in this section has 14 pins. The function of each pin is given in
Table. Figure shows the pin positions for various LCD.

VCC, VSS, and VEE


While VCC and VSS provide +5V and ground, respectively,
VEE is used for controlling LCD contrast.
RS, register select
There are two very important registers inside the LCD. The RS pin is used for their
selection as follows.

If RS=0, the instruction command code register is selected,

allowing the user to send a command such as clear display, cursor at home, etc. IF RS=1
the data register is selected, allowing the user to send data to be displayed on the LCD.
R/W, read/write
R/W input allows the user to write information to the LCD or read information from it.
R/W=1 when reading; R/W=0 when writing.
E, enable
The enable pin is used by the LCD to latch information presented to its data pins. When
data is supplied to data pins, a high-to-low pulse must be applied to this pin in order for
the LCD to latch in the data present at the data pins. This pulse must be a minimum of
450 ns wide.

Data Pins of LCD (D0 - D7)


The 8-bit data pins, D0 - D7, are used to send information to the LCD or read the
contents of the LCDs internal registers.
To display letters and numbers, we send ASCII codes for the letters A - Z, a - z, and
numbers 0 - 9 to these pins while making RS=1.
There are also instruction command codes that can be sent to the LCD to clear the display
or force the cursor to the home position or blink the cursor. Table 12-2 lists the
instruction command codes.
We also use RS = 0 to check the busy flag bit to see if the LCD is ready to receive
information. The busy flag is D7 and can be read when R/W=1 and RS = 0, as follows: if
R/W = 1, RS = 0. When D7 = 1 (busy flag = 1), the LCD is busy taking care of internal
operations and will not accept any new information. When D7 = 0, the LCD is ready to
receive new information. Note: It is recommended to check the busy flag before writing
any data to the LCD.

4.7.2. Table of Pin Descriptions for LCD

PIN

SYMBOL

I/O

DESCRIPTION

VSS

Ground

VCC

+5V Power Supply

VEE

Power Supply to Control Contrast

RS

RS =0 to select command Register


RS=1 to select Data Register

R/W

R/W=0 to Write
R/W=1 to Read

I/O

Enable

DB0

I/O

The 8 Pin Data Bus

DB1

I/O

The 8 Pin Data Bus

DB2

I/O

The 8 Pin Data Bus

10

DB3

I/O

The 8 Pin Data Bus

11

DB4

I/O

The 8 Pin Data Bus

12

DB5

I/O

The 8 Pin Data Bus

13

DB6

I/O

The 8 Pin Data Bus

14

DB7

I/O

The 8 Pin Data Bus

4.7.3. Table LCD Command Codes

Code Command to LCD Instruction


(Hex)

Register

Clear display screen

Return home

Decrement cursor (shift cursor to left)

Increment cursor (shift cursor to right)

Shift display right

Shift display left

Display off, cursor off

Display off, cursor on

Display on, cursor off

Display on, cursor blinking

Display on, cursor blinking

10

Shift cursor position to left

14

Shift cursor position to right

18

Shift the entire display to the left

1C

Shift the entire display to the right

80

Force cursor to beginning of 1st line

C0

Force cursor to beginning of 1st line

38

2 lines and 5x7 matrix

CHAPTER 5

APPLICATIONS & ADVANTAGES

5.1.

APPLICATIONS

1. It automatically detects improper locking and displays particular


door locker is not properly locked.
2. Domestic applications
3. It can be employed even in industries, with slight modification in the circuits.

5.2.

ADVANTAGES

1. Improper locking is avoided


2. Increases safety
3. More comfortable in driving
4. Risk of human life is minimized

CHAPTER 6
CONCLUSION & FUTURE SCOPE

6.1. CONCLUSION

We designed this project to make comfortable journey in car with out any troubles. Using
LDR sensing circuit we controlled the car lighting system. And if any door is unlocked, the
display of particular door has shown with buzzer sound.
When a particular door is unlocked (releasing of limiting switch), the controller showing the
unlocked door. During night time travelling car head lights are controlled as per the opposite
vehicle.

6.2. FUTURE COPE

In the future we can add wireless communication to this project in-order to known the
accident information of vehicle. And also car engine heat can be controlled to increase the life
span of car engine.

Anda mungkin juga menyukai