New Microsoft Office Word Document

138
MANAGEMENT SYSTEMS FOR LATERAL SUPPORT IN VECHILE INTRODUCTION Cars and autos converting to gas could be the only solution to our pollution problem. But time and again scares are raised about the safety of this. However, none of the nine reported explosions in vehicles in the city has been caused by an LPG blast, point out the members of the Indian Autogas Association. They add that there has not been a single accident caused by conversion from petrol to gas in city cars or autos LP Gas Leakage can be very dangerous because it increases the risk of Fire or deadly Explosion. Therefore we have planned to develop a system that warns by providing information and sounds an alarm as soon a leakage is detected. But unfortunately those detectors are pretty much expensive. This detector will turn buzzer to corresponding persons as soon as a leakage takes place. Detector will warn you Buzzer that a sound as long as the leakage occurs, stopping only when the problem disappears. This detector is calibrated to detect gas up to 10% of the L.E.L (Low Explosion Limit). Small gas quantities coming out from the left open tank for some MINUTES do not cause the gas detector alarm signaling even if it is clearly nose perceptible; in fact the quantity of gas presents in the environment can be under the alarm threshold.

Transcript of New Microsoft Office Word Document

Page 1: New Microsoft Office Word Document

MANAGEMENT SYSTEMS FOR LATERAL SUPPORT

IN VECHILE

INTRODUCTION

Cars and autos converting to gas could be the only solution to our pollution problem. But time

and again scares are raised about the safety of this. However, none of the nine reported

explosions in vehicles in the city has been caused by an LPG blast, point out the members of the

Indian Autogas Association. They add that there has not been a single accident caused by

conversion from petrol to gas in city cars or autos LP Gas Leakage can be very dangerous

because it increases the risk of Fire or deadly Explosion. Therefore we have planned to develop a

system that warns by providing information and sounds an alarm as soon a leakage is detected.

But unfortunately those detectors are pretty much expensive. This detector will turn buzzer to

corresponding persons as soon as a leakage takes place. Detector will warn you Buzzer that a

sound as long as the leakage occurs, stopping only when the problem disappears. This detector is

calibrated to detect gas up to 10% of the L.E.L (Low Explosion Limit). Small gas quantities

coming out from the left open tank for some MINUTES do not cause the gas detector alarm

signaling even if it is clearly nose perceptible; in fact the quantity of gas presents in the

environment can be under the alarm threshold.

Drunk driving is very dangerous. Alcohol causes one to not be as aware. It also slows one's

reflexes. This is a real problem when one is driving. Drunk drivers get into car accidents because

they cannot tell what is happening around them or they cannot react fast enough.Drunk driving is

dangerous to many different people. When one drives an automobile while under the influence of

alcohol they put themselves in danger. Because one cannot react as fast to actions happening

around them and their automobile accidents happen and people are killed. Many times it is not

the driver that dies. When this happens not only do the drivers have to go to jail but they have to

live with the fact that they killed someone because of their irresponsibility. The driver obviously,

is not the only person affected by drunk driving. When a drunk driver kills someone the family

and friends of the victim are affected.

Page 2: New Microsoft Office Word Document

Drunk Driving is becoming a major concern in our society today. Drunk driving is not a funny

thing. It has killed many people and ruined the lives of many others.

So we came with a new idea to avoid these problems by developing a system which is located in

the vehicle which detects the alcoholics by breath and switch of the ignition system of the

vehicle.

Only one in every 20 road accidents is caused by the driver breaking the speed limit, the

Government has admitted.

Critics said the research, based on official police reports, destroyed the case for speed cameras.

It came amid a separate row over the accuracy of the Government's figures for the number of

people being injured or killed on the roads, which showed a three per cent fall last year.

Humans tend to blame somebody or something else when a mistake or accident occurs. A recent

European study concluded that 80% of drivers involved in motor vehicle accidents believed that

the other party could have done something to prevent the accident. A miniscule 5% admitted that

they were the only one at fault. Surveys consistently reveal that the majority consider themselves

more skillful and safer than the average driver. Some mistakes occur when a driver becomes

distracted, perhaps by a cell phone call or a spilled cup of coffee. Very few accidents result from

an 'Act of God,' like a tree falling on a vehicle.

Speed Kills - The faster the speed of a vehicle, the greater the risk of an accident. The forces

experienced by the human body in a collision increase exponentially as the speed increases.

Smart Motorist recommends that drivers observe our 3 second rule in everyday traffic, no matter

what your speed. Most people agree that going 100 mph is foolhardy and will lead to disaster.

The problem is that exceeding the speed limit by only 5 mph in the wrong place can be just as

dangerous. Traffic engineers and local governments have determined the maximum speeds

allowable for safe travel on the nation's roadways. Speeding is a deliberate and calculated

behavior where the driver knows the risk but ignores the danger. Fully 90% of all licensed

Page 3: New Microsoft Office Word Document

drivers speed at some point in their driving career; 75% admit to committing this offense

regularly.

Consider this example: a pedestrian walks out in front of a car. If the car is traveling at just 30

mph, and the driver brakes when the pedestrian is 45 feet away, there will be enough space in

which to stop without hitting the pedestrian. Increase the vehicle speed by just 5 mph and the

situation changes dramatically. At 35 mph, with the pedestrian 45 feet away and the driver

braking at the same point, the car will be traveling at 18 mph when it hits the pedestrian. An

impact at 18 mph can seriously injure or even kill the pedestrian.

Who are the bad drivers? They are young, middle-aged, and old; men and women; they drive

luxury cars, sports cars, SUVs and family cars. Almost every qualified driver I know admits to

some type of risky driving behavior, most commonly speeding.

Aggressive Drivers - As we've described, modern cars are manufactured to very safe standards,

and the environment they're driven in is engineered to minimize the injuries suffered during an

accident. The most difficult area to change is aggressive driver behavior and selfish attitudes. A

1995 study by the Automobile Association in Great Britain found that 88% of the respondents

reported at least one of the behaviors listed below directed at them (in order of descending

frequency):

Aggressive tailgating

Lights flashed at them because the other motorist was annoyed

Aggressive or rude gestures

Deliberate obstruction -- preventing them from moving their vehicle

Verbal abuse

Physical assault

The same group was then asked about aggressive behavior they had displayed towards other

drivers. 40% indicated that they had never behaved aggressively towards another driver. A

further 60% of the survey respondents admitted to one or more of the following behaviors (listed

in order of descending frequency):

Page 4: New Microsoft Office Word Document

Flashed lights at another motorist because they were annoyed with them

Gave aggressive or rude gestures

Gave verbal abuse

Aggressively tailgated another motorist

Deliberately obstructed or prevented another from moving their vehicle

Physically assaulted another motorist (one positive response)

These behaviors are probably under-reported, since most people are not willing to admit to the

more serious actions, even if no penalty exists. The majority of these incidents happened during

the daylight hours (70%), on a main road (not freeway or divided highway).

BLOCK DIAGRAM

LPC 2129 ARMMICROCONTROLLER

ALCOHOL BREATH ANALYZER

IGNITION CUT

OFF

OP-AMP

LPG/CNG

SENSORACCELERATION/

DE-ACCELERATION

LCD 16X2

Page 5: New Microsoft Office Word Document

BLOCK DIAGRAM DESCRIPTION:

This system consists of 8-bit microcontroller which acts as a heart of the system, which will be

monitoring the sensor continuously and sends the information to the hardware which will switch

of the ignition system of the vehicle. Alcohol detection is a tin dioxide semiconductor gas sensor

which has a high sensitivity to alcohol with quick response speed. this model is suitable for

alcohol detection such as portable breath alcohol checker or ignition locking system in

automobiles Ignition cut off system is a solid state electro mechanical relay which is connected

to microcontroller and ignition unit when microcontroller provides the information this will turn

on or off depending on the condition

Ideal sensor for use to detect the presence of a dangerous LPG leak in your storage tank. This

unit can be easily incorporated into an alarm unit, to sound an alarm or give a visual indication of

the LPG concentration. The sensor has excellent sensitivity combined with a quick response

time. The sensor can also sense iso-butane, propane, LNG and smoke.

Page 6: New Microsoft Office Word Document

CIRCUIT DIAGRAM

ARM7TDMI

3.1 ADVANCED RISC MACHINE

• T - Thumb architecture extension(16)

• D - Core has debug extensions

• M - Enhanced multiplier

• I - Embedded ICE macro cell

• S - Fully Synthesizable

3.2 FEATURES OF ARM7

• CPU at the heart of LPC2000 family is an ARM7.

Page 7: New Microsoft Office Word Document

• ARM7 is a RISC computer with a small instruction set and consequently with a small

gate count.

• It had high performance

• Low power consumption.

• It takes small amount of Silicon die area.

• Heart of ARM7 CPU is the instruction pipeline.

3.3 INTRODUCTION

The ARM7TDMI is a member of the Advanced RISC Machines (ARM) family of general

purpose 32-bit microprocessors, which offer high performance for very low power consumption

and price. The ARM architecture is based on Reduced Instruction Set Computer (RISC)

principles, and the instruction set and related decode mechanism are much simpler than those of

micro programmed Complex Instruction Set Computers. This simplicity results in a high

instruction throughput and impressive real-time interrupt response from a small and cost-

effective chip.

Pipelining is employed so that all parts of the processing and memory systems can operate

continuously. Typically, while one instruction is being executed, its successor is being decoded,

and a third instruction is being fetched from memory. The ARM memory interface has been

designed to allow the performance potential to be realized without incurring high costs in the

memory system. Speed-critical control signals are pipelined to allow system control functions to

be implemented in standard low-power logic, and these control signals facilitate the exploitation

of the fast local access modes offered by industry standard dynamic RAMs.

3.4 ARM ARCHITECTURE

The ARM7TDMI processor employs a unique architectural strategy known as THUMB, which

makes it ideally suited to high-volume applications with memory restrictions, or applications

where code density is an issue.

Page 8: New Microsoft Office Word Document

3.4.1 Thumb Concept

The key idea behind THUMB is that of a super-reduced instruction set. Essentially, the

ARM7TDMI processor has two instruction sets:

• The standard 32-bit ARM set

• A 16-bit THUMB set

The THUMB set’s 16-bit instruction length allows it to approach twice the density of standard

ARM code while retaining most of the ARM’s performance advantage over a traditional 16-bit

processor using 16-bit registers. This is possible because THUMB code operates on the same 32-

bit register set as ARM code.

The major advantage of a 32-bit (ARM) architecture over a 16-bit architecture is its ability to

manipulate 32-bit integers with single instructions, and to address a large address space

efficiently. When processing 32-bit data, a 16-bit architecture will take at least two instructions

to perform the same task as a single ARM instruction.

THUMB also has a major advantage over other 32-bit architectures with 16-bit instructions. This

is the ability to switch back to full ARM code and execute at full speed. Thus critical loops for

applications such as

• Fast interrupts

• DSP algorithms

Can be coded using the full ARM instruction set, and linked with THUMB code.

Various portions of a system can be optimized for speed or for code density by switching

between THUMB and ARM execution as appropriate.

Page 9: New Microsoft Office Word Document

3.5 ARM7 FUNCTIONAL DIAGRAM

Page 10: New Microsoft Office Word Document

Fig 3.1 Functional block diagram of ARM7

3.6 SIGNAL DESCRIPTION

3.6.1 Transistor sizes

For a 0.6 m ARM7TDMI:

INV4 driver has transistor sizes of

p = 22.32 m/0.6 m

N = 12.6 m/0.6 m

INV8 driver has transistor sizes of

p = 44.64 m/0.6 m

N = 25.2 m/0.6 m

3.6.2 Key to signal types

IC Input CMOS thresholds

P Power

Page 11: New Microsoft Office Word Document

O4 Output with INV4 driver

O8 Output with INV8 driver

3.7 PROGRAMMER’S MODEL PROCESSOR OPERATING STATES

From the programmer’s point of view, the ARM7TDMI can be in one of two states:

ARM state which executes 32-bit, word-aligned ARM instructions.

THUMB state which operates with 16-bit, half word-aligned THUMB instructions. In

this state, the PC uses bit 1 to select between alternate half words.

Note Transition between these two states does not affect the processor mode or the contents of

the registers.

3.7.1 Switching State

Entering THUMB state:

Entry into THUMB state can be achieved by executing a BX instruction with the state bit (bit 0)

set in the operand register. Transition to THUMB state will also occur automatically on return

from an exception (IRQ, FIQ, UNDEF, ABORT, SWI etc.), if the exception was entered with the

processor in THUMB state.

Entering ARM state:

Entry into ARM state happens:

1. On execution of the BX instruction with the state bit clear in the operand register.

2. On the processor taking an exception (IRQ, FIQ, RESET, UNDEF, ABORT, SWI etc.).

In this case, the PC is placed in the exception mode’s link register, and execution commences at

the exception’s vector address.

Page 12: New Microsoft Office Word Document

3.8 MEMORY FORMATS

ARM7TDMI views memory as a linear collection of bytes numbered upwards from zero. Bytes

0 to 3 hold the first stored word, bytes 4 to 7 the second and so on. ARM7TDMI can treat words

in memory as being stored either in Big Endian or Little Endian format.

3.8.1 Big Endian Format

In Big Endian format, the most significant byte of a word is stored at the lowest numbered byte

and the least significant byte at the highest numbered byte. Byte 0 of the memory system is

therefore connected to data lines 31 through 24.

Fig 3.2 Big Endian Format

3.8.2 Little Endian Format

In Little Endian format, the lowest numbered byte in a word is considered the word’s least

significant byte, and the highest numbered byte the most significant. Byte 0 of the memory

system is therefore connected to data lines 7 through 0.

Page 13: New Microsoft Office Word Document

Fig 3.3 Little Endian Format

3.8.3 Instruction Length

Instructions are either 32 bits long (in ARM state) or 16 bits long (in THUMB state).

3.8.4 Data Types

ARM7TDMI supports byte (8-bit), half word (16-bit) and word (32-bit) data types. Words must

be aligned to four-byte boundaries and half words to two-byte boundaries.

3.8.5 Operating Modes

ARM7TDMI supports seven modes of operation:

User (usr): The normal ARM program execution state

FIQ (fiq): Designed to support a data transfer or channel process

IRQ (irq): Used for general-purpose interrupt handling

Supervisor (svc): Protected mode for the operating system

Abort mode (abt): Entered after a data or instruction prefetch abort

System (sys): A privileged user mode for the operating system

Page 14: New Microsoft Office Word Document

Undefined (und): Entered when an undefined instruction is executed

Mode changes may be made under software control, or may be brought about by external

interrupts or exception processing. Most application programs will execute in User mode. The

non-user modes - known as privileged modes - are entered in order to service interrupts or

exceptions, or to access protected resources.

3.9 REGISTERS

ARM7TDMI has a total of 37 registers - 31 general-purpose 32-bit registers and six status

registers - but these cannot all be seen at once. The processor state and operating mode dictate

which registers are available to the programmer.

3.9.1 The Arm State Register Set

In ARM state, 16 general registers and one or two status registers are visible at any one time. In

privileged (non-User) modes, mode-specific banked registers are switched in. Register

organization in ARM state shows which registers are available in each mode: the banked

registers are marked with a shaded triangle. The ARM state register set contains 16 directly

accessible registers: R0 to R15. All of these except R15 are general-purpose, and may be used to

hold either data or address values. In addition to these, there is a seventeenth register used to

store status information

Register 14 is used as the subroutine link register. This receives a copy of R15 when a Branch

and Link (BL) instruction is executed. At all other times it may be treated as a

general-purpose register. The corresponding banked registers R14_svc, R14_irq,

R14_fiq, R14_abt and R14_und are similarly used to hold the return values of

Page 15: New Microsoft Office Word Document

R15 when interrupts and exceptions arise, or when Branch and Link instructions

are executed within interrupt or exception routines.

Register 15 holds the Program Counter (PC). In ARM state, bits [1:0] of R15 are zero and bits

[31:2] contain the PC. In THUMB state, bit [0] is zero and bits [31:1] contain the

PC.

Register 16 is the CPSR (Current Program Status Register). This contains condition code flags

and the current mode bits. FIQ mode has seven banked registers mapped to R8-14

(R8_fiq-R14_fiq). In ARM state, many FIQ handlers do not need to save any

registers. User, IRQ, Supervisor, Abort and Undefined each have two banked

registers mapped to R13 and R14, allowing each of these modes to have a private

stack pointer and link registers.

3.9.2 The Thumb State Register Set

The THUMB state register set is a subset of the ARM state set. The programme has direct access

to eight general registers, R0-R7, as well as the Program Counter (PC), a stack pointer register

(SP), a link register (LR), and the CPSR. There are banked Stack Pointers, Link Registers and

Saved Process Status Registers (SPSRs) for each privileged mode.

Page 16: New Microsoft Office Word Document

Fig 3.4 Thumb State Register Set

3.10 THE RELATIONSHIP BETWEEN ARM AND THUMB STATE REGISTERS

The THUMB state registers relate to the ARM state registers in the following way:

THUMB state R0-R7 and ARM state R0-R7 are identical

THUMB state CPSR and SPSRs and ARM state CPSR and SPSRs are identical

THUMB state SP maps onto ARM state R13

THUMB state LR maps onto ARM state R14

The THUMB state Program Counter maps onto the ARM state Program Counter (R15).

Page 17: New Microsoft Office Word Document

Fig 3.5

Mapping of THUMB state registers onto ARM state registers.

3.10.1 Accessing Hi Registers In Thumb State

In THUMB state, registers R8-R15 (the Hi registers) are not part of the standard register set.

However, the assembly language programmer has limited access to them, and can use them for

fast temporary storage. A value may be transferred from a register in the range R0-R7 (a Lo

register) to a Hi register and from a Hi register to a Low register, using special variants of the

MOV instruction. Hi register values can also be compared against or added to Lo register values

with the CMP and ADD instructions.

3.10.2 The Program Status Registers

Page 18: New Microsoft Office Word Document

The ARM7TDMI contains a Current Program Status Register (CPSR), plus five Saved Program

Status Registers (SPSRs) for use by exception handlers. These registers

hold information about the most recently performed ALU operation

control the enabling and disabling of interrupts

set the processor operating mode.

3.10.3 Program Status Register Format

Fig 3.6 Program Status Register Format

3.10.4 The Condition Code Flags

The N, Z, C and V bits are the condition code flags. These may be changed as a result of

arithmetic and logical operations, and may be tested to determine whether an instruction should

be executed.

3.10.5 The Control Bits

The bottom 8 bits of a PSR (incorporating I, F, T and M[4:0]) are known collectively as the

control bits. These will change when an exception arises. If the processor is operating in a

privileged mode, they can also be manipulated by software. The T bit This reflects the operating

state. When this bit is set, the processor is executing in THUMB state, otherwise it is executing

Page 19: New Microsoft Office Word Document

in ARM state. This is reflected on the TBIT external signal. Note that the software must never

change the state of the TBIT in the CPSR. If this happens, the processor will enter an

unpredictable state.

Interrupt disable bits the I and F bits are the interrupt disable bits. When set, these disable the

IRQ and FIQ interrupts respectively. The mode bits The M4, M3, M2, M1 and M0 bits (M[4:0])

are the mode bits. Not all combinations of the mode bits define a valid processor mode. Only

those explicitly described shall be used. The user should be aware that if any illegal value is

programmed into the mode bits, M[4:0], then the processor will enter an unrecoverable state. If

this occurs, reset should be applied.

Table 3.1: For control bits

Reserved bits the remaining bits in the PSRs are reserved. When changing a PSR’s flag or

control bits, you must ensure that these unused bits are not altered. Also, your program should

Page 20: New Microsoft Office Word Document

not rely on them containing specific values, since in future processors they may read as one or

zero.

CHAPTER 4

LPC2129

4.1 GENERAL DESCRIPTION

The LPC2119/2129/2194/2292/2294 are based on a 16/32 bit ARM7TDMI-STM CPU with real-

time emulation and embedded trace support, together with 128/256 kilobytes (kB) of embedded

high speed flash memory. A 128-bit wide internal memory interface and unique accelerator

architecture enable 32-bit code execution at maximum clock rate. For critical code size

applications, the alternative 16-bit Thumb Mode reduces code by more than 30% with minimal

performance penalty. With their compact 64 and 144 pin packages, low power consumption,

various 32-bit timers, combination of 4-channel 10-bit ADC and 2/4 advanced CAN channels or

8-channel 10-bit ADC and 2/4 advanced CAN channels (64 and 144 pin packages respectively),

and up to 9 external interrupt pins these microcontrollers are particularly suitable for industrial

control, medical systems, access control and point-of-sale.

Number of available GPIOs goes up to 46 in 64 pin package. In 144 pin packages number of

available GPIOs tops 76 (with external memory in use) through 112 (single-chip application).

Being equipped wide range of serial communications interfaces, they are also very well suited

for communication gateways, protocol converters and embedded soft modems as well as many

other general-purpose applications.

4.2 FEATURES

• 16/32-bit ARM7TDMI-S microcontroller in a 64 or 144 pin package.

• 16 KB on-chip Static RAM

Page 21: New Microsoft Office Word Document

• 128/256 KB on-chip Flash Program Memory (at least 10,000 erate/write cycles over the whole

temperature range). 128-bit wide

Interface/accelerator enables high speed 60 MHz operation.

• External 8, 16 or 32-bit bus (144 pin packages only)

• In-System Programming (ISP) and In-Application Programming (IAP) via on-chip boot-loader

software. Flash programming takes 1 ms per 512 byte line. Single sector or full chip erase takes

400 ms.

• Embedded ICE-RT interface enables breakpoints and watch points. Interrupt service routines

can continue to execute whilst

the foreground task is debugged with the on-chip Real Monitor software.

• Embedded Trace Macrocell enables non-intrusive high speed real-time tracing of instruction

execution.

• Two/four interconnected CAN interfaces with advanced acceptance filters.

• Four/eight channel (64/144 pin package) 10-bit A/D converter with conversion time as low as

2.44 ms.

• Two 32-bit timers (with 4 capture and 4 compare channels), PWM unit (6 outputs), Real Time

Clock and Watchdog.

• Multiple serial interfaces including two UARTs (16C550), Fast I2C (400 kbits/s) and two

SPIs™.

• 60 MHz maximum CPU clock available from programmable on-chip Phase-Locked Loop.

• Vectored Interrupt Controller with configurable priorities and vector addresses.

• Up to forty-six (64 pin) and hundred-twelve (144 pin package) 5 V tolerant general purpose I/O

pins. Up to 12 independent external interrupt pins available (EIN and CAP functions).

• On-chip crystal oscillator with an operating range of 1 MHz to 30 MHz.

Page 22: New Microsoft Office Word Document

• Two low power modes Idle and Power-down.

• Processor wake-up from Power-down mode via external interrupt.

• Individual enable/disable of peripheral functions for power optimization.

• Dual power supply.

- CPU operating voltage range of 1.65V to 1.95V (1.8V +/- 8.3%).

- I/O power supply range of 3.0V to 3.6V (3.3V +/- 10%).

4.3 APPLICATIONS

• Industrial control

• Medical systems

• Access control

• Point-of-sale

• Communication gateway

• Embedded soft modem

• General purpose applications

Page 23: New Microsoft Office Word Document

4.4 DEVICE INFORMATION

Table 4.1: LPC2119/2129/2194/2292/2294 device information

