Professional Documents
Culture Documents
IV 8051manua PDF
IV 8051manua PDF
IV 8051manua PDF
VTU SYLLABUS
I. PROGRAMMING
1. Data Transfer - Block move, Exchange, Sorting, Finding largest element in an array
2. Arithmetic Instructions - Addition/Subtraction, Multiplication and Division, Square,
Cube – (16 bits Arithmetic operations – bit addressable)
3. Counters
4. Boolean & Logical Instructions (Bit manipulations)
5. Conditional CALL & RETURN
6. Code conversion: BCD – ASCII; ASCII – Decimal; Decimal - ASCII; HEX – Decimal
and Decimal - HEX
7. Programs to generate delay, Programs using serial port and on-Chip timer /counter
II. INTERFACING
8. Simple Calculator using 6 digit seven-segment display and Hex Keyboard interface to
8051
9. Alphanumeric LCD panel and Hex keypad input interface to 8051
10. External ADC and Temperature control interface to 8051
11. Generate different waveforms Sine, Square, Triangular, Ramp etc. using DAC
interface to 8051; change the frequency and amplitude
12. Stepper and DC motor control interface to 8051
13. Elevator interface to 8051
PROCESSOR used is Atmel AT89C51ED2 - micro controller that has 64Kbytes of on-
chip program memory. It is a version of 8051 with enhanced features.
AT 89C51ED2 operates at 11.0592 MHz
PROCESSOR FEATURES
ON-CHIP MEMORY: CODE MEMORY: 64K Bytes of flash.
DATA MEMORY: 256 Bytes of RAM, 1792 Bytes of XRAM, 2K Bytes of EEPROM.
ON-CHIP PERIPHERALS
3 16-bit Timers/Counters, Watch Dog Timer, Programmable Counter
Array (PCA) on Port1 i.e. PWM and Capture & Compare, SPI (Serial Peripheral Interface)
on Port1,Full duplex enhanced UART.
INTERRUPTS
Nine sources of interrupt (both external and internal).
Two External interrupts INT0 and INT1 are provided with push button switches; these can
also be used as general-purpose switches.
I/O (Port) Lines Four 10-pin connectors for all the 32 I/O lines.
P0, P1 and P2 Port lines are available on a 26-pin connector,
4. Create a source file (using File->New), type in the assembly or C program and save this
(filename.asm/ filename.c) and add this source file to the project using either one of the
following two methods.
(i) Project-Components, Environmentand Books->addfiles-> browse to the required file
-> OK “OR”
(ii) Right click on the Source Group in the Project Window and the Add Files to Group
Option.
5. Set the Target options using -> Project – Options for Target opens the Vision2
Options for Target – Target configuration dialog. Set the Xtal frequency as 11.0592
Mhz, and also the Options for Target – Debug – use either Simulator / Keil
Monitor- 51 driver.
If Keil Monitor- 51 driver is used click on Settings -> COM Port settings select the
COM Port to which the board is connected and select the baud rate as 19200 or 9600
(recommended). Enable Serial Interrupt option if the user application is not using on-
chip UART, to stop program execution.
6. Build the project; using Project -> Build Project. Vision translates all the user
application and links. Any errors in the code are indicated by – “Target not created” in
the Build window, along with the error line. Debug the errors. After an error free build,
goto Debug mode
7. Now user can enter into Debug mode with Debug- Start / Stop Debug session dialog.
“OR” by clicking in the icon.
8. The program is run using the Debug-Run command & halted using Debug-Stop
Running. Also the (reset, run, halt) icons can be used. Additional icons are
9. If it is an interface program the outputs can be seen on the LCD, CRO, motor, led status,
etc. If it is a part A program, the appropriate memory window is opened using View ->
memory window (for data RAM & XRAM locations), Watch window (for timer
program), serial window, etc.
I.PROGRAMMING
Algorithm
1. Initialize registers to hold count data & also the source & destination addresses.
2. Get data from source location into accumulator and transfer to the destination
location.
3. Decrement the count register and repeat step 2 till count is zero.
Note: For data transfer with overlap start transferring data from the last location of
source array to the last location of the destination array.
RESULT:
After Execution: 10 locations X:8041h are filled up with data from 8035h.
ORG 00H
SJMP 30H
ORG 30H
MOV R0,#27H //source address
MOV R1,#41H //destination address
MOV R3,#05H //count
BACK: MOVX A,@r0
MOV r2,a
MOVX a,@r1
MOVX @r0,a
MOV a, r2
MOVX @r1,a
INC R0
INC R1
DJNZ R3, BACK
HERE: SJMP HERE
END
Either using XCH command.
ORG 0000H
SJMP 30H
ORG 30H
MOV R0,#27H //source address
MOV R1,#41H //destination address
MOV R3,#05H //count
BACK: MOVX A,@r0
MOV r2,a
MOVX a,@r1
XCH a, r2
MOVX @r1,a
XCH a, r2
MOVX @r0,a
INC R0
INC R1
DJNZ R3, BACK
HERE: SJMP HERE
END
Algorithm
1. Initialize registers to hold count data (array size) & also the source & destination
addresses.
2. Get data from source location into accumulator and save in a register.
3. Get data from the destination location into accumulator.
4. Exchange the data at the two memory locations.
5. Decrement the count register and repeat from step 2 to 4 till count is zero.
RESULT:
Before Execution: 5 locations at X:0027h & X:0041h are filled up with data.
ORG 0000H
SJMP 30H
ORG 30H
RESULT:
Before Execution:Unsorted Array at 9000h. After Execution: Sorted Array at 9000h.
4) Write an assembly language program to find the largest element in a given string
of n = 6 bytes at location 4000h. Store the largest element at location 4062h.
ORG 0000H
SJMP 30H
ORG 30H
MOV R3,#6 //length of the array
MOV DPTR,#4000H //starting address of the array
MOVX A,@DPTR
RESULT:
Before Execution:
2. ARITHMETIC INSTRUCTIONS
ASSEMBLY LANGUAGE PROGRAM ILLUSTRATING ADDITION,
SUBTRACTION, MULTIPLICATION AND DIVISION.
5) Write an ALP to perform the following:
If x=0-perform w + v; else if x=1-perform w-v; else if x=2-perform w*v; elseif x=3-
perform w/v, where w & v are eight bit numbers.
ORG 0000H
SJMP 30H
ORG 30H
MOV R0, #40H
Algorithm
1. Store the condition x in r1.
2. Load the first and second numbers to A and B registers respectively
3. Compare the contents of r1 and perform the operations add, sub, etc accordingly.
4. Store the result present in A and B registers to the appropriate memory locations.
RESULT:
RESULT:
CUBE OF 56H IS 9B498 WHICH IS STORED AS 98, B4, 09 (LOWER BYTE FIRST)
To get square make the D1 bit of data memory 20h high, say FF,02,06,etc. The bit address
is 01. Similarly bit address 78h correspond to D0 bit 0f data ram location 2Fh.
Algorithm:
1. Store the elements of the array from the address 4000h
2. Move the first number in r0 and the second number in register A respectively
3. Clear carry flag and subtract the two numbers, if the carry flag is 0(if the nos are
equal), Clear both LSB & MSB of bit addressable memory location 2Fh
4. If the carry bit is set then Set MSB of 2F(7FH), else LSB of data RAM 2F (bit
address 78H).
RESULT:
1) Before Execution: X:08000h = 45 & X:8001 = 35
After Executuion: D:02FH =01
2) Before Execution: X:08000h = 25 & X:8001 = 35
After Executuion: D:02FH =80
3) Before Execution: X:08000h = 45 & X:8001 = 45
After Executuion: D:02FH =00
4. LOGICAL INSTRUCTIONS
Algorithm:
1. Point to the data RAM register 20h and store the condition x.
2. Point to 21h and 22h and move the first number to A register.
3. Compare the contents of r1 and perform the operations accordingly.
4. The result will be stored in 23H register.
RESULT:
1)Before Execution: D:020H =00, 21=0f, 22 = 12
After Execution D:023H = 02
2)Before Execution: D:020H =01, 21=0f, 22 = 12
After Execution D:023H = 1F
3)Before Execution: D:020H =02, 21=0f, 22 = 12
After Execution D:023H = 1D
4)Before Execution: D:020H =34, 21=0f, 22 = 12
After Execution D:023H = 00
The above program can also be written as shown below (using indirect addressing)
ORG 0000H
SJMP 30H
ORG 30H
mov r0,#20h
MOV A,@R0 //ON CHIP DATA RAM-DONOT USE MOVX
MOV R1,A //X IN R1
INC R0
ORG 00H
SJMP 30h
ORG 30h
MOV R0,20H //R0-X
CJNE R0,#0,CK1
MOV C,08H //LSB OF NUM1 (21H) - BIT ADDRESS -08
ANL C,10H //LSB OF NUM2 (22H) - BIT ADDRESS -10
SJMP LAST
CK1:CJNE R0,#1,CK2
MOV C,0FH //MSB OF NUM1 (21H) - BIT ADDRESS -0F
ANL C,17H //MSB OF NUM2 (22H) - BIT ADDRESS -17
SJMP LAST
CK2:CJNE R0,#2,CK3
CPL 0FH or MOV C, OFH
MOV C, 0FH CPL C //MSB OF NUM1 (21H) - BIT ADDRESS -0F
SJMP LAST
CK3:CLR C
LAST:MOV 1FH,C //RES IS MSB OF 23H LOCATION -1FH
HERE:SJMP HERE
END
Algorithm:
1. Move the condition X (from 20h location) into R0 register.
2. If X=0; then move LSB bit of 21h to carry flag and ‘AND’ Carry flag with LSB bit
of 22h. Goto step5
3. If X=1; then move MSB bit of 21h to carry flag and ‘OR’ Carry flag with MSB bit
of 22h. Goto step5
4. If X=0; then complement MSB bit of 21h and move it to carry flag. Goto step5
5. Store Carry flag at MSB bit of 23h location.
5. COUNTERS
ASSEMBLY PROGRAM ILLUSTRATING HEX UP/DOWN COUNTERS.
//counter program - hex/binary counters
10) Write an ALP to implement (display) an eight bit up/down binary (hex) counters on
watch window.
Note: to run this program, after selecting DEBUG session in the main menu use
View-> Watch& call Stack window, in the Watches select watch 1(or 2) and
Algorithm:
1. Move 00 to A register
2. Call the delay subroutine for 1 second, in delay program move FFH to registers r1,
r2 and r3, loop and decrement until 0.
3. Increment A register(decrement for down counter)
ASSEMBLY
PROGRAM
ILLUSTRATING
BCD UP/DOWN
COUNTERS.
//counter program –
BCD up/down
counters
11) Write an ALP to implement (display) an eight bit up/down BCD counters on watch
window.
ORG 0H
SJMP 30H
ORG 30H
MOV a,#00
BACK:ACALL DELAY
ADD a,#99H //ADD 01 for BCD up counter
DA A //for bcd counter
Algorithm:
4. Move 00 to A register
5. Call the delay subroutine for 1 second (in delay program move FFH to registers r1,
r2 and r3, loop and decrement until 0).
6. Increment A register(add 99h for down counter)
7. Decimal adjust accumulator for the BCD up/down counter.
RESULT: Accumulator A is incremented in BCD from 00, 01, 02…09, 10, 11,…99.
Algorithm:
1. Initialize timer 1 to operate in mode 2 by loading TMOD register.
2. load TH1 with -3 to obtain 9600 baud.
3. Initialize the asynchronous serial communication transmission (SCON) register.
4. Start timer1 to generate the baud rate clock.
5. Transmit the characters “y” & “E” by writing into the SBUF register and waiting
for the TI flag.
RESULT: yE is printed on the serial window each time the program is executed.
Algorithm:
1. Set up timer0 in mode 2 operation
2. Load TH1 with 118 to generate an interrupt every 0.05msec.
3. Reset registers a, r1 & r0.
4. Repeat step 4 continuously
5. On interrupt; ISR at 000B location goes to step 6
6. disable timer0
7. Update r1 & r0
8. Check if 20000 interrupts (=1 sec) over. Yes –increment accumulator a.
9. Enable timer & return from ISR.
Timerdelay = 12*(257-delay)/frequency
Timerdelay=0.05msec
Delay=256-((timerdelay * frequency)/12) =256-(0.05*10 -3 * 33*106)/12
=256-137.5 =118.5 //loaded in TH0
To get 1sec delay
1/0.05msec = 200*100 in the ISR
(assuming 33 MHZ crystal frequency. For 11 MHz, the calculations change).
8. CONVERSION PROGRAMS
ORG 0000H
SJMP 30h
ORG 30h
MOV DPTR,#40H //2-digit decimal number to be converted is given in data
memory 40h
MOVX A, @DPTR
ANL A, #0F0H //obtain upper decimal digit
SWAP A //bring to the units place
MOV B,#0AH //MULTIPLY tens digit with #0A-toget tens in hex
MUL AB
MOV r1,a //temporarily store the converted tens value
MOVX A,@DPTR //get the decimal number again
ANL A,#0FH //obtain the units digit
ADD A,R1 //add to the converted tens value
INC DPTR //increment data address
MOVX @DPTR,A //converted hexadecimal number in next location
HERE:SJMP HERE
END
Algorithm
1. Move the decimal data to be converted from external memory 40h to accumulator.
2. AND A reg with 0f0h and obtain the upper MSB of the decimal digit and swap the
LSB and MSB of accumulator to bring the same to units place.
3. Move 0ah to B register and multiply with A reg to convert to hex value, store the
converted tens value in r1
4. Get the LSB of the decimal number and add to the converted tens value
5. point to the next memory location and store the result (hexadecimal).
RESULT:
Before execution- X:0040H = 45 (Decimal/BCD)
After Execution: X:0041h = 2D (hex value)
Algorithm
Algorithm :
Algorithm :
//Converts the hexadecimal byte in A into two ASCII characters.
1. Move the hexadecimal data to be converted to accumulator.
2. Get the lower nibble & call ASCII routine
3. Store the converted ASCII value
4. Get the higher nibble & call ASCII routine
5. Store the converted ASCII value
ASCII subroutine
1. If digit greater than 09,(for A-F) add 07h & 30h
2. Else (i.e., for 0-9) add only 30h
3. return
RESULT: The BCD code 2C at D:0050h is converted to 2 ASCII codes-43h(for 0B) &
32h (for 02) Another Example-BA
Algorithm :
Note: For this program the input data should be only in the range 30h-39h & 41h to 46h.
II.INTERFACING
21) Click project on new Menu & select Rebuild all the files
22) Switch on the power supply for kit, initially LCD shows ESA MCB 51 V1.00
23) Click DEBUG & Select Start/Stop
24) Click Ok & wait until loading completes
25) Click DEBUG & Select RUN.
Hardware Interfacing
Features of Embedded C
• C is a simple programming language and so very easy to code.
• Embedded C has most features of C-language with more stress on certain bit
manipulative instructions.
• This feature makes it easy to write program for μC and μP.
Algorithm
• Read the numbers n1 and n2 from keyboard and display them on seven segment.
• Read the operand from the keypad if key pressed is B (+), C (-), D (*),E(/) then
respective operation is performed.
• Result is displayed on 2 digit seven segment display.
• If any time the key pressed value returned as 10h then clear the LCD.
PS
PS
8051µC Keypad
P0
FRC 26pin
Cable
7 Seg
Display
#include <REG51xD2.H>
void DispChar(unsigned char ch);
void ClrLED();
unsigned char getkey();
unsigned char getnum();
unsigned char getOp();
sbit Clk = P3^4; /* Clock line for 7 segment display */
sbit Dat = P0^0; /* Data line for 7 segment display */
main()
{
unsigned char tmp=0x0ff,n1=0,n2,Op,Res;
unsigned char NumTab[10]={ 0x0c0,0x0f9,0x0a4,0xb0,0x99,0x92,0x82,0x0f8,0x80,0x90 };
unsigned char OpTab[4] = { 0x88,0x0Bf,0xc8,0x0a1};
bit Neg=0;
ClrLED(); /* Clear 7 segment display */
while(1)
{
Neg = 0; /* Negative flag */
n1=getnum(); /* Get 1st number */
Op = getOp() - 0x0B; /* Get Opcode. 0x0b is keycode of '+'(see keyboard
schematics)*/
n2=getnum(); /* Get 2nd number */
while(getkey()!=0x13); /* wait for '=' key */
ClrLED();
Neg = 1;
Res = n2 - n1;
break; }
Res = n1 - n2;
break;
case 2: Res = n1 * n2;
break;
case 3: Res = n1 / n2;
break; }
DispChar(NumTab[Res%10]); /* Display number */
DispChar(NumTab[Res/10]);
if(Neg) /* if negative result display '-' */
DispChar(0x0Bf);
}}
void DispChar(unsigned char ch) /* Routine to display char on 7 segment */
{
unsigned char i,tmp;
P0=0x00;
for(i=0;i<8;i++) /* for all bits */
{
tmp = ch & 0x80;
if(tmp) /* write data depending on MSB */
Dat = 1;
else
Dat = 0;
Clk = 0; /* Give Clk Pulse for synchronization */
Clk = 1;
ch = ch << 1; /* Get next bit */
}
}
void ClrLED()
{
unsigned char i;
for(i=0;i<4;i++)
DispChar(0x0ff); /* 0xff for clear segment ( see 7 segment manual for more info) */
}
unsigned char getkey()
{ unsigned char i,j,indx,t;
• Configure P1 as output port to scan the rows and P0 as input port to read the column
values.
• First select the last row by grounding that row. Scan the columns of entire row if a
key is pressed in that row then one of the column reads ‘0’.
• If now key is pressed in the selected row all 1’s is returned. So scan next row. Repeat
the action until all rows are scanned.
PS
PS
8051µC
P0 4X4
Keyboard 4X4 Hex
FRC 26pin
Interface keypad
Cable
Card
PS
PS
8051µC
Temp Heat
P0,P2,P3 Sensor Source
FRC 26pin Interface
Cable
The interface card has a DAC to convert the actual temperature to digital this is compared
with reference temperature. Relay also a part of interface card will turn on and off to
indicate if the actual temperature is above or below reference.
#include <REG51xD2.H>
sbit Cmp_Out = P3^4; /*Input Bit for Comparator output*/
sbit Rel_Con = P0^0; /*Relay controller Bit i.e Heater Power supply control*/
/*1- Supply OFF, 0-Supply ON*/
#define Dac_Data P1 /*DAC input Data PORT i.e. P1*/
void delay()
{ int l;
for (l=0;l<=0x8;l++);
}
main()
{ unsigned char DacIp;
void delay(void);
Dac_Data =0x00; /*Move 00h to Dac input*/
P0=0x00; /*make P0 as output*/
while(1)
{ DacIp= 0xff; /*DAC input Data counter*/
do
{DacIp++; /*Increment the DAC input Data*/
Dac_Data = DacIp; /*Move the DAC data to DAC*/
delay(); }while(Cmp_Out); /* Check comparator output for low */
if(DacIp > 0x20) /*Compare with the set value i.e.0x20*/
Rel_Con = 1;
else
Rel_Con = 0; }} /* Relay ON, Supply OFF */
A. Square waveform
B.Triangular Waveform
C.Ramp waveform
D.Sine waveform
8
0 Dual CRO
5 P0 Xout
DAC
1 P1
μC
Let initial, amplitude of the square wave be 2.5v(7F) and frequency count 100.
Output the values 00h (0ff) and 7fh(on) Values through P0.
If amplitude key is pressed then increase the voltage in steps of 0.15v(8).
If the frequency key is pressed increment the count in steps of 50. If the count
exceeds 1000 reset it back to 100.
Every time amplitude and frequency changes output the value thro P0 and note the
waveform on CRO.
#include <REG51xD2.H>
sbit Amp = P3^3; /* Port line to change amplitude */
sbit Fre = P3^2; /* Port line to change frequency */
void delay(unsigned int x) /* delay routine */
{
for(;x>0;x--);
}
main()
{
unsigned char on = 0x7f,off=0x00;
unsigned int fre = 100;
while(1)
{
if(!Amp) /* if user choice is to change amplitude */
{
while(!Amp); /* wait for key release */
on+=0x08; /* Increase the amplitude */
}
if(!Fre) /* if user choice is to change frequency */
#include <REG51xD2.H>
main()
{
unsigned char i=0;
P0 = 0x00; /* P0 as Output port */
while(1)
{
for(i=0;i<0xff;i++){ /* Generate ON pulse */
P1 = i;
P0 = i;
}
for(i=0xfe;i>0x00;i--) /* Generate OFF pulse */
{P0 = i;
P1 = i;}
}
}
#include <REG51xD2.H>
main()
{ Unsigned char i=0;
P0 = 0x00; /* P0 as Output port */
while(1)
{
for (i=0;i<0xff;i++) /* Generate ON pulse */
{
P1 = i;
P0 = i; }
}
}
#include <REG51xD2.H>
main()
{
static int a[13]={128,192,238,255,238,192,128,64,17,0,17,64,128};
unsigned char i=0;
P0 = 0x00; /* P0 as Output port */
while(1)
{
for(i=0;i<13;i++) /* Output different values */
{
P0 = a[i];
}}}
Stepper Motor
• Stepper motor unlike DC motor rotates in steps.
• Stepper motor has 4 coils which forms the stator and a central rotor.
• Rotation depends on excitation of stator coils.
step coil A coil B coil C coil D
1 0 0 0 1
2 1 0 0 0
3 0 1 0 0
4 0 0 0 1
Anyone of these values forms the initial value. To get 3600 revolution 200 steps are
required.
Step angle= 360o /200 = 1.8o. (difference between 2 teeth).
PS
PS
8051µC
P0 Stepper
Motor Stepper
FRC 26pin
Interface Motor
Cable
Card
#include<REG51xD2.H>
void delay (unsigned int x) /* Delay Routine */
{
for(;x>0;x--);
return;
}
main( )
{unsigned char Val, i;
P0=0x00;
Val = 0x11;
for (i=0;i<4;i++)
{P0 = Val;
Val = Val<<1; /* Val= Val>>1; for clockwise direction*/
delay (500); }}
DC Motor
PS
PS
8051µC
P0 DC Motor
FRC 26pin Interface DC
Cable Card Motor
P3.2(inr)
P3.3(dec)
#include <REG51xD2.H>
sbit inr= P3^2; //speed increment switch
sbit dcr= P3^3; //speed decrement switch
main()
{
unsigned char i=0x80;
P0 = 0x7f; /*Run the motor at half speed.*/
while (1)
{ if (!inr)
{while (!inr);
if(i>10)
i=i-10; //increase the DC motor speed
}
if(!dcr)
{
while(!dcr);
if(i<0xf0)
i=i+10; //decrease the DC motor speed
}
P0=i;
} }
PS
PS
8051µC
P0 Elevator
FRC 26pin interface
Cable
Experiment I
Aim: To Demonstrate the Stepper Motor interface to 8051
Write a program to control stepper motor direction & speed through software.
Apparatus Required: ESA MCB51, RS232 cable, Power Adapter ESA ADD 5(2),
ESA Interface Module [Stepper Motor Module] & 26 pin
FRC connector.
Theory: A Steeper motor is a widely used device that translates electrical pulses
into Mechanical Movement.
There are two types of stepper motor:
a) Permanent magnet
b) Variable reluctance
Operations: Figure (1) shows a stepper motor in its simplest form .It consists of two
stator windings A, B & a motor having two magnetic poles N & S when a +ve Voltage is
applied to stator winding A, a magnetic field Fa is generated as shown in fig (a) The rotor
positions itself such that its poles lock with corresponding stator poles. With the winding
‘A’ Excited as before winding ‘B’ is now switched on to a +ve Voltage as shown in figure
(b).This produces a magnetic field Fb in addition to Fa .The resulting magnetic filed F
makes an angle of 450 as shown in fig (b). The rotor consequently moves through 45 0 in
Stepper Motor
PA0
PA1
8051 PA2
PA3
Com Com
COM +5v
COM +5V
Description:
The steeper motor interface uses 4 transistor pairs in a darlington
configuration. each Darlington pair is used to excite the particular winding of the motor
connected through 4 pin connector on the interface. The inputs to these transistors are
Expected Result:
When program is burn on interface module, motor rotates in anti-clock
wise .When interrupt button is pressed, direction changes.
Reference Questions:
1) Write a program to control stepper motor direction using port 0.
2) Demonstrate the stepper motor interface for 8051.
3) Write a program to control stepper motor direction so that it should start rotating
anti -clock wise direction.
4) Write a program to control speed of the stepper motor.
Experiment 2
Aim: To demonstrate the DC motor interface for 8051 .Write a program to control DC
motor Speed through softwares.
Apparatus Required: ESA MCB51, RS232 cable, Power Adapter ESA ADD-5 ESA
interface module [DC motor Module] & 26 pin FRC Connector.
Theory: DC motors are used in many applications like process control & automation in an
industry, robotics, consumer electronics etc.One can consider the use of DC motor where
ever there is need to control the motion of an object .Speed control of the motor is
important in the applications involving them .The DC motor used in this interface module
is a 12V, 4watt motor.
Operation: The Pulse Width Modulation technique is used to vary the speed of the DC
motor .The frequency of the Pulses is 120Hz. Keeping the frequency constant, the width of
the pulses is used to change the speed .When the pulse width is minimum, the speed is
Expected Result:
When program is burn on interface module, motor starts rotating from lower
speed to higher speed. To change the speed of motor, interrupt button has to be used.
Reference Questions:
1. Write a program to control the speed of the DC motor
2. Demonstrate the DC motor interface for 8051
3. Write a program to display measured speed of DC motor
4. Write a program to control the speed of DC motor & it should run with half speed.
Experiment: 3
Aim: To Demonstrate DAC interface to 8051. Write a program to generate a square wave
with 2.5V (0x7f) Amplitude . To change the amplitude use P3.3 (INT1) on 8051.
Apparatus Required: ESA MCB51, RS232 cable, power adapter, ESA interface Module
[DAC module] & 26 pin FRC connector.
Theory: The Dual DAC interface can be used to generate different intersecting wave
forms using 8051 c. There are 2 8bit Digital to Analog converters provided based on
DAC. The digital inputs to these DACs are provided through the port A & port B of 8051
used as output ports. The analog outputs from the DACs are given to operational
amplifiers which act as current to voltage converters. Two 10K pots are provided for the
offset balancing of Op-Amps.
Connection: For installing refer Dual DAC interface manual & part A
Reference Questions:
1. Write a program to generate a square wave with 2.5V amplitude
2. Demonstrate the DAC interface to 8051 for getting square wave with 2.5V
amplitude
3. Write a program to generate a Square wave with 5V amplitude.
Experiment:4
Apparatus Required: ESA MCB51, RS232 cable, power adapter ESA ADD-5, ESA
interface Module [DAC interface Module] & 26 pin FRC Connector & CRO.
Theory: The Dual DAC interface can be used to generate different wave forms using 8051
c. In this experiment DAC is used to generate triangular waveform. There are two 8 bit
Digital to Analog converters provided based on DAC. The Digital inputs to these DACs
are provided through the port A & port B of 8051 used as output ports. The analog outputs
from the DACs are given to Op-Amps which act as current to voltage converters. Two
10K pots are provided for the offset balancing of Op-Amps.
Connection: For connecting 8051 to Dual DAC interface module refers installing steps
from Dual DAC interface manuals & port A initiating Keil software.
Reference Questions:
1. Write a program to generate a triangular wave with 5V amplitude
2. Demonstrate the DAC interface to 8051 for getting triangular wave with 5V
amplitude
3. Write a program to generate a triangular wave with 10V amplitude.
Experiment :5
Apparatus Required: ESA MCB51, RS232, ESA ADD-5, ESA interface module [DAC
interface module]& 26-pin FRC connector & CRO.
Theory: The Dual DAC interface can be used to generate Ramp wave form there are two
8 bit Digital to Analog converters provided based on DAC. The digital inputs to these
DACs are provided through the port A & port B of 8051 used as output ports. The analog
outputs from the DACs are given to Op-Amps which act as current to voltage converters.
Two 10K pots are provided for the offset balancing of Op-Amps.
Connection: For connecting 8051 to Dual DAC interface module refer installing steps
from Dual DAC interface manual & part A initiating Keil software.
Reference Questions:
2. Demonstrate the DAC interface to 8051 for getting ramp wave with 5V
amplitude
Experiment: 6
Aim: Write a program to demonstrate Elevator interface to 8051
Apparatus Required: ESA MCB51, RS232 cable, ESAADD-5 (Power Adapter), ESA
interface module [Elevator interface module] & 26 pin FRC Connector.
Theory: Elevator interface simulates the control & operation of an Elevator. Four floors
are assumed & for each floor a key & corresponding LED indicator are provided to serve
as request buttons & request status indicators .The elevator itself is represented by a
column of ten LED’s the motion of the elevator can be simulated by turning on successive
LED’s, one at a time the delay between turning Off one LED & turning on the next LED
can simulate the “Speed”of the Elevator. User can need the request status information
through one port, reset the request indicators through another port & control the elevator
through another port.
Connection: For connecting 8051 to Elevator interface module refer Elevator interface
manual & part A initial steps of Keil software.
Expected Result: When program is burn on interface module, initially Other LED glows
& when buttons (0 , 1, 2, & 3) pressed that particular LED glows (0 or 1 or 2 or 3).
Reference Questions:
1. Write a program to demonstrate elevator interface to 8051
2. Write a program to perform elevator interface using 4 software’s & 4 LED’s
3. Using 3 different ports control the operation of elevator through software
Apparatus required: ESA, MCB51, RS232 cable, ESA ADD-5 (power adapter) ESA
interface module [Calculator Keyboard Interface Module] & 26 pin FRC Connector.
Operation: The 20 keys are arranged in a 3x8 matrix fashion .The row lines are driven by
PC0, PC1 & PC2. The column lines are read through port A. When no key is pressed, all
the return lines are low. The rows are driven high one after another in sequence when a
row is driven high. Pressing a key in that row causes the corresponding return line to be as
high. Then it scans for the column for which the key is depressed. The row and column
positions can then be used to encode the key as the scanning of the rows occurs at very
high speed compared to human reaction times.
Connection: For connection 8051 to calculator interface module refer calculator keypad
interface manual & part A initial steps of Keil software.
Expected result: When program is burn on interface module the module works as
calculator. It performs the following functions like Addition, Subtraction, Multiplication
etc.
Reference Questions:
1. Demonstrate the calculator keypad interface to 8051
2. Write a program to display calculated result on onboard LCD pattern 0f 8051
3. Write a program to display calculated result for 3x8 matrix fashioned calculator .
Aim: To demonstrate the Keyboard Interface to 8051. Write the program to display the
pressed key’s key code on the on-board LCD pattern of 8051.
Apparatus Required: ESA MCB51, RS232 cable, ESA ADD-5, ESA interface module
[Keyboard Interface Module]& 26-pin FRC connector.
Theory: The keyboard interface module consists of 20 keys. These 20 keys are arranged
in a 3x8 matrix .The row lines can be driven through port C & the status of column lines
can be read through port A. This interface allows the user to study a number of techniques
generally used in keyboard interfacing.
Connection: For connecting 8051 to Keyboard interface refer keyboard interface manual
& part A initiating steps of Keil software.
Expected Result: When program is burn on interface module, the key pressed by the user
will be displayed on LCD.
Reference Questions:
1. Demonstrate the keyboard interface to 8051
2. Write a program to display the pressed Keys’s key code on the on-board LCD
pattern of 8051
3. Write a program for key board interface to 8051