Professional Documents
Culture Documents
1
Aim : Study of the Embedded system Hardware Components
Description :
1.
1.
Hardware
2.
Software
3.
Mechanical Components
And it is supposed to do one specific task only.
The hardware could be a part of Input, output or both usually and includes
buttons, display, LEDs, sensors, actuators and other electronic circuitry.
4.
2.
Software: It has a chip on the circuit that holds the software which
drives controls & monitors the various operations possible.
3.
4.
1.
2.
Software: It has a chip on the circuit that holds the software which drives
controls & monitors the various operations possible. The software monitors the
external temperature through the sensors and then releases the coolant or
suppresses it.
3.
Page No : _____
In this practical we review some hardware components that are used in embedded
systems.
Page No : _____
1. Microcontroller/Microprocessors
1.
2.
3.
A microcontroller is a highly integrated chip that contains a CPU, scratch pad RAM,
special and general purpose register arrays,on chip ROM/FLASH memory for program
storage , timer and interrupt control units and dedicated I/O ports.
4.
5.
The Intel 8051 microcontroller is one of the most popular general purpose
microcontrollers in use today. The success of the Intel 8051 spawned a number of clones
(also called derivatives) which are collectively referred to as the MCS-51 family of
microcontrollers, which includes chips from vendors such as Atmel, Philips, Infineon,
and Texas Instruments.
6. 8051 Variants
1.
The 8051 has the widest range of variants of any embedded controller in the market.
2.
The smallest device is the Atmel 89c1051, a 20 pin flash variant with 2 timers, UART,
20mA.
3.
The fastest parts are from Dallas, with performance close to 10 MIPS.
4.
The most powerful chip is the Siemens 80C517A, with 32-bit ALU, 2 UARTs, 2K RAM,
PLCC84 package, 816 bit PWMs and other features.
ROM [ bytes]
4K
RAM [bytes]
128
Timers
Page No :
1.
2.
32
Serial port
Interrupt sources
The 8051 is the original member of the MCS-51 family, and is the core for all MCS-51 devices.
The features of the 8051 core are1.
2.
3.
4.
5.
6.
7.
8.
9.
2.
3.
10.
11.
12.
13.
14.
Thirty two I/O pins arranged as four 8-bit ports P0, P1,P2 and P3 addressed as PX.0PX.7.
15.
Page No :
16.
17.
Page No :
Page No :
Page No :
Page No :
1.
2.
3.
Page No :
4. Capacitors:
1. A capacitor (originally known as a condenser) is a passive two-terminal electrical
component used to store energy electrostatically in an electric field. The forms of
practical capacitors vary widely, but all contain at least two electrical
conductors (plates) separated by adielectric (i.e. insulator).
2. When there is a potential difference across the conductors (e.g., when a capacitor is
attached across a battery), an electric field develops across the dielectric, causing
positive charge +Q to collect on one plate and negative charge Q to collect on the
other plate.
3. Capacitors are widely used in electronic circuits for blocking direct current while
allowing alternating current to pass. In analog filter networks, they smooth the output
of power supplies. In resonant circuits they tune radios to particular frequencies.
In electric power transmission systems, they stabilize voltage and power flow.
4.
Inductors:
1.
2.
Page No :
3.
LEDs/Displays
1.
2.
An LED is often small in area (less than 1 mm2) and integrated optical components may be used
to shape its radiation pattern.
1.
Alphanumeric displays are available in seven-segment, starburst and dot-matrix format. Sevensegment displays handle all numbers and a limited set of letters. Starburst displays can display
all letters. Dot-matrix displays typically use 5x7 pixels per character
A 16 x 2 lcd display
Page No :
2.
1.
Diodes
2.
3.
Transistors
1.
A transistor is a semiconductor device used to amplify and switch electronic signals and
electrical power.
It is composed of semiconductor material with at least three terminals for connection to
an external circuit.
A voltage or current applied to one pair of the transistor's terminals changes the current
through another pair of terminals. Because the controlled (output) power can be higher
than the controlling (input) power, a transistor can amplify a signal.
2.
3.
Page No :
4.
Sensors
1.
2.
3.
5.
Actuators
1.
2.
Page No :
6.
Crystal oscillator
1.
2.
3.
7.
Operational Amplifiers:
8.
An operational
amplifier (op-amp)
is
a DC-coupled high-gain
electronic
voltage amplifier with a differential input and, usually, a single-ended output.
In this configuration, an op-amp produces an output potential (relative to circuit ground)
that is typically hundreds of thousands of times larger than the potential difference
between its input terminals.
9.
Page No :
Page No :
10.
ADC, DAC
1.
2.
3.
Conclusion: The practical of the study of the Embedded System hardware components
is successfully completed.
Page No :
PRACTICAL NO: 2
1.
1.
2.
Write the code using and IDE and generate the hex file.
3.
Give the hex file as input to the Designed circuit and execute.
2.
1.
2.
Delay();
3.
4.
Delay();
5.
Repeat step 1
1.
// all leds ON
// wait for some time
// all leds OFF
// wait for some time
alternatively
Page No :
COMPONENTS
CRYSTAL
LED-BIBY
RESISTOR
CAPACITOR
MICROCONTROLLER
Design:
Page No :
Code:
#include <reg51.h>
void delay();
void main()
{
P1=0;
while(1)
{
P1 = 0x00;
delay();
P1 = 0xFF;
delay();
}
}
void delay()
{
unsigned int i,j,k;
for(i=0; i < 6; i++ )
{
for(j=0;j<250;j++)
{
for(k=0;k<250;k++);
}
}
}
Page No :
Page No :
2.
3.
Create a new file by pressing Ctrl + N, type the code and save it with a name
blinkingled.c
Right click on the Source Group 1 and select Add Files to Group Source Group 1.
Page No :
4.
Go the Project ->Options for Target Target 1. In the Target tab, change the
Xtal(mhz): 11.059
Click the Output tab on top and Select the create HEX file option
Page No :
In the design page, right click on the micro controller and select Edit properties. In
the Edit Component window under the program file option, browse and add the hex file
of the code. blinking led.hex
2.
Page No :
OUTPUT
Page No :
PRACTICAL NO : 3
Description:
3.
4.
For the output to be displayed we have setup another serial port and
established a virtual connection between these two virtual serial ports
using a third party software Virtual Serial Port driver. This enables to
send the data from our micro controller via serial port and receive
the same in the simulated environment to view the output
MAX232
1.
2.
Page No :
3.
creates virtual serial ports and connects them in pairs via virtual null
modem cable. Applications on both ends of the pair will be able to
exchange data in such a way, that everything written to the first port
will appear in the second one and backwards.
5.
All virtual serial ports work and behave exactly like real ones,
emulating all their settings. We can create as many virtual port pairs
as you want, so there will be no serial ports shortage and no
additional hardware crowding your desk.
Page No :
COMPONENTS:
1.
2.
CAPACITORS
3.
1.
C1:33PF
2.
C2:33PF
3.
C3:1UF
4.
C4:10UF
5.
C5:10UF
6.
C6:10UF
7.
C7:10UF
8.
C8:10UF
9.
C9:10UF
COMPIM1, COMPIM2
1.
2.
4.
CRYSTAL:11.059MhZ
5.
MAX232
6.
RESISTORS: R1 10K
7.
Page No :
DESIGN:
TRANSMITTER
RECEIVER
Page No :
CODE:
#include<REG51.H>
#include<stdio.h>
void serial_init(void);
void main(void)
{
serial_init();
while(1)
{
printf("hello world!! \n\r");
}
}
void serial_init(void)
{
SCON=0x50;
TMOD=0x20;
TH1=0xFD;
TR1=1;
TI=1;
}
Diagram for Virtual Serial Port Driver Configuration
Page No :
OUTPUT:
Page No :
Practical No 4
Description:
In this practical we interface a 4 x 4 keypad and and LCD panel to a
microcontroller.
The keys pressed on the keypad have to be displayed on the LCD panel.
We have created a 4x4 keypad using push buttons, also we could use a 4x4 keypad
that is available under the components library.
We will use a 16 x 2 LCD panel for display purpose which is LM016L
The LCD can be used in 2 modes 8 bit mode and 4 bit mode.
Before using the LCD for display purpose, LCD has to be initialized. The LCD is
initialized in the following sequence.
1.
2.
Delay 20ms
3.
4.
Delay 20ms
5.
6.
Delay 20ms
7.
8.
9.
The first 3 commands are usually not required but are recommended when you
are using 4-bit interface
Page No :
Page No :
Pin Configuration:
Pin
No
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Function
Name
Ground (0V)
Supply voltage; 5V (4.7V 5.3V)
Contrast adjustment; through a variable resistor
Selects command register when low; and data register when high
0 = Instruction input , 1 = Data input
Low to write to the register; High to read from the register
0 = Write to LCD Module, 1 = Read from LCD module
Sends data to data pins when a high to low pulse is given
Vss
VDD
VEE
Register
Select(RS)
Read/write (RW)
Enable (E)
DB0
DB1
DB2
DB3
DB4
DB5
DB6
DB7
Led+
Led
LCD Memory
LCD display contains three memory blocks:
1.
DDRAM Display Data RAM;
2.
CGRAM Character Generator RAM; and
3.
CGROM Character Generator ROM.
DDRAM Memory
1.
DDRAM memory is used for storing characters to be displayed. The size of this memory
is capable of storing 80 characters. Some memory locations are directly connected to the
characters on display.
Page No :
2.
3.
4.
RS
RW
D7
D6
D5
D4
D3
D2
D1
D0
EXECUTION
TIME
Clear display
1.64mS
Cursor home
1.64mS
I/D
40uS
40uS
Cursor/Display Shift
D/C
R/L
40uS
Function set
DL
40uS
DDRAM address
40uS
BF
DDRAM address
Write to CGRAM or
DDRAM
D7
D6
D5
D4
D3
D2
D1
D0
40uS
D7
D6
D5
D4
D3
D2
D1
D0
40uS
CGRAM address
40uS
Page No :
I/D
1 = Increment (by 1)
0 = Decrement (by 1)
S
1 = Display shift on
R/L
1 = Shift right
0 = Shift left
DL
1 = 8-bit interface
0 = 4-bit interface
D
1 = Display on
0 = Display off
N
1 = Display in two lines
0 = Display in one line
U
1 = Cursor on
0 = Cursor off
F
1 = Character format 5x10 dots
0 = Character format 5x7 dots
B
1 = Cursor blink on
0 = Cursor blink off
D/C
1 = Display shift
0 = Cursor shift
THE BUSY FLAG: Compared to the microcontroller, the LCD is an extremely slow
component. For this reason, it is necessary to provide a signal which would, upon command
execution, indicate that the display is ready for the next piece of data. That signal, called the busy
flag, can be read from the line D7. The display is ready to receive new data when the voltage on
this line is 0V (BF=0).
LCD
Entry
mode
Two
bits
decide
the
entry
mode
for
LCD,
these
bits
are:
a)
I/D
Increment/Decrement
bit
b)
S
Display
shift.
With these two bits we get four combinations of entry mode which are 0x04,0x05,0x06,0x07
(see table 3 in LCD Command section). So we get different results with these different entry
modes. Normally entry mode 0x06 is used which is No shift and auto incremement. I
recommend you to try all the possible entry modes and see the results, I am sure you will be
surprised.
COMPONENTS:
1. AT89C51:11.059MHz
2. BUTTON
3. CAPACITOR
1. C1:33pf
2. C2:33pf
3. C3:1uf
4. CRYSTAL:11.059MHz
5. LED-BLUE
6. LM016L
Embedded Systems Journal
Page No :
DESIGN
Page No :
CODE:
#include<reg51.h>
void cct_init(void);
void delay(int);
void lcdinit(void);
void writecmd(int);
void writedata(char);
void Return(void);
char READ_SWITCHES(void);
char get_key(void);
sbit RowA = P1^0;
sbit RowB = P1^1;
sbit RowC = P1^2;
sbit RowD = P1^3;
sbit C1
sbit C2
sbit C3
sbit C4
= P1^4;
= P1^5;
= P1^6;
= P1^7;
//RowA
//RowB
//RowC
//RowD
//Column1
//Column2
//Column3
//Column4
while(1)
{
key = get_key();
writecmd(0x01);
writedata(key);
}
}
void cct_init(void)
{
P0 = 0x00;
P1 = 0xf0;
P2 = 0x00;
P3 = 0x00;
}
//not used
//used for generating outputs and taking inputs from Keypad
//used as data port for LCD
//used for RS and E
Page No :
void delay(int a)
{
int i;
for(i=0;i<a;i++); //null statement
}
void writedata(char t)
{
RS = 1;
P2 = t;
E = 1;
delay(150);
E = 0;
delay(150);
}
void writecmd(int z)
{
RS = 0;
// This is command mode
P2 = z;
//Data transfer
E = 1;
// => E = 1
delay(150);
E = 0;
// => E = 0
delay(150);
}
void lcdinit(void)
{
delay(15000);
writecmd(0x30);
delay(4500);
writecmd(0x30);
delay(300);
writecmd(0x30);
delay(650);
writecmd(0x38);
writecmd(0x0c);
writecmd(0x01);
writecmd(0x06);
//function set
//display on,cursor off,blink off
//clear display
//entry mode, set increment
}
void Return(void) //Return to 0 location on LCD
{
writecmd(0x02);
Embedded Systems Journal
Page No :
delay(1500);
}
char READ_SWITCHES(void)
{
RowA = 0; RowB = 1; RowC = 1; RowD = 1;
//Test Row A
//Test Row B
//Test Row C
//Test Row D
}
char get_key(void)
//get key from user
{
char key = 'n';
//assume no key pressed
while(key=='n')
//wait untill a key is pressed
key = READ_SWITCHES(); //scan the keys again and again
return key;
//when key pressed then return its value
}
Page No :
Output:
Conclusion: The practical for LCD & Keypad interfacing is successfully completed.
Page No :
PRACTICAL NO : 5
Description:
Embedded Systems Journal
Page No :
corresponding
to
5V
reference
an
external clock to operate unlike ADC0804 which has an internal clock. The
ADC needs some specific control signals for its operations like start
conversion and bring data to output pins. When the conversion is complete
the EOC pins goes low to indicate the end of conversion and data ready to
be picked up.
Page No :
Components:
1. ADC0808
2. AT89C51:11.059MHz
3. CAP
1.
C1:33pf
2.
C2:33pf
3.
C3:1uf
4. CAP-ELEC
5. CRYSTAL
6. LM016L
7. POT-HG
8. RES
Page No :
Page No :
DESIGN
Page No :
Code:
Page No :
Output:
Page No :
PRACTICAL NO : 6
Description:
Stepper motor is one of the commonly used motors for precise angular movement.
The advantage of using a stepper motor is that the angular position of the motor
shaft can be controlled without any feedback mechanism. Stepper motors are
widely used in industrial and commercial applications. They are also commonly
used as in drive systems of autonomous robots.
The microcontroller is programmed to rotate the stepper in Full Step modes.
For a bipolar stepper motor, in the full step mode both the phases are energized
simultaneously. The coils A, B, C, D are energized in the following order:
Step
1
Embedded Systems Journal
Coil A
H
Coil B
L
Coil C
L
Coil D
H
Page No :
2
3
4
H
L
L
H
H
L
L
H
H
L
L
H
Page No :
COMPONENTS :
1.
ULN2003A
2.
3.
4.
C1 & C2 33pF
5.
C3 1uF
6.
7.
R1 10k
Design :
Page No :
Page No :
Code :
#include<reg51.h>
#include<stdio.h>
void delay(int);
void main()
{
while(1)
{
P2=0x09;
delay(500);
P2=0x0C;
delay(500);
P2=0x06;
delay(500);
P2=0x03;
delay(500);
}
}
void delay(int k)
{
int i,j;
for(i=0;i<k;i++)
{
for(j=0;j<100;j++)
Embedded Systems Journal
Page No :
{
}
}
}
Page No :
Output:
Page No :
PRACTICAL NO 7
Description:
The above diagram illustrates the traffic flow layout of the four way road
The traffic flow can be classified in to four phases in the above diagram and we
have considered the North as starting point of this traffic flow. And in the above
scheme vehicles are allowed to make a free right turn so we need to consider only
two directions straight and left. So the green signal was classified into two types
one for G for permitting vehicle to proceed forward and GL for permitting vehicles
to left.
PHASE I1.
2.
Page No :
1.
2.
Traffic flow from rest of the two roads North and south was stopped by
means of Red signal.
PHASE III1.
Phase three permits traffic flow in the left directions from A to D and from
E to H.
2.
Traffic flow in East and west are stopped by means of red signal.
PHASE IV1.
2.
Traffic flow in the North and south are stopped by means of red signal.
3.
The cycle repeats again from Phase I to Phase IV and thus the traffic is
regulated.
Page No :
COMPONENT :
4.
5.
C1 & C2 33pF
6.
C3 1uF
7.
8.
R1 10k
9.
R2 R17 100
10.
LED 10mA
11.
Traffic Lights
DESIGN :
Page No :
Page No :
Page No :
Code :
#include <REG51.H>
void delay();
void count1();
sbit NR = P0^0;
sbit NY = P0^1;
sbit NG = P0^2;
sbit NL = P0^3;
sbit SR = P0^4;
sbit SY = P0^5;
sbit SG = P0^6;
sbit SL = P0^7;
sbit ER = P1^0;
sbit EY = P1^1;
sbit EG = P1^2;
sbit EL = P1^3;
Page No :
void main(void)
{
while(1){
/*
NR = 1;
NY = 1;
NG = 0;
NL = 1;
SR = 1;
SY = 1;
SG = 0;
SL = 1;
ER = 0;
EY = 1;
EG = 1;
EL = 1;
WRR = 0;
WY = 1;
Embedded Systems Journal
Page No :
WG = 1;
WL = 1;
count1();
NR = 0;
NY = 1;
NG = 1;
NL = 1;
SR = 0;
SY = 1;
SG = 1;
SL = 1;
ER = 1;
EY = 1;
EG = 0;
EL = 1;
WRR = 1;
WY = 1;
WG = 0;
WL = 1;
count1();
Embedded Systems Journal
Page No :
NG=0;
SG=0;
ER=0;
WRR=0;
count1();
EY=0;
WY=0;
ER=1;
WRR=1;
count1();
EY=1;
WY=1;
NG=1;
SG=1;
NR=0;
SR=0;
ER=1;
WRR=1;
EG=0;
WG=0; */
NY = 1;
Embedded Systems Journal
Page No :
NG = 0;
NL = 1;
SR = 1;
SY = 1;
SG = 0;
SL = 1;
ER = 0;
EY = 1;
EG = 1;
EL = 1;
WRR = 0;
WY = 1;
WG = 1;
WL = 1;
count1();
//2ND 7SEC, NORTH TO SOUTH AND yELLOW FOR EAST TO WEST N WEST TO EAST
NR = 1;
NY = 1;
NG = 0;
NL = 1;
Embedded Systems Journal
Page No :
SR = 1;
SY = 1;
SG = 0;
SL = 1;
ER = 1;
EY = 0;
EG = 1;
EL = 1;
WRR = 1;
WY = 0;
WG = 1;
WL = 1;
count1();
NY = 1;
NG = 1;
NL = 1;
SR = 0;
Embedded Systems Journal
Page No :
SY = 1;
SG = 1;
SL = 1;
ER = 1;
EY = 1;
EG = 0;
EL = 1;
WRR = 1;
WY = 1;
WG = 0;
WL = 1;
count1();
//4TH 7 SEC, SOUTH TO WEST AND NORTH TO EAST REST ALL BLOCKED
NR = 0;
NY = 1;
NG = 1;
NL = 0;
SR = 0;
SY = 1;
Embedded Systems Journal
Page No :
SG = 1;
SL = 0;
ER = 0;
EY = 1;
EG = 1;
EL = 1;
WRR = 0;
WY = 1;
WG = 1;
WL = 1;
count1();
//5TH 7 SEC, EAST TO SOUTH AND WEST TO NORTH REST ALL BLOCKED
NR = 1;
NY = 0;
NG = 1;
NL = 1;
SR = 1;
SY = 0;
SG = 1;
SL = 1;
Embedded Systems Journal
Page No :
ER = 1;
EY = 1;
EG = 1;
EL = 0;
WRR = 1;
WY = 1;
WG = 1;
WL = 0;
count1();
}
}
void count1()
{
unsigned int i,j;
for(j=0;j<=2;)
{
for(i=0;i<=3;)
{
i++;
delay();
}
j++;
Embedded Systems Journal
Page No :
delay();
}
}
void delay(void)
{
unsigned int s,k;
for(s=0;s<=230;s++)
{
for(k=0;k<238;k++);
}
}
OUTPUT:
Page No :
Page No :
Page No :
PRACTICAL NO 8
Aim: WAP to implement elevator control.
Description:
This practical is based on the concept of elevator control. Here the elevator
is simulated for a Ground + 3 Floors structures.
A button is made available on every floor to call the lift.
An LED is used to indicate the availability of the lift. RED indicates. BUSY
and GREEN Indicates available.
A 7 segment display is used to indicate the current position of the lift. The
seven segment LED is used in the Common Cathode configuration.
The following table displays the how decimal values 0-9 are displayed on
the 7 segment display
Page No :
Page No :
DESIGN:
Page No :
Code:
#include<reg51.h>
void delayd();
char key;
char READ_SWITCHES(void);
char get_key(void);
void main()
{
P2 = 0x3f;
P1 = 0x00;
while(1)
{
key = get_key();
P1 = 0x00;
led=0;
Embedded Systems Journal
Page No :
}
}
char get_key(void)
{
char key = 'n';
while(key=='n')
return key;
char READ_SWITCHES(void)
{
//ground floor
if (GF == 1)
{
led=1;
// third to ground
if(GF==1 && key=='T')
{
delayd();
P2 = 0x5b;
Embedded Systems Journal
Page No :
delayd();
P2 = 0x06;
delayd();
P2 = 0x3f;
}
// second to ground
if(GF==1 && key=='S')
{
delayd();
P2 = 0x06;
delayd();
P2 = 0x3f;
}
// first to ground
if(GF==1 && key=='F')
{
delayd();
P2 = 0x3f;
}
return 'G';
}
//first floor
if (FF == 1)
{
Embedded Systems Journal
Page No :
led=1;
//third floor to first floor
if(FF==1 && key=='T')
{
delayd();
P2 = 0x5b;
delayd();
P2 = 0x06;
}
//second floor to first floor
if(FF==1 && key=='S')
{
delayd();
P2 = 0x06;
}
//ground floor to first floor
if(FF==1 && key=='G')
{
delayd();
P2 = 0x06;
}
delayd();
return 'F';
}
//second floor
Embedded Systems Journal
Page No :
if (SF == 1)
{
led=1;
//third floor to second floor
if(SF==1 && key=='T')
{
delayd();
P2 = 0x5b;
}
//first floor to second floor
if(SF==1 && key=='F')
{
delayd();
P2 = 0x5b;
}
//ground floor to second floor
if(FF==1 && key=='G')
{
delayd();
P2 = 0x06;
delayd();
P2 = 0x5b;
}
delayd();
return 'S';
Embedded Systems Journal
Page No :
}
//third floor
if (TF == 1)
{
led=1;
if(TF==1 && key='G')
{
delayd();
P2 = 0x06;
delayd();
P2 = 0x5b;
delayd();
P2 = 0x4f;
}
if(TF==1 && key='F')
{
delayd();
P2 = 0x5b;
delayd();
P2 = 0x4f;
}
{
delayd();
Embedded Systems Journal
Page No :
P2 = 0x4f;
}
delayd();
return 'T';
}
}
void delayd ( )
{
unsigned int s,k,i;
for(i=0;i<3;i++)
{
for(s=0;s<=230;s++)
{
for(k=0;k<238;k++);
}
}
}
Page No :
Output:
Page No :
Page No :