eye blink document
TRANSCRIPT
-
7/30/2019 eye blink document
1/38
Chapter 1
EMBEDDED SYSTEMS
Embedded systemAn 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.
SYSTEM DESIGN CALLS
-
7/30/2019 eye blink document
2/38
Fig:1.1 System Design Calls
EMBEDDED SYSTEM DESIGN CYCLE
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.
-
7/30/2019 eye blink document
3/38
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.
APPLICATIONS:
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
Chapter 2
BLOCK DIAGRAM
-
7/30/2019 eye blink document
4/38
Fig 2.1:block diagram
Chapter 3
HARDWARE REQUIREMENTS
3.1 POWER SUPPLY
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)
FILTER ICREGULATOR
LOAD
BUILD DOWNLOAD
-
7/30/2019 eye blink document
5/38
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 highvoltage 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,
-
7/30/2019 eye blink document
6/38
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.
-
7/30/2019 eye blink document
7/38
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.
-
7/30/2019 eye blink document
8/38
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
3.2 MICRO CONTROLLER(AT89C51)
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
-
7/30/2019 eye blink document
9/38
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
-
7/30/2019 eye blink document
10/38
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 whichprovides a highly flexible and cost effective solution to many embedded control
applications
3.2.1 ARCHITECTURE OF AN 8051 MICROCONTROLLER
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
-
7/30/2019 eye blink document
11/38
3.2.2PIN OUT DIAGRAM OF THE 8051
-
7/30/2019 eye blink document
12/38
FIG.3.2.2 Pin Diagram of 8051(AT 89C51)
3.2.3 DATA POINTER (DPTR)
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
-
7/30/2019 eye blink document
13/38
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.
3.2.4 PROGRAM STATUS WORD (PSW)
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.
-
7/30/2019 eye blink document
14/38
Table 3.2.4 (a)Program Status Word
.
Table.3.2.4 (b) Register Banks
3.2.5 INTERNAL MEMORY
CY PSW.7 Carry flag
AC PSW.6 Auxiliary carry flag
F0 PSW.5 Flag 0 (User Flag)
RS1 PSW.4 Register bank selector bit1
RS0 PSW.3 Register bank selector bit0
OV PSW.2 Overflow flag
-- PSW.1 Reserved for future use
P PSW.0 Parity flag
RS1 RS0 Register Bank Address
0 0 0 00H-07H
0 1 1 08H-0FH
1 0 2 10H-17H
1 1 3 18H-1FH
-
7/30/2019 eye blink document
15/38
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
3.2.6. INTERNAL ROM
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
-
7/30/2019 eye blink document
16/38
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.
3.2.7. INTERNAL RAM OF 256 BYTES (128BYTES GENERAL
PURPOSE)
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.
-
7/30/2019 eye blink document
17/38
3.2.8. INTERNAL RAM ORGANIZATION
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. 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.
3.2.9. REGISTER BANKS
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:
ADD A, R4
Thus if the Accumulator (A) contained the value 3 and R4 contained the value 3, theAccumulator 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
-
7/30/2019 eye blink document
18/38
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).
3.2.10 THIRTY TWO INPUT AND OUTPUT PORTS
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
-
7/30/2019 eye blink document
19/38
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 usesexternal 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.
-
7/30/2019 eye blink document
20/38
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.
3.2.11. TWO 16-BIT TIMER / COUNTER
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 16-
bit 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.
3.2.12. FULL DUPLEX SERIAL DATA RECEIVER/TRANSMITTER
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
-
7/30/2019 eye blink document
21/38
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.
3.2.13. INTERRUPTS
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.
3.2.14 OSCILLATOR AND CLOCK CIRCUITS
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
-
7/30/2019 eye blink document
22/38
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.
.C2
XTAL 2
C1
XTAL 1
GND 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.
-
7/30/2019 eye blink document
23/38
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 P1State 1State 6State 5State 4
P1 P2P2 P2 P1P1P2P2 P2 P2P1
State 3
-
7/30/2019 eye blink document
24/38
FIG. 3.2.14.(b)8051 Timing
ALE PULSE PER MACHINE CYCLE
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
IRSENSOR
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
State 2
-
7/30/2019 eye blink document
25/38
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
-
7/30/2019 eye blink document
26/38
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.
Theory
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.
-
7/30/2019 eye blink document
27/38
Fig. 5.2: Pin Diagram of LCD
Pins Description
1 "Vss" - Ground
2 "Vcc" - +5v power supply
3 "Vee" - Contrast Voltage
4 "R/S" - Instruction/Register Select
5 "R/W" - Read/Write LCD Registers
6 "E" - Enable
714 Data I/O Pins
Table 5.2: Pin Description of LCD
5.3 Pin Description
Vcc, Vss, VEE
-
7/30/2019 eye blink document
28/38
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
-
7/30/2019 eye blink document
29/38
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 D7 D6 D5 D4 D3 D2 D1 D0 Function
0 0 0 0 0 0 0 0 0 1 Clear LCD &memory,
Home cursor
0 0 0 0 0 0 0 0 1 0 Clear and home cursor only
0 0 0 0 0 0 0 1 1/0 S 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: Cursor on/off
B=1/0: Cursor blink/no
blinks
-
7/30/2019 eye blink document
30/38
0 0 0 0 0 1 S/C R/L 0 0 S/C=1/0: Screen/Cursor
R/L==1/0: Shift one space
R/L
0 0 0 0 1 DL N F 0 0 DL=1/0: 8/4 bits per
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
-
7/30/2019 eye blink document
31/38
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 DB 7 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.
-
7/30/2019 eye blink document
32/38
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.
MECHANICAL BUZZER
A joy buzzer is an example of a purely mechanical buzzer.
ELECTRO MECHANICAL BUZZEREarly 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.
http://en.wikipedia.org/wiki/Soundhttp://en.wikipedia.org/wiki/Machinehttp://en.wikipedia.org/wiki/Electromechanicshttp://en.wikipedia.org/wiki/Piezoelectricityhttp://en.wikipedia.org/wiki/Alarm_deviceshttp://en.wikipedia.org/wiki/Alarm_deviceshttp://en.wikipedia.org/wiki/Timerhttp://en.wikipedia.org/wiki/Joy_buzzerhttp://en.wikipedia.org/wiki/Electric_bellhttp://en.wikipedia.org/wiki/Electric_bellhttp://en.wikipedia.org/wiki/Relayhttp://en.wikipedia.org/wiki/Electric_currenthttp://en.wikipedia.org/wiki/Switchhttp://en.wikipedia.org/wiki/Switchhttp://en.wikipedia.org/wiki/Electric_currenthttp://en.wikipedia.org/wiki/Relayhttp://en.wikipedia.org/wiki/Electric_bellhttp://en.wikipedia.org/wiki/Electric_bellhttp://en.wikipedia.org/wiki/Joy_buzzerhttp://en.wikipedia.org/wiki/Timerhttp://en.wikipedia.org/wiki/Alarm_deviceshttp://en.wikipedia.org/wiki/Alarm_deviceshttp://en.wikipedia.org/wiki/Piezoelectricityhttp://en.wikipedia.org/wiki/Electromechanicshttp://en.wikipedia.org/wiki/Machinehttp://en.wikipedia.org/wiki/Sound -
7/30/2019 eye blink document
33/38
ELECTRONIC
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
Chapter 7
SCHEMATIC DIAGRAM
http://en.wikipedia.org/wiki/Piezoelectrichttp://en.wikipedia.org/wiki/Oscillationhttp://en.wikipedia.org/wiki/Oscillationhttp://en.wikipedia.org/wiki/Piezoelectric -
7/30/2019 eye blink document
34/38
FIG.7.1 Schematic Diagram
Chapter 8
SOFTWARE REQUIREMENTS
8.1 INTRODUCTION TO KEIL MICRO VISION (IDE)
-
7/30/2019 eye blink document
35/38
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.
8.2 CONCEPT OF COMPILERCompilers 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)
-
7/30/2019 eye blink document
36/38
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. .
8.4 EMBEDDED CUse 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.
-
7/30/2019 eye blink document
37/38
9. CONCLUSION
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.
10. BIBLIOGRAPHY
-
7/30/2019 eye blink document
38/38
TEXT BOOKS REFERED:
The 8051 Microcontroller and Embedded systems by Muhammad
Ali Mazidi and Janice Gillispie Mazidi , Pearson Education.
WEB SITES:
www.atmel.com
www.beyondlogic.org
www.wikipedia.org
www.howstuffworks.com
www.alldatasheets.com
http://www.atmel.com/http://www.atmel.com/http://www.beyondlogic.org/http://www.wikipedia.org/http://www.howstuffworks.com/http://www.howstuffworks.com/http://www.wikipedia.org/http://www.beyondlogic.org/http://www.atmel.com/