Chapter 1: INTRODUCTION: 1.1 Basics of Embedded Systems
Chapter 1: INTRODUCTION: 1.1 Basics of Embedded Systems
Chapter 1: INTRODUCTION: 1.1 Basics of Embedded Systems
Chapter 1: INTRODUCTION
An embedded system can be defined as a computing device that does a specific focused
job. Appliances such as the air-conditioner, VCD player, DVD player, printer, fax machine,
mobile phone etc. are examples of embedded systems. Each of these appliances will have a
processor and special hardware to meet the specific requirement of the application along with
the embedded software that is executed by the processor for meeting that specific
requirement. The embedded software is also called “firm ware”. The desktop/laptop
computer is a general purpose computer. You can use it for a variety of applications such as
playing games, word processing, accounting, software development and so on. In contrast,
the software in the embedded systems is always fixed listed below:
· Some embedded systems have to operate in extreme environmental conditions such as very
high temperatures and humidity.
Applications:
Nearly 99 per cent of the processors manufactured end up in embedded systems. The
embedded system market is one of the highest growth areas as these systems are used in very
market segment- consumer electronics, office automation, industrial automation, biomedical
engineering, wireless communication,
1
Geethanjali College of Engineering & Technology ECE
1.2.1 WHAT IS RF :
Radio frequency (RF) is a frequency or rate of oscillation within the range of about 30kHz to
300 GHz. This range corresponds to frequency of alternating current electrical signals used to
produce and detect radio waves. RF is widely used because it does not require any line of
sight, less distortions and no interference
2
Geethanjali College of Engineering & Technology ECE
s = 300/f
Many types of wireless devices make use of RF fields. Cordless and cellular telephone, radio
and T.V broadcast stations, satellite communications systems, and two-way radio services all
operate in the RF spectrum. Some wireless devices operate at IR or visible-light frequencies,
whose electromagnetic wavelengths are shorter than those of RF fields.
1.2.3 RF Advantages:
3
Geethanjali College of Engineering & Technology ECE
1.2.3 RF Disadvantages:
4
Geethanjali College of Engineering & Technology ECE
5
Geethanjali College of Engineering & Technology ECE
6
Geethanjali College of Engineering & Technology ECE
7
Geethanjali College of Engineering & Technology ECE
2.1 MICROCONTROLLERS
8
Geethanjali College of Engineering & Technology ECE
2.1.2 Description:
The AT89S52 is a low-voltage, high-performance CMOS 8-bit microcomputer with 8K bytes
of Flash programmable memory. The device is manufactured using Atmel’s high-density
nonvolatile memory technology and is compatible with the industry-standard MCS-51
instruction set. By combining a versatile 8-bit CPU with Flash on a monolithic chip, the
Atmel AT89S52 is a powerful microcomputer, which provides a highly flexible and cost-
effective solution to many embedded control applications.
In addition, the AT89S52 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.
9
Geethanjali College of Engineering & Technology ECE
10
Geethanjali College of Engineering & Technology ECE
11
Geethanjali College of Engineering & Technology ECE
Vcc
Pin 40 provides supply voltage to the chip. The voltage source is +5V.
GND
XTAL1 and XTAL2 are the input and output, respectively, of an inverting amplifier that 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.
C1, C2 = 30 pF ± 10 pF for Crystals
= 40 pF ± 10 pF for Ceramic Resonators
RESET
Pin9 is the reset pin. It is an input and is active high. Upon applying a high pulse to this pin,
the microcontroller will reset and terminate all the activities. This is often referred to as a
power-on reset.
EA (External access)
Pin 31 is EA. It is an active low signal. It is an input pin and must be connected to either Vcc
or GND but it cannot be left unconnected.
The 8051 family members all come with on-chip ROM to store programs. In such cases, the
EA pin is connected to Vcc. If the code is stored on an external ROM, the EA pin must be
connected to GND to indicate that the code is stored externally.
PSEN (Program store enable)
This is an output pin.
ALE (Address latch enable)
This is an output pin and is active high.
12
Geethanjali College of Engineering & Technology ECE
Ports 0, 1, 2 and 3
The four ports P0, P1, P2 and P3 each use 8 pins, making them 8-bit ports. All the ports upon
RESET are configured as input, since P0-P3 have value FFH on them.
Port 0(P0)
Port 0 is also designated as AD0-AD7, allowing it to be used for both address and data. ALE
indicates if P0 has address or data. When ALE=0, it provides data D0-D7, but when ALE=1,
it has address A0-A7. Therefore, ALE is used for demultiplexing address and data with the
help of an internal latch.
When there is no external memory connection, the pins of P0 must be connected to a 10K-
ohm pull-up resistor. This is due to the fact that P0 is an open drain. With external pull-up
resistors connected to P0, it can be used as a simple I/O, just like P1 and P2. But the ports P1,
P2 and P3 do not need any pull-up resistors since they already have pull-up resistors
internally. Upon reset, ports P1, P2 and P3 are configured as input ports.
Port 1 and Port 2
With no external memory connection, both P1 and P2 are used as simple I/O. With external
memory connections, port 2 must be used along with P0 to provide the 16-bit address for the
external memory. Port 2 is designated as A8-A15 indicating its dual function. While P0
provides the lower 8 bits via A0-A7, it is the job of P2 to provide bits A8-A15 of the address.
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 port 1 and port 2. Port 3 has an additional function
of providing some extremely important signals such as interrupts.
13
Geethanjali College of Engineering & Technology ECE
The AT89S52 code memory array is programmed byte-byte in either programming mode.
To program any nonblankbyte in the on-chip Flash Memory, the entire memorymust be
erased using the Chip Erase Mode.
Programming Algorithm:
Before programming the AT89S52, the address, data and control signals should be set up
according to the Flash programming mode table. To program the AT89S52, the following
steps should be considered:
14
Geethanjali College of Engineering & Technology ECE
Data Polling:
The AT89S52 features Data Polling to indicate the end of a write cycle. During a write cycle,
an attempted read of the last byte written will result in the complement of the written datum
on PO.7. Once the write cycle has been completed, true data are valid on all outputs, and the
next cycle may begin. Data Polling may begin any time after a write cycle has been initiated.
Ready/Busy:
The progress of byte programming can also be monitored by the RDY/BSY output signal.
P3.4 is pulled low after ALE goes high during programming to indicate BUSY. P3.4 is pulled
high again when programming is done to indicate READY.
Chip Erase:
The entire Flash array is erased electrically by using the proper combination of control
signals and by holding ALE/PROG low for 10 ms. The code array is written with all “1”s.
The chip erase operation must be executed before the code memory can be re-programmed.
Reading the Signature Bytes:
The signature bytes are read by the same procedure as a normal verification of locations
030H, 031H, and 032H, except that P3.6 and P3.7 must be pulled to a logic low. The values
returned are as follows.
(030H) = 1EH indicates manufactured by Atmel
(031H) = 51H indicates 89C51
(032H) = FFH indicates 12V programming
(032H) = 05H indicates 5V programming
15
Geethanjali College of Engineering & Technology ECE
RF Transmitter
RF Receiver
Encoder and Decoder
Figure 6 : RF Transmitter
The STT-433 is ideal for remote control applications where low cost and longer range
is required.
The transmitter operates from 1.5-12V supply, making it ideal for battery-powered
applications.
The transmitter employs a SAW-stabilized oscillator, ensuring accurate frequency
control for best range performance.
16
Geethanjali College of Engineering & Technology ECE
The manufacturing-friendly SIP style package and low-cost make the STT-433
suitable for high volume applications.
2.2.1.2 Features :
2.2.1.4 APPLICATION:
17
Geethanjali College of Engineering & Technology ECE
The typical connection shown in the above figure may not work exactly at all times because
there will be no proper synchronization between the transmitter and the microcontroller unit.
Thus, we need an intermediate device which can accept the input from the microcontroller,
process it in the range of radio frequency range and then send it to the transmitter. Thus, an
encoder is used.The encoder used here is HT640 from HOLTEK SEMICONDUCTORS INC.
18
Geethanjali College of Engineering & Technology ECE
19
Geethanjali College of Engineering & Technology ECE
The 318 (3 power of 18) series of encoders begins a three-word transmission cycle upon
receipt of a transmission enable (TE for the HT600/HT640/HT680 or D12~D17 for the
HT6187/HT6207/HT6247, active high). This cycle will repeat itself as long as the
transmission enable (TE or D12~D17) is held high. Once the transmission enable falls low,
the encoder output completes its final cycle and then stops as shown below.
20
Geethanjali College of Engineering & Technology ECE
The status of each address/data pin can be individually preset to logic high, logic low, or
floating. If a transmission enable signal is applied, the encoder scans and transmits the status
of the 18 bits of address/data serially in the order A0 to AD17.
Transmission enable
For the TE trigger type of encoders, transmission is enabled by applying a high signal to the
TE pin. But for the Data trigger type of encoders, it is enabled by applying a high signal to
one of the data pins D12~D17.
21
Geethanjali College of Engineering & Technology ECE
The graph shown above decides the resistance value to be connected to the oscillator pins of
the encoder. The oscillator resistance will have an effect on startup time and steady state
amplitude. For the data communication at a particular frequency in the RF range, both the
transmitter and receiver should be set to a particular frequency. The exact setting of the
frequency can be obtained in the encoder and decoder circuits. The frequency value can be
set using the graph. The operating voltage of encoder and decoder is 5V. Thus looking at the
graph at 5V VDD, if we select the frequency in the range of 1.25 and 1.50 we are selecting
220k resistance.
22
Geethanjali College of Engineering & Technology ECE
2.2.2.2 Transmission
Circuit :
23
Geethanjali College of Engineering & Technology ECE
encoded and sent to RF transmitter. The data is transmitted on the antenna pin. Thus, this data
should be received on the destination i.e, on RF receiver.
Figure 13 : RF Receiver
2.2.3.1 PINOUT:
2.2.3.2 APPLICATIONS:
24
Geethanjali College of Engineering & Technology ECE
2.2.4 DECODER:
25
Geethanjali College of Engineering & Technology ECE
2.2.4.1 Features :
The 3^18 decoders are a series of CMOS LSIs for remote control system applications.
They are paired with the 3^18 series of encoders.
For proper operation, a pair of encoder/decoder pair with the same number of address
and data format should be selected.
The 3^18 series of decoders receives serial address and data from that series of
encoders that are transmitted by a carrier using an RF medium.
26
Geethanjali College of Engineering & Technology ECE
A signal on the DIN pin then activates the oscillator which in turns decodes the
incoming address and data.
It then compares the serial input data twice continuously with its local address.
If no errors or unmatched codes are encountered, the input data codes are decoded and
then transferred to the output pins.
The VT pin also goes high to indicate a valid transmission. That will last until the
address code is incorrect or no signal has been received.
The 3^18 decoders are capable of decoding 18 bits of information that consists of N
bits of address and 18–N bits of data.
Figure 16 : STR 433 Connections
The data transmitted into the air is received by the receiver. The received data is taken from
the data line of the receiver and is
fed to the decoder .The output of
decoder is given to microcontroller
and then data is processed
according to the applications.
27
Geethanjali College of Engineering & Technology ECE
LCD stands for Liquid Crystal Display. LCD is finding wide spread use replacing LEDs
(seven segment LEDs or other multi segment LEDs) because of the following reasons:
2. The ability to display numbers, characters and graphics. This is in contrast to LEDs,
which are limited to numbers and a few characters.
3. Incorporation of a refreshing controller into the LCD, thereby relieving the CPU of
the task of refreshing the LCD. In contrast, the LED must be refreshed by the CPU to keep
displaying the data.
Figure 18 : LCD
28
Geethanjali College of Engineering & Technology ECE
A model described here is for its low price and great possibilities most frequently used in
practice. It is based on the HD44780 microcontroller (Hitachi) and can display messages in
two lines with 16 characters each . It displays all the alphabets, Greek letters, punctuation
marks, mathematical symbols etc. In addition, it is possible to display symbols that user
makes up on its own. Automatic shifting message on display (shift left and right), appearance
of the pointer, backlight etc. are considered as useful characteristics.
There are pins along one side of the small printed board used for connection to the
microcontroller. There are total of 14 pins marked with numbers (16 in case the background
light is built in). Their function is described in the table below:
Pin Logic
Function Name Description
Number State
Ground 1 Vss - 0V
Power supply 2 Vdd - +5V
Contrast 3 Vee - 0 - Vdd
D0 – D7 are interpreted as
0
4 RS commands
1
D0 – D7 are interpreted as data
0 Write data (from controller to LCD)
Control of 5 R/W
1 Read data (from LCD to controller)
operating
Access to LCD disabled
0
Normal operating
6 E 1
Data/commands are transferred to
From 1 to 0
LCD
7 D0 0/1 Bit 0 LSB
8 D1 0/1 Bit 1
9 D2 0/1 Bit 2
10 D3 0/1 Bit 3
Data / commands
11 D4 0/1 Bit 4
12 D5 0/1 Bit 5
13 D6 0/1 Bit 6
14 D7 0/1 Bit 7 MSB
29
Geethanjali College of Engineering & Technology ECE
All data transferred to LCD through outputs D0-D7 will be interpreted as commands or as
data, which depends on logic state on pin RS: RS = 1 - Bits D0 - D7 are addresses of
characters that should be displayed. Built in processor addresses built in “map of characters”
and displays corresponding symbols. Displaying position is determined by DDRAM address.
This address is either previously defined or the address of previously transferred character is
automatically incremented. RS = 0 - Bits D0 - D7 are commands which determine display
mode. List of commands which LCD recognizes are given in the table below:
R Execution
Command RW D7 D6 D5 D4 D3 D2 D1 D0
S Time
Clear display 0 0 0 0 0 0 0 0 0 1 1.64mS
Cursor home 0 0 0 0 0 0 0 0 1 x 1.64mS
Entry mode set 0 0 0 0 0 0 0 1 I/D S 40uS
Display on/off control 0 0 0 0 0 0 1 D U B 40uS
Cursor/Display Shift 0 0 0 0 0 1 D/C R/L x x 40uS
D
Function set 0 0 0 0 1 N F x x 40uS
L
Set CGRAM address 0 0 0 1 CGRAM address 40uS
Set DDRAM address 0 0 1 DDRAM address 40uS
B
Read “BUSY” flag (BF) 0 1 DDRAM address -
F
Write to CGRAM or
1 0 D7 D6 D5 D4 D3 D2 D1 D0 40uS
DDRAM
Read from CGRAM or
1 1 D7 D6 D5 D4 D3 D2 D1 D0 40uS
DDRAM
30
Geethanjali College of Engineering & Technology ECE
LCD Initialization
Once the power supply is turned on, LCD is automatically cleared. This process lasts for
approximately 15mS. After that, display is ready to operate. The mode of operating is set by
default. This means that:
1. Display is cleared
2. Mode
DL = 1 Communication through 8-bit interface
N = 0 Messages are displayed in one line
F = 0 Character font 5 x 8 dots
3. Display/Cursor on/off
D = 0 Display off
U = 0 Cursor off
B = 0 Cursor blink off
4. Character entry
ID = 1 Addresses on display are automatically incremented by 1
S = 0 Display shift off
Automatic reset is mainly performed without any problems. Mainly but not always! If for any
reason power supply voltage does not reach full value in the course of 10mS, display will
start perform completely unpredictably. If voltage supply unit cannot meet this condition or if
it is needed to provide completely safe operating, the process of initialization by which a new
reset enabling display to operate normally must be applied.
31
Geethanjali College of Engineering & Technology ECE
2.4 KEYPAD:
Keypads and LCDs are the most widely used input/output devices of the 89S52 and a basic
understanding of them is essential. The keypads are mainly three types:
1. 4*3 keypad
2. 4*4 keypad
3. 4*8 keypad.
2.4.1 INTERFACING THE KEYPAD TO 89S52 :
32
Geethanjali College of Engineering & Technology ECE
At the lowest level, keyboards are organized in a matrix of rows and columns. The CPU
accesses both rows and columns through ports. Therefore, with two 8-bit ports, an 8*8 matrix
of keys can be connected to a microprocessor. When a key is pressed, a row and a column
make a contact, otherwise there is no connection between rows and columns. A single
microcontroller (consisting of a microprocessor, RAM, EPROM and several ports all on a
single chip) takes care of hardware and software interfacing of the keypad. In such systems, it
is the function of programs stored in EPROM of the microcontroller to scan the keys
continuously, identify which one has been activated and present it to the motherboard.
The rows are connected to an output port and the columns are connected to an input port. If
no key has been pressed, reading the input port will yield 1s for all columns since they are all
connected to high (Vcc). If all the rows are grounded and a key is pressed, one of the columns
will have 0 since the key pressed provides the path to ground. It is the function of the
microcontroller to scan the keypad continuously to detect and identify the key pressed.
33
Geethanjali College of Engineering & Technology ECE
To detect a pressed key, the microcontroller grounds all rows by providing 0 (zero) to the
output latch, then it reads the columns. If the data read from the columns is D2-D0 =111, no
key has been pressed and the process continues until a key press is detected. However, if one
of the column bits has a zero, this means that a key press has occurred i.e., for example, if
D2-D0=110, this means that a key in the D0 column has been pressed. After a key press is
detected, the microcontroller will go through a process of identifying the key. Starting with
the top row, the microcontroller grounds it by providing a low to row D0 only and then it
reads the columns. If the data read is all 1s, no key in that row is activated and the process is
moved to the next row. It grounds the next row, reads the columns and checks for any zero.
This process continues until the row is identified. After identification of the row in which the
key has been pressed, the next task is to find out which column the pressed key belongs to.
Now this will be easy since the microcontroller knows at any time which row and column are
being accessed.
Encryption is a process of coding information which could either be a file or mail message
in into cipher text a form unreadable without a decoding key in order to prevent anyone
except the intended recipient from reading that data.
Decryption is the reverse process of converting encoded data to its original un-encoded form,
plaintext.
34
Geethanjali College of Engineering & Technology ECE
35
Geethanjali College of Engineering & Technology ECE
converting a plain text message to its cipher text form is called enciphering. Reversing that
act (i.e., cipher text form to plain text message) is deciphering. Enciphering and deciphering
are more commonly referred to as encryption and decryption, respectively.
There are a number of algorithms for performing encryption and decryption, but
comparatively few such algorithms have stood the test of time. The most successful
algorithms use a key. A key is simply a parameter to the algorithm that allows the encryption
and decryption process to occur. There are many modern key-based cryptographic techniques
. These are divided into two classes: symmetric and asymmetric (also called public/private)
key cryptography. In symmetric key cryptography, the same key is used for both encryption
and decryption. In asymmetric key cryptography, one key is used for encryption and another,
mathematically related key, is used for decryption.
Substitution ciphers can be compared with transposition ciphers. In a transposition cipher, the
units of the plaintext are rearranged in a different and usually quite complex order, but the
units themselves are left unchanged. By contrast, in a substitution cipher, the units of the
plaintext are retained in the same sequence in the ciphertext, but the units themselves are
altered.
36
Geethanjali College of Engineering & Technology ECE
Simple substitution
Example:
Using this system, the keyword "zebras" gives us the following alphabets:
A message of
enciphers to
Keil compiler is a software used where the machine language code is written and compiled.
After compilation, the machine source code is converted into hex code which is to be dumped
into the microcontroller for further processing. Keil compiler also supports C language code.
37
Geethanjali College of Engineering & Technology ECE
µVision3 adds many new features to the Editor like Text Templates, Quick Function
Navigation, and Syntax Coloring with brace high lighting Configuration Wizard for dialog
based startup and debugger setup. µVision3 is fully compatible to µVision2 and can be used
in parallel with µVision2.
The programming Language used here in this project is an Embedded C Language. This
Embedded C Language is different from the generic C language in few things like
a) Data types
b) Access over the architecture addresses.
The Embedded C Programming Language forms the user friendly language with access
over Port addresses, SFR Register addresses etc.
38
Geethanjali College of Engineering & Technology ECE
10. When you click on any one of the microcontrollers, the features of that particular
microcontroller will be displayed on the right side of the page. The most appropriate
microcontroller with which most of the projects can be implemented is the AT89C51. Click
on this microcontroller and have a look at its features. Now click on “OK” to select this
microcontroller.
11. A small window opens asking whether to copy the startup code into the file you have
created just now. Just click on “No” to proceed further.
12. Now you can see the TARGET and SOURCE GROUP created in the project
workspace.
13. Now click on “File” and in that “New”. A new page opens and you can start writing
program in it.
14. After the program is completed, save it with any name but with the .asm extension.
Save the program in the file you have created earlier.
15. You can notice that after you save the program, the predefined keywords will be
highlighted in bold letters.
16. Now add this file to the target by giving a right click on the source group. A list of
options open and in that select “Add files to the source group”. Check for this file where you
have saved and add it.
17. Right click on the target and select the first option “Options for target”. A window
opens with different options like device, target, output etc. First click on “target”.
18. Since the set frequency of the microcontroller is 11.0592 MHz to interface with the
PC, just enter this frequency value in the Xtal (MHz) text area and put a tick on the Use on-
chip ROM. This is because the program what we write here in the keil will later be dumped
into the microcontroller and will be stored in the inbuilt ROM in the microcontroller.
19. Now click the option “Output” and give any name to the hex file to be created in the
“Name of executable” text area and put a tick to the “Create HEX file” option present in the
same window. The hex file can be created in any of the drives. You can change the folder by
clicking on “Select folder for Objects”.
20. Now to check whether the program you have written is errorless or not, click on the
icon exactly below the “Open file” icon which is nothing but Build Target icon. You can
even use the shortcut key F7 to compile the program written.
21. To check for the output, there are several windows like serial window, memory
window, project window etc. Depending on the program you have written, select the
appropriate window to see the output by entering into debug mode.
39
Geethanjali College of Engineering & Technology ECE
22. The icon with the letter “d” indicates the debug mode.
23. Click on this icon and now click on the option “View” and select the appropriate
window to check for the output.
24. After this is done, click the icon “debug” again to come out of the debug mode.
25. The hex file created as shown earlier will be dumped into the microcontroller with the
help of another software called Proload.
3.3 PROLOAD:
Proload is a software which accepts only hex files. Once the machine code is converted into
hex code, that hex code has to be dumped into the microcontroller placed in the programmer
kit and this is done by the Proload. Programmer kit contains a microcontroller on it other than
the one which is to be programmed. This microcontroller has a program in it written in such a
way that it accepts the hex file from the keil compiler and dumps this hex file into the
microcontroller which is to be programmed. As this programmer kit requires power supply to
be operated, this power supply is given from the power supply circuit designed above. It
40
Geethanjali College of Engineering & Technology ECE
should be noted that this programmer kit contains a power supply section in the board itself
but in order to switch on that power supply, a source is required. Thus this is accomplished
from the power supply board with an output of 12volts or from an adapter connected to 230
V AC.
4.1 Conclusion
Integrating features of all the hardware components used have developed it.
41
Geethanjali College of Engineering & Technology ECE
Presence of every module has been reasoned out and placed carefully thus
systems in real time, gained knowledge of the practically used components and
troubleshooting of problems
4.3 Bibliography
42
Geethanjali College of Engineering & Technology ECE
GAONKAR
http://www.wikipedia.org/
http://www.8051projects.net/
http://www.ikalogic.com/tut_8051_1_.php
http://www.atmel.com
http://www.keil.com
http://www.scribd.com
43