4.5 BLOCK DIAGRAM

Page 24: New Microsoft Office Word Document

Fig 4.1 Block diagram of LPC2129

Page 25: New Microsoft Office Word Document

4.6 ARCHITECTURAL OVERVIEW

The ARM7TDMI-S is a general purpose 32-bit microprocessor, which offers high performance

and very low power consumption. The ARM® architecture is based on Reduced Instruction Set

Computer (RISC) principles, and the instruction set and related decode mechanism are much

simpler than those of micro programmed Complex Instruction Set Computers. This simplicity

results in a high instruction throughput and impressive real-time interrupt response from a small

and cost-effective processor core.

Pipeline techniques are employed so that all parts of the processing and memory systems can

operate continuously. Typically, while one instruction is being executed, its successor is being

decoded, and a third instruction is being fetched from memory.

The ARM7TDMI-S processor also employs a unique architectural strategy known as Thumb,

which makes it ideally suited to high-volume applications with memory restrictions, or

applications where code density is an issue.

The key idea behind Thumb is that of a super-reduced instruction set. Essentially, the

ARM7TDMI-S processor has two instruction sets:

• The standard 32-bit ARM set.

• A 16-bit Thumb set.

The Thumb set’s 16-bit instruction length allows it to approach twice the density of standard

ARM code while retaining most of the ARM’s performance advantage over a traditional 16-bit

processor using 16-bit registers. This is possible because Thumb code operates on the same 32-

bit register set as ARM code. Thumb code is able to provide up to 65 % of the code size of

ARM, and 160 % of the performance of an equivalent ARM processor connected to a 16-bit

memory system.

4.6.1 On-Chip Flash Memory System

The LPC2119/LPC2129 incorporates a 128 kB and 256 kB Flash memory system respectively.

This memory may be used for both code and data storage. Programming of the Flash memory

may be accomplished in several ways. It may be programmed In System via the serial port. The

Page 26: New Microsoft Office Word Document

application program may also erase and/or program the Flash while the application is running,

allowing a great degree of flexibility for data storage field firmware upgrades, etc. When on-chip

boot loader is used, 120/248 kB of Flash memory is available for user code.

The LPC2119/LPC2129 Flash memory provides a minimum of 100,000 erase/write cycles and

20 years of data retention. On-chip boot loader (as of revision 1.60) provides Code Read

Protection (CRP) for the LPC2119/LPC2129 on-chip Flash memory. When the CRP is enabled,

the JTAG debug port and ISP commands accessing either the on-chip RAM or Flash memory are

disabled. However, the ISP Flash Erase command can be executed at any time (no matter

whether the CRP is on or off). Removal of CRP is achieved by erasure of full on-chip user Flash.

With the CRP off, full access to the chip via the JTAG and/or ISP is restored.

4.6.2 On-Chip Static Ram

The LPC2119/2129/2194/2292/2294 provides a 16 kB static RAM memory that may be used for

code and/or data storage. The SRAM supports 8-bit, 16-bit, and 32-bit accesses.

The SRAM controller incorporates a write-back buffer in order to prevent CPU stalls during

back-to-back writes. The write-back buffer always holds the last data sent by software to the

SRAM. This data is only written to the SRAM when another write is requested by software (the

data is only written to the SRAM when software does another write). If a chip reset occurs,

actual SRAM contents will not reflect the most recent write request

(i.e. after a "warm" chip reset, the SRAM does not reflect the last write operation). Any software

that checks SRAM contents after reset must take this into account. Two identical writes to a

location guarantee that the data will be present after a Reset. Alternatively, a dummy write

operation before entering idle or power-down mode will similarly guarantee that the last data

written will be present in SRAM after a subsequent Reset.

4.6.3 System Control

The oscillator supports crystals in the range of 1 MHz to 30 MHz. The oscillator output

frequency is called fosc and the ARM processor clock frequency is referred to as cclk for

Page 27: New Microsoft Office Word Document

purposes of rate equations, etc. fosc and cclk are the same value unless the PLL is running and

connected.

4.6.4 Crystal Oscillator

While an input signal of 50-50 duty cycle within a frequency range from 1 MHz to 50 MHz can

be used by LPC2119/2129/2194/2292/2294 if supplied to its input XTAL1 pin, this

microcontroller’s onboard oscillator circuit supports external crystals in the range of 1 MHz to

30 MHz only. If on-chip PLL system or boot-loader is used, input clock frequency is limited to

exclusive range of 10 MHz to 25 MHz. The oscillator output frequency is called Fosc and the

ARM processor clock frequency is referred to as cclk for purposes of rate equations, etc.

elsewhere in this document. Fosc and cclk are the same value unless the PLL is running and

connected. Refer to the PLL description in this chapter for details and frequency limitations.

Onboard oscillator in LPC2119/2129/2194/2292/2294 can operate in one of two modes: slave

mode and oscillation mode. In slave mode the input clock signal should be coupled by means of

a capacitor of 100 pF (Cc in Figure , drawing a), with an

Amplitude of at least 200 mVrms. X2 pin in this configuration can be left not connected. If slave

mode is selected, Fosc signal of 50-50 duty cycle can range from 1 MHz to 50 MHz.

External components and models used in oscillation mode are shown in Figure, drawings b and

c. Since the feedback resistance is integrated on chip, only a crystal and the capacitances CX1

and CX2 need to be connected externally in case of fundamental mode oscillation (the

fundamental frequency is represented by L, CL and RS). Capacitance Cp in Figure, drawing c,

represents the parallel package capacitance and should not be larger than 7 pF. Parameters FC,

CL, RS and CP are supplied by the crystal manufacturer. Choosing an oscillation mode as an on-

board oscillator mode of operation limits Fosc clock selection to 1 MHz to 30 MHz.

Page 28: New Microsoft Office Word Document

Fig 4.2

Oscillator modes and models: a) slave mode of operation, b) oscillation mode of operation)

external crystal model used for CX1/X2 evaluation

4.6.5 PLL (Phase Locked Loop)

The PLL accepts an input clock frequency in the range of 10 MHz to 25 MHz The input

frequency is multiplied up into the range of 10 MHz to 60 MHz with a Current Controlled

Oscillator (CCO). The multiplier can be an integer value from 1 to 32 (in practice, the multiplier

value cannot be higher than 6 on this family of microcontrollers due to the upper frequency limit

of the CPU). The CCO operates in the range of 156 MHz to 320 MHz, so there is an additional

divider in the loop to keep the CCO within its frequency range while the PLL is providing the

desired output frequency. The output divider may be set to divide by 2, 4, 8, or 16 to produce the

output clock. Since the minimum output divider value is 2, it is insured that the PLL output has a

50 % duty cycle. The PLL is turned off and bypassed following a chip Reset and may be enabled

by software. The program must configure and activate the PLL, wait for the PLL to Lock, then

connect to the PLL as a clock source. The PLL settling time is 100 ms.

Page 29: New Microsoft Office Word Document

Fig 4.3 PLL Block Diagram

4.6.7 Reset and Wakeup Timer

Reset has two sources on the LPC2119/LPC2129: the RESET pin and Watchdog Reset. The

RESET pin is a Schmitt trigger input pin with an additional glitch filter. Assertion of chip Reset

by any source starts the Wake-up Timer (see Wake-up Timer description below), causing the

internal chip reset to remain asserted until the external Reset is de-asserted, the oscillator is

running, a fixed number of clocks have passed, and the on-chip Flash controller has completed

its initialization. When the internal Reset is removed, the processor begins executing at address

0, which is the Reset vector. At that point, all of the processor and peripheral registers have been

initialized to predetermined values.

Page 30: New Microsoft Office Word Document

The wake-up timer ensures that the oscillator and other analog functions required for chip

operation are fully functional before the processor is allowed to execute instructions. This is

important at power on, all types of Reset, and whenever any of the aforementioned functions are

turned off for any reason. Since the oscillator and other functions are turned off during Power-

down mode, any wake-up of the processor from Power-down mode makes use of the Wake-up

Timer. The Wake-up Timer monitors the crystal oscillator as the means of checking whether it is

safe to begin code execution. When power is applied to the chip, or some event

Caused the chip to exit Power-down mode, some time is required for the oscillator to produce a

signal of sufficient amplitude to drive the clock logic. The amount of time depends on many

factors, including the rate of VDD ramp (in the case of power on), the type of crystal and its

electrical characteristics (if a quartz crystal is used), as well as any other external circuitry (e.g.

capacitors), and the characteristics of the oscillator itself under the existing ambient conditions.

4.6.8 External Interrupt Inputs

The LPC2119/LPC2129 include up to nine edge or level sensitive External Interrupt Inputs as

selectable pin functions. When the pins are combined, external events can be processed as four

independent interrupt signals. The External Interrupt Inputs can optionally be used to wake up

the processor from Power-down mode.

4.6.8 Memory Mapping Control

The Memory Mapping Control alters the mapping of the interrupt vectors that appear beginning

at address 0x00000000. Vectors may be mapped to the bottom of the on-chip Flash memory, or

to the on-chip static RAM. This allows code running in different memory spaces to have control

of the interrupts.

Page 31: New Microsoft Office Word Document

4.6.9 Power Control

The LPC2119/LPC2129 support two reduced power modes: Idle mode and Power-down mode.

In Idle mode, execution of instructions is suspended until either a Reset or interrupt occurs.

Peripheral functions continue operation during Idle mode and may generate interrupts to cause

the processor to resume execution. Idle mode eliminates power used by the processor itself,

memory systems and related controllers, and internal buses.

In Power-down mode, the oscillator is shut down and the chip receives no internal clocks. The

processor state and registers, peripheral registers, and internal SRAM values are preserved

throughout Power-down mode and the logic levels of chip output pins remain static. The Power-

down mode can be terminated and normal operation resumed by either a Reset or certain specific

interrupts that are able to function without clocks. Since all dynamic operation of the chip is

suspended, Power-down mode reduces chip power consumption to nearly zero.

A Power Control for Peripherals feature allows individual peripherals to be turned off if they are

not needed in the application, resulting in additional power savings.

4.6.10 VPB bus

The VPB divider determines the relationship between the processor clock (CCLK) and the clock

used by peripheral devices (PCLK). The VPB divider serves two purposes. The first is to provide

peripherals with the desired PCLK via VPB bus so that they can operate at the speed chosen for

the ARM processor. In order to achieve this, the VPB bus may be slowed down to 1¤2 to 1¤4 of

the processor clock rate. Because the VPB bus must work properly at power-up (and its timing

cannot be altered if it does not work since the VPB divider control registers reside on the VPB

bus), the default condition at reset is for the VPB bus to run at 1¤4 of the processor clock rate.

The second purpose of the VPB divider is to allow power savings when an application does not

require any peripherals to run at the full processor rate. Because the VPB divider is connected to

the PLL output, the PLL remains active (if it was running) during Idle mode.

Page 32: New Microsoft Office Word Document

4.6.11 Emulation and Debugging

The LPC2119/LPC2129 support emulation and debugging via a JTAG serial port. A trace port

allows tracing program execution. Debugging and trace functions are multiplexed only with

GPIOs on Port 1. This means that all communication, timer and interface peripherals residing on

Port 0 are available during the development and debugging phase as they are when the

application is run in the embedded system itself.

4.6.12 Embedded ICE

Standard ARM Embedded ICE® logic provides on-chip debug support. The debugging of the

target system requires a host computer running the debugger software and an Embedded ICE

protocol convertor. Embedded ICE protocol convertor converts the Remote Debug Protocol

commands to the JTAG data needed to access the ARM core.

The ARM core has a Debug Communication Channel function built-in. The debug

communication channel allows a program running on the target to communicate with the host

debugger or another separate host without stopping the program flow or even entering the debug

state. The debug communication channel is accessed as a co-processor 14 by the program

running on the ARM7TDMI-S core. The debug communication channel allows the JTAG port to

be used for sending and receiving data without affecting the normal program flow. The debug

communication channel data and control registers are mapped in to addresses in the Embedded

ICE logic.

4.6.13 Embedded Trace

Page 33: New Microsoft Office Word Document

Since the LPC2119/LPC2129 have significant amounts of on-chip memory, it is not possible to

determine how the processor core is operating simply by observing the external pins. The

Embedded Trace Macrocell™ provides real-time trace capability for deeply embedded processor

cores. It outputs information about processor execution to the trace port.

The ETM is connected directly to the ARM core and not to the main AMBA system bus. It

compresses the trace information and exports it through a narrow trace port. An external trace

port analyzer must capture the trace information under software debugger control. Instruction

trace (or PC trace) shows the flow of execution of the processor and provides a list of all the

instructions that were executed. Instruction trace is significantly compressed by only

broadcasting branch addresses as well as a set of status signals that indicate the pipeline status on

a cycle by cycle basis. Trace information generation can be controlled by selecting the trigger

resource. Trigger resources include address comparators, counters and sequencers. Since trace

information is compressed the software debugger requires a static image of the code being

executed. Self-modifying code cannot be traced because of this restriction.

4.6.14 Real Monitor

Real Monitor is a configurable software module, developed by ARM Inc., which enables real

time debug. It is a lightweight debug monitor that runs in the background while users debug their

foreground application. It communicates with the host using the DCC (Debug Communications

Channel), which is present in the Embedded ICE logic. The LPC2119/LPC2129 contains a

specific configuration of Real Monitor software programmed into the on-chip Flash memory.

Page 34: New Microsoft Office Word Document

4.7 PIN DIAGRAM

Fig4.4 LPC2119/2129 64pin package

Page 35: New Microsoft Office Word Document

4.8 PIN CONNECTION OF LPC2129

Page 36: New Microsoft Office Word Document

Fig 4.5 Pin connection of LPC2129

4.9 PIN DESCRIPTION FOR LPC2119/2129/2194

Page 37: New Microsoft Office Word Document

Pin description for LPC2119/2129/2194 and a brief of corresponding functions are shown in the

following table.

Table 4.1: Pin description for LPC2119/2129/2194

Table 4.2: Pin description for LPC2119/2129/2194

Page 38: New Microsoft Office Word Document
Page 39: New Microsoft Office Word Document

Table 4.3: Pin description for LPC2119/2129/2194

Page 40: New Microsoft Office Word Document

Table 4.4: Pin description for LPC2119/2129/2194

Page 41: New Microsoft Office Word Document

Table 4.5: Pin description for LPC2119/2129/2194

PWM

(PULSE WIDTH MODULATOR)

LPC2119/2129/2194/2292/2294 Pulse Width Modulator is based on standard Timer 0/1

Application can choose among PWM and match functions available.

7.1 FEATURES

• Seven match registers allow up to 6 single edge controlled or 3 double edge controlled PWM

outputs, or a mix of both types.

The match registers also allow:

- Continuous operation with optional interrupt generation on match.

- Stop timer on match with optional interrupt generation.

Page 42: New Microsoft Office Word Document

- Reset timer on match with optional interrupt generation.

• An external output for each match register with the following capabilities:

- Set low on match.

- Set high on match.

- Toggle on match.

- Do nothing on match.

• Supports single edge controlled and/or double edge controlled PWM outputs. Single edge

controlled PWM outputs all go high at the beginning of each cycle unless the output is a constant

low. Double edge controlled PWM outputs can have either edge occur at any position within a

cycle. This allows for both positive going and negative going pulses.

• Pulse period and width can be any number of timer counts. This allows complete flexibility in

the trade-off between resolution and repetition rate. All PWM outputs will occur at the same

repetition rate.

• Double edge controlled PWM outputs can be programmed to be either positive going or

negative going pulses.

• Match register updates are synchronized with pulse outputs to prevent generation of erroneous

pulses. Software must "release" new match values before they can become effective.

• May be used as a standard timer if the PWM mode is not enabled.

• A 32-bit Timer/Counter with a programmable 32-bit Prescaler.

• Four 32-bit capture channels take a snapshot of the timer value when an input signals

transitions. A capture event may also optionally generate an interrupt.

7.2 DESCRIPTION

Page 43: New Microsoft Office Word Document

The PWM is based on the standard Timer block and inherits all of its features, although only the

PWM function is pinned out o the LPC2119/2129/2194/2292/2294. The Timer is designed to

count cycles of the peripheral clock (pclk) and optionally generate interrupts or perform other

actions when specified timer values occur, based on seven match registers. It also includes four

capture inputs to save the timer value when an input signal transitions, and optionally generate an

interrupt when those events occur. The PWM function is in addition to these features, and is

based on match register events. The ability to separately control rising and falling edge locations

allows the PWM to be used for more applications. For instance,

multi-phase motor control typically requires three non-overlapping PWM outputs with individual

control of all three pulse width sand positions. Two match registers can be used to provide a

single edge controlled PWM output. One match register (PWMMR0) controls the

PWM cycle rate, by resetting the count upon match. The other match register controls the PWM

edge position. Additional single edge controlled PWM outputs require only one match register

each, since the repetition rate is the same for all PWM outputs. Multiple single edge controlled

PWM outputs will all have a rising edge at the beginning of each PWM cycle, when an

PWMMR0 match occurs. Three match registers can be used to provide a PWM output with both

edges controlled. Again, the PWMMR0 match register controls the PWM cycle rate. The other

match registers control the two PWM edge positions. Additional double edge controlled PWM

outputs require only two match registers each, since the repetition rate is the same for all PWM

outputs. With double edge controlled PWM outputs, specific match registers control the rising

and falling edge of the output. This allows both positive going PWM pulses (when the rising

edge occurs prior to the falling edge), and negative going PWM pulses (when the falling edge

occurs prior to the rising edge).Figure 7.1 shows the block diagram of the PWM. The portions

that have been added to the standard timer block are on the right hand side and at the top of the

diagram.

7.3 BLOCK DIAGRAM

Page 44: New Microsoft Office Word Document

Fig 7.1 PWM block diagram

Page 45: New Microsoft Office Word Document

Fig 7.2 Sample PWM waveforms

A sample of how PWM values relate to waveform outputs is shown in Figure 43. PWM output

logic is shown in Figure 42 that allows selection of either single or double edge controlled PWM

outputs via the muxes controlled by the PWMSEL n bits. The match register selection for

various PWM outputs is shown in Table 164. This implementation supports up to N-1 single

edge PWM outputs or (N-1)/2 double edge PWM outputs, where N is the number of match

registers that are implemented. PWM types can be mixed if desired.

7.4 RULES FOR SINGLE EDGE CONTROLLED PWM OUTPUTS

1. All single edge controlled PWM outputs go high at the beginning of a PWM cycle unless their

match value is equal to 0.

Page 46: New Microsoft Office Word Document

2. Each PWM output will go low when its match value is reached. If no match occurs (i.e. the

match value is greater than the

PWM rate), the PWM output remains continuously high.

7.5 RULES FOR DOUBLE EDGE CONTROLLED PWM OUTPUTS

Five rules are used to determine the next value of a PWM output when a new cycle is about to

begin:

1.The match values for the next PWM cycle are used at the end of a PWM cycle (a time point

which is coincident with the beginning of the next PWM cycle), except as noted in rule 3.

2. A match value equal to 0 or the current PWM rate (the same as the Match channel 0 value) has

the same effect, except as noted in rule 3. For example, a request for a falling edge at the

beginning of the PWM cycle has the same effect as a request for a falling edge at the end of a

PWM cycle.

3. When match values are changing, if one of the "old" match values is equal to the PWM rate, it

is used again once if the neither of the new match values are equal to 0 or the PWM rate, nor

there was no old match value equal to 0.

4. If both a set and a clear of a PWM output are requested at the same time, clear takes

precedence. This can occur when the set and clear match values are the same as in, or when the

set or clear value equals 0 and the other value equals the PWM rate.

5. If a match value is out of range (i.e. greater than the PWM rate value), no match event occurs

and that match channel has no effect on the output. This means that the PWM output will remain

always in one state, allowing always low, always high, or "no change" outputs.

Page 47: New Microsoft Office Word Document

CHAPTER 8

DC MOTOR

8.1 DC MOTOR DRIVER

L293D is a bipolar motor driver IC. This is a high voltage, high current push pull four channel

driver compatible to TTL logic levels and drive inductive loads. It has 600 mA output current

capabilities per channel and internal clamp diodes.

The L293 is designed to provide bidirectional drive currents of up to 1 A at voltages from 4.5 V

to 36 V. The L293D is designed to provide bidirectional drive currents of up to 600-mA at

voltages from 4.5 V to 36 V. Both devices are designed to drive inductive loads such as relays,

solenoids, dc and bipolar stepping motors, as well as other high-current/high-voltage loads in

positive supply applications. All inputs are TTL compatible. Each output is a complete totem-

pole drive circuit, with a Darlington transistor sink and a pseudo-Darlington source. Drivers are

enabled in pairs, with drivers 1 and 2 enabled by 1,2EN and drivers 3 and 4 enabled by 3,4EN.

When an enable input is high, the associated drivers are enabled, and their outputs are active and

in phase with their inputs. When the enable input is low, those drivers are disabled, and their

outputs are off and in the high-impedance state. With the proper data inputs, each pair of drivers

forms a full-H (or bridge) reversible drive suitable for solenoid or motor applications.

Page 48: New Microsoft Office Word Document

Fig 8.1 IC L293D

8.2 PIN DIAGRAM OF L293D

4 5 12 13

16 8

1

2

15

9

7

10

314

6

11

VCC1- LOGIC SUPPLY= 5V

LM+ OUTPUT FOR MOTOR1

OUTPUT FOR MOTOR2

L_IN1

L_EN

GND

L293DINPUT LINES

R_EN

L_IN2

R_IN2

R_IN1

LM-

RM+

RM-

Fig 8.2 Pin Diagram of L293D

Page 49: New Microsoft Office Word Document

The Device is a monolithic integrated high voltage, high current four channel driver designed to

accept standard DTL or TTL logic levels and drive inductive loads (such as relays solenoids, DC

and stepping motors) and switching power transistors. To simplify use as two bridges each pair

of channels is equipped with an enable input. A separate supply input is provided for the logic,

allowing operation at a lower voltage and internal clamp diodes are included. This device is

suitable for use in switching applications at frequencies up to 5 kHz.

The L293D is assembled in a 16 lead plastic package which has 4 centre pins connected together

and used for heat sinking The L293DD is assembled in a 20 lead surface mount which has 8

centre pins connected together and used for heat sinking.

8.3 PIN CONNECTIONS

Page 50: New Microsoft Office Word Document

Fig 8.3

Connection Diagram for Driving Dc Motor

Page 51: New Microsoft Office Word Document

8.4 DC MOTOR

Whenever a robotics hobbyist talk about making a robot, the first thing comes to his mind is

making the robot move on the ground. And there are always two options in front of the designer

whether to use a DC motor or a stepper motor. When it comes to speed, weight, size, cost. DC

motors are always preferred over stepper motors. There are many things which you can do with

your DC motor when interfaced with a microcontroller. For example you can control the speed

of motor, you can control the direction of rotation, you can also do encoding of the rotation made

by DC motor i.e. keeping track of how many turns are made by your motors etc. So you can see

DC motors are no less than a stepper motor.

Fig.8.4 Internal Structure of Dc Motor

Page 52: New Microsoft Office Word Document

4.12 REGULATOR:

A discrete voltage regulator fabricated on a single chip, it is called monolithic voltage

regulator. These regulators have:

i. High performance (ideal 100% regulation)

ii. Low cost.

iii. Reduced size.

iv. Easier to use.

Usually monolithic voltage regulator is available as 3 terminals IC7805 as shown in below

figure. The 3 terminals are denoted as IN (input), COM (common), OUT (output). This +5V

regulator is useful in power up to 500mw.It must have a heat sink for high current. A 1mf high

quality and tantalum capacitor should be placed from output to ground for stability. By using this

regulator

circuit we are

deriving 5v

from 12v

battery.

Page 53: New Microsoft Office Word Document

Fig. 4.21 REGULATOR CIRCUIT

Page 54: New Microsoft Office Word Document

LCD 16x2

Liquid crystal display is very important device in embedded system. It offers high flexibility to

user as he can display the required data on it. But due to lack of proper approach to LCD

interfacing many of them fail. Many people consider LCD interfacing a complex job but

according to me LCD interfacing is very easy task, you just need to have a logical approach. This

page is to help the enthusiast who wants to interface LCD with through understanding. Copy and

Paste technique may not work when an embedded system engineer wants to apply LCD

interfacing in real world projects.

You will be knowing about the booster rockets on space shuttle. Without these booster rockets

the space shuttle would not launch in geosynchronous orbit. Similarly to understand LCD

interfacing you need to have booster rockets attached! To get it done right you must have general

idea how to approach any given LCD.This page will help you develop logical approach towards

LCD interfacing.

First thing to begin with is to know what LCD driver/controller is used in LCD.Yes, your LCD is

dumb it does not know to talk with your microcontroller. LCD driver is a link between the

microcontroller and LCD. You can refer the datasheet of LCD to know the LCD driver for e.g.

JHD 162A is name of LCD having driver HD44780U.You have to interface the LCD according

to the driver specification. To understand the algorithm of LCD interfacing user must have

datasheet of both LCD and LCD driver. Many people ignore the datasheets and end up in

troubles. If you want to interface LCD successfully you must have datasheets.

Why people ignore datasheets? Most of us do not like to read 100 pages of datasheet. But for a

accurate technical specification datasheets are must. I will show you a technique to manipulate a

datasheet within minutes.

First thing to find out in datasheet is the features viz. operating voltage, type of interface,

maximum speed for interface in MHz, size of display data RAM, number of pixels, bits per

Page 55: New Microsoft Office Word Document

pixel, number of row and columns. You must have the pin diagram of LCD.Pin diagram of LCD

driver can be omitted.

Study the type of communication protocol whether it is parallel or serial interface. Check how

LCD discriminates data bytes and command bytes, which pins on LCD are used for

communication. Study Interface timing diagram given in the datasheet.

From datasheet of LCD driver find out whether hardware reset is required at startup, what is the

time of reset pulse, is it active low and which pins of LCD are to be toggled.

Major task in LCD interfacing is the initialization sequence. In LCD initialization you have to

send command bytes to LCD. Here you set the interface mode, display mode, address counter

increment direction, set contrast of LCD, horizontal or vertical addressing mode, color format.

This sequence is given in respective LCD driver datasheet. Studying the function set of LCD lets

you know the definition of command bytes. It varies from one LCD to another. If you are able to

initialize the LCD properly 90% of your job is done.

Next step after initialization is to send data bytes to required display data RAM memory location.

Firstly set the address location using address set command byte and than send data bytes using

the DDRAM write command. To address specific location in display data RAM one must have

the knowledge of how the address counter is incremented.

LCD INTERFACING:

The most commonly used Character based LCDs are based on Hitachi's HD44780 controller or

other which are compatible with HD44580. In this, we will discuss about character based LCDs,

their interfacing with various microcontrollers, various interfaces (8-bit/4-bit), programming,

special stuff and tricks you can do with these simple looking LCDs which can give a new look to

your application.

Pin Description:

Page 56: New Microsoft Office Word Document

The most commonly used LCDs found in the market today are 1 Line, 2 Line or 4 Line LCDs

which have only 1 controller and support at most of 80 characters, whereas LCDs supporting

more than 80 characters make use of 2 HD44780 controllers. 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 description is shown in the table below.

Character LCD type HD44780 Pin diagram

Page 57: New Microsoft Office Word Document

Character LCD pins with 1 Controller

Character LCD pins with 2 Controller

DDRAM-Display data RAM:

Display data RAM (DDRAM) stores display data represented in 8-bit character codes. Its

extended capacity is 80 X 8 bits, or 80 characters. The area in display data RAM (DDRAM) that

is not used for display can be used as general data RAM. So whatever you send on the DDRAM

is actually displayed on the LCD. For LCDs like 1x16, only 16 characters are visible, so

whatever you write after 16 chars is written in DDRAM but is not visible to the user.

Page 58: New Microsoft Office Word Document

Figures below will show you the DDRAM addresses of 1 Line, 2 Line and 4 Line LCDs.

DDRAM Address for 1 Line LCD

DDRAM Address for 2 Line LCD

DDRAM Address for 4 Line LCD

CGROM - Character Generator ROM

Now you might be thinking that when you send an ASCII value to DDRAM, how the character

is displayed on LCD? So the answer is CGROM. The character generator ROM generates 5 x 8

Page 59: New Microsoft Office Word Document

dot or 5 x 10 dot character patterns from 8-bit character codes. It can generate 208 5 x 8 dot

character patterns and 32 5 x 10 dot character patterns. User defined character patterns are also

available by mask-programmed ROM.

CGRAM - Character Generator RAM

CGRAM area is used to create custom characters in LCD. In the character generator RAM, the

user can rewrite character patterns by program. For 5 x 8 dots, eight character patterns can be

written, and for 5 x 10 dots, four character patterns can be written.

BF - Busy Flag

Busy Flag is a status indicator flag for LCD. When we send a command or data to the LCD for

processing, this flag is set (i.e. BF =1) and as soon as the instruction is executed successfully this

flag is cleared (BF = 0). This is helpful in producing and exact amount of delay. To read Busy

Flag, the condition RS = 0 and R/W = 1 must be met and The MSB of the LCD data bus (D7) act

as busy flag. When BF = 1 means LCD is busy and will not accept next command or data and BF

= 0 means LCD is ready for the next command or data to process.

Instruction Register (IR) and Data Register (DR)

There are two 8-bit registers in HD44780 controller Instruction and Data register. Instruction

register corresponds to the register where you send commands to LCD e.g. LCD shift command,

LCD clear, LCD address etc. and Data register is used for storing data , which is to be

displayed on LCD when send the enable signal of the LCD is asserted, the data on the pins is

Page 60: New Microsoft Office Word Document

latched in to the data register and data is then moved automatically to the DDRAM and hence is

displayed on the LCD?

Data Register is not only used for sending data to DDRAM but also for CGRAM, the address

where you want to send the data, is decided by the instruction you send to LCD.

Commands and Instruction set

Only the instruction register (IR) and the data register (DR) of the LCD can be controlled by the

MCU. Before starting the internal operation of the LCD, control information is temporarily

stored into these registers to allow interfacing with various MCUs, which operate at different

speeds, or various peripheral control devices. The internal operation of the LCD is determined by

signals sent from the MCU. These signals, which include register selection signal (RS),

read/write signal (R/W), and the data bus (DB0 to DB7), make up the LCD instructions (table

below). There are four categories of instructions that:

Designate LCD functions, such as display format, data length, etc.

Set internal RAM addresses

Perform data transfer with internal RAM

Perform miscellaneous functions

Page 61: New Microsoft Office Word Document

Table: Command and Instruction set for LCD type HD44780

Although looking at the table you can make your own commands and test them. Below is a brief

list of useful commands which are used frequently while working on the LCD.

Page 62: New Microsoft Office Word Document

Frequently used commands and instructions for LCD

LCD Initialization

Before using the LCD for display purpose, LCD has to be initialized either by the internal reset

circuit or sending set of commands to initialize the LCD. It is the user who has to decide whether

Page 63: New Microsoft Office Word Document

an LCD has to be initialized by instructions or by internal reset circuit. we will discuss both ways

of initialization one by one.

Initialization by internal Reset Circuit

An internal reset circuit automatically initializes the HD44780U when the power is turned on.

The following instructions are executed during the initialization. The busy flag (BF) is kept in

the busy state until the initialization ends (BF = 1). The busy state lasts for 10 ms after VCC rises

to 4.5 V.

Display clear

Function set:

DL = 1; 8-bit interface data

N = 0; 1-line display

F = 0; 5 x 8 dot character font

Display on/off control:

D = 0; Display off

C = 0; Cursor off

B = 0; Blinking off

Entry mode set:

I/D = 1; Increment by 1

S = 0; No shift

Power Supply condition for Internal Reset circuit

Page 64: New Microsoft Office Word Document

Figure 7 shows the test conditions which are to be met for internal reset circuit to be active.

Now the problem with the internal reset circuit is, it is highly dependent on power supply, to

meet this critical power supply conditions is not hard but are difficult to achieve when you are

making a simple application. So usually the second method i.e. Initialization by instruction is

used and is recommended most of the time.

Initialization by instructions

Initializing LCD with instructions is really simple. Given below is a flowchart that describes the

step to follow, to initialize the LCD.

Page 65: New Microsoft Office Word Document

Flow chart for LCD initialization

As you can see from the flow chart, the LCD is initialized in the following sequence.

1) Send command 0x30 - Using 8-bit interface

2) Delay 20ms

3) Send command 0x30 - 8-bit interface

4) Delay 20ms

5) Send command 0x30 - 8-bit interface

6) Delay 20ms

Page 66: New Microsoft Office Word Document

7) Send Function set - see Table 4 for more information

8) Display Clear command

9) Set entry mode command - explained below

The first 3 commands are usually not required but are recommended when you are using 4-bit

interface. So you can program the LCD starting from step 7 when working with 8-bit interface.

Function set command depends on what kind of LCD you are using and what kind of interface

you are using.

LCD interfacing with Microcontrollers-4bit mode

In 4-bit mode the data is sent in nibbles, first we send the higher nibble and then the lower nibble.

To enable the 4-bit mode of LCD, we need to follow special sequence of initialization that tells the

LCD controller that user has selected 4-bit mode of operation. We call this special sequence as

resetting the LCD. Following is the reset sequence of LCD.

Wait for about 20mS

Send the first init value (0x30)

Wait for about 10mS

Send second init value (0x30)

Wait for about 1mS

Send third init value (0x30)

Wait for 1mS

Select bus width (0x30 - for 8-bit and 0x20 for 4-bit)

Wait for 1mS

The busy flag will only be valid after the above reset sequence. Usually we do not use busy flag

in 4-bit mode as we have to write code for reading two nibbles from the LCD. Instead we simply

put a certain amount of delay usually 300 to 600uS. This delay might vary depending on the

Page 67: New Microsoft Office Word Document

LCD you are using, as you might have a different crystal frequency on which LCD controller is

running. So it actually depends on the LCD module you are using. So if you feel any problem

running the LCD, simply try to increase the delay. This usually works.

LCD connections in 4-bit Mode

Above is the connection diagram of LCD in 4-bit mode, where we only need 6 pins to interface

an LCD. D4-D7 are the data pins connection and Enable and Register select are for LCD control

pins. We are not using Read/Write (RW) Pin of the LCD, as we are only writing on the LCD so

we have made it grounded permanently. If you want to use it. Then you may connect it on your

controller but that will only increase another pin and does not make any big difference.

Page 68: New Microsoft Office Word Document

Potentiometer RV1 is used to control the LCD contrast. The unwanted data pins of LCD i.e. D0-

D3 are connected to ground.

Gas detector

A gas detector is a device which detects the presence of various gases within an area, usually as

part of a safety system. This type of equipment is used to detect a gas leak and interface with a

control system so a process can be automatically shut down. A gas detector can also sound an

alarm to operators in the area where the leak is occurring, giving them the opportunity to leave

the area. This type of device is important because there are many gases that can be harmful to

organic life, such as humans or animals.

Gas detectors can be used to detect combustible, flammable and toxic gases, and oxygen

depletion. This type of device is used widely in industry and can found in a variety of locations

such as on oil rigs, to monitor manufacture processes and emerging technologies such as

photovoltaic. They may also be used in firefighting.

Gas detectors are usually battery operated. They transmit warnings via a series of audible and

visible signals such as alarms and flashing lights, when dangerous levels of gas vapors are

detected. As detectors measure a gas concentration, the sensor responds to a calibration gas,

which serves as the reference point or scale. As a sensor’s detection exceeds a preset alarm level,

the alarm or signal will be activated. As units, gas detectors are produced as portable or

stationary devices. Originally, detectors were produced to detect a single gas, but modern units

may detect several toxic or combustible gases, or even a combination of both types

Types

Gas detectors come in two main types: portable devices and fixed gas detectors. The first is used

to monitor the atmosphere around personnel and is worn on clothing or on a belt/harness. They

can also be classified according to the operation mechanism (semiconductors, oxidation,

catalytic, infrared, etc.).

Page 69: New Microsoft Office Word Document

Oxygen concentration

Oxygen deficiency gas monitors are used for employee and workforce safety. Cryogenics such as

liquid nitrogen (LN2), helium (He), and argon (Ar) are inert and can displace oxygen (O2) in a

confined space if a leak is present. A rapid decrease of oxygen can provide a very dangerous

environment for employees. With this in mind, an oxygen gas monitor is important to have when

cryogenics are present. Laboratories, MRI rooms, pharmaceutical, semiconductor, and cryogenic

suppliers are typical customers.

Oxygen fraction in a breathing gas is measured by electro-galvanic fuel cell sensors. They may

be used stand-alone, for example to determine the proportion of oxygen in a nitrox mixture used

in scuba diving,[2] or as part of feeback loop which maintains a constant partial pressure of

oxygen in a rebreather.[3]

Gas leak detection

Gas leak detection is the process of identifying potentially hazardous gas leaks by means of

various sensors. These sensors usually employ an audible alarm to alert people when a dangerous

gas has been detected. Common sensors used today include Infrared Point Sensors, Ultrasonic

Sensors, Electrochemical Sensors, and Semiconductor Sensors. These sensors are used for a

wide range of applications, and can be found in industrial plants, refineries, wastewater treatment

facilities, vehicles, and around the home.

History

Gas leak detection methods became a concern after the effects of harmful gases on human health

were discovered. Before modern electronic sensors, early detection methods relied on less

precise detectors. Through the 19th and early 20th centuries, coal miners would bring canaries

down to the tunnels with them as an early detection system against life threatening gases such as

carbon monoxide and methane. The canary, normally a very songful bird, would stop singing

and eventually die in the presence of these gases, signaling the miners to exit the mine quickly.

Before the development of electronic household carbon monoxide detectors in the 1980s and

90s, carbon monoxide presence was detected with a chemically infused paper that turned brown

Page 70: New Microsoft Office Word Document

when exposed to the gas. Since then, many technologies and devices have been developed to

detect, monitor, and alert the leakage of a wide array of gases.

Types of Gas Detectors

Electrochemical Detectors

Electrochemical gas detectors work by allowing gases to diffuse through a porous membrane to

an electrode where it is either oxidized or reduced. The amount of current produced is

determined by how much of the gas is oxidized at the electrode.[1] The sensor is then able to

determine the concentration of the gas. Manufactures can customize electrochemical gas

detectors by changing the porous barrier to allow for the detection of a certain gas concentration

range. Also, since the diffusion barrier is a physical/mechanical barrier, the detector tends to be

more stable and reliable over the sensor's duration and thus requires less maintenance than other

types of detectors. However, the sensors themselves are subject to corrosive elements and may

last only 1-2 years before a replacement is required.[2] Electrochemical gas detectors are used in a

wide variety of environments such as refineries, gas turbines, chemical plants, underground gas

storage facilities, and more.

Infrared Point Detectors

Infrared point sensors (IR) use radiation passing through a volume of gas to detect leaks. Energy

from the radiation is absorbed as it passes through the gas at certain wavelengths. The range of

wavelengths that is absorbed depends on the properties of the specific gas. Carbon monoxide

absorbs wavelengths of about 4.2-4.5 μm, for example.[3] This is approximately a factor of 10

larger than the wavelength of visible light, which ranges from .39 μm to .75 μm for most people.

The energy in this wavelength is compared to a wavelength outside of the absorption range; the

difference in energy between these two wavelengths is proportional to the concentration of gas

present.[4] This type of sensor is advantageous because it does not have to be placed in the gas

itself in order to detect it. Infrared point sensors can be used to detect hydrocarbons,[5]

compounds composed of hydrogen and carbon atoms, and other infrared active gases such as

water vapor and calcium fluoride. IR sensors are commonly found in wastewater treatment

facilities, refineries, gas turbines, chemical plants, and other facilities where flammable gases are

Page 71: New Microsoft Office Word Document

present and the possibility of an explosion exists. Engine emissions are another area where IR

sensors are being researched for use. The sensor would be able to detect high levels of carbon

dioxide in the vehicles’ exhaust, and even be integrated with the vehicles’ electronic systems to

notify drivers.[6]

Semiconductor Detectors

Semiconductor sensors detect gases by a chemical reaction that takes place when the gas comes

in contact with the sensor. Tin dioxide is the most common material used in semiconductor

sensors,[7] and the electrical resistance in the sensor is decreased when it comes in contact with

the monitored gas. The resistance of the tin dioxide is typically around 50 kΩ in air but can drop

to around 3.5 kΩ in the presence of 1% methane.[8] This change in resistance is used to calculate

the gas concentration. Semiconductor sensors are commonly used to detect hydrogen, oxygen,

alcohol, and harmful gases such as carbon monoxide.[9] One of the most common uses for

semiconductor sensors is in carbon monoxide sensors. They are also used in breathalyzers. [10]

Because the sensor must come in contact with the gas in order to detect it, semiconductor sensors

work in a smaller range than infrared point or ultrasonic detectors.

Ultrasonic Detectors

Ultrasonic gas detectors use acoustic sensors to detect changes in the background noise of its

environment. Since most gas leaks occur in the ultrasonic range of 25 kHz to 10 MHz, the

sensors are able to easily distinguish these frequencies from background noise which occurs in

the audible range of 20 Hz to 20 kHz.[11] The ultrasonic gas leak detector then produces an alarm

when there is an ultrasonic deviation from the normal condition of background noise. Despite the

fact that Ultrasonic gas leak detectors don’t measure gas concentration, the device is still able to

determine the leak rate of an escaping gas.[12] By measuring its ultrasonic sound level, the

detector is able to determine the leak rate, which depends on the gas pressure and size of the

leak. The bigger the leak, the larger its ultrasonic sound level will be. Ultrasonic gas detectors

are mainly used for outdoor environments where weather conditions can easily dissipate

escaping gas before allowing it to reach gas leak detectors that require contact with the gas in

order to detect it and sound an alarm. These detectors are commonly found on offshore and

Page 72: New Microsoft Office Word Document

onshore oil/gas platforms, gas compressor and metering stations, gas turbine power plants, and

other facilities that house a lot of outdoor pipeline.

Holographic Detectors

Holographic gas Sensor use light reflection to detect changes in a polymer film matrix containing

a hologram. Since holograms reflect light at certain wavelengths a change in their composition

can generate a colorful reflection indicative of the presence of a gas molecule [13]. Holographic

sensor require however illumination sources such as white light or lasers and an observer or

CCD detector.

Household Safety

There are many different sensors that can be purchased to detect hazardous gases around the

house. Carbon monoxide is a very dangerous gas that robs the lungs of oxygen, killing hundreds

of people worldwide each year. It is an odorless, colorless gas, making it impossible for humans

to detect it. Carbon monoxide detectors can be purchased for around $20-60. Handheld

flammable gas detectors can be used to trace leaks from natural gas lines, propane tanks, butane

tanks, or any other combustible gas

Alchol sensor

Page 73: New Microsoft Office Word Document
Page 74: New Microsoft Office Word Document
Page 75: New Microsoft Office Word Document

Blood alcohol content

Blood alcohol content, or BAC, (also called Blood alcohol content, blood alcohol

concentration, blood ethanol concentration, Blood Alcohol Level (BAL)) is most commonly

used as a metric of intoxication for legal or medical purposes. It is usually expressed as a

fractional percentage in terms of volume of alcohol per liter of blood in the body. That is

commonly expressed without units, or as a decimal with 2-3 significant digits followed by a

Page 76: New Microsoft Office Word Document

percentage sign, which means 1/100 of the previous number (e.g., 0.0008 expressed as a

percentage = 0.08%). Each country or state may define BAC differently. For example, the U.S.

state of California defines their BAC as a ratio of grams of alcohol per 100 milliliters of blood, [1]

which is equal to grams of alcohol per deciliter of blood.

Since measurement must be accurate and inexpensive, several measurement techniques are used

as proxies to approximate the true parts per million measure. Some of the most common are

listed here: (1) Mass of alcohol per volume of exhaled breath (e.g. 0.38 mg/L; see also breath gas

analysis), (2) Mass per volume of blood in the body (e.g.: 0.08 g/dL), and (3) Mass of alcohol

per mass of the body (e.g.: 0.0013 g/Kg).

The number of drinks consumed is often a poor measure of blood alcohol content, largely

because of variations in weight, sex and body fat.

An ethanol level of 0.10% is equal to 22 mmol/l or 100 mg/dl of blood alcohol.[2][3] This same

0.10% BAC also equates to 0.10 g/dL of blood alcohol or 0.10 g/210L of exhaled breath alcohol

or 0.476 mg/L of exhaled breath alcohol. Likewise, 0.10 mg/L of exhaled breath alcohol converts

to 0.02% BAC, 0.022 g/dL of blood alcohol or 0.022 g/210L of exhaled breath alcohol.

Progressive effects of alcohol[4]

BAC (% by vol.) Behavior Impairment

0.010–0.029 Average individual appears

normal

Subtle effects that can be

detected with special tests

0.030–0.059

Mild euphoria

Sense of well-being

Relaxation

Joyousness

Talkativeness

Decreased inhibition

Concentration

0.06–0.09 Blunted feelings Reasoning

Page 77: New Microsoft Office Word Document

Disinhibition

Extroversion

Depth perception

Peripheral vision

Glare recovery

0.10–0.19

Over-expression

Emotional swings

Angriness or sadness

Boisterousness

Super human feeling

Decreased libido

Reflexes

Reaction time

Gross motor control

Staggering

Slurred speech

0.20–0.29

Stupor

Loss of understanding

Impaired sensations

Severe motor impairment

Loss of consciousness

Memory

0.30–0.39

Severe CNS depression

Unconsciousness

Death is possible

Bladder function

Breathing

Heart rate

≥0.40

General lack of behavior

Unconsciousness

Death

Breathing

Heart rate

Standard drink chart (US)[5]

AlcoholAmount

(ml)

Amount

(fl oz)

Serving

size

Alcohol (% by

vol.)Alcohol

80 proof

liquor44 1.5 One shot 40

0.6 US fl oz

(18 ml)

Table wine 148 5 One glass 120.6 US fl oz

(18 ml)

Page 78: New Microsoft Office Word Document

Beer 355 12 One can 50.6 US fl oz

(18 ml)

Male

Female

Approximate blood alcohol percentage (by vol.)[6]

One drink has 0.5 US fl oz (15 ml) alcohol by volume

Drinks

Body weight

40 kg 45 kg 55 kg 64 kg 73 kg 82 kg 91 kg 100 kg 109 kg

90 lb 100 lb 120 lb 140 lb 160 lb 180 lb 200 lb 220 lb 240 lb

1–

0.05

0.04

0.05

0.03

0.04

0.03

0.03

0.02

0.03

0.02

0.03

0.02

0.02

0.02

0.02

0.02

0.02

2–

0.10

0.08

0.09

0.06

0.08

0.05

0.07

0.05

0.06

0.04

0.05

0.04

0.05

0.03

0.04

0.03

0.04

3–

0.15

0.11

0.14

0.09

0.11

0.08

0.10

0.07

0.09

0.06

0.08

0.06

0.07

0.05

0.06

0.05

0.06

4–

0.20

0.15

0.18

0.12

0.15

0.11

0.13

0.09

0.11

0.08

0.10

0.08

0.09

0.07

0.08

0.06

0.08

5–

0.25

0.19

0.23

0.16

0.19

0.13

0.16

0.12

0.14

0.11

0.13

0.09

0.11

0.09

0.10

0.08

0.09

6–

0.30

0.23

0.27

0.19

0.23

0.16

0.19

0.14

0.17

0.13

0.15

0.11

0.14

0.10

0.12

0.09

0.11

7–

0.35

0.26

0.32

0.22

0.27

0.19

0.23

0.16

0.20

0.15

0.18

0.13

0.16

0.12

0.14

0.11

0.13

8–

0.40

0.30

0.36

0.25

0.30

0.21

0.26

0.19

0.23

0.17

0.20

0.15

0.18

0.14

0.17

0.13

0.15

9 – 0.34 0.28 0.24 0.21 0.19 0.17 0.15 0.14

Page 79: New Microsoft Office Word Document

0.45 0.41 0.34 0.29 0.26 0.23 0.20 0.19 0.17

10–

0.51

0.38

0.45

0.31

0.38

0.27

0.32

0.23

0.28

0.21

0.25

0.19

0.23

0.17

0.21

0.16

0.19

Units of measurement

There are several different units in use around the world for defining blood alcohol

concentration. Each is defined as either a mass of alcohol per volume of blood or a mass of

alcohol per mass of blood (never a volume per volume). 1 milliliter of blood is approximately

equivalent to 1.06 grams of blood. Because of this, units by volume are similar but not identical

to units by mass. In the U.S. the concentration unit 1% w/v (percent weight/volume, equivalent

to 10g/l or 1g per 100ml) is in use[7]. This is not to be confused with the amount of alcohol

measured on the breath, as with a breathalyzer. The amount of alcohol measured on the breath is

generally accepted to be proportional to the amount of alcohol present in the blood at a rate of

1:2100. Therefore, a breathalyzer measurement of 0.10 mg/L of breath alcohol converts to 0.021

g/210L of breath alcohol, or 0.021 g/dL of blood alcohol (the units of the BAC in the United

States).

Unit Dimensions Equivalent to Used in

1 percent (%)

BAC by volume

1/100 g/mL =

1 cg/mL

9.43 mg/g,

217.4 mmol/L

United States, Australia, Canada,

Spain

1 permille (‰)

BAC by volume

1/1000 g/mL =

1 mg/mL

0.943 mg/g,

21.7 mmol/L

Netherlands, Lithuania, Latvia,

Poland, Switzerland, Austria,

Romania, Turkey

Page 80: New Microsoft Office Word Document

1 basis point

(‱) BAC by

volume

1/10,000 g/mL =

100 μg/mL

94.3 ppm,

2.17 mmol/LBritain

1 permille (‰)

BAC by mass1/1000 g/g = 1 mg/g

1.06 mg/mL,

23 mmol/L

Finland, Norway, Sweden, Denmark,

Germany

1 part per million

(ppm)

1/1,000,000 g/g = 1

μg/g

1.06 μg/mL,

23 μmol/L

Legal limits

For purposes of law enforcement, blood alcohol content is used to define intoxication and

provides a rough measure of impairment. Although the degree of impairment may vary among

individuals with the same blood alcohol content, it can be measured objectively and is therefore

legally useful and difficult to contest in court. Most countries disallow operation of motor

vehicles and heavy machinery above prescribed levels of blood alcohol content. Operation of

boats and aircraft are also regulated.

The alcohol level at which a person is considered to be legally impaired varies by country. The

list below gives limits by country. These are typically blood alcohol content limits for the

operation of a vehicle. In the United States, the legal limit can vary by state but (for all states as

of 2011) is 0.08 blood alcohol content as measured by a breath device, urinalysis or blood test.

This legal limit is down from 0.15 just a few decades previously

Test assumptions

Blood alcohol tests assume the individual being tested is average in various ways. For example,

on average the ratio of blood alcohol content to breath alcohol content (the partition ratio) is

2100 to 1. In other words, there are 2100 parts of alcohol in the blood for every part in the

breath. However, the actual ratio in any given individual can vary from 1300:1 to 3100:1, or

Page 81: New Microsoft Office Word Document

even more widely. This ratio varies not only from person to person, but within one person from

moment to moment. Thus a person with a true blood alcohol level of .08 but a partition ratio of

1700:1 at the time of testing would have a .10 reading on a Breathalyzer calibrated for the

average 2100:1 ratio.

A similar assumption is made in urinalysis. When urine is analyzed for alcohol, the assumption

is that there are 1.3 parts of alcohol in the urine for every 1 part in the blood, even though the

actual ratio can vary greatly.

Breath alcohol testing further assumes that the test is post-absorptive—that is, that the absorption

of alcohol in the subject's body is complete. If the subject is still actively absorbing alcohol, their

body has not reached a state of equilibrium where the concentration of alcohol is uniform

throughout the body. Most forensic alcohol experts reject test results during this period as the

amounts of alcohol in the breath will not accurately reflect a true concentration in the blood.

Blood alcohol content calculation

Blood alcohol content can be roughly estimated using a mathematical approach. Mathematical

estimations can be useful for calculating a blood alcohol content level that is not currently

testable, or a level that may be present in the future. While there are several ways to calculate it,

one of the most effective ways is to simply measure the total amount of alcohol consumed

divided by the total amount of water in the body—effectively giving the percent alcohol per

volume water in the blood.

Gender plays an important role in the total amount of water that a person has. In general, men

have a higher percent of water (58%) than women (49%). This fact alone strongly contributes to

the generalization that men require more alcohol than women to achieve the same blood alcohol

content level. Additionally, men are, on average, heavier than women. The more water a person

has, the more alcohol is required to achieve the same alcohol:blood ratio, or blood alcohol

content level. Further, studies have shown that women's alcohol metabolism varies from that of

men due to such biochemical factors as different levels of alcohol dehydrogenase (the enzyme

which breaks down alcohol) and the effects of oral contraceptives.[29]

Page 82: New Microsoft Office Word Document

It is not strictly accurate to say that the water content of a person alone is responsible for the

dissolution of alcohol within the body, because alcohol does dissolve in fatty tissue as well.

When it does, a certain amount of alcohol is temporarily taken out of the blood and briefly stored

in the fat. For this reason, most calculations of alcohol to body mass simply use the weight of the

individual, and not specifically his water content.

Cases of high blood alcohol levels

In November 2007, a driver was found passed out in her car in Oregon in the United States. A

blood test showed her blood alcohol level was 0.550%. She was charged with several offenses,

including two counts of driving under the influence of an intoxicant, reckless endangerment of a

person, criminal mischief and driving with a suspended license. Her bail was later set at USD

50,000 since she had several previous convictions for similar offenses.[30][31][32]

In December 2007, a driver was arrested in Klamath County, Oregon after she was found

unconscious in her car which was stuck in a snow bank with its engine running. Police were

forced to break a car window to remove her. After realizing she was in alcohol induced-coma,

they rushed her to the hospital where a blood test showed her blood alcohol level was 0.720%.

She reportedly was released from the hospital the next day. [30][33] She was subsequently charged

with drunk driving.[34]

In July 2008, a driver was arrested after he ran into a highway message board on Interstate 95 in

Providence, Rhode Island. A breath test showed his blood alcohol level was at 0.491% and he

was raced to the hospital where he was sedated and placed in a detoxification unit. He was

subsequently charged with driving while intoxicated and resisting arrest.[35][36] He was later

sentenced to one year probation, a $500 fine, 40 hours of community service and a one-year loss

of his driver's license. The police later stated that his blood alcohol level was the highest they had

ever seen for someone who hadn't died of alcohol poisoning.[37] It was later estimated that the

driver had consumed 10-14 drinks over the course of 1–2 hours.,[30] based on the standard levels

of elimination which as documented previously can vary by up to 300%.

In December 2009, a South Dakota woman was found behind the wheel of a stolen car with a

measured blood alcohol content of .708%, almost nine times the state's limit of .08%, thus

Page 83: New Microsoft Office Word Document

becoming the highest recorded level of alcohol toxicity for the state. After she was hospitalized,

she was released on bond and subsequently found in another stolen automobile while under the

influence

INTRODUCTION TO KEIL COMPILER

When the Keil μVision is used, the project development cycle is roughly the same as it is for any

other software development project.

Create source file in C or assembly

Build application with the project manager

Correct errors in source file

Test the linked application

μ VISION IDE

The μvision IDE combines project managements, a rich featured editor with interactive error

correction, option setup make facility, and online help. Use μvision to create source files and

organize them into a project that defines your target application.μ vision automatically compiles,

assembles and links your embedded application and provides a single focal point for your

development efforts.

Power Supply

The ac voltage, typically 220V, is connected to a transformer, which steps down that ac voltage

down to the level of the desired dc output. A diode rectifier then provides a full-wave rectified

voltage that is initially filtered by a simple capacitor filter to produce a dc voltage. This resulting

dc voltage usually has some ripple or ac voltage variation.

Page 84: New Microsoft Office Word Document

A regulator circuit removes the ripples and also retains the same dc value even if the input dc

voltage varies, or the load connected to the output dc voltage changes. This voltage regulation is

usually obtained using one of the popular voltage regulator IC units.

Fig. Block Diagram of Power Supply

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. Most power

supplies use a step-down transformer to reduce the dangerously high mains voltage (230V in

India) to a safer low voltage. 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. 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 transformer will step down the power supply voltage (0-

230V) to (0- 6V) level. Then the secondary of the potential transformer will be connected to the

bridge rectifier, which is constructed with the help of PN junction diodes. The advantages of

using bridge rectifier are it will give peak voltage output as DC.

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. A full-wave rectifier can

also be made from just two diodes if a centre-tap transformer is used, but this method is rarely

used now that diodes are cheaper. A single diode can be used as a rectifier but it only uses the

positive (+) parts of the AC wave to produce half-wave varying DC

Page 85: New Microsoft Office Word Document

Single Diode Rectifier

A single diode can be used as a rectifier but this produces half-wave varying DC which has gaps

when the AC is negative. It is hard to smooth this sufficiently well to supply electronic circuits

unless they require a very small current so the smoothing capacitor does not significantly

discharge during the gaps

FIG: rectifying circuit

Page 86: New Microsoft Office Word Document

FIG: wave diagram

Bridge Rectifier

When four diodes are connected as shown in figure, the circuit is called as bridge rectifier. The

input to the circuit is applied to the diagonally opposite corners of the network, and the output is

taken from the remaining two corners. Let us assume that the transformer is working properly

and there is a positive potential, at point A and a negative potential at point B. the positive

potential at point A will forward bias D3 and reverse bias D4. The negative potential at point B

will forward bias D1 and reverse D2. At this time D3 and D1 are forward biased and will allow

current flow to pass through them; D4 and D2 are reverse biased and will block current flow.

One advantage of a bridge rectifier over a conventional full-wave rectifier is that with a given

transformer the bridge rectifier produces a voltage output that is nearly twice that of the

conventional full-wave circuit. Assume that the same transformer is used in both circuits. The

peak voltage developed between points X and y is 1000 volts in both circuits. In the conventional

full-wave circuit, the peak voltage from the center tap to either X or Y is 500 volts. Since only

one diode can conduct at any instant, the maximum voltage that can be rectified at any instant is

500 volts. The maximum voltage that appears across the load resistor is nearly-but never

exceeds-500 v0lts, as result of the small voltage drop across the diode. In the bridge rectifier

shown in view B, the maximum voltage that can be rectified is the full secondary voltage, which

is 1000 volts. Therefore, the peak output voltage across the load resistor is nearly 1000 volts.

With both circuits using the same transformer, the bridge rectifier circuit produces a higher

output voltage than the conventional full-wave rectifier circuit.

Page 87: New Microsoft Office Word Document

FIG: Bridge Rectifier

FIG: Wave Diagram

Smoothing

Smoothing 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 unsmoothed varying DC (dotted line) and the

smoothed DC (solid line). The capacitor charges quickly near the peak of the varying DC, and

then discharges as it supplies current to the output. Note that smoothing significantly increases

the average DC voltage to almost the peak value (1.4 × RMS value). For example 6V RMS AC

is rectified to full wave DC of about 4.6V RMS (1.4V is lost in the bridge rectifier), with

smoothing this increases to almost the peak value giving 1.4 × 4.6 = 6.4V smooth DC.

Page 88: New Microsoft Office Word Document

Fig: Smoothing Wave Form

Smoothing is not perfect due to the capacitor voltage falls a little as it discharges, giving a small

ripple voltage. For many circuits a ripple which is 10% of the supply voltage is satisfactory. A

larger capacitor will give fewer ripples. The capacitor value must be doubled when smoothing

half-wave DC.

Voltage Regulators

Voltage regulators comprise a class of widely used ICs. Regulator IC units contain the circuitry

for reference source, comparator amplifier, control device, and overload protection all in a single

IC. IC units provide regulation of either a fixed positive voltage, a fixed negative voltage, or an

adjustably set voltage. The regulators can be selected for operation with load currents from

hundreds of milli amperes to tens of amperes, corresponding to power ratings from milli watts to

tens of watts. A fixed three-terminal voltage regulator has an unregulated dc input voltage, Vi,

applied to one input terminal, a regulated dc output voltage, Vo, from a second terminal, with the

third terminal connected to ground. The series 78 regulators provide fixed positive regulated

voltages from 5 to 24 volts. Similarly, the series 79 regulators provide fixed negative regulated

voltages from 5 to 24 volts.

Page 89: New Microsoft Office Word Document

IC Voltage Regulators

Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output

voltages. They are also rated by the maximum current they can pass. Negative voltage regulators

are available, mainly for use in dual supplies. Most regulators include some automatic protection

from excessive current ('overload protection') and overheating ('thermal protection'). Many of the

fixed voltage regulator ICs has 3 leads and look like power transistors, such as the 7805 +5V

1Amp regulator. They include a hole for attaching a heat sink if necessary.

Fig. IC Voltage Regulator

Zener Diode Regulator

For low current power supplies a simple voltage regulator can be made with a resistor and a

zener diode connected in reverse as shown in the diagram. Zener diodes are rated by their

breakdown voltage and maximum power (typically 400mW or 1.3W). The resistor limits the

current (like an LED resistor). The current through the resistor is constant, so when there are no

output current all the current flows through the zener diode and its power rating must be large

enough to withstand this.

Page 90: New Microsoft Office Word Document

Fig: Zener Diode Regulator

Fig. Circuit diagram of Power Supply

Virtually every piece of electronic equipment, e.g., computers and their peripherals, calculators,

TV and hi-fi equipment, and instruments, is powered from a DC power source, be it a battery or

a DC power supply. Most of this equipment requires not only DC voltage but voltage that is also

well filtered and regulated. Since power supplies are so widely used in electronic equipment,

these devices now comprise a worldwide segment of the electronics market in excess of $5

billion annually.

Page 91: New Microsoft Office Word Document

There are three types of electronic power conversion devices in use today which are classified as

follows according to their input and output voltages:

1) DC/DC converter;

2) The AC/DC power supply;

3) The DC/AC inverter.

Each has its own area of use but this paper will only deal with the first two, which are the most

commonly used. A power supply converting AC line voltage to DC power must perform the

following functions at high efficiency and at low cost:

1. Rectification: Convert the incoming AC line voltage to DC voltage.

2. Voltage transformation: Supply the correct DC voltage level(s).

3. Filtering: Smooth the ripple of the rectified voltage.

4. Regulation: Control the output voltage level to a constant value irrespective of line, load and

temperature changes.

5. Isolation: Separate electrically the output from the input voltage source.

6. Protection: Prevent damaging voltage surges from reaching the output; provide back-up power

or shutdown during a brown-out.

An ideal power supply would be characterized by supplying a smooth and constant output

voltage regardless of variations in the voltage, load current or ambient temperature at 100%

conversion efficiency. Figure 1 compares a real power supply to this ideal one and further

illustrates some power supply terms.

Page 92: New Microsoft Office Word Document

Linear Power Supplies

Two common linear power supply circuits in current are used. Both circuits employ full-wave

rectification to reduce ripple voltage to capacitor C1. The bridge rectifier circuit has a simple

transformer but current must flow through two diodes. The center-tapped configuration is

preferred for low output voltages since there is just one diode voltage drop. For 5V and 12V

outputs, Schottky barrier diodes are commonly used since they have lower voltage drops than

equivalently rated ultra-fast types, which further increase power conversion efficiency. However,

each diode must withstand twice the reverse voltage that a diode sees in a full-wave bridge for

the same input voltage. The linear voltage regulator behaves as a variable resistance between the

input and the output as it provides the precise output voltage. One of the limitations to the

efficiency of this circuit is due to the fact that the linear device must drop the difference in

voltage between the input and output. Consequently the power dissipated by the linear device is

(Vi–Vo) x Io. While these supplies have many desirable characteristics, such as simplicity, low

output ripple, excellent line and load regulation, fast response time to load or line changes and

low EMI, they suffer from low efficiency and occupy large volumes. Switching power supplies

are becoming popular because they offer better solutions to these problems.

C51 COMPILER AND A51 MACRO ASSEMBLER

Page 93: New Microsoft Office Word Document

Source file created by μ vision IDE and passed to the C51 compiler macro assembler. The

compiler and assembler process source files and create relocatable object files. The keil C51

compiler is a full ANSI implementation of the C programming language that supports all

standard features of the C language.

CHAPTER 5

SYSTEM IMPLEMENTATION

5.1 PCB LAYOUT

Page 94: New Microsoft Office Word Document

5.1.1 Main Board

Page 95: New Microsoft Office Word Document

Fig. 5.1 MAIN BOARD PCB

5.2 PCB DESIGN

PCB design starts right from the selection of the laminates .The two main types of base

laminate are epoxy glass and phenolic paper laminates are generally used for simple circuits.

Though it is very cheap and can easily be drilled, phenolic paper has poor electrical

characteristics and it absorbs more moisture than epoxy glass. Epoxy glass has higher

mechanical strength.

Page 96: New Microsoft Office Word Document

The important properties that have to be considered for selecting the PCB substrate are

the dielectric strength, insulation resistance, water absorption property, coefficient of thermal

expansion, shear strength, hardness, dimensional stability etc.

5.2.1 PCB Fabrication

The fabrication of a PCB includes four steps.

a) Preparing the PCB pattern.

b) Transferring the pattern onto the PCB.

c) Developing the PCB.

d) Finishing (i.e.) drilling, cutting, smoothing, turning etc.

Pattern designing is the primary step in fabricating a PCB. In this step, all interconnection

between the components in the given circuit are converted into PCB tracks. Several factors such

as positioning the diameter of holes, the area that each component would occupy, the type of end

terminal should be considered.

5.2.2 Transferring the PCB Pattern

The copper side of the PCB should be thoroughly cleaned with the help of alcoholic spirit or

petrol. It must be completely free from dust and other contaminants.

The mirror image of the pattern must be carbon copied and to the laminate the complete

pattern may now be made each resistant with the help of paint and thin brush.

5.2.3 Developing

Page 97: New Microsoft Office Word Document

In this developing all excessive copper is removed from the board and only the

printed pattern is left behind. About 100ml of tap water should be heated to 75 ° C and 30.5

grams of FeCl3 added to it, the mixture should be thoroughly stirred and a few drops of HCl may

be added to speed up the process.

The board with its copper side facing upward should be placed in a flat bottomed plastic

tray and the aqueous solution of FeCl2 poured in the etching process would take 40 to 60 min to

complete.

After etching the board it should be washed under running water and then

held against light .the printed pattern should be clearly visible. The paint should be removed with

the help of thinner.

Page 98: New Microsoft Office Word Document

5.2.4 Finishing Touches

After the etching is completed, hole of suitable diameter should be drilled, then the PCB

may be tin plated using an ordinary 35 Watts soldering rod along with the solder core, the copper

side may be given a coat of varnish to prevent oxidation.

5.2.5 Drilling

Drills for PCB use usually come with either a set of collects of various sizes or a 3-Jaw

chuck. For accuracy however 3-jaw chunks aren’t brilliant and small drill below 1 mm from

grooves in the jaws preventing good grips.

5.2.6 Soldering

Begin the construction by soldering the resistors followed by the capacitors and the LEDs

diodes and IC sockets. Don’t try soldering an IC directly unless trust in our skill in soldering.

All components should be soldered as shown in the figure. Now connect the switch and then

solder/screw if on the PCB using multiple washers or spaces. Soldering it directly will only

reduce its height above other components and hamper in its easy fixation in the cabinet. Now

connect the battery lead.

5.2.7 Assembling

Page 99: New Microsoft Office Word Document

The circuit can be enclosed in any kind of cabinet. Before fitting the PCB suitable holes

must be drilled in the cabinet for the switch, LED and buzzer. Note that a rotary switch can be

used instead of a slide type.

Switch on the circuit to be desired range. It will automatically start its timing cycles. To

be sure that it is working properly watch the LED flash. The components are selected to trigger

the alarm a few minutes before the set limit.

Page 100: New Microsoft Office Word Document

CHAPTER 6

SOFTWARE DESCRIPTION

Page 101: New Microsoft Office Word Document
Page 102: New Microsoft Office Word Document

Fig. 6.1 FLOW CHART

Page 103: New Microsoft Office Word Document

CHAPTER 7

APPLICATIONS AND ADVANTAGES

7.1 APPLICATIONS

In auto mobile off all kind

7.2 ADVANTAGES

i. Circuit is very simple.

ii. Components used are economical.

iii. Compact, Power Efficient.

iv. No Manual Interpretation Required.

v. Accuracy Is Very High.

vi. Can Be Used In All Kinds Of Environment.

Page 104: New Microsoft Office Word Document

CHAPTER 8

FUTURE ENHANCEMENTS

Distance sensing and position logging & transmission

Control area based based control

Automatic breaking system

Fuel cutoff

Information sending via gprs

CONCLUSION

The project has been accomplished with the help of KEIL C compiler and philips

programmer. The project has been tested successfully and has been approved by the concerned

project guides.

Page 105: New Microsoft Office Word Document

BIBLIOGRAPHY

REFERENCE BOOKS

[1] Muhammad Ali Mazidi –“THE 8051 MICROCONTROLLER AND EMBEDDED

SYSTEMS”, Pearson education,

[2] Ayala- “INTRODUCTION TO 8051 MICROCONTROLLER”

Page 106: New Microsoft Office Word Document

SOFTWARES

[1] Keil C51 compiler user guide (Keil Software V3.60)

WEB LINKS

[1] www.8052.com

[2] www.google.com

[3] www.robotroom.com

[4] www.roboticsindia.com

[5] www.wekipedia.org

[6] www.keil.com

[7] www.datasheetarchive.com

[8] www.atmel.com

[9] www.8051projects.info

[10] www.8051projects.net

[11] www.rentron.com