embeded system report
TRANSCRIPT
COMPANY PROFILE
It’s important that the technology we implement is the most secure and as secure as
possible.RAD continually explores and remains knowledgeable in the latest
technologies available in the industry.RAD is a company of qualified & committed
professionals who are working with a vision of developing technical excellence in
young engineers and technocrats. India is a powerhouse of technical workforce and
has acquired a lead in providing technical manpower worldwide. However, to become
competent enough for global technical challenges, our engineers need to develop
experience of real projects and products. At RAD we help people develop sharp
technical skills and professional attitude to stay ahead even in the most challenging
circumstances.
However, to become competent enough for global technical challenges, our engineers
need to develop experience of real projects and products. In RAD,emphasis is given
on spending more time in lab to gain hands-on experience in various interfacing
techniques that can be useful in the construction of an embedded system. We are
offering training programs for Electronics/Electrical/Computers/Mechanical/Bio-
medical fields.
1
CHAPTER-1
EMBEDDED SYSTEM
1.1 INTRODUCTION TO EMBEDDED SYSTEM
Now a day’s electronics have developed at very fast rate. It plays a major role in the
life of human being and makes it very easy and comfortable. Electronics circuits are
designed to obtain a particular function. For this purpose a no of electronic component
are suitably connected. Embedded systems have proved changing face of today's
industrial scenario. An embedded system is a system is a special-
purpose computer system designed to perform one or a few dedicated functions often
with real-time computing constraints or embedded system employs a combination of
software & hardware to perform a specific function. It is a part of a larger system
which may not be a “computer” Works in a reactive & time constrained environment.
Any electronic system that uses a CPU chip, but that is not a general-purpose
workstation, desktop or laptop computer is known as embedded system. Such systems
generally use microprocessors; microcontroller or they may use custom-designed
chips or both. They are used in automobiles, planes, trains, space vehicles, machine
tools, cameras, consumer and office appliances, cell phones, PDAs and other
handhelds as well as robots and toys. The uses are endless, and billions of
microprocessors are shipped every year for a myriad of applications.
In embedded systems, the software is permanently set into a read-only memory such
as a ROM or flash memory chip, in contrast to a general-purpose computer that loads
its programs into RAM each time. Sometimes, single board and rack mounted
general-purpose computers are called "embedded computers" if used to control.
We are living in the Embedded World. You are surrounded with many embedded
products and your daily life largely depends on the proper functioning of these
gadgets. Television, Radio, CD player of your living room, Washing Machine or
Microwave Oven in your kitchen, Card readers, Access Controllers, Palm devices of
your work space enable you to do many of your tasks very effectively. Apart from all
2
these, many controllers embedded in your car take care of car operations between the
bumpers and most of the times you tend to ignore all these controllers.
In recent days, you are showered with variety of information about these embedded
controllers in many places. All kinds of magazines and journals regularly dish out
details about latest technologies, new devices; fast applications which make you
believe that your basic survival is controlled by these embedded products. Now you
can agree to the fact that
These embedded products have successfully invaded into our world. You must be
wondering about these embedded controllers or systems. What is this Embedded
System?
The computer you use to compose your mails, or create a document or analyze the
database is known as the standard desktop computer. These desktop computers are
manufactured to serve many purposes and applications.
You need to install the relevant software to get the required processing facility. So,
these desktop computers can do many things. In contrast, embedded controllers
carryout a specific work for which they are designed. Most of the time, engineers
design these embedded controllers with a specific goal in mind. So these controllers
cannot be used in any other place.
Theoretically, an embedded controller is a combination of a piece of microprocessor
based hardware and the suitable software to undertake a specific task.
These days designers have many choices in microprocessors/microcontrollers.
Especially, in 8 bit and 32 bit, the available variety really may overwhelm even an
experienced designer. Selecting a right microprocessor may turn out as a most
difficult first step and it is getting complicated as new devices continue to pop-up
very often.
1.2 EMBEDDED APPLICATIONS
1.2.1 AUTOMOBILES:
i) Automatic Parking
ii) Tyre Pressure Monitoring
iii) Keyless Entry3
iv) Collision Avoidance System
v) Driver Information & Navigation System Light
vi) Door & Seat Control
Figure 1.1 Embedded System in a car
1.2.2 BUSINESS APPLICATIONS:
Vending Machine, Scanners , Printers
1.2.3MEDICAL ELECTRONICS:
i) Patient Monitoring
ii) Blood Pressure Monitor
iii) Clinical Treatment : Dialysis
iv) Machine
v) Diagnostic Imaging : MRI , CT Scan
vi) Hospital Networking and Information System
Figure 1.2 Blood Pressure Monitor
4
1.2.4 CONSUMER ELECTRONICS:
i) Microwave Oven
ii) Air Conditioning System
iii) Home-security & burglar alarm
iv) Audio / Music system
v) DVD(Digital Versatile Disk),Video Player
vi) Mobile , Modem
vii) Washing Machine
Figure 1.3: Consumer Electronics
1.2.5 INDUSTRIAL AUTOMATION APPLICATION:
i)Process Control: Control of chemical plant , oil refinery etc.
ii)SCADA(Supervisory Control & Data Acquisition) : PC control &monitor
smaller controllers mounted in field .
iii) Plant automation: Computer numeric control machines , robots for
manufacturing
iv) Safety Interlocks: Safety systems to avoid life and material hazard , like plant
shutdown if gas leaks.
Figure 1.4 Fabrication equipment
5
1.2.6 DEFENCE APPLICATIONS:
RADARs, SONARs (for suvellience) , Guided Missiles System and many more…
1.2.7 ROBOTICS:
Embedded systems are used for making robots.
Figure 1.5: Robot
6
CHAPTER-2
MICROCONTROLLER
2.1 INTRODUCTION
Microcontroller are widely used in Embedded System products. An Embedded
product uses the microprocessor(or microcontroller) to do one task & one task only. A
printer is an example of Embedded system since the processor inside it perform one
task only namely getting the data and printing it. Contrast this with Pentium based PC.
A PC can be used for any no. of applications such as word processor, print server,
bank teller terminal, video game player, network server or internet terminal. Software
for variety of applications can be loaded and run. Of course the reason a PC can
perform multiple task is that it has RAM memory and an operating system that loads
the application software into RAM & lets the CPU run it. In and Embedded system
there is only one application software that is typically burn into ROM. An x86PC
Contain or its connected to various Embedded Products such as keyboard, printer,
modem, Disc controller, Sound card, CD-Rom Driver, Mouse & so on. Each one of
these peripherals as a microcontroller inside it that performs only one task. Although
microcontroller are preferred choice for many Embedded systems, There are times
that a microcontroller is inadequate for the task. For this reason in recent years many
manufactures of general purpose microprocessors such as INTEL, Motorolla, AMD &
Cyrix have targeted their microprocessors for the high end of Embedded market.
While INTEL, AMD, Cyrix push their x86 processors for both the embedded and
desktop pc market, Motorolla is determined to keep the 68000 families alive by
targeting it mainly for high end of embedded system. One of the most critical needs of
the embedded system is to decrease power consumptions and space. This can be
achieved by integrating more functions into the CPU chips. All the embedded
processors based on the x86 and 680x0 have low power consumptions in additions to
some forms of I/O, Com port & ROM all on a single chip. In higher performance
Embedded system the trend is to integrate more & more function on the CPU chip &
let the designer decide which feature he/she wants to use.
7
2.2 DEFINITION
Microcontroller, as the name suggests, are small controllers. They are like single
chip computers that are often embedded into other systems to function as
processing/controlling unit. For example, the remote control you are using probably
has microcontrollers inside that do decoding and other controlling functions. They are
also used in automobiles, washing machines, microwave ovens, toys ... etc, where
automation is needed.
2.3 HISTORY
Intel Corporation introduced an 8-bit microcontroller called 8051 in 1981
this controller had 128 bytes of RAM, 4k bytes of on chip ROM, two timers, one
serial port, and four ports all are on single chip. The 8051 is an 8 bit processor,
meaning that the CPU can work on only 8 bit data at a time. Data larger than 8 bits
broken into 8- bit pieces to be processed by CPU. It has for I/O 8 bit wide.
2.4 FEATURES
FEATURE QUANTITY
ROM 4K bytes
RAM 128 bytes
Timer 2
I/O pins 32
Serial port 1
Interrupt sources 6
2.5 CHOOSING CRITERIA
a) Meeting the computing needs of the task efficiently and cost effectively
i) Speed, the amount of ROM and RAM, the number of I/O ports and
8
timers, size, packaging, power consumption
i) easy to upgrade
iii) cost per unit
b) Availability of software development tools -assemblers, debuggers, C
compilers, emulator, simulator, technical support
c) Wide availability and reliable sources of the microcontrollers.
2.6 8051 ARCHITECTURE OVERVIEW
The 8051 family is one of the most common microcontroller architectures used
worldwide. 8051 based microcontrollers are offered in hundreds of variants from
many different silicon manufacturers.
The 8051 is based on an 8-bit CISC core with Harvard architecture. It's an 8-bit CPU,
optimized for control applications with extensive Boolean processing (single-bit logic
capabilities), 64K program and data memory address space and various on-chip
peripherals.
The 8051 microcontroller family offers developers a wide variety of high-integration
and cost-effective solutions for virtually every basic embedded control application.
From traffic control equipment to input devices and computer networking products,
8051 u.c deliver high performance together with a choice of configurations and
options matched to the special needs of each application. Whether it's low power
operation, higher frequency performance, expanded on-chip RAM, or an application-
specific requirement, there's a version of the 8051 microcontroller that's right for the
job.
When it's time to upgrade product features and functionality, the 8051 architecture
puts you on the first step of a smooth and cost-effective upgrade path - to the
enhanced performance of the 151 and 251 microcontrollers.
TYPES OF ARCHITECTURE
I. Von Neumann Architecture
9
II. Harvard Architecture
TABLE 2.1: VON NEUMANN & HARVARD ARCHITECTURE:
Von Neumann
Harvard
Doesn’t distinguish between data and
instructions. Both are stored in same
memory and has same word size.
Instructions and data have different
memory spaces , with separate address ,
data and control buses for each memory
space .
Concurrent instruction and data fetch.
Size of instruction is independent of data
word size.
II.7 BLOCK DIAGRAM OF MICROCONTROLLER:
Fig-2.1-Block diagram of MICROCONTROLLER
10
2.8 DIP 40 PIN CONFIGURATIONS:
Figure 2.2: Pin description
11
1.VCC: - PIN (40) - This pin is used to supply voltage to the micro controller.
Generally +5V is provided to microcontroller.
2.GND: - PIN (20) - This pin is used for ground.
3.RST: - (PIN 9) It is a Reset Input. When this pin is given a high for the two
continuous machine cycles while the oscillator is running, the device gets resets.
Logical one on this pin stops microcontroller’s operating and erases the contents of
most registers. By applying logical zero to this pin, the program starts execution from
the beginning. In other words, a positive voltage pulse on this pin resets the
microcontroller.
4. ALE: - (PIN 30): - It is an Address latch enable. With the bit set the ALE is
enabled during the MOVX or MOVC instruction. Prior to each reading from external
memory, the microcontroller will set the lower address byte (A0-A7) on P0 and
immediately after that activates the output ALE. Upon receiving signal from the ALE
pin, the external register (74HCT373 or 74HCT375 circuit is usually embedded )
memorizes the state of P0 and uses it as an address for memory chip. In the second
part of the microcontroller’s machine cycle, a signal on this pin stops being emitted
and P0 is used now for data transmission (Data Bus). In this way, by means of only
one additional (and cheap) integrated circuit, data multiplexing from the port is
performed. This port at the same time used for data and address transmission.
5. PSEN : - (PIN 29): - Program Store Enabled is the read strobe to external program
memory. When the AT89C51 is executing code from external memory, This pin is
activated during each machine cycle, except that two activation are skipped during
each access to external data memory. If external ROM is used for storing program
then it has a logic-0 value every time the microcontroller reads a byte from memory.
6. EA / VPP: - (PIN 31): - External access enabled. EA must be strapped to ground
in order to enable the device to fetch code from external program memory location
starting at 0000H to FFFFH. EA should be strapped to VCC for internal program
execution. This pin also receives the 12 -Volt programming enabled voltage during
12
Flash Programming, for parts that require 12-volt VPP. Where VPP is a peak to peak
voltage.
7. By applying logic zero to this pin, P2 and P3 are used for data and address
transmission with no regard to whether there is internal memory or not. That means
that even there is a program written to the microcontroller, it will not be executed, the
program written to external ROM will be used instead. Otherwise, by applying logic
one to the EA pin, the microcontroller will use both memories, first internal and
afterwards external (if it exists), up to end of address spaced to VCC for internal
program execution. This pin also receives the 12 -Volt programming enabled voltage
during Flash Programming, for parts that require 12-volt VPP. Where VPP is a peak
to peak voltage.
8. PORT 0 AS INPUT:
With resistors connected to port 0, in order to make it an input, the port must be
programmed by writing 1 to all the bits. In the following code, port 0 is configured
first as an input port by writing 1's to it, and then data is received from the port and
sent to P1.
13
Fig-2.3-P0 port with pull up resistors
Dual Role of Port 0 :-Port 0 is also designated as AD0-AD7, allowing it to be used
for both address and data. When connecting an 8051/31 to an external memory, port 0
provides both address and data. The 8051 multiplexes address and data through port 0
to save pins. ALE indicates if P0 has address or data. When ALE = 0, it provides data
D0-D7, but when ALE =1 it has address and data with the help of a 74LS373 latch.
9. PORT 1
Port 1 occupies a total of 8 pins (pins 1 through 8). It can be used as input or output.
In contrast to port 0, this port does not need any pull-up resistors since it already has
pull-up resistors internally. Upon reset, Port 1 is configured as an output port. For
example, the following code will continuously send out to port1 the alternating values
55h & AAh
9.1 PORT 1 AS INPUT
To make port1 an input port, it must be programmed as such by writing 1 to all its
bits. In the following code port1 is configured first as an input port by writing 1’s to
it, then data is received from the port and saved in R7 ,R6 & R5.
10. PORT 2
Port 2 occupies a total of 8 pins (pins 21- 28). It can be used as input or output. Just
like P1, P2 does not need any pull-up resistors since it already has pull-up resistors
internally. Upon reset, Port 2 is configured as an output port. For example, the
following code will send out continuously to port 2 the alternating values 55h and
AAH. That is all the bits of port 2 toggle continuously.
10.1 PORT 2 AS INPUT
14
To make port 2 an input, it must programmed as such by writing 1 to all its bits. In
the following code, port 2 is configured first as an input port by writing 1’s to it. Then
data is received from that port and is sent to P1 continuously.
DUAL ROLE OF PORT 2
In systems based on the 8751, 8951, and DS5000, P2 is used as simple I/O.
However, in 8031-based systems, port 2 must be used along with P0 to provide the
16-bit address for the external memory. As shown in pin configuration 8051, port 2 is
also designed as A8-A15, indicating the dual function. Since an 8031 is capable of
accessing 64K bytes of external memory, it needs a path for the 16 bits of the address.
While P0 provides the lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-
A15 of the address. In other words, when 8031 is connected to external memory, P2 is
used for the upper 8 bits of the 16 bit address, and it cannot be used for I/O.
11. PORT 3
Port 3 occupies a total of 8 pins, pins 10 through 17. It can be used as input or
output. P3 does not need any pull-up resistors, the same as P1 and P2 did not.
Although port 3 is configured as an output port upon reset. Port 3 has the additional
function of providing some extremely important signals such as interrupts. This
information applies both 8051 and 8031 chips. There functions are as follows:-
Table 2.2: PORT 3 functions
Port Pins Alternate Functions
P3.0 RXD ( serial input port)- This is used in serial communication at
receiver’s side
P3.1 TXD (serial output port)- This is used in serial communication at
transmitter’s side
P3.2 INT0 (external interrupt 0) - This pin is used for providing the
15
interrupts.
P3.3 INT1 (external interrupt 1) - This pin is used for providing the
interrupts.
P3.4 T0 (timer 0 external input) - This pin is used for providing the timers.
P3.5 T1 (timer 1 external input) - This pin is used for providing the timers.
P3.6 WR (external data memory write strobe) - This pin is used when we
have to perform a write operation.
P3.7 RD (external data memory read strobe) - This pin is used when we
have to perform a write operation.
P3.0 and P3.1 are used for the RxD and TxD serial communications signals. Bits P3.2
and P3.3 are set aside for external interrupts. Bits P3.4 and P3.5 are used for timers 0
and 1. Finally P3.6 and P3.7 are used to provide the WR and RD signals of external
memories connected in 8031 based systems.
12. ALE/PROG
Address Latch Enable is an output pulse for latching the low byte of the address
during accesses to external memory. This pin is also the program pulse input (PROG)
during Flash programming. In normal operation, ALE is emitted at a constant rate of
1/ 6 the oscillator frequency and may be used for external timing or clocking
purposes. Note, however, that one ALE pulse is skipped during each access to
external data memory. If desired, ALE operation can be disabled by setting bit 0 of
SFR location 8EH. With the bit set, ALE is active only during a MOVX or MOVC
instruction. Otherwise, the pin is weakly pulled high. Setting the ALE-disable bit has
no effect if the microcontroller is in external execution mode.
13.PSE
Program Store Enable is the read strobe to external program memory. When the
AT89S8252 is executing code from external program memory, PSEN is activated
16
twice each machine cycle, except that two PSEN activations are skipped during each
access to external data memory.
14. External Access Enable
EA must be strapped to GND in order to enable the device to fetch code from external
program memory locations starting at 0000H up to FFFFH. Note, however, that if
lock bit 1 is programmed, EA will be internally latched on reset. EA should be
strapped to VCC for internal program executions. This pin also receives the 12-volt
programming enable voltage (VPP) during Flash programming when 12-volt
programming is selected.
15. XTAL1
Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
16. XTAL2
Output from the inverting oscillator amplifier.
17. OSCILLATOR CRYSTAL
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier
which can be configured for use as an on-chip oscillator; Either a quartz crystal or
ceramic resonator may be used. To drive the device from an external clock source,
XTAL2 should be left unconnected while XTAL1 is driven. There are no
requirements on the duty cycle of the external clock signal, since the input to the
internal clocking circuitry is through a divide-by-two flip-flop, but minimum and
maximum voltage high and low time specifications must be observed.
2.9 SPECIAL PURPOSE REGISTERS:
SFRs are a kind of control table used for running and monitoring microcontroller’s
operating. Each of these registers, even each bit they include, has its name, address in
17
the scope of RAM and clearly defined purpose ( for example: timer control, interrupt,
serial connection etc.). Even though there are 128 free memory locations intended for
their storage, the basic core, shared by all types of 8051 controllers, has only 21 such
registers. Rest of locations are intentionally left free in order to enable the producers
to further improved models keeping at the same time compatibility with the previous
versions. It also enables the use of programs written a long time ago for the
microcontrollers which are out of production now.
2.9.1 CPU Registers:
a) ACCUMULATOR: - It is an 8 – bit register and used as working register for the
Arithmetic, Logical instructions. All the calculations are performed using this register.
It can also be used as General purpose register. It is very necessary for some
instructions. It is denoted by A. A number (an operand) should be added to the
accumulator prior to execute an instruction upon it. Once an arithmetical operation is
performed by the ALU, the result is placed into the accumulator. If a data should be
transferred from one register to another, it must go through accumulator. For such
universal purpose, this is the most commonly used register that none microcontroller
can be imagined without (more than a half 8051 microcontroller's instructions used
use the accumulator in some way).
b) B – REGISTER: - It also an 8 – bit register and can be used as General Purpose
register. It is very necessary for the multiplication and division operations which can
be performed only upon numbers stored in the A and B registers ,without it the
operations are not accomplished. All other instructions in the program can use this
register as a spare accumulator (A).
2.10 PSW-PROGRAM STATUS WORD (BIT ADDRESSABLE)
18
Fig-2.4-PROGRAM STATUS WORD
This is one of the most important SFRs. The Program Status Word (PSW) contains
several status bits that reflect the current state of the CPU. This register contains:
Carry bit, Auxiliary Carry, two register bank select bits, Overflow flag, parity bit, and
user-definable status flag. The ALU automatically changes some of register’s bits,
which is usually used in regulation of the program performing.
P - Parity bit:
If a number in accumulator is even then this bit will be automatically set (1),
otherwise it will be cleared (0). It is mainly used during data transmission and
receiving via serial communication.
Bit 1:
This bit is intended for the future versions of the microcontrollers, so it is not
supposed to be here.
OV Overflow:
Sets when the result of arithmetical operation is greater than 255 (deci mal), so that it
cannot be stored in one register. In that case, this bit will be set (1). If there is no
overflow, this bit will be cleared (0).
RS0, RS1 - Register bank select bits:
These two bits are used to select one of the four register banks in RAM. By writing
zeroes and ones to these bits, a group of registers R0-R7 is stored in one of four banks
in RAM.
TABLE-2.3 DIFFERENT COMBINATIONS OF RS0 AND RS1:
RS1 RS2 SPACE IN RAM
0 0 Bank 0 (00h-07h)
19
0 1 Bank 1 (08h-0Fh)
1 0 Bank 2 (10h-17h)
1 1 Bank 3 (18h-1Fh)
F0 - Flag 0:
This is a general-purpose bit available to the user.
AC - Auxiliary Carry Flag:
It is used for BCD operations only.
CY - Carry Flag:
It is the (ninth) auxiliary bit used for all arithmetical operations and shift instructions.
The above table shows that RS0 and RS1 are responsible for selecting the particular
Register bank i.e. by using the different combinations of RS0 and RS1 the Register
Banks are selected.
CHAPTER-3
MICROPROCESSOR
20
3.1 INTRODUCTION
A microprocessor is a general-purpose digital computer central processing unit
(CPU). Although popularly known as a “computer on a chip” is in no sense a
complete digital computer . The block diagram of a microprocessor CPU is shown,
which contains an arithmetic and logical unit (ALU), a program counter (PC),
a stack pointer (SP),some working registers, a clock timing circuit, and interrupt
circuits.
Fig-3.1-BLOCK DIAGRAM OF A MICROPROCESSOR
3.2 COMPARISON BETWEEN MICROPROCESSORS &
MICROCONTROLLERS
The microprocessor must have many additional parts to be operational as a
computer whereas microcontroller requires no additional external digital parts.
21
1.The prime use of microprocessor is to read data, perform extensive calculations on
that data and store them in the mass storage device or display it. The prime functions
of microcontroller is to read data, perform limited calculations on it, control its
environment based on these data. Thus the microprocessor is said to be general-
purpose digital computers whereas the microcontroller are intend to be special
purpose digital controller.
2.Microprocessor is concerned with the rapid movement of the code and data from
the external addresses to the chip, microcontroller is concerned with the rapid
movement of the bits within the chip.
Lastly, the microprocessor design accomplishes the goal of flexibility in the
hardware configuration by enabling large amounts of memory and I/O that could be
connected to the address and data pins on the IC package. The microcontroller
design uses much more limited set of single and double byte instructions to move
code and data from internal memory to ALU.
CHAPTER-4
PERIPHERAL INTERFACING WITH 8051
4.1 LED INTERFACING
22
LED can be interface with micro-controller as shown in the fig. 2.7. Here the common
anode configuration is used, in which common end is connected to power supply of
+5V. When the port, to which LED’s are interfaced, have logic “0” on it, LED’s will
glow.
The color of emitted light depends on the composition and condition of the
semiconductor material used, and can be infrared, visible or nearly ultra-violet. An
LED can be used as a regular home light source.
Resistor is used to control flow of current through LED’s and EA pin is always
connected to +Vcc in case of 8051 microcontroller.
USE
A LED can be used as an indicator in ac circuit. The LEDs in a seven segment
display may be connected in common anode or in common-cathode configuration.
Figure 4.1: LED interfacing with 8051 microcontroller
4.2 SEVEN SEGMENT INTERFACING:
The Light Emitting Diode (LED), finds its place in many applications in this modern
electronic fields. One of them is the Seven Segment Display. Seven-segment displays
contains the arrangement of the LEDs in “Eight” (8) passion, and a Dot (.) with a
common electrode, lead (Anode or Cathode). The purpose of arranging it in that
23
passion is that we can make any number out of that by switching ON and OFF the
particular LED’s. Here is the block diagram of the Seven Segment LED arrangement.
Pin configuration of a seven segment display:
Fig-4.2-Seven-Segment Display
Seven Segments are basically of two types:
1. Common Cathode(CC)
All the 8 anode legs uses only one cathode, which is common.
2. Common Anode (CA)
The common leg for all the cathode is of Anode type.
24
Figure 4.3: Circuit diagram for Common Cathode 7-Segment Display
LCD INTERFACING :
16x2 LCD Description
Fig 4.4-LCD diagram with pins description
LCD pin description:The LCD discuss in this section has the most common
connector used for the Hitatchi 44780 based LCD is 14 pins in a row and modes of
operation and how to program and interface with microcontroller is describes in this
section.
The voltage VCC and VSS provided by +5V and ground respectively while VEE is
used for controlling LCD contrast. Variable voltage between Ground and Vcc is used
to specify the contrast (or "darkness") of the characters on the LCD screen.
RS (register select)
There are two 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, then
allowing to 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.
25
R/W (read/write)
The R/W (read/write) input allowing the user to write information from it. R/W=1,
when it read and R/W=0, when it writing.
Fig 4.4-LCD Pin Description Diagram
EN (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 power, a high-to-low pulse must be applied to this
pin in order to for the LCD to latch in the data presented at the data pins.
D0-D7 (data lines)
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 displays the letters and numbers, we send
ASCII codes for the letters A-Z, a-z, and numbers 0-9 to these pins while making RS
26
=1. There are also command codes that can be sent to clear the display or force the
cursor to the home position or blink the cursor.
We also use RS =0 to check the busy flag bit to see if the LCD is ready to receive the
information. The busy flag is D7 and can be read when R/W =1 and RS =0, as
follows: if R/W =1 and RS =0, when D7 =1(busy flag =1), the LCD is busy taking
care of internal operations and will not accept any information. When D7 =0, the LCD
is ready to receive new information.
Interfacing of micro controller with LCD display
In most applications, the "R/W" line is grounded. This simplifies the application
because when data is read back, the microcontroller I/O pins have to be alternated
between input and output modes. In this case, "R/W" to ground and just wait the
maximum amount of time for each instruction (4.1 msecs for clearing the display or
moving the cursor/display to the "home position", 160 usecs for all other commands)
and also the application software is simpler, it also frees up a
Fig 4.5-Interfacing of Microcontroller with LCD
microcontroller pin for other uses. Different LCD execute instructions at different
rates and to avoid problems later on (such as if the LCD is changed to a slower unit).
Before sending commands or data to the LCD module, the Module must be
27
initialized. Once the initialization is complete, the LCD can be written to with data or
instructions as required. Each character to display is written like the control bytes,
except that the "RS" line is set. During initialization, by setting the "S/C" bit during
the "Move Cursor/Shift Display" command, after each character is sent to the LCD,
the cursor built into the LCD will increment to the next position (either right or left).
Normally, the "S/C" bit is set (equal to "1").
4.5 STEPPER MOTOR INTERFACING
Stepper motors can be used in various areas of your microcontroller projects such as
making robots, robotic arm, automatic door lock system etc. The construction of
stepper motors (unipolar and bipolar stepper motors ), basic pricipal, different
controlling types (Half step and Full step), Interfacing Techniques
(using L293D or ULN2003).
There are actually many ways you can interface a stepper motor to your controller,
out of them the most used interfaces are:
1. Interface using L293D - H-Bridge Motor Driver
2. Interface using ULN2003/2004 - Darlington Arrays
We will dicuss both connection techniques one by one. The above mentioned methods
need 4 controller pins for interface.
28
Figure 4.6: Stepper motor interfacing with microcontroller
Here in this circuit too the four pins "Controller pin 1",2,3 and 4 will control the
motion and direction of the stepper motor according to the step sequence sent by the
controller.
Why to use ULN2003?
It is a driver IC. ULN IC are basically current amplifiers that are used to
interface motor or LED's to controller. Motor needs more current to drive the rotor.
The current at port pins are very less around 25Ma which is amplified to 500ma for
motor operation. So we use current amplifier to drive the motor.
29
CHAPTER-5
PROJECT COVERED
30
PASSWORD BASED DOOR LOCKING
SYSTEM
5.1 INTRODUCTION
Security is a prime concern in our day-today life. Everyone wants to be as much
secure as possible. An access control for doors forms a vital link in a security chain.
The microcontroller based Door locker is an access control system that allows only
authorized persons to access a restricted area. The system is fully controlled by the 8
bit microcontroller AT89C2051 which has a 2Kbytes of ROM for the program
memory. The password is stored in the EPROM so that we can change it at any time.
The system has a Keypad by which the password can be entered through it. When the
31
entered password equals with the password stored in the memory then the relay gets
on and so that the door is opened .If we entered a wrong password then the alarm will
be switched on.
5.2 Design Strategy
This console project is intended to be a low-end and low-cost system that will focus
mainly on affordability and simplicity rather than connectivity or even ease-of-use.
Hence this will be a stand-alone system that will not need a special communications
interface. These limit the design phase to four sub-systems: keypad, controller, and
visual/mechanical interface.
5.3 Main Modules of the System
LCD (Liquid Crystal Display)
The most commonly used Character based LCDs are based on Hitachi's
HD44780 controller or other which are compatible with HD44580.
Stepper Motor
Stepper motors can be used in various areas of your microcontroller projects such as
making robots, robotic arm, automatic door lock system etc. The construction of
stepper motors (unipolar and bipolar stepper motors ), basic pricipal, different
controlling types (Half step and Full step), Interfacing Techniques (using L293D or
ULN2003).
Power Supply:
The +5 volt supply is useful for both analog and digital circuits. DTL, TTL, and
CMOS ICs will all operate nicely from a +5 volt supply. In addition, the +5 volt
supply is useful for circuits that use both analog and digital signals in various ways.
32
Figure 5.1: Power supply
ULN2003
It is a driver IC. ULN IC are basically current amplifiers that are used to interface
motor or LED's to controller. Motor needs more current to drive the rotor. The current
at port pins are very less around 25Ma which is amplified to 500ma for motor
operation. So we use current amplifier to drive the motor.
Fig-5.2-pin diagram of ULN2003
PROGRAM:
$include(mod51)
org 0000h
main: mov r1, #0ffh
mov r2, #0ffh
mov r3, #0ffh
mov p0, #0ffh
main1: lcall lcdon
lcall lcdenterpass
mov a, #0c4h
lcall cmdw
33
lcall delay
lcall checkpw
lcall delay
lcall delay
ljmp main
lcdon: mov a, #38h
lcall cmdw
lcall delay
mov a, #0Eh
lcall cmdW
lcall delay
mov a, #01h
lcall cmdw
lcall delay
mov a, #06h
lcall cmdw
lcall delay
mov a, #80h
lcall cmdw
lcall delay
ret
lcdenterpass: mov a, #'E'
lcall datw
lcall delay
mov a, #'n'
lcall datw
lcall delay
mov a, #'t'
lcall datw
lcall delay
mov a, #'e'
lcall datw
lcall delay
mov a, #'r'
lcall datw
lcall delay
34
mov a, #' '
lcall datw
lcall delay
mov a, #'P'
lcall datw
lcall delay
mov a, #'a'
lcall datw
lcall delay
mov a, #'s'
lcall datw
lcall delay
mov a, #'s'
lcall datw
lcall delay
mov a, #'w'
lcall datw
lcall delay
mov a, #'o'
lcall datw
lcall delay
mov a, #'r'
lcall datw
lcall delay
mov a, #'d'
lcall datw
lcall delay
ret
checkpw: jb p2.7, savedata1
mov r0, #00h
ljmp savedata
savedata1: jb p2.6, savedata3
mov r0, #01h
ljmp savedata
savedata3: jb p1.7, savedata4
mov r0, #02h
35
ljmp savedata
savedata4: jb p1.0, savedata5
mov r0, #03h
ljmp savedata
savedata5: jb p1.6, savedata6
mov r0, #04h
ljmp savedata
savedata6: jb p1.5, savedata7
mov r0, #05h
ljmp savedata
savedata7: jb p1.4, savedata8
mov r0, #06h
ljmp savedata
savedata8: jb p1.3, savedata9
mov r0, #07h
ljmp savedata
savedata9: jb p1.2, savedata10
mov r0, #08h
ljmp savedata
savedata10: jb p1.1, checkpw
mov r0, #09h
savedata: lcall star
lcall delay
mov a, r1
cjne a, #0ffh, save1
mov a, r0
mov r1, a
ljmp checkpw
save1: mov a, r2
cjne a, #0ffh, save2
mov a, r0
mov r2, a
ljmp checkpw
save2: mov a, r3
cjne a, #0ffh, checkpw
mov a, r0
36
mov r3, a
ljmp checkpw
compare: mov a, r1
cjne a, #03h, lcdinvalid
mov a, r2
cjne a, #05h, lcdinvalid
mov a, r3
cjne a, #01h, lcdinvalid
ret
lcdinvalid: mov a, #80h
lcall cmdw
lcall delay
mov a, #'I'
lcall datw
lcall delay
mov a, #'n'
lcall datw
lcall delay
mov a, #'v'
lcall datw
lcall delay
mov a, #'a'
lcall datw
lcall delay
mov a, #'l'
lcall datw
lcall delay
mov a, #'i'
lcall datw
lcall delay
mov a, #'d'
lcall datw
lcall delay
mov a, #' '
lcall datw
lcall delay
37
mov a, #'P'
lcall datw
lcall delay
mov a, #'a'
lcall datw
lcall delay
mov a, #'s'
lcall datw
lcall delay
mov a, #'s'
lcall datw
lcall delay
mov a, #'w'
lcall datw
lcall delay
mov a, #'o'
lcall datw
lcall delay
mov a, #'r'
lcall datw
lcall delay
mov a, #'d'
lcall datw
lcall delay
setb p0.7
lcall delayb
lcall delayb
lcall delayb
clr p0.7
ret
vpss: mov a, #80h
lcall cmdw
lcall delay
mov a, #'v'
lcall datw
lcall delay
38
mov a, #'a'
lcall datw
lcall delay
mov a, #'l'
lcall datw
lcall delay
mov a, #'i'
lcall datw
lcall delay
mov a, #'d'
lcall datw
lcall delay
mov a, #' '
lcall datw
lcall delay
mov a, #'P'
lcall datw
lcall delay
mov a, #'a'
lcall datw
lcall delay
mov a, #'s'
lcall datw
lcall delay
mov a, #'s'
lcall datw
lcall delay
mov a, #'w'
lcall datw
lcall delay
mov a, #'o'
lcall datw
lcall delay
mov a, #'r'
lcall datw
lcall delay
39
mov a, #'d'
lcall datw
lcall delay
smotor: mov r6, #03h
mtrf: mov p0, #09h
lcall delayn
mov p0, #0ch
lcall delayn
mov p0, #06h
lcall delayn
mov p0, #03h
lcall delayn
djnz r6, mtrf
lcall delayb
lcall delayb
lcall delayb
mov r6, #03h
mtrr: mov p0, #03h
lcall delayn
mov p0, #06h
lcall delayn
mov p0, #0ch
lcall delayn
mov p0, #09h
lcall delayn
djnz r6, mtrr
mov p0, #00h
lcall delay
ret
star: mov a, #'*'
lcall datw
lcall delayb
ret
cmdw: mov p1, a
clr p2.3
clr p2.4
40
setb p2.5
lcall delay
clr p2.5
ret
datw: mov p1, a
setb p2.3
clr p2.4
setb p2.5
lcall delay
clr p2.5
ret
delayb: mov r7, #05h
back13:mov r4, #0ffh
back11:mov r5, #0ffh
back12:djnz r5, back12
djnz r4, back11
djnz r7, back13
ret
delay: mov r4, #22h
back1: mov r5, #0ffh
back: djnz r5, back
djnz r4, back1
ret
delayn: mov r4, #0ffh
bac: mov r5, #0ffh
ba: djnz r5, ba
djnz r4, bac
ret
end
5.4 CIRCUIT DIAGRAM
41
Fig-5.3-circuit diagram of password based door locking system
5.5 Applications
Home:
Home security is top priority of all concerned. Today there are plenty of home
security products to ensure your family’s security completely. Home security is the
most significant one for every homeowner either in an individual house or an
apartment. To get the absolute peace of mind whether you are at first time home or
out of home you must ensure that your home is installed with the perfect home
security monitoring system. Home security system using PASSWORD PROTECTED
DOOR LOCKING SYSTEM is the best way to protect your family and your
belongings. People engaged in business and often going on a business or personal trip
is at the maximum need. .
Safes:
42
A security system without a high security safe is not a complete theft prevention
system. Throughout history there has been an enduring need to protect irreplaceable
possessions from theft . In the Middle Ages merchants constructed treasury safes
made of oak conjoined with iron as a repository of security. With technological
advances, today's safes have tempered steel walls with fire-retardant material
interspersed within the walls, affording a deterrent to theft , unimaginable just a
century ago. Only safes can provide a superior level of protection for documents,
jewelry, guns and personal items. A security safe based on PASSWORD
PROTECTED DOOR LOCKING SYSTEM designed for specific needs can meet
the varied necessities of home, business and office requirements. Security safes are
an essential protection against theft.
Vehicles:
Nine-out-of-ten cars are hot-wired and driven away. Mechanical devices such as
steering wheel bars and pedal locks are only a minor inconvenience for the
professional. Although they may work as a deterrent, car alarms can be "hot wired"
around. The professional thief simply cuts or jumps the alarm wires and he is gone.
Tracking devices used by police to locate stolen cars do not STOP the vehicle from
being hot-wired and driven away. They depend on early notification of authorities by
the owner. A car that is taken at 2 a.m. can be dismantled miles away before the
owner even realizes it is gone. Although the PASSWORD PROTECTED DOOR
LOCKING SYSTEM can defeat most tactical attempts made by the thief and can be
regarded as the safest means of security.
5.6 CONCLUSION
PASSWORD PROTECTED DOOR LOCKING SYSTEM is an access control
system that allows only authorized person to access the restricted area. This provides
us with intense safety and security at various levels of livelihood. Some of them
include houses, offices, institutions, car locking system, safes. Some of its important
features are
a) Easily affordable means of security
b) Low power consumption
43
c) Easy to install
d) Easily compatible product.
REFERENCES
1. www.8051projects.net
2. www.datasheet.in
3. www.microchip.com
44
45