Bedi
Bedi
Bedi
1
Preface
This training report is all about the embedded
systems and it application in various fields of real world. We are living in the
Embedded World. We are surrounded with many embedded products and our daily
life largely depends on the proper functioning of these gadgets. Television , Radio,
CD player , Washing Machine or Microwave Oven in our kitchen , Card Readers ,
Access Controllers , Palm devices of our work space enable us to do many of our
tasks very effectively . Apart from all these, many controllers embedded in our car
take care of car operations between the bumpers. All kinds of magazines and journals
regularly dish out details about latest technologies, new devices; fast applications
which make us believe that our basic survival is controlled by these embedded
products. Now we can agree to the fact that these embedded products have
successfully invaded into our world.
2
I. PROFILE OF THE COMPANY-
ATECH
Fateh Technologies is a leading provider of High Quality TELECOM Services and offers world-class
Embedded System Development programs. Employing latest advanced software technologies and
innovations, Fateh offers a variety of products and solutions that allow individuals and businesses
around the world to start a telecom and embedded system business or to expand an existing one.
Company harnesses the unique combinations of Telecom And Embedded Systems expertise which
culminated in evolution of many unique techniques to focus on extended development centre and
turn-key projects. Fateh’s vision of achieving performance excellence and creating standards is
pushing the limits each time and paving way for more exciting things across the nation. The present
projects underway in south zone of India are the minute examples of Fateh's global impact. With its
fast growth in diverse industries viz. Telecom, Embedded system & Software development, it is
moving in the right direction to capture the global market.
With the promise shown already, Fateh Technologies is sure of joining some big names in the market
in its pursuit of excellence in the near future.
I.2 Portfolio
3
I.2.1 Human Resource Development
Fateh Technologies follows a Human Resource Development program, which caters to:
This Centre is responsible for knowledge transfer across project teams. After completion of each
project, the experiences are presented through documents and interactive sessions. This Center also
collects and maintains project data for ready reference and use. The necessary technical literatures are
available with our Learning Centre.
Quality Leadership
The executive management has developed the Vision, Mission, Quality Policy and Quality
Objectives as part of the leadership process.
I.3.1 Vision
I.3.2 Mission
4
Provide dependable services in response to changing needs and to provide value addition in all our
endeavors as well as maintaining high standards of quality.
Fateh Technologies understand and fulfill their customer’s needs, provide responsible solutions.
They support their customers in achieving their overall system goals. They strive for continual
improvement of their processes.
The following are first phase objectives for quality improvement in Fateh Technologies:
• Measure and improve project execution capabilities.
• Prevent defects by process control.
• Follow Plan-Do-Check-Act cycle to improve processes.
I.4 Services
I.4.1 Telecom
5
• Installation, Testing & Commissioning of all ranges of Telecom equipments related to GSM,
CDMA and Wi-Max
• Transportation Carrier-Terrestrial Microwave (SDH / PDH)
• Network Integration
• In-building solutions for wireless networks
• IT Enabled Services
• Electrical Installations
• Entrepreneur Solutions
6
I.5 Embedded System
• Keil compiler
• Assembly Language
• Embedded C
• Micro C
• Microcontroller unit(MCU)
• PC
• Biomedical
• Wireless IR/RF
• OFC
• GSM
• Speech processing
• Image Processing
• Various Displays
7
I.6 Software Development
• Application Development
• Application Migration
• Application Maintenance
• Software Testing
• On Site consulting
• Java
• C/C++
• .Net
• SQL
• PHP
I.6.3 Projects
I.7 Strengths
8
Skilled Manpower available for various projects.
They are well equipped with highly experienced Engineers / Technicians and all necessary tools, test
equipment for execution of various projects and to name
some of them are:
9
II INTRODUCTION
II.1EMBEDDED SYSTEM
Since the embedded system is dedicated to specific tasks, design engineers can optimize it, reducing
the size and cost of the product, or increasing the reliability and performance. Some embedded
systems are mass-produced, benefiting from economies of scale.
Physically, embedded systems range from portable devices such as digital watches and MP4 players,
to large stationary installations like traffic lights, factory controllers, or the systems controlling
nuclear power plants. Complexity varies from low, with a single microcontroller chip, to very high
with multiple units, peripherals and networks mounted inside a large chassis or enclosure.
II.2MICROCONTROLLERS
Circumstances that we find ourselves in today in the field of microcontrollers had their beginnings in
the development of technology of integrated circuits. This development has made it possible to store
hundreds of thousands of transistors into one chip. That was a prerequisite for production of
microprocessors, and the first computers were made by adding external peripherals such as memory,
input-output lines, timers and other. Further increasing of the volume of the package resulted in
creation of integrated circuits. These integrated circuits contained both processor and peripherals.
That is how the first chip containing a microcomputer, or what would later be known as a
microcontroller came about.
II.2.1Definition
10
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.
Assembly language is often used in microcontrollers and since they usually follow RISC architecture,
the instruction set is small. The development package of microcontrollers often includes an
assembler, a simulator, a programmer to "burn" the chip and a demonstration board. Some packages
include a high level language compiler such as a C compiler and more sophisticated libraries.
• A Timer module to allow the microcontroller to perform tasks for certain time periods.
• A serial I/O port to allow data to flow between the microcontroller and other devices such as a PC
or another microcontroller.
• An ADC to allow the microcontroller to accept analogue input data for processing.
11
Figure II.1: Showing a typical microcontroller device and its different subunits
12
• Binary system (base 2)
• Octal system (base 8)
• Hexadecimal system (base 16)
Human beings use decimal & computer use the binary system. The convenient representation of
binary numbers in base 16 is called hexadecimal number system. The base of the decimal number
system is 10 because it has 10 building blocks (i.e. 10 distinct symbols) which are 0, 1, 2, 3, ……..,
9. The base of the binary number system is 2 because there are only two building blocks, 0 and 1,
with which to generate numbers. These two binary digits, 0 and 1, are referred to as bits. The binary
system is used in computers because 1 and 0 represent the two voltage levels (Low level/ Ground
level & High level/ +VCC).The hexadecimal number system has 16 digits. In this system, the first 10
digits, 0 to 9, are the same as in decimal, and for the remaining six digits, the letters A, B, C, D, E, F
are used.
Given Table shows the equivalent binary, decimal and hexadecimal representations for 0 to 15.
13
Figure IV.1
ARITHMETIC
AND
LOGICAL UNIT
ACCUMULATOR
WORKING REGISTERS
PROGRAM STACK
COUNTER POINTER
COUNTER
14
CLOCK INTERRUPT
CIRCUIT CIRCUITS
IV.2.1 Figure shows the block diagram of a typical microcontroller, which is a true computer on a
chip. The design incorporates all of the features found in micro-processor CPU: ALU, PC, SP, and
registers. It also added the other features needed to make a complete computer: ROM, RAM, parallel
I/O, serial I/O, counters, and clock circuit.
CLOCK
CIRCUIT
ALU
PROGRAM COUNTER
15
Figure IV.3:- BLOCK DIAGRAM OF A MICROCONTROLLER
IV.3 COMPARISON
MPU MCU
PIN CONFIGURATIONS
Total pins 40 40
Address pins 16(fixed) 16
Data pins 8(fixed) 8
Interrupt pins 2(fixed) 2
I/O pins 0 32
ARCHITECTURE
8-bit registers 20 34
16-bit registers 4 2
Stack size 64 128
Internal ROM 0 4K
Internal RAM 0 128
External memory 64K 128K
Timers 0 2
Flags 6 4
Figure IV.4
IV.4 VARIOUS MICROCONTROLLERS
16
• Internally PROM (programmable read only memory) is provided so it called one time
programmable (OTP).
The 8051 provides the following standard features: 4Kbytes of ROM, 128 bytes of RAM, 32 I/O
lines, two 16-bit timer/counters, a five vector two-level interrupt architecture, a full duplex serial
port, on-chip oscillator and clock circuitry. In addition, the 8051 is designed with static logic for
operation down to zero frequency and supports two software selectable power saving modes. The
Idle Mode stops the CPU while allowing the RAM, timer/ counters, serial port and
interrupt system to continue functioning. The Power Down Mode saves the RAM contents but
freezes the oscillator disabling all other chip functions until the next hardware reset.
17
IV.7 PIN CONFIGURATION
P1.0 1 40 Vcc
P1.1 2 39 P0.0(AD0)
P1.2 3 38 P0.1(AD1)
P1.3
P1.4
4
5
8051 37
36
P0.2(AD2)
P0.3(AD3)
P1.5 6 (8031) 35 P0.4(AD4)
P1.6 7 ARITHMETIC 34 P0.5(AD5)
P1.7 8 AND 33 P0.6(AD6)
RST 9 LOGICNIT 32 P0.7(AD7)
(RXD)P3.0 10 31 EA/VPP
(TXD)P3.1 11 30 ALE/PROG
(INT0)P3.2 12 29 PSEN
(INT1)P3.3 13 28 P2.7(A15)
(T0)P3.4 14 27 P2.6(A14)
(T1)P3.5 15 26 P2.5(A13)
(WR)P3.6 16 25 P2.4(A12)
(RD)P3.7 17 24 P2.3(A11)
XTAL2 18 23 P2.2(A10)
XTAL1 19 22 P2.1(A9)
GND 20 21 P2.0(A8)
Figure IV.4
• Port 1 -- Port 1 is an 8-bit bi-directional I/O port with internal pull-ups. The Port1 output buffers
can sink/source four TTL inputs. When 1s are written to Port1 pins they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 1 pins that are externally being pulled
18
low will source current (IIL) because of the internal pull-ups. Port1 also receives the low-order
address bytes during ROM programming and verification.
• Port 2 -- Port 2 is an 8-bit bi-directional I/O port with internal pull-ups. The Port2 output buffers
can sink/source four TTL inputs. When 1s are written to Port2 pins they are pulled high by the
internal pull-ups and can be used as inputs. As inputs, Port 2 pins that are externally being pulled
low will source current (IIL) because of the internal pull-ups. Port2 emits the high-order address
byte during fetches from external program memory and during accesses to external data memory
that uses 16-bit addresses (MOVX @ DPTR). In this application it uses strong internal pull-ups
when emitting 1s. During accesses to external data memory that use 8-bit addresses (MOVX @
RI), Port 2 emits the contents of the P2 Special Function Register. Port 2 also receives the high-
order address bits and some control signals during Flash programming and verification.
• Port 3 -- Port 3 is an 8-bit bi-directional I/O port with internal pull-ups. The Port3 output buffers
can sink/source four TTL inputs. When 1s are written to Port3 pins
they are pulled high by the internal pull-ups and can be used as inputs. As inputs, Port 3 pins that are
externally being pulled low will source current (IIL) because of the pull-ups. Port 3 also receives
some control signals for ROM programming and verification. Port 3 also serves the functions of
various special features of the 8051.
• RST -- Reset input. A high on this pin for two machine cycles while the oscillator is
running resets the device.
+Vcc
19
Figure IV.5
• ALE/PROG -- Address Latch Enable 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 ROM
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.
• PSEN -- Program Store Enable is the read strobe to external program memory. When the 8051
is executing code from external program memory, PSEN is activated twice each machine
cycle, except that two PSEN activation’s are skipped during each access to external data
memory.
• EA/VPP-- 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
20
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, for parts that
require12-volt VPP.
• XTAL1—Input to the inverting oscillator amplifier and input to the internal clock operating
circuit.
XTAL2-- Output from the inverting oscillator amplifier.
IV.8.1 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.
Figure IV.6
First models from 8051 family lacked the internal program memory, but it could be added externally
in a form of a separate chip. These MCU’s can be recognized by their mark which begins with 803
(e.g. 8031 or 8032). New models have built-in ROM, although there are substantial variations. With
some models internal memory cannot be programmed directly by the user. Instead, the user needs to
precede the program to the manufacturer, so that the MCU can be programmed (masked)
appropriately in the process of fabrication. Obviously, this option is cost-effective only for large
series. Fortunately, there are MCU models ideal for experimentation and small specialized series.
21
Many manufacturers deliver controllers that can be programmed directly by the user. These come in a
ceramic case with an opening (EPROM version) or in a plastic case without an opening (EEPROM
version). This book deals with one of the latter models that can be programmed via simple
programmer, even if the chip has already been mounted to the designated device.
As previously stated, RAM is used for storing temporary data and auxiliary results generated during
the runtime. Apart from that, RAM comprises a number of registers: hardware counters and timers,
I/O ports, buffer for serial connection, etc. With older versions, RAM spanned 256 locations, while
new models feature additional 128 registers. First 256 memory locations form the basis of RAM
(addresses 0 – FFh) of every 8051 MCU. Locations that are available to the user span addresses from
0 to 7Fh, i.e. first 128 registers, and this part of RAM is split into several blocks as can be seen in the
following image.
Figure IV.7
IV.10.1 First block comprises 4 "banks" of 8 registers each, marked as R0 - R7. To address these, the
parent bank has to be selected.
IV.10.2 Second memory block (range 20h – 2Fh) is bit-addressable, meaning that every belonging bit
has its own address (0 to 7Fh). Since the block comprises 16 of these registers, there is a total of 128
addressable bits. (Bit 0 of byte 20h has bit address 0, while bit 7 of byte 2Fh has bit address 7Fh).
IV.10.3 Third is the group of available registers at addresses 2Fh-7Fh (total of 80 locations)
without special features or a preset purpose.
22
IV.11 EXTRA MEMORY BLOCK
To satisfy the programmers' ever-increasing demands for RAM, latest 8051 models were added an
extra memory block of 128 locations. But it is not all that simple. The problem lies in the
fact that the electronics which addresses RAM employs 1 byte (8 bits), reaching only the
first 256 locations. Therefore, a little trick had to be applied in order to keep the existing
8-bit architecture for the sake of compatibility with older models. The idea is to make
the additional memory block share the addresses with the existent locations intended
for SFR registers (80h - FFh). For distinguishing these two physically separate
memory areas, different methods of addressing are used: if SFR registers are in
question, direct addressing is used; for extra RAM locations, indirect addressing is
used.
23
IV.12 THE PROGRAM STATUS WORD (PSW) SF REGISTER
Figure IV.9
24
IV.13 THE SPECIAL FUNCTION REGISTERS
The 8051 operations that do not use the internal 128-byte Ram addresses from 00h to 7Fh
are done by a group of specific internal register, each called a special function register
(SFR).
[ TIMER1 ][ TIMER0 ]
25
BIT SYMBOL FUNCTION
Figure IV.10
TMOD is not bit addressable.
IV.15.1 POWER SUPPLY (+5V)
Power supplies are designed to convert high voltage AC mains electricity to a suitable low voltage
supply for electronics circuits and other devices. A power supply can by broken down into a
series of blocks, each of which performs a particular function.
Figure IV.17
IV.15.2 TRANSFORMER
Transformers convert AC electricity from one voltage to another with little loss of power.
Transformers work only with AC and this is one of the reasons why mains electricity is AC.
The two types of transformers
• Step-up transformers increase voltage,
• Step-down transformers reduce voltage.
26
Transformer
Figure IV.18
Most power supplies use a step-down transformer to reduce the dangerously high mains
voltage (230V in UK) to a safer low voltage. The input coil is called the primary and the
output coil is called the secondary. There is no electrical connection between the two
coils, instead they are linked by an alternating magnetic field created in the soft-iron core of
the transformer. The two lines in the middle of the circuit symbol represent the core.
Transformers waste very little power so the power out is (almost) equal to the power in. Note that as
voltage is stepped down current is stepped up. The 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.
Turns ratio = Vp = Np
Vs Ns
Vs × Is = Vp × Ip
Where
27
Is = secondary (output) current
Vs = secondary (output) voltage
IV.15.3 BRIDGE RECTIFIER
A bridge rectifier can be made using four individual diodes, but it is also available in special
packages containing the four diodes required. It is called a full-wave rectifier because it uses all the
AC wave (both positive and negative sections). 1.4V is used up in the bridge rectifier because each
diode uses 0.7V when conducting and there are always two diodes conducting, as shown in the
diagram below. Bridge rectifiers are rated by the maximum current they can pass and the maximum
reverse voltage
they can withstand (this must be at least three times the supply RMS voltage so
the rectifier can withstand the peak voltages). In this alternate pairs of diodes conduct, changing over
the connections so the alternating directions of AC are converted to the one direction of DC.
IV.15.4 SMOOTHING
Smoothing is performed by a large value electrolytic capacitor connected across the DC supply to
act as a reservoir, supplying current to the output when the varying DC voltage from the rectifier
is falling. The diagram shows the unsmoothed varying DC (dotted line) and the smoothed DC (solid
line). The capacitor charges quickly near the peak of the varying DC, and then discharges as it
supplies current to the output.
28
Figure IV.20
Note that smoothing significantly increases the average DC voltage to almost the
peak value (1.4 × RMS value). For example 6V RMS AC is rectified to full wave
DC of about 4.6V RMS (1.4V is lost in the bridge rectifier), with smoothing this increases to
almost the peak value giving 1.4 × 4.6 = 6.4V smooth DC.
Smoothing is not perfect due to the capacitor voltage falling a little as it discharges, giving a small
ripple voltage. For many circuits a ripple which is 10% of the supply voltage is satisfactory and the
equation below gives the required value for the smoothing capacitor. A larger capacitor will give
fewer ripples. The capacitor value must be doubled when smoothing half-wave DC.
Smoothing capacitor for 10% ripple, C = 5 × Io
Vs × f
Where
IV.15.5 REGULATOR
Figure IV.21
Voltage regulator ICs are available with fixed (typically 5, 12 and 15V) or variable output voltages.
They are also rated by the maximum current they can pass. Negative voltage regulators are available,
29
mainly for use in dual supplies. Most regulators include some automatic protection from excessive
current (‘overload protection')
and overheating (‘thermal protection'). Many of the fixed voltage regulator ICs has 3 leads and look
like power transistors, such as the 7805 +5V 1A regulator shown on the right. They include a hole for
attaching a heat sink if necessary.
Figure IV.22
The low voltage AC output is suitable for lamps, heaters and special AC motors. It is not suitable for
electronic circuits unless they include a rectifier and a smoothing capacitor.
• Transformer + Rectifier
Figure IV.23
The varying DC output is suitable for lamps, heaters and standard motors. It is not suitable for
electronic circuits unless they include a smoothing capacitor.
30
Figure IV.24
The smooth DC output has a small ripple. It is suitable for most electronic circuits.
D 1 L M 7 8 0 5
1 N 4 0 0 7 + 5 V
1 2
V I NV O U T
GND
J 1 D 2 1 0 0 0 u f
3
2 g n d C 1
3
1 V
D 3
D 4
Figure IV.25
The regulated DC output is very smooth with no ripple. It is suitable for all electronic circuits.
31
An interface is a set of commands or menus through which a user Communicates with a
program. A command-driven interface is one in which you enter commands. A menu-driven
interface is one in which you select command choices from various menus displayed on the screen.
IV.16.2 INTERFACING
Interfacing is a common term for a variety of materials used on the unseen or "wrong" side of fabrics
in sewing. Interfacings can be used to stiffen or add body to fabric, such as the interfacing used
in shirt collars; to strengthen a certain area of the fabric, for instance where buttonholes will be
sewn; or to keep fabrics, particularly knit fabrics, from stretching out of shape. Interfacings come
in a variety of weights and stiffnesses to suit different purposes.
32
user interface design.
Optimized User Interface Design requires a systematic approach to the
design process. But, to ensure optimum performance, Usability testing is required. This
empirical testing permits naïve users to provide data about what does work as anticipated and
what does not work. Only after the resulting repairs are made can a product be deemed to
have a user optimized interface. The importance of good User Interface Design can be the
difference between product acceptance and rejection in the marketplace. If end-users feel it is
not easy to learn, not easy to use, or too cumbersome, an otherwise excellent product could fail.
Good User Interface Design can make a product easy to understand and use, which results in
greater user acceptance.
2. Input Unit
In input unit, we have used the device SWITCH in two ways as follows
(i) switch in push position
(ii) switch in release position
So after studying about the interfacing and user interface units we were given the first minor
project on “USER INTERFACE”.
IV.16.4 LIGHT-EMITTING DIODE (LED)
The best known of all the photo electronic
devices is the so called LED (Light-emitting diode), which emits a fairly narrow bandwidth of visible
or invisible light when its internal diode junction is stimulated by a forward electric current / voltage
(power). A cross-sectional view of a typically diffused LED is shown.
EMITTED LIGHT
EPITAXIAL -
N-TYPE
33
GOLD FILM CATHODE
CONNECTION
LED
Figure IV.26
The semiconductor material used is gallium arsenide (GaAs), gallium arsenide phosphide
(GaAsP), or gallium phosphide (GaP). An N-type epitaxial layer is grown upon a substrate, and
the P-region is produced by diffusion. Recombination of charge carriers occur in the P-region so
this region is required to be kept at the top. Thus, the p-region becomes the device surface. Figure
shows a circuit symbol for a LED. The arrow indicate radiation emitted by the diode.
ANODE CATHODE
SYMBOL
Figure IV.27
• OPERATION
The operation of light-emitting diode (LED) is based on the phenomenon of electro-luminance,
which is the emission of light from a semiconductor under the influence of an electrical field. The
recombination of charge carriers take place in a forward P-N junction as the electrons cross from
the N-region and recombine with holes exiting in the P-region. Typically, these electrons give up
energy in the form of heat and light.
• 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, as illustrated.
a
b C O M M O N A N O D E
c
d
e
f
g
34
Figure IV.27
a
b
c
d
e
f
C O M M O N g
C A T H O D E
• DRAWBACK
The drawback of LEDs is that over-voltage may damage them.
f b
g
e c
d
35
The segments are conventionally notated from a to g in the as shown and It is possible to make
them display any numeral from 0 to 9 or any alphabetic characters from A to F by activating
these segments in different combinations as illustrated in Truth Table given.
TRUTH TABLE
√ √ √ √ √ √
√ √
√ √ √ √ √
√ √ √ √ √
√ √ √ √
√ √ √ √ √
√ √ √ √ √ √
√ √ √
√ √ √ √ √ √ √
√ √ √ √ √
√ √ √ √ √ √
√ √ √ √ √
√ √ √ √
√ √ √ √ √
√ √ √ √ √ 36
Figure IV.30
Liquid crystal displays (LCD) are widely used in recent years as compares to LEDs. This is due to
the declining prices of LCD, the ability to display numbers, characters and graphics, incorporation of
a refreshing controller into the LCD, their by relieving the CPU of the task of refreshing the LCD and
also the ease of programming for characters and graphics. HD 44780 based LCDs are most
commonly used.
The LCD discuss in this section has the most common connector used for the Hitachi 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.
37
1 6 G n d
1 6 1 5
1 5 V c c
1 4 D 7
1 4 1 3
1 3 D 6
1 2 D 5
1 2 1 1
1 1 D 4
1 0 D 3
1 0 9
9 D 2
8 D 1
8 7
7 D 0
6 E
3
6 5
5 R / W
4 R S
4 3
3 C o n t r a 2s t
2 V c c
2 1
1 G n d
1
Figure IV.32
• 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.
• 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.
• 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.
38
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 =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.
The LCD, which is used as a display in the system, is LMB162A. The main features of this LCD are:
16*2 display, intelligent LCD, used for alphanumeric characters & based on ASCII codes. This LCD
contains 16 pins, in which 8 pins are used as 8-bit data I/O, which are extended ASCII. Three pins
are used as control lines these are Read/Write pin, Enable pin and Register select pin. Two pins are
used for Backlight and LCD voltage, another two pins are for Backlight & LCD ground and one pin
is used for contrast change.
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.1ms
for clearing the display or moving the cursor/display to the "home position", 160µs for all other
commands) and also the application software is simpler,
it also frees up a 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 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")
39
VCC VCC
31
EA/VPP 33pF 22uF
30 9
ALE/PROG RST 18 33pF
29 XTAL2 19
8.2 K
PSEN XTAL1 16
16
AT89C51
17 8 15
VCC 15
16 P3.7/RD P1.7 7 14
P3.6/WR P1.6 13 14
15 6 13
14 P3.5/T1 P1.5 5 12
P3.4/TO P1.4 11 12
13 4 11
12 P3.3/INT1 P1.3 3 10
9
P3.2/INTO P1.2 10
9
11 2 8
10 P3.1/TXD P1.1 1 7 8
P3.0/RXD P1.0 6 7
28 32 5 6
27 P2.7/A15 P0.7/AD7 33 4 5
26 P2.6/A14 P0.6/AD6 34 3 4
25 P2.5/A13 P0.5/AD5 35 2 3
24 P2.4/A12 P0.4/AD4 36 1 2
23 P2.3/A11 P0.3/AD3 37 1
22 P2.2/A10 P0.2/AD2 38
21 P2.1/A9 P0.1/AD1 39
P2.0/A8 P0.0/AD0
3 1
VCC
VCC
A stepper motor is a widely used devicethat translates electrical pulses into mechanical movement. In
applications such as disk drives, dot matrix printers, and robotics the stepper motor is used for
positioning control. Every stepper motor has a permanent magnet rotor(also called the shaft)
surrounded by a stator. The most common stepper motors have 4 stator windings that are paired with
a centre-tapped common. This type of stepper motor is commonly referred to as four phased stepper
motor. The centre tap allows a change of current directionin each of two coils when a winding is
grounded, thereby resulting in a polarity changeof the stator. Notice that a conventional motor shaft
runs freely, the stepper motor shaft moves in a fixed repeatable incrementwhich allows one to move
it to a precise position. This repeatable fixed movement is possible as a result of basic magnetic
theorywhere poles of the same polarity repel and opposite poles attract. The direction of rotation is
directed by the stator poles. The stator poles are determined by the current sent through the wire
coils. As the direction of the current is changed, the polarity is also changedcausing the reverse
motion of the rotor.The stepper motor discussed here has a total of 6 leads.As the sequense of power
is applied to each stator winding the rotor will rotate.
41
IV.19.1 VARIOUS TERMS OF STEPPER MOTOR STEP ANGLE
How much movement is associated with a single step, this depends on the internal construction of the
motor, in particular the number of teeth on the stator and the rotor. The step angle is the minimum
degree of rotation associated with a single step. Various motors has different step angles.
42
• Embedded C Language
43
2. Name the project ‘amrit.a51’
3. Click on the Save Button.
44
7. Scroll down and select the AT89C51 Part
8. Click OK
45
Creating Source File
46
o write any code on this file.
47
5. Name the file with extension (.asm for assembly language code & .c for embedded
C language code).
6. Click the Save Button
48
2. Click on Project and select Targets, Groups, Files…
49
3. Click on Groups/Add Files tab
4. Under Available Groups select Source Group 1
5. Click Add Files to Group… button
50
6. Change file type to Asm Source file(*.a*; *.src)
7. Click on toggle.a51
8. Click Add button
9. Click Close Button
10. Click OK button when you return to Target, Groups, Files… dialog box.
51
11. Expand the Source Group 1 in the Tree menu to ensure that the file was added to
the project.
52
3. Select Target Tab
4. Change Xtal (Mhz) from 50.0 to 11.0592
53
5. Select Output Tab
6. Click on Create Hex File check box
7. Click OK Button
54
55