Chapter 1: INTRODUCTION: 1.1 Basics of Embedded Systems

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 44

Geethanjali College of Engineering & Technology ECE

Chapter 1: INTRODUCTION

1.1 BASICS OF EMBEDDED SYSTEMS

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:

· Embedded systems do a very specific task, they cannot be programmed to do different


things. . Embedded systems have very limited resources, particularly the memory. Generally,
they do not have secondary storage devices such as the CDROM or the floppy disk.
Embedded systems have to work against some deadlines. A specific job has to be completed
within a specific time. In some embedded systems, called real-time systems, the deadlines are
stringent. Missing a deadline may cause a catastrophe-loss of life or damage to property.
Embedded systems are constrained for power. As many embedded systems operate through a
battery, the power consumption has to be very low.

· 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,

data communication, telecommunications, transportation, military and so on.

1
Geethanjali College of Engineering & Technology ECE

1.2 Wireless Communication:

Wireless communication, as the term implies, allows information to be


exchanged between two devices without the use of wire or cable. Changing television
channels, opening and closing a garage door, and transferring a file from one computer to
another can all be accomplished using wireless technology. In all such cases, information is
being transmitted and received using electromagnetic energy, also referred to as
electromagnetic radiation. One of the most familiar sources of electromagnetic radiation is
the sun, other common sources include TV and radio signals, light bulbs and microwaves.

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

Different Ranges present in RF and their applications :

Name Frequency Range Applications


extremely low ELF 3 to 30 10,000 km to directly audible when converted to
frequency Hz k 100,000 km sound, communication with
submarines
Super low SLF 30 to 1,000 km to directly audible when converted to
frequency 300 Hz 10,000 km sound, AC power grids (50 hertz and
60 hertz)
Ultra low ULF 300 to 100 km to directly audible when converted to
frequency 3000 Hz 1,000 km sound, communication with mines
Very low VLF 3 to 30 10km to 100km directly audible when converted to
frequency kHz sound (below ca. 18-20 kHz; or
"ultrasound" 20-30+ kHz)
Low frequency LF 30k to 1 km to 10 km AM broadcasting, navigational
300kHz beacons, lowfrequency
Medium frequency MF 300k to 100 m to 1 km navigational beacons, AM
3000kHz broadcasting, maritime and aviation
communication
High frequency HF 3M to 10 m to 100 m Shortwave, amateur radio, citizens'
30MHz band radio
Very high VHF 30M to 1 m to 10 m FM broadcasting broadcast television,
frequency 300 MHz aviation, GPR
Ultra high UHF 300 to 10 cm to 100 Broadcast television, mobile
frequency 3000 MHz cm telephones, cordless telephones,
wireless networking, remote keyless

2
Geethanjali College of Engineering & Technology ECE

entry for automobiles, microwave


ovens, GPR
Super high SHF 3 to 30 1 cm to 10 cm Wireless networking, satellite links,
frequency GHz microwave links, Satellite television,
(Microwaves) door openers.
Extremely high EHF 30 to 1 mm to 10 mm Microwave data links, radio
frequency 300 GHz astronomy, remote sensing, advanced
(Microwaves) weapons systems, advanced security
scanning
Table 1: Different Ranges present in RF

1.2.2 DESCRIPTION OF RF:

When an RF current is supplied to an antenna, it gives rise to an electromagnetic field that


propagates through space. This field is sometimes called an RF field, in less technical jargon
it is a "radio wave". In the atmosphere or in outer space, if f is the frequency in megahertz
and sis the wavelength in meters, then

s = 300/f

The frequency of an RF signal is inversely proportional to the wavelength of the EM field to


which it corresponds. At 9 kHz, the free-space wavelength is approximately 33 kilometers
(km) or 21 miles (mi). At the highest radio frequencies, the EM wavelengths measure
approximately one millimeter (1 mm). As the frequency is increased beyond that of the RF
spectrum, EM energy takes the form of infrared (IR), visible, ultraviolet (UV), X rays, and
gamma rays.

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:

1. No line of sight is needed.


2. Not blocked by common materials: It can penetrate most solids and pass through
walls.
3. Longer range.

3
Geethanjali College of Engineering & Technology ECE

4. It is not sensitive to the light.


5. It is not much sensitive to the environmental changes and weather conditions.

1.2.3 RF Disadvantages:

1. Interference: communication devices using similar frequencies - wireless phones,


scanners, wrist radios .
2. Lack of security: easier to "eavesdrop" on transmissions since signals are spread out
in space rather than confined to a wire
3. Higher cost than infrared
4. Federal Communications Commission(FCC) licenses required for some products
5. Lower speed: data rate transmission is lower than wired and infrared transmission

4
Geethanjali College of Engineering & Technology ECE

1.3 Block Diagram

Figure 1 : Block diagram of transmitter and receiver

5
Geethanjali College of Engineering & Technology ECE

1.4.1 Schematic of Transmitter

6
Geethanjali College of Engineering & Technology ECE

Figure 2 : Schematic of Transmitter

1.4.2 Schematic of Receiver

7
Geethanjali College of Engineering & Technology ECE

Figure 2 : Schematic of Receiver

Chapter 2: HARDWARE COMPONENTS

2.1 MICROCONTROLLERS

Microprocessors and microcontrollers are widely used in embedded systems products.


Microcontroller is a programmable device. A microcontroller has a CPU in addition to a
fixed amount of RAM, ROM, I/O ports and a timer embedded all on a single chip. The fixed
amount of on-chip ROM, RAM and number of I/O ports in microcontrollers makes them
ideal for many applications in which cost and space are critical.
The Intel 8051 is a Harvard architecture, single chip microcontroller (µC) which was
developed by Intel in 1980 for use in embedded systems. It was popular in the 1980s and
early 1990s, but today it has largely been superseded by a vast range of enhanced devices
with 8051-compatible processor cores that are manufactured by more than 20 independent
manufacturers including Atmel, Infineon Technologies and Maxim Integrated Products.
8051 is an 8-bit processor, meaning that the CPU can work on only 8 bits of data at a
time. Data larger than 8 bits has to be broken into 8-bit pieces to be processed by the CPU.
8051 is available in different memory types such as UV-EPROM, Flash and NV-RAM.
The microcontroller used in this project is AT89S52. Atmel Corporation introduced this
89S52 microcontroller. This microcontroller belongs to 8051 family. This microcontroller
had 128 bytes of RAM, 8K bytes of on-chip ROM, two timers, one serial port and four ports
(each 8-bits wide) all on a single chip. AT89S52 is Flash type 8051.
The present project is implemented on Keil Uvision. In order to program the device, Proload
tool has been used to burn the program onto the microcontroller.
The features, pin description of the microcontroller and the software tools used are discussed
in the following sections.
2.1.1 FEATURES OF AT89S52:

 8K Bytes of Re-programmable Flash Memory.

 RAM is 128 bytes.

 2.7V to 6V Operating Range.

8
Geethanjali College of Engineering & Technology ECE

 Fully Static Operation: 0 Hz to 24 MHz.

 Two-level Program Memory Lock.

 128 x 8-bit Internal RAM.

 32 Programmable I/O Lines.

 Two 16-bit Timer/Counters.

 Six Interrupt Sources.

 Programmable Serial UART Channel.

 Low-power Idle and Power-down Modes.

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

2.1.3 Pin Diagram


Figure 4: Pin Diagram of 89S52

10
Geethanjali College of Engineering & Technology ECE

Figure 5: Block diagram

11
Geethanjali College of Engineering & Technology ECE

2.1.4 PIN DESCRIPTION:

Vcc

Pin 40 provides supply voltage to the chip. The voltage source is +5V.

GND

Pin 20 is the ground.

XTAL1 and XTAL2

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

Table 2 : Port 3 Alternate Functions

2.1.5 PROGRAMMING THE FLASH:


The AT89S52 is normally shipped with the on-chip Flash memory array in the erased state
(that is, contents = FFH) and ready to be programmed. The programming interface accepts
either a high-voltage (12-volt) or a low-voltage (VCC) program enable signal. The low-
voltage programming mode provides a convenient way to program the AT89S52 inside the
user’s system, while the high-voltage programming mode is compatible with conventional
third party Flash or EPROM programmers. The AT89S52 is shipped with either the high-
voltage or low-voltage programming mode enabled. The respective top-side marking and
device signature codes are listed in the following table.

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

1. Input the desired memory location on the address lines.


2. Input the appropriate data byte on the data lines.
3. Activate the correct combination of control signals.
4. Raise EA/VPP to 12V for the high-voltage programming mode.
5. Pulse ALE/PROG once to program a byte in the Flash array or the lock bits. The byte-
write cycle is self-timed and typically takes no more than 1.5 ms.
Repeat steps 1 through 5, changing the address and data for the entire array or until the end of
the object file is reached.

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

2.2 COMMUNICATION USING RF :


Basic components required for RF communication

 RF Transmitter
 RF Receiver
 Encoder and Decoder

2.2.1 RF TRANSMITTER STT-433MHz:

Figure 6 : RF Transmitter

2.2.1.1 ABOUT THE 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 :

 433.92 MHz Frequency


 Low Cost
 1.5-12V operation
 Small size

2.2.1.3 Pin Description:


GND Transmitter ground. Connect to ground plane
DATA Digital data input. This input is CMOS compatible and should be
driven with CMOS level inputs.
VCC Operating voltage for the transmitter. VCC should be bypassed
with a .01uF ceramic capacitor and filtered with a 4.7uF tantalum
capacitor. Noise on the power supply will degrade transmitter
noise performance.
ANTENNA 50 ohm antenna output. The antenna port impedance affects
output power and harmonic emissions. Antenna can be single core
wire of approximately 17cm length or PCBtrace antenna.

Figure 7: RF Transmitter Connections

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.

2.2.2 ENCODER HT640:

18
Geethanjali College of Engineering & Technology ECE

19
Geethanjali College of Engineering & Technology ECE

Table 3: Pinout of HT640

2.2.2.1 WORKING OF ENCODER :

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.

Figure 8 : HT640 Transmission Timing

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.

Figure 9: Connections of HT640

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

Figure 10 : Graph showing Frequency versus Voltage

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

BASIC APPLICATION CIRCUIT OF HT640 ENCODER:

Figure 11: HT640 connections

2.2.2.2 Transmission
Circuit :

The data sent from the


microcontroller is

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 12 :Transmission Circuit

2.2.3 RF RECEIVER STR-433 MHz:

The data is received by the RF receiver


from the antenna pin and this data is
available on the data pins. Two Data
pins are provided in the receiver
module. Thus, this data can be used for
further applications

Figure 13 : RF Receiver

2.2.3.1 PINOUT:

ANTENN Antenna input.


A
GROUND Receiver Ground. Connect to ground plane.
VCC VCC pins are electrically connected and provide operating voltage for the receiver. VCC
can be applied to either or both. VCC should be bypassed with a .1μF ceramic capacitor.
Noise on the power supply will degrade receiver sensitivity.

DATA Digital data output.


This output is capable of driving one TTL or CMOS load. It is a CMOS compatible
output.
Table 4 : Pinout of STR 433

2.2.3.2 APPLICATIONS:

Similarly, as the transmitter requires an encoder, the


receiver module requires a decoder.

24
Geethanjali College of Engineering & Technology ECE

Figure 14 : Receiver circuit

2.2.4 DECODER:

Figure 15 : HT648 Decoder

The decoder used is HT648L from HOLTEK SEMICONDUCTOR INC.

25
Geethanjali College of Engineering & Technology ECE

2.2.4.1 Features :

 Operating voltage: 2.4V~12V.


 Low power and high noise immunity CMOS technology.
 Low standby current.
 Capable of decoding 18 bits of information.
 Pairs with HOLTEK’s 318 series of encoders.
 8~18 address pins.
 0~8 data pins.

2.2.4.2 WORKING OF DECODER :

Table 5 : STR 433 Pinout

 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

2.2.4.3 Receiver circuit :

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

Figure 17 : Receiver Circuit

2.3 LIQUID CRYSTAL DISPLAY:

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:

1. The declining prices of LCDs.

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.

4. Ease of programming for characters and graphics.

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.

2.3.1 Pin Description :

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

Table 6 : LCD pin description

2.3.2 LCD Basic Commands:

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

I/D 1 = Increment (by 1) R/L 1 = Shift right


0 = Decrement (by 1) 0 = Shift left

S 1 = Display shift on DL 1 = 8-bit interface


0 = Display shift off 0 = 4-bit interface

D 1 = Display on N 1 = Display in two lines


0 = Display off 0 = Display in one line

30
Geethanjali College of Engineering & Technology ECE

U 1 = Cursor on F 1 = Character format 5x10 dots


0 = Cursor off 0 = Character format 5x7 dots

B 1 = Cursor blink on D/C 1 = Display shift


0 = Cursor blink off 0 = Cursor shift

Table 7 : LCD Commands

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.3.3 LCD INTERFACING WITH THE MICROCONTROLLER:

Figure 19 : LCD Interfacing

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.

Figure 20 : 4*3 Matrix Keypad Connections to Ports

Scanning and identifying the key:

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.

Grounding rows and reading the columns:

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.

Chapter 3: SOFTWARES USED

3.1 ENCRYPTION AND DECRYPTION ALGORITHM :

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

A key in cryptography is a long sequence of bits used by encryption / decryption algorithms.


For example, the following represents a hypothetical 40-bit key:
00001010 01101001 10011110 00011100 01010101
A given encryption algorithm takes the original message, and a key, and alters the original
message mathematically based on the key's bits to create a new encrypted message. Likewise,
a decryption algorithm takes an encrypted message and restores it to its original form using
one or more keys.
When a user encodes a file, another user cannot decode and read the file without the
decryption key. Adding a digital signature, a form of personal authentication, ensures the
integrity of the original message
“To encode plaintext, an encryption key is used to impose an encryption algorithm onto the
data. To decode cipher, a user must possess the appropriate decryption key. A decryption key
consists of a random string of numbers, from 40 through 2,000 bits in length. The key
imposes a decryption algorithm onto the data. This decryption algorithm reverses the
encryption algorithm, returning the data to plaintext. The longer the encryption key is, the
more difficult it is to decode. For a 40-bit encryption key, over one trillion possible
decryption keys exist.
There are two primary approaches to encryption: symmetric and public-key. Symmetric
encryption is the most common type of encryption and uses the same key for encoding and
decoding data. This key is known as a session key. Public-key encryption uses two different
keys, a public key and a private key. One key encodes the message and the other decodes it.
The public key is widely distributed while the private key is secret.
Aside from key length and encryption approach, other factors and variables impact the
success of a cryptographic system. For example, different cipher modes, in coordination with
initialization vectors and salt values, can be used to modify the encryption method. Cipher
modes define the method in which data is encrypted. The stream cipher mode encodes data
one bit at a time. The block cipher mode encodes data one block at a time. Although block
cipher tends to execute more slowly than stream cipher, block”

BACKGROUND OF ENCRYPTION AND DECRYPTION ALGORITHM


CRYPTOGRAPHY is an algorithmic process of converting a plain text or clear text message
to a cipher text or cipher message based on an algorithm that both the sender and receiver
know, so that the cipher text message can be returned to its original, plain text form. In its
cipher form, a message cannot be read by anyone but the intended receiver. The act of

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.

TYPES OF CRYPTOGRAPHIC ALGORITHMS


There are several ways of classifying cryptographic algorithms. For purposes of this report
they will be categorized based on the number of keys that are employed for encryption and
decryption, and further defined by their application and use. The following are the three types
of Algorithm that are disscused
· Secret Key Cryptography (SKC): Uses a single key for both encryption and decryption
· Public Key Cryptography (PKC): Uses one key for encryption and another for decryption
·Hash Functions: Uses a mathematical transformation to irreversibly "encrypt" information

In cryptography, a substitution cipher is a method of encryption by which units of plaintext


are replaced with ciphertext according to a regular system; the "units" may be single letters
(the most common), pairs of letters, triplets of letters, mixtures of the above, and so forth.
The receiver deciphers the text by performing an inverse substitution.

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

Substitution over a single letter—simple substitution—can be demonstrated by writing out


the alphabet in some order to represent the substitution. This is termed a substitution
alphabet. The cipher alphabet may be shifted or reversed or scrambled in a more complex
fashion, in which case it is called a mixed alphabet or deranged alphabet. Traditionally,
mixed alphabets are created by first writing out a keyword, removing repeated letters in it,
then writing all the remaining letters in the alphabet.

Example:

Using this system, the keyword "zebras" gives us the following alphabets:

Plaintext alphabet: ABCDEFGHIJKLMNOPQRSTUVWXYZ

Ciphertext alphabet: ZEBRASCDFGHIJKLMNOPQTUVWXY

A message of

flee at once. we are discovered!

enciphers to

SIAA ZQ LKBA. VA ZOA RFPBLUAOAR!

3.2 KEIL SOFTWARE:

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.

3.2.1 STEPS TO WRITE AN ASSEMBLY LANGUAGE PROGRAM IN KEIL:

1. Install the Keil Software in the PC in any of the drives.


2. After installation, an icon will be created with the name “Keil uVision3”. Just drag
this icon onto the desktop so that it becomes easy whenever you try to write programs in keil.
3. Double click on this icon to start the keil compiler.
4. A page opens with different options in it showing the project workspace at the
leftmost corner side, output window in the bottom and an ash coloured space for the program
to be written.
5. Now to start using the keil, click on the option “project”.
6. A small window opens showing the options like new project, import project, open
project etc. Click on “New project”.
7. A small window with the title bar “Create new project” opens. The window asks the
user to give the project name with which it should be created and the destination location.
The project can be created in any of the drives available. You can create a new folder and
then a new file or can create directly a new file.
8. After the file is saved in the given destination location, a window opens where a list
of vendors will be displayed and you have to select the device for the target you have created.
9. The most widely used vendor is Atmel. So click on Atmel and now the family of
microcontrollers manufactured by Atmel opens. You can select any one of the
microcontrollers according to the requirement.

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.2.2 Embedded C Data types:

Data Types Size in Bits Data Range/Usage

unsigned char 8-bit 0-255

signed char 8-bit -128 to +127

unsigned int 16-bit 0 to 65535

signed int 16-bit -32,768 to +32,767

sbit 1-bit SFR bit addressable only

bit 1-bit RAM bit addressable only

sfr 8-bit RAM addresses 80-FFH only

Table 8: Embedded C Data types

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.

Chapter 4: FINAL DESCRIPTION

4.1 Conclusion

The project “Wireless Data Encryption and Decryption for Secured

Communication Using RF” has been successfully designed and tested.

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

contributing to the best working of the unit.

This Project helped us to understand and learn the working of embedded

systems in real time, gained knowledge of the practically used components and

troubleshooting of problems

4.2 Future Aspects

 Authentication of the user before the data is transmitted can be done.

 The range can be increased by using gsm technology

 Handshaking signals can be added for confirmation of transmission and


reception.

4.3 Bibliography

4.3.1 Books Referred

 8051 Micro controller and Embedded Systems by MAZDI

42
Geethanjali College of Engineering & Technology ECE

 Micro processor Architecture, Programming & Applications by

GAONKAR

 Electronic Components by D V PRASAD

 Embedded C (Paperback) by Michael J Pont

4.3.2 Website Links

 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

You might also like