Anda di halaman 1dari 38


Embedded system
An Embedded System is a combination of computer hardware and software, and perhaps additional mechanical part designed to perform a specific function. An embedded system is a microcontroller-based, software driven, reliable, real-time control system, autonomous, or human or network interactive, operating on diverse physical variables and in diverse environments and sold into a competitive and cost conscious market. An embedded system is not a computer system that is used primarily for processing, not a software system on PC or UNIX, not a traditional business or scientific application. High-end embedded & lower end embedded systems. High-end embedded system - Generally 32, 64 Bit Controllers used with OS. Examples Personal Digital Assistant and Mobile phones etc .Lower end embedded systems - Generally 8,16 Bit Controllers used with an minimal operating systems and hardware layout designed for the specific purpose. Examples Small controllers and devices in our everyday life like Washing Machine, Microwave Ovens, where they are embedded in.


Fig:1.1 System Design Calls


Fig:1.2 V Diagram

Characteristics of Embedded System

An embedded system is any computer system hidden inside a product other than a computer. Throughput Our system may need to handle a lot of data in a short period of time. ResponseOur system may need to react to events quickly. TestabilitySetting up equipment to test embedded software can be difficult. DebugabilityWithout a screen or a keyboard, finding out what the software is doing Reliability embedded systems must be able to handle any situation without human intervention. Memory space Memory is limited on embedded systems, and you must make the software and the data fit into whatever memory exists.

Program installation you will need special tools to get your software into embedded systems. Power consumption Portable systems must run on battery power, and the software in these systems must conserve power. Embedded systems have a microprocessor/ microcontroller and a memory.

Some have a serial port or a network connection. They usually do not have keyboards, screens or disk drives.

Military and aerospace embedded software applications
1) Communication Applications 2) Industrial automation and process control software

3) Mastering the complexity of applications. 4) Reduction of product design time. 5) Real time processing of ever increasing amounts of data. 6) Intelligent, autonomous sensors


Fig 2.1:block diagram



Block diagram:
The ac voltage, typically 220V rms, is connected to a transformer, which steps 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. A regulator circuit removes the ripples and also remains 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 3.1 Block diagram (Power supply)


WORKING PRINCIPLE 3.1.1 Transformer

Introduction Transformers convert AC electricity from one voltage to another with a little loss of power. Step-up transformers increase voltage, step-down transformers reduce voltage. Most power supplies use a step-down transformer to reduce the dangerously high voltage to a safer low voltage.

Fig.3.1.1: A Typical Transformer The input coil is called the primary and the output coil is called the secondary. There is no electrical connection between the two coils; instead they are linked by an alternating magnetic field created in the soft-iron core of the transformer. The two lines in the middle of the circuit symbol represent the core. The ratio of the number of turns on each coil, called the turns ratio, determines the ratio of the voltages. A step-down transformer has a large number of turns on its primary (input) coil which is connected to the high voltage mains supply, and a small number of turns on its secondary (output) coil to give a low output voltage The ratio of the number of turns on each coil, called the turns ratio, TURNS RATIO = (Vp / Vs) = ( Np / Ns ) Where,

Vp = primary (input) voltage. Vs = secondary (output) voltage Np = number of turns on primary coil Ns = number of turns on secondary coil Ip = primary (input) current Is = secondary (output) current.

3.1.2 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. The path for current flow is from point B through D1, up through RL, through D3, through the secondary of the transformer back to point B. this path is indicated by the solid arrows. Waveforms (1) and (2) can be observed across D1 and D3. One-half cycle later the polarity across the secondary of the transformer reverse, forward biasing D2 and D4 and reverse biasing D1 and D3. Current flow will now be from point A through D4, up through RL, through D2, through the secondary of T1, and back to point A. This path is indicated by the broken arrows. Waveforms (3) and (4) can be observed across D2 and D4. The current flow through RL is always in the same direction. In flowing through RL this current develops a voltage corresponding to that shown waveform (5). Since current flows through the load (RL) during both half cycles of the applied voltage, this bridge rectifier is a full-wave rectifier.

3.1.3 IC voltage regulators

Voltage regulators comprise a class of widely used ICs. Regulator IC units contain the circuitry for reference source, comparator amplifier, control device, and overload protection all in a single IC. 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.

Fig 3.1.3: Circuit diagram (Power supply). 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.

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. For ICs, microcontroller, LCD --------- 5 volts For alarm circuit, op-amp, relay circuits ---------- 12 volts


Microcontroller is a general purpose device, which integrates a number of the components of a microprocessor system on to single chip. It has inbuilt CPU, memory and peripherals to make it as a mini computer. A microcontroller combines on to the same microchip: The CPU core Memory(both ROM and RAM) Some parallel digital i/o

Microcontrollers will combine other devices such as: A timer module to allow the microcontroller to perform tasks for certain time periods. as a PIC or another microcontroller. An ADC to allow the microcontroller to accept analogue input data for processing. Microcontrollers are: Smaller in size Consumes less power

Inexpensive Micro controller is a stand alone unit, which can perform functions on its own

without any requirement for additional hardware like I/O ports and external memory. The heart of the microcontroller is the CPU core. In the past, this has traditionally been based on a 8-bit microprocessor unit. For example Motorola uses a basic 6800 microprocessor core in their 6805/6808 microcontroller devices. In the recent years, microcontrollers have been developed around specifically designed CPU cores, for example the microchip PIC range of microcontrollers. AT89C51 is the 40 pins, 8 bit Microcontroller manufactured by Atmel group. It is the flash type reprogrammable memory. Advantage of this flash memory is we can erase the program with in few minutes. It has 4kb on chip ROM and 128 bytes internal RAM and 32 I/O pin as arranged as port 0 to port 3 each has 8 bit bin .Port 0 contain 8 data line(D0-D7) as well as low order address line(AO-A7). Port 2 contain higher order address line (A8-A15). Port 3 contains special purpose register such as serial input receiver register SBUF, interrupt INT0,INT1 and timers T0 , T1 many of the pins have multi functions which can be used as general purpose I/O pins (or) Special purpose function can be decided by the programmer itself.

4K Bytes of In-System Reprogrammable Flash Memory

Endurance: 1,000 Write/Erase Cycles Fully Static Operation: 0 Hz to 24 MHz Three-Level Program Memory Lock 128 x 8-Bit Internal RAM

Two 16-Bit Timer/Counters Six Interrupt Sources

Programmable Serial Channel

Low Power Idle and Power Down Modes

The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with 4K bytes of Flash Programmable and Erasable Read Only Memory (PEROM). The device is manufactured using Atmel is high density nonvolatile memory technology and is compatible with the industry standard MCS-51 instruction set and pinout. The on-chip Flash allows the program memory to be reprogrammed in-system or by a conventional nonvolatile memory programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a highly flexible and cost effective solution to many embedded control applications


The 8051 consists of : Eight-bit CPU with registers A (the accumulator) and B Program counter (PC) Data pointer (DPTR) Flags and the Program Status Word (PSW) Eight-bit stack pointer (SP) Internal ROM or EPROM or FLASH ROM Internal RAM of 256bytes(128bytes general purpose): Four register banks, each containing eight registers Two 16-bit timer / counter: T0 and T1 Full duplex serial data receiver/transmitter; SBUF Interrupts Oscillator and clock circuit


FIG.3.2.2 Pin Diagram of 8051(AT 89C51)


The DPTR register is made up of two 8-bit registers, named DPH and DPL, which are used to furnish memory addresses for internal and external code access and external data access. The DPTR is under the control of program instructions name, DPH

and DPL. DPTR does not have a single internal address; DPH and DPL are each assigned an address. The Data Pointer (DPTR) is the 8051s only user-accessible 16-bit (2-byte) register. DPTR, as the name suggests, is used to point to address something like HL register pair in 8085 microprocessor. It is used by a number of commands that allow the 8051 to access external memory and internal memory. While DPTR is most often used to point to data in external memory, many programmers often take advantage of the fact that its the only true 16-bit register available. It is often used to store 2-byte values that have nothing to do with memory locations.


Flags are 1-bit registers provided to store the results of certain program instructions. Other instructions can test the condition of the flags and make decisions based on the flag states. In order that the flags may be conveniently addressed, they are grouped inside the program status word (PSW) and the power control (PCON) registers. The 8051 have four math flags that respond automatically to the outcomes of math operations and three general-purpose user flags that can be set to 1 or cleared to 0 by the programmer as desired. The math flags include Carry (CY), Auxiliary Carry (AC), Overflow (OV), and Parity (P). Register bank selection may be done by the use of RS0 and RS1 Note that all of the flags can be set and cleared by the programmer at will. The math flags, however, are also affected by math operations.



Carry flag Auxiliary carry flag Flag 0 (User Flag) Register bank selector bit1 Register bank selector bit0 Overflow flag Reserved for future use Parity flag

Table 3.2.4 (a)Program Status Word

RS1 0 0 1 1

RS0 0 1 0 1

Register Bank 0 1 2 3

Address 00H-07H 08H-0FH 10H-17H 18H-1FH .

Table.3.2.4 (b) Register Banks


A functioning computer must have memory for program codes, commonly in ROM, and RAM memory for variable data that can be altered as the program runs.The 8051 has internal RAM and ROM memory for these functions.Additional memory can be added externally using suitable circuits. Unlike Microcontrollers with Von Neumann architectures, which can use a single memory address for either program code or data, but not for both, the 8051 has a Harvard architecture, which uses the same address, in different memories, for code and data. Internal circuitry accesses the correct memory based on the nature of the operation in progress. Harvard architecture uses separate buses to fetch the data and the address


The 8051 is organized so that data memory and program code memory can be in two entirely different physical memory entities. Each has the same address range. The structure of the internal RAM will be discussed later. Generally 8051 microcontroller is available with 4Kilo Bytes internal ROM. A corresponding block of internal program code, contained in an internal ROM, occupies code address space 000h to FFFh. The Program Counter is ordinarily used to address program code bytes from address 0000h to FFFFh. Program addresses higher than 0FFFh, which exceed the internal ROM capacity, will cause the 8051 to automatically fetch code bytes from external program memory. Code bytes can also be fetched exclusively from an external memory, address 0000h to FFFFh, by connecting the external access pin (EA pin no 31 on the DIP) to ground. The PC does not care where the code is, the circuit designer decides whether the code is found totally in internal ROM, totally in external ROM, or in a combination of internal and external ROM. Each register bank address are Bank 0 00h-07h Bank 1 08h-0fh Bank 2 10h-17h

Bank 3 18h-1fh 8051 microcontroller has 16-bit address bus and 8 bit data bus, with 16-bit

address bus we can address maximum of 64Kilobytes of external memory that is from 0000h to FFFF. 8051 is available with 4kilobytes of internal ROM its derivatives 8751,8951are available with EPROM, FLASH ROM respectively with 4kilobytes capacity.


As mentioned at the beginning of this chapter, the 8051 includes a certain amount of on-chip memory. On-chip memory is really one of two types: Internal RAM and Special Function Register (SFR) memory. The layout of the 8051's internal RAM is presented. As is illustrated in this map, the 8051 has a bank of 128 bytes of Internal RAM. This Internal RAM is found on-chip on the 8051 so it is the fastest RAM available, and it is also the most flexible in terms of reading, writing, and modifying its contents. Internal RAM is volatile, so when the 8051 is switched off this memory is cleared. The 128 bytes of internal ram is subdivided as shown on the memory map. The first 8 bytes (00h - 07h) are "register bank 0". By manipulating certain SFRs, a program may choose to use register banks 1, 2, or 3. These alternative register banks are located in internal RAM in addresses 08h through 1Fh. So the registers are part of internal RAM. Bit Memory also lives and is part of internal RAM. Bit memory actually resides in internal RAM, from addresses 20h through 2Fh. It can be bit addressed from 00h to 7fh (totally 128 bits) The 80 bytes remaining of Internal RAM, from addresses 30h through 7Fh, may be used by user variables that need to be accessed frequently or at high-speed. This area is also utilized by the microcontroller as a storage area for the operating stack.


The 80 bytes remaining of Internal RAM, from addresses 30h through 7Fh,
0 7 =

may be used by user variables that need to be accessed frequently or at high-speed. This area is also utilized by the microcontroller as a storage area for the operating stack. This fact severely limits the 8051s stack since, as illustrated in the memory map, the area reserved for the stack is only 80 bytes and usually it is less since these 80 bytes has to be shared between the stack and user variables.


The 8051 use 8 "R" registers, which are used in many of its instructions. These "R" registers are numbered from 0 through 7 (R0, R1, R2, R3, R4, R5, R6, and R7). These registers are generally used to assist in manipulating values and moving data from one memory location to another. For example, to add the value of R4 to the Accumulator, we would execute the following instruction:

Thus if the Accumulator (A) contained the value 3 and R4 contained the value 3, the Accumulator would contain the value 6 after this instruction was executed. However, as the memory map shows, the "R" Register R4 is really part of Internal RAM. Specifically, R4 is address 04h. Thus the above instruction accomplishes the same thing as the following operation:

ADD A, 04h
This instruction adds the value found in Internal RAM address 04h to the value of the Accumulator, leaving the result in the Accumulator. Since R4 is really Internal RAM 04h, the above instruction effectively accomplished the same thing. But watch out! As the memory map shows, the 8051 has four distinct register banks. When the 8051 is first booted up, register bank 0 (addresses 00h through 07h) is used by default. However, your program may instruct the 8051 to use one of the

alternate register banks; i.e., register banks 1, 2, or 3. In this case, R4 will no longer be the same as Internal RAM address 04h. For example, if your program instructs the 8051 to use register bank 3, "R" register R4 will now be synonymous with Internal RAM address 1Ch. The concept of register banks adds a great level of flexibility to the 8051, especially when dealing with interrupts (we'll talk about interrupts later). However, always remember that the register banks really reside in the first 32 bytes of Internal RAM. Register banks can be selected with the help of RS0, RS1 bits in the program status word (PSW).


All four ports in the 8051 are bi-directional each contains a latch, an output driver and input buffer. The output drivers of port0 and 2, and the input buffers of port 0 are used in access to external memory. In this application port 0 is used as a lower byte of the external memory address multiplexed with data bus and port 2 is used as a higher byte of the external memory address when address is sixteen bit wide. Otherwise it can be used as general purpose I/O P0 (Port 0, SFR Address 80h, Bit-Addressable): This is input/output port 0. Each bit of this SFR corresponds to one of the pins on the microcontroller. For example, bit 0 of port 0 is pin P0.0 i.e. pin number 39 in microcontroller bit 7 is pin P0.7 i.e., pin number 32 in the IC. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to a low level. While the 8051 has four I/O port (P0, P1, P2, and P3), if your hardware uses external RAM or external code memory (i.e., your program is stored in an external ROM or EPROM chip or if you are using external RAM chips) or if your hardware consists of any peripheral interface like ADC or DAC, you may not use P0 and P2). This is because the 8051 use ports P0 and P2 to address the external memory. Thus if you are

using external RAM or code memory or peripheral interface you may only use ports P1 and P3 for your own use. P1 (Port 1, Address 90h, Bit-Addressable): This is input/output port 1. Each bit of this SFR corresponds to one of the pins on the microcontroller. For

example, bit 0 of port 1 is pin P1.0 i.e., pin number 1 bit 7 is pin P1.7 i.e., pin number 8. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to a low level. P2 (Port 2, Address A0h, Bit-Addressable): This is input/output port 2. Each bit of this SFR corresponds to one of the pins on the Microcontroller. For example, bit 0 of port 2 is pin P2.0 i.e., pin number 21, bit 7 is pin P2.7 i.e., pin number 28. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will being it to a low level While the 8051 has four I/O port (P0, P1, P2 and P3), if your hardware uses external RAM or external code memory (i.e., your program is stored in an external ROM or EPROM chip or if you are using external RAM chips) you may not use P0 or P2. This is because the 8051 uses ports P0 and P2 to address the external memory. Thus if you are using external RAM or code memory you may only use ports P1 and P3 for your own use. P3 (Port 3, Address B0h, Bit Addressable): This is input/output port 3. Each bit of this SFR corresponds to one of the pins on the microcontroller. For example, bit 0 of port 3 is pin P3.0 i.e., pin number 10, bit 7 is pin P3.7 i.e., pin number 17. Writing a value of 1 to a bit of this SFR will send a high level on the corresponding I/O pin whereas a value of 0 will bring it to a low level. While the 8051 has four I/O port (P0, P1, P2 and P3), if your hardware uses external RAM or external code memory (i.e., your program is stored in an external ROM or EPROM chip or if you are using external RAM chips) you may not use P0 or P2 and p3.6, p3.7. This is because the 8051 uses ports P0 and P2 to address the external memory and P3.6 and P3.7 for write and read operations. Thus if you are using external RAM or code memory you may only use ports P1 and P3 for your own use.

Port 3 can also used for timer/counter, interrupts, serial ports also. P3.0 is also used for serial data reception, P3.1 is for serial data transmission, P3.2 & P3.3 is for external interrupts P3.4 & P3.5 is for timer0 and timer1 respectively. P3.6&P3.7 for write and read operations respectively.


Many microcontroller applications require the counting of external events, such as the frequency of a pulse train, or the generation or precise internal time delays between computer actions. Both of these tasks can be accomplished using software techniques, but software loops for counting or timing keep the processor occupied so that other, perhaps more important, functions are not done. To relieve the processor of this burden, two 16bit up counters, named T0 and T1, are provided for the general use of the programmer. Each counter may be programmed to count internal clock pulses, acting as a timer, or programmed to count external pulses as a counter. The counters are divided into two-8 bit registers called the timer low (TL0, TL1) and high (TH0, TH1) bytes. All counter action is controlled by bit states in the timer mode control register (TMOD), the timer/counter control register (TCON), and certain program instructions.


Computers must be able to communicate with other computers in modern multiprocessor distributed systems. One cost-effective way to communication is to send and receive data bits serially. The 8051 has a serial data communication circuit that uses register SBUF to hold data. Register SCON controls data communication, register PCON controls data rates, and pins RXD (P3.0) and TXD (P3.1) connect to the serial data network. SBUF is physically two registers. One is write only and is used to hold data to be transmitted out of the 8051 via TXD. The other is read only and holds received data from external sources via RXD. Both mutually exclusive registers use address

99h.There are four programmable modes for serial data communication that are chosen by setting the SMX bits in SCON. Baud rates are determined by the mode chose. We will discuss about serial port later.

An interrupt is a special feature, which allows the 8051 to provide the illusion of "multi-tasking," although in reality the 8051 is only doing one thing at a time. The word "interrupt" can often be substituted with the word "event." An interrupt is triggered whenever a corresponding event occurs. When the event occurs, the 8051 temporarily puts "on hold" the normal execution of the program and executes a special section of code referred to as an interrupt handler. The interrupt handler performs whatever special functions are required to handle the event and then returns control to the 8051 at which point program execution continues as if it had never been interrupted. The topic of interrupts is somewhat tricky and very important. For that reason, an entire chapter will be dedicated to the topic. For now, suffice it to say that Interrupts can cause program flow to change.Software techniques use up processor time that could be devoted to other tasks Five interrupts are provided in the 8051. Three of these are generated automatically by internal operations: Timer flag 0, Timer flag 1, and the serial port interrupt (RI or TI). Two interrupts are triggered by external signals provided by circuitry that is connected to pins INT0 and INT1 (port pins P3.2 and P3.3 After the Interrupt has been handled by the interrupt subroutine. Program resumption is done by storing the interrupted PC address on the stack in RAM before changing the PC to the interrupt address in ROM. The PC address will be restored from the stack after an RETI instruction is executed at the end of the interrupt subroutine.


The heart of the 8051 is the circuitry that generates the clock pulse by which all internal operations are synchronized. Pins XTAL1 and XTAL2 are provided for connecting a resonant network to form an oscillator.The manufactures make available

8051 designs that can run at specified maximum and minimum frequencies, typically 1 megahertz to 24 megahertz. Minimum frequencies imply that some internal memories are dynamic and must always operate above a minimum frequency or data will be lost.





FIG.3.2.14 (a)Oscillator Circuit

Ceramic resonators may be used as low-cost alternative to crystal resonators. However, decreases in frequency stability data accuracy make the ceramic resonator a poor choice if high-speed serial data communication with the systems, or critical timing, is to be done.

The oscillator formed by the crystal, capacitors, and an on-chip inverter microcontroller, called the pulse, P, time. The smallest interval of time to accomplish any simple instruction, or part of a complex instruction, however, is the machine cycle. Program instructions may require one, two, or four machine cycles to the executed, depending on the type of instruction. Instructions are fetched and executed by the microcontroller automatically, beginning with the instruction located by the microcontroller automatically.To calculate the time any particular instruction will take to be executed, find the number of cycles, C, The time to execute that instruction is then found by multiplying C by 12 and dividing the product by the crystal frequency: C x 12 T inst = -------------------------------------------Crystal frequency For example, if the crystal frequency is 16 megahertz, then the time to execute an ADD A, R1 one-cycle instructions is .75 microseconds. A 12-megahertz crystal yields the convenient time of 1 microsecond per cycle. An 11.0592-megahertz crystal, although seemingly an odd value, yields a cycle frequency of 921.6 kilohertz, which can be divided evenly by the standard communication baud rates of 19200, 9600, 4800, 2400, 1200, and 300 hertz Oscillator frequency (f)
P1 P2 P2 P2 P2 P1 P2 P2 P1 P2 P1


State 4

State 5 State 3

State 6

State 1


State 2

FIG. 3.2.14.(b)8051 Timing


There are two ALE pulse per machine cycle. The ALE pulse, which is primarily used as a timing pulse for external memory access, indicates when every instruction byte is fetched. Two bytes of a single instruction may thus be fetched, and executed, in one machine cycle. Single byte instructions are nor executed in a half cycle, however, Single-byte instructions "throw-away" the second byte (which is the first byte of the next instruction.)

Chapter 4

Fig 4.1 circuit diagram for IR sensor

The transmitted signal is given to IR transmitter whenever the signal is high, the IR transmitter LED is conducting it passes the IR rays to the receiver. The IR receiver is connected with comparator. The comparator is constructed with LM 358 operational amplifier. In the comparator circuit the reference voltage is given to inverting input

terminal. The non inverting input terminal is connected IR receiver. When interrupt the IR rays between the IR transmitter and receiver, the IR receiver is not conducting. When IR transmitter passes the rays to receiver, the IR receiver is conducting due to that non inverting input voltage is lower than inverting input. Now the comparator output is GND so the output is given to microcontroller or PC. This circuit is mainly used to for counting application, intruder detector etc.

Chapter 5 Liquid Crystal Display

The LCD is used for the purpose of displaying the words which we are given in the program code. This code will be executed on microcontroller chip. By following the instructions in code the LCD display the related words. Fig.5.6 shows the LCD display.

5.1 Introduction

Fig. 5.1: LCD Display The LCD display consists of two lines, 20 characters per line that is interfaced with the PIC16F73.The protocol (handshaking) for the display is as shown in Fig. The display contains two internal byte-wide registers, one for commands (RS=0) and the

second for characters to be displayed (RS=1). It also contains a user-programmed RAM area (the character RAM) that can be programmed to generate any desired character that can be formed using a dot matrix. To distinguish between these two data areas, the hex command byte 80 will be used to signify that the display RAM address 00h will be chosen Port1 is used to furnish the command or data type, and ports 3.2 to 3.4 furnish register select and read/write levels.

A liquid crystal is a material (normally organic for LCDs) that will flow like a liquid but whose molecular structure has some properties normally associated with solids. The Liquid Crystal Display (LCD) is a low power device. The power requirement is typically in the order of microwatts for the LCD. However, an LCD requires an external or internal light source. It is limited to a temperature range of about 0C to 60C and lifetime is an area of concern, because LCDs can chemically degrade. There are two major types of LCDs which are: Dynamic-scattering LCDs and Field-effect LCDs The turn-on and turn-off time is an important consideration in all displays. The response time of LCDs is in the range of 100 to 300ms.The lifetime of LCDs is steadily increasing beyond 10,000+hours limit. Since the color generated by LCD units is dependent on the source of illumination, there is a wide range of color choice.

5.2 Pin Diagram

The Pin diagram for LCD is shown in the following fig 5.7 and the pin description is also explained in Table 5.1.

Fig. 5.2: Pin Diagram of LCD

Pins 1 2 3 4 5 6 7 14 "Vss" "Vcc" "Vee" "R/S" "R/W" "E" -

Description Ground +5v power supply Contrast Voltage Instruction/Register Select Read/Write LCD Registers Enable

Data I/O Pins Table 5.2: Pin Description of LCD

5.3 Pin Description Vcc, Vss, VEE

While Vcc and Vss provide +5v and ground, respectively, Vee is used for controlling LCD contrast.

RS, Register Select

There are two very important registers inside the LCD. The RS pin is used for their selection as follows. If RS = 0, the instruction command code register is selected, allowing the user to send as command code register is selected, allowing the user to send a command such as clear display, cursor at home, etc. If RS = 1 the data register is selected, allowing the user to send data to be displayed on the LCD.

R/W, Read/Write
R/W input allows the user to write information to the LCD or read information from it. R/W = 1 when reading R/W = 0 when writing. E, Enable The enable pin is used by the LCD to latch information presented to its data pins. When data is supplied to data pins, a high - to - low pulse must be applied to this pin in order for the LCD latch in the data pins. This pulse must be a minimum of 450 ns wide.

D0 - D7
The 8 - bit data pins, D0 - D7, are used to send information to the LCD or read the contents of the LCD's internal registers. To display letters and numbers, send ASCII codes for the letters A - Z, a - z, and numbers 0 - 9 to these pins while RS = 1. When RS = 0 to check the busy flag bit to see if

the LCD is ready to receive information. The busy flag is D7 and can be read when R/W = 1 and RS = 0, as follows: if R/W = 1, RS = 0. When D7 =1 (busy flag = 1), the LCD is busy taking care of internal operation and will not accept any new information. The description of the pins is shown in Table 5.1.

LCD Commands Description

RS R/W 0 0 D7 D6 D5 D4 0 0 0 0 D3 0 D2 0 D1 0 D0 Function 1 Clear LCD &memory, Home cursor 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1/0 0 S Clear and home cursor only Screen action as display character Written S=1/0:shift screen/ cursor 0 0 0 0 0 0 1 D C B D=1/0: Screen on/off C=1/0: B=1/0: blinks Cursor Cursor on/off blink/no


R/L 0

S/C=1/0: Screen/Cursor R/L==1/0: Shift one space R/L






character N=1/0: 2/1 Rows of characters F=1/0:

5*10/5*7dots/character 0 0 0 1 Character address Write to character RAM address after this 0 0 1 Display data address Write to display RAM

address after this 0 1 BF Current addresses BF=1/0:busy/Not busy

Table 5.4: LCD Commands

Handling the EN Control Line

As mentioned above, the EN line is used to tell the LCD that it is ready to execute an instruction that prepared on the data bus and on the other control lines. Note that the EN line must be raised/lowered before/after each instruction sent to the LCD regardless of whether that instruction is read or write, text or instruction. In short, someone must always manipulate EN when communicating with the LCD. EN is the LCD's way of knowing that someone is talking to it. If one doesnt raise/lower EN, the LCD doesn't know that someone is talking to it on the other lines.

Checking the Busy Status of the LCD:

As previously mentioned, it takes a certain amount of time for each instruction to be executed by the LCD. The delay varies depending on the frequency of the crystal attached to the oscillator input of the controller as well as the instruction which is being

executed. While it is possible to write code that waits for a specific amount of time to allow the LCD to execute instructions, this method of "waiting" is not very flexible. If the crystal frequency is changed, the software will need to be modified. Additionally, if the LCD itself is changed for another LCD which, although 44780 compatible, requires more time to perform its operations, the program will not work until it is properly modified. A more robust method of programming is to use the "Get LCD Status" command to determine whether the LCD is still busy executing the last instruction received. The "Get LCD Status" command will return to the user two bits of information; the information that is useful to the user right now is found in DB7. In summary, when user issue the "Get LCD Status" command the LCD will immediately raise DB7 if it's still busy executing a command or lower DB7 to indicate that the LCD is no longer occupied. Thus the program can query the LCD until DB7 goes low, indicating the LCD is no longer busy. At that point user is free to continue and send the next command.

Initializing the LCD

LCD must be initialized and configured before using. This is accomplished by sending a number of initialization instructions to the LCD. The first instruction send must tell the LCD whether it is to be communicated with an 8-bit or 4-bit data bus. 5x8 dot character font should also be selected. These two options are selected by sending the command 38h to the LCD as a command.

a) Clearing the Display

When the LCD is first initialized, the screen should automatically be cleared by the controller.

b) Writing Text into the LCD

The data to be displayed is send to the LCD through data bus.

c) Cursor Positioning The cursor positioning in a LCD can be done in the right entry mode or left entry mode. As left entry mode is flexible it is implemented. The circuit diagram of Check post Control System using RFID Module and its components description is described in next chapter.

Chapter 6 BUZZER
A buzzer or beeper is an audio signaling device, which may be mechanical, electromechanical, or piezoelectric. Typical uses of buzzers and beepers include alarm devices, timers and confirmation of user input such as a mouse click.

A joy buzzer is an example of a purely mechanical buzzer.


Early devices were based on an electromechanical system identical to an electric bell without the metal gong. Similarly, a relay may be connected to interrupt its own actuating current, causing the contacts to buzz. Often these units were anchored to a wall or ceiling to use it as a sounding board. The word "buzzer" comes from the rasping noise that electromechanical buzzers made.

A piezoelectric element may be driven by an oscillating electronic circuit or other audio signal source. Sounds commonly used to indicate that a button has been pressed are a click, a ring or a beep. Electronic find many applications in modern days.

FIG.6.1 Buzzer


FIG.7.1 Schematic Diagram



Keil an ARM Company makes C compilers, macro assemblers, real-time kernels, debuggers, simulators, integrated environments, evaluation boards, and emulators for ARM7/ARM9/Cortex-M3, XC16x/C16x/ST10, 251, and 8051 MCU families. Keil development tools for the 8051 Microcontroller Architecture support every level of software developer from the professional applications engineer to the student just learning about embedded software development. When starting a new project, simply select the microcontroller you use from the Device Database and the Vision IDE sets all compiler, assembler, linker, and memory options for you. Keil is a cross compiler. So first we have to understand the concept of compilers and cross compilers. After then we shall learn how to work with keil.


Compilers are programs used to convert a High Level Language to object code. Desktop compilers produce an output object code for the underlying microprocessor, but not for other microprocessors. I.E the programs written in one of the HLL like C will compile the code to run on the system for a particular processor like x86 (underlying microprocessor in the computer). For example compilers for Dos platform is different from the Compilers for Unix platform So if one wants to define a compiler then compiler is a program that translates source code into object code. The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instruction. See there is a bit little difference between compiler and an interpreter. Interpreter just interprets whole program at a time while compiler analyses and execute each line of source code in succession, without looking at the entire program. The advantage of interpreters is that they can execute a program immediately. Secondly programs produced by compilers run much faster than the same programs executed by an interpreter. However compilers require some time before an executable program emerges. Now as compilers translate source code into object code, which is unique for each type of computer, many compilers are available for the same language. development tools like IDE (Integrated Development environment)

Project Manager Simulator Debugger C Cross Compiler, Cross Assembler, Locator/Linker 5. 3 KEIL C CROSS COMPILER Keil is a German based Software development company. It provides several assemble the ARM assembly program: Keil is a German based Software development company. It provides several assemble the absolute object module suitable for our in-circuit emulator. .

Use of embedded processors in passenger cars, mobile phones, medical equipment, aerospace systems and defense systems is widespread, and even everyday domestic appliances such as dish washers, televisions, washing machines and video recorders now include at least one such device. Because most embedded projects have severe cost constraints, they tend to use low-cost processors like the 8051 family of devices considered in this book. These popular chips have very limited resources available most such devices have around 256 bytes (not megabytes!) of RAM, and the available processor power is around 1000 times less than that of a desktop processor. As a result, developing embedded software presents significant new challenges, even for experienced desktop programmers. If you have some programming experience - in C, C++ or Java - then this book and its accompanying CD will help make your move to the embedded world as quick and painless as possible.

This project of EYE BLINK SENSING AND ACCIDENT PREVENTER is a cost effective, practical, eco friendly and the safest way to save energy. It clearly tackles the two problems that world is facing today, saving of energy and also prevention of accidents , very efficient.Initial cost and maintenance can be the draw backs of this project. With the advances in technology and good resource planning the cost of the project can be cut down and also with the use of good equipment the maintenance can also be reduced in terms of periodic checks. The IR sensors have long life can be used for fast switching. For these reasons our project presents far more advantages which can over shadow the present limitations. Keeping in view the long term benefits and the initial cost would never be a problem as the investment return time is very less.



The 8051 Microcontroller and Embedded systems by Muhammad Ali Mazidi and Janice Gillispie Mazidi , Pearson Education. WEB SITES: