Beruflich Dokumente
Kultur Dokumente
The hardware could be a part of Input, output or both usually and includes
buttons, display, LED’s, sensors, actuators and other electronic circuitry.
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.
8051 Variants
• The 8051 has the widest range of variants of any embedded controller in the market.
• The smallest device is the Atmel 89c1051, a 20 pin flash variant with 2 timers, UART,
20mA.
• The fastest parts are from Dallas, with performance close to 10 MIPS.
• The most powerful chip is the Siemens 80C517A, with 32-bit ALU, 2 UARTs, 2K RAM,
PLCC84 package, 8×16 bit PWMs and other features.
Intel 8051
ROM [ bytes] 4K
Timers 2
I/O pins 32
Serial port 1
Interrupt sources 6
4. Inductors:
An inductor, also called a coil or reactor, is a passive two-terminal electrical
component which resists changes in electric current passing through it. It consists of a
conductor such as a wire, usually wound into a coil. When a current flows through
it, energy is stored temporarily in a magnetic field in the coil.
When the current flowing through an inductor changes, the time-varying magnetic
field induces a voltage in the conductor, according to Faraday’s law of
electromagnetic induction, which opposes the change in current that created it.
7. Transistors
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.
o The sensitivity is then defined as the ratio between output signal and measured
property. For example, if a sensor measures temperature and has a voltage output, the
sensitivity is a constant with the unit [V/K]; this sensor is linear because the ratio is
constant at all points of measurement.
9. Actuators
o An actuator is a type of motor that is responsible for moving or controlling a
mechanism or system.
o It is operated by a source of energy, typically electric current, hydraulic
fluid pressure, or pneumatic pressure, and converts that energy into motion. An
actuator is the mechanism by which a control system acts upon an environment. The
control system can be simple (a fixed mechanical or electronic system), software-
based (e.g. a printer driver, robot control system), a human, or any other input.
11.Operational Amplifiers:
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.
Conclusion: The practical of the study of the Embedded System hardware components
is successfully completed.
Description:
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.
Design:
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++);
}
}
}
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”.
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
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
For a stepper motor, in the full step mode both the phases are energized
ULN2003A
C1 & C2 – 33pF
C3 – 1uF
R1 – 10k
Design :
#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++)
{
}
}
}
Description:
MAX232
signals suitable for use in TTL compatible digital logic circuits. The
creates virtual serial ports and connects them in pairs via virtual null
exchange data in such a way, that everything written to the first port
All virtual serial ports work and behave exactly like real ones,
emulating all their settings. We can create as many virtual port pairs
CAPACITORS
o C1:33PF
o C2:33PF
o C3:1UF
o C4:10UF
o C5:10UF
o C6:10UF
o C7:10UF
o C8:10UF
o C9:10UF
COMPIM1, COMPIM2
CRYSTAL:11.059MhZ
MAX232
RESISTORS: R1 – 10K
TRANSMITTER
RECEIVER
#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;
}
Description:
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. Send command 0x30 - Using 8-bit interface
2. Delay 20ms
3. Send command 0x30 - 8-bit interface
4. Delay 20ms
5. Send command 0x30 - 8-bit interface
6. Delay 20ms
7. Send Function set - see Table 4 for more information
8. Display Clear command
9. Set entry mode command
The first 3 commands are usually not required but are recommended when you
are using 4-bit interface
Pin
Function Name
No
1 Ground (0V) Vss
2 Supply voltage; 5V (4.7V – 5.3V) VDD
3 Contrast adjustment; through a variable resistor VEE
4 Selects command register when low; and data register when high Register
0 = Instruction input , 1 = Data input Select(RS)
5 Low to write to the register; High to read from the register Read/write (RW)
0 = Write to LCD Module, 1 = Read from LCD module
6 Sends data to data pins when a high to low pulse is given Enable (E)
7 DB0
8 DB1
9 DB2
10 DB3
8-bit data pins
11 DB4
12 DB5
13 DB6
14 DB7
15 Backlight VCC (5V) Led+
16 Backlight Ground (0V) Led
LCD Memory
LCD display contains three memory blocks:
DDRAM Display Data RAM;
CGRAM Character Generator RAM; and
CGROM Character Generator ROM.
DDRAM Memory
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.
All data transferred to an LCD through the outputs D0-D7 will be interpreted as a command or a
data, which depends on the RS pin logic state:
RS = 1 - Bits D0 - D7 are addresses of the characters to be displayed. LCD processor
addresses one character from the character map and displays it. The DDRAM address
specifies location on which the character is to be displayed. This address is defined prior
to transferring character or the address of the previously transferred character is
automatically incremented.
RS = 0 - Bits D0 - D7 are commands for setting the display mode.
EXECUTION
COMMAND RS RW D7 D6 D5 D4 D3 D2 D1 D0
TIME
Write to CGRAM or
1 0 D7 D6 D5 D4 D3 D2 D1 D0 40uS
DDRAM
D N
1 = Display on 1 = Display in two lines
0 = Display off 0 = Display in one line
U F
1 = Cursor on 1 = Character format 5x10 dots
0 = Cursor off 0 = Character format 5x7 dots
B D/C
1 = Cursor blink on 1 = Display shift
0 = Cursor blink off 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).
COMPONENTS:
AT89C51:11.059MHz
BUTTON
CAPACITOR
C1:33pf
C2:33pf
C3:1uf
CRYSTAL:11.059MHz
LED-BLUE
LM016L
char READ_SWITCHES(void)
{
Return ‘A’; // or the other characters
}
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);
int main(void)
{
char key; // key char for keeping record of pressed key
cct_init(); // Make input and output pins as required
lcdinit(); // Initilize LCD
while(1)
{
key = get_key(); // Get pressed key
writecmd(0x01); // Clear screen
writedata(key); // Echo the key pressed to LCD
}
}
void cct_init(void)
{
P0 = 0x00; //not used
P1 = 0xf0; //used for generating outputs and taking inputs from Keypad
P2 = 0x00; //used as data port for LCD
P3 = 0x00; //used for RS and E
}
void writedata(char t)
{
RS = 1; // This is data mode
P2 = t; //Data transfer
E = 1; // => E = 1
delay(150);
E = 0; // => 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);
Conclusion: The practical for LCD & Keypad interfacing is successfully completed.
Description:
For this practical we will use LED of red, green, yellow and blue color and are
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 I-
Initially Vehicle from A needs to travel to F and from E to B roads.
So in the first Phase forward green signal in A and E permits vehicles to
pass through while East and west roads are stopped by red signal.
PHASE II-
DESIGN :
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;
void main(void)
{
while(1){
/*
NR = 1; //allow north to south AND WEST
NY = 1;
NG = 0;
NL = 1;
count1();
NR = 0;
NY = 1;
NG = 1;
NL = 1;
SR = 0;
SY = 1;
SG = 1;
SL = 1;
NG=0;
SG=0;
ER=0;
WRR=0;
count1();
EY=0;
WY=0;
ER=1;
Embedded Systems Manual
WRR=1;
count1();
EY=1;
WY=1;
NG=1;
SG=1;
NR=0;
SR=0;
ER=1;
WRR=1;
EG=0;
WG=0; */
//2ND 7SEC, NORTH TO SOUTH AND yELLOW FOR EAST TO WEST N WEST TO EAST
NR = 1; //allow north to south AND WEST
NY = 1;
NG = 0;
NL = 1;
Embedded Systems Manual
SR = 1; //allow south to north AND EAST
SY = 1;
SG = 0;
SL = 1;
SR = 0;
SY = 1;
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;
void count1()
{
unsigned int i,j;
for(j=0;j<=2;)
{
for(i=0;i<=3;)
{
i++;
delay();
}
j++;
delay();
}
}
void delay(void)
{
unsigned int s,k;
for(s=0;s<=230;s++)
{
for(k=0;k<238;k++);
}
}
OUTPUT:
An LED is used to indicate the availability of the lift. RED indicates. BUSY
A 7 segment display is used to indicate the current position of the lift. The
The following table displays the how decimal values 0-9 are displayed on
C1 & C2 – 33pF
C3 – 1uF
R1 – 10k
DESIGN:
#include<reg51.h>
void delayd();
char READ_SWITCHES(void);
char get_key(void);
void main()
{
P2 = 0x3f;
P1 = 0x00;
while(1)
{
char READ_SWITCHES(void)
{
//ground floor
Embedded Systems Manual
if (GF == 1)
{
led=1;
// third to ground
if(GF==1 && key=='T')
{
delayd();
P2 = 0x5b;
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)
{
led=1;
//third floor to first floor
if(FF==1 && key=='T')
{
delayd();
P2 = 0x5b;
delayd();
Embedded Systems Manual
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
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;
}
Embedded Systems Manual
delayd();
return 'S';
}
//third floor
if (TF == 1)
{
led=1;
if(TF==1 && key='G') //ground floor to third floor
{
delayd();
P2 = 0x06;
delayd();
P2 = 0x5b;
delayd();
P2 = 0x4f;
}
if(TF==1 && key='F') //first floor to third floor
{
delayd();
P2 = 0x5b;
delayd();
P2 = 0x4f;
}
void delayd ( )
{
unsigned int s,k,i;
for(i=0;i<3;i++)
{
for(s=0;s<=230;s++)
{
Embedded Systems Manual
for(k=0;k<238;k++);
}
}
}
Description:
channels, i.e., it can take eight different analog inputs. The input which is to
The voltage reference can be set using the Vref+ and Vref- pins. The step
size is decided based on set reference value. Step size is the change in analog
input to cause a unit change in the output of ADC. The default step size is
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.
Embedded Systems Manual
Components:
ADC0808
AT89C51:11.059MHz
CAP
C1:33pf
C2:33pf
C3:1uf
CAP-ELEC
CRYSTAL
LM016L
POT-HG
RES
#include<reg51.h>
//Pin description
/*
P1.4 to P1.7 is data bus
P1.1 is RS
P1.0 is E
*/
//********************
// Defines Pins
sbit RS = P1^1;
sbit E = P1^0;
// Function Declarations
void delay_sec(unsigned int);
void __delay_us(unsigned int);
void InitLCD(void);
void WriteCommandToLCD(int);
void WriteDataToLCD(char);
void WriteStringToLCD(const char*);
void ClearLCDScreen(void);
void InitADC(void);
unsigned char ReadADC(unsigned char);
void main()
{
unsigned char ADC_Value = 0; // To capture ADC value
unsigned char Digit[3] = { 0,0,0 }; // To make digits to display on LCD
while(1)
{
ADC_Value = ReadADC(AN1); // Read ADC value from Channel 1
ClearLCDScreen();
// Clear LCD
WriteStringToLCD("ADC value = ");
// Display string
WriteDataToLCD(Digit[2]+0x30);
// Display first digit
WriteDataToLCD(Digit[1]+0x30);
// Display second digit
WriteDataToLCD(Digit[0]+0x30);
// Display third digit
delay_sec(1);
// Delay of one second
}
}
void InitADC(void)
{
Add_A = 0; // Make output
Add_B = 0; // Make output
Add_C = 0; // Make output
ALE = 0; // Make output
EOC = 1; // Make input
OE = 0; // Make output
START = 0; // Make output
CLK = 0; // Make output
for(i=0;i<2000;i++)
{
CLK = !CLK; // Toggle Clock
__delay_us(HalfCycleDelay); // 250kHz Frequency
for(i=0;i<2000;i++)
{
CLK = !CLK; // Toggle Clock
__delay_us(HalfCycleDelay); // 250kHz Frequency
for(i=0;i<(d*20);i++)
__delay_us(50000);
}
for(i=0;i<limit;i++);
}
void ToggleEpinOfLCD(void)
{
E = 1; // Give a pulse on E pin
__delay_us(E_Delay); // so that LCD can latch the
E = 0; // data from data bus
__delay_us(E_Delay);
}
void WriteDataToLCD(char t)
{
RS = 1; // This is data
void InitLCD(void)
{
RS = 0; // Make pin zero
E = 0; // Make Pin zero
__delay_us(4500);
__delay_us(300);
__delay_us(650);
__delay_us(650);
/////////////////////////////////////////////////////
WriteCommandToLCD(0x28); //function set
WriteCommandToLCD(0x0c); //display on,cursor off,blink off
WriteCommandToLCD(0x01); //clear display
WriteCommandToLCD(0x06); //entry mode, set increment
}
Embedded Systems Manual
void WriteStringToLCD(const char *s)
{
while(*s)
WriteDataToLCD(*s++); // print first character on LCD
}
void ClearLCDScreen(void) // Clear the Screen and return cursor to zero position
{
WriteCommandToLCD(0x01); // Clear the screen
__delay_us(2000); // Delay for cursor to return at zero position
}
Output: