Edsim 51 Lab Manual Embedded System and Iot
Edsim 51 Lab Manual Embedded System and Iot
EXPERIMENT No. : 01
A. Aim: - Write Program for addition and subtraction of two 8-bit numbers using GNU
SIM software.
B. Apparatus Used: - 1. GNU SIM software.
C. Theory:-
EdSim51 Simulator
The top left box gives the user access to all the 8051's registers, data memory and code memory.
In the centre is a textbox where the user either loads an assembly program or writes the code
directly. Shown above is a program being single-stepped (execution is currently at location 0034H
in code memory - hence that line is highlighted).
On the right is a list of the 32 port pins and what each one is connected to. The current value of the
port pin is displayed here.
The bottom panel shows all the peripherals that are connected to the 8051.
I hope this simulator will help students learn to write programs to exercise the 8051. Students can
begin by ignoring the peripherals. In this way they can first become accustomed to the many
different move, arithmetic and branch instructions that make up the 8051 instruction set.
As the students gain experience and confidence they can then write code to scan a keypad, or
count the motor's revolutions, or multiplex 7-segment displays, etc.
Some of the peripherals share the same port pins. For example, the 7-segment displays' data lines
and the DAC are connected to port 1. This means that, if the student wishes to use the display
and the DAC together, he/she must learn how to disable one to access the other.
Consider the first number 26H is stored in memory location 8500H and the second number 62H is
stored in memory location 8501H. The result after addition of two numbers is to be stored in the
memory location 8502H. Assume program starts from memory location 8000H.
Algorithm:
1. Initialize the memory location of first number in HL register pair.
2. Move first number/data into accumulator.
3. Increment the content of HL register pair to initialize the memory location of second data.
4. Add the second data with accumulator.
5. Store the result in memory location 8003H.
Procedure:-
G. Conclusions:
The addition of two 8-bit numbers is performed using 8051 microcontroller where sum is 8 – bit.
H. Precautions:
1. Properly connect the 8051 microcontroller kit with power supply terminals.
2. Switch on the power supply after checking connections.
3. Handle the Trainer kit carefully.
EXPERIMENT No. : 02
A. Aim: Write a program for addition and subtraction of two 16-bit numbers using GNU SIM
software.
B. Apparatus Used: 1. GNU SIM software.
C. Theory:
Algorithm:
1. Initialize register C for using it as a counter for storing carry value.
2. Load data into HL register pair from the memory address 9000H and 9001H.
3. Exchange contents of register pair HL with DE.
4. Load second data into HL register pair from 9002H and 9003H.
5. Add register pair DE with HL, and store the result in HL.
6. If carry is not generated then go to Loop, else increment register C by 1.
8. Store value present in register pair HL to memory address 9004H and 9005H.
9. Move content of register C to accumulator A, and store the value present in accumulator (i.e.,
carry) into 9006H.
11. Terminate the program.
D. Program:
Memory Machine
Labels Mnemonics Operands Comments
address Codes
8000 0E,00 MVI C, 00H
8002 2A,00,90 LHLD 9000H Get first 16-bit number in HL
8005 EB XCHG Save first 16-bit number in DE
8006 2A,02,90 LHLD 9002H Get second 16-bit number in HL
Add register pair DE with HL and store
8009 19 DAD D
the result in HL.
800A D2,0E,80 JNC LOOP If carry is present, go to LOOP
800D 0C INR C Increment register C by 1.
Store value present in register pair HL to
800E 22,04,90 LOOP: SHLD 9004H
9004H.
G. Conclusions:
The addition and subtraction of two 16-bit numbers is performed using 8051 microcontroller
where sum and sub is 16 – bit.
H. Precautions:
1. Properly connect the 8051 microcontroller kit with power supply terminals.
2. Switch on the power supply after checking connections.
3. Handle the Trainer kit carefully.
EXPERIMENT No. : 03
A. Aim: To write an assembly language for multiplying and division two 8-bit numbers using
GNU SIM software.
B. Apparatus Used: 1. 8051 microcontroller kit.
2. +5V power supply.
C. Theory:
Consider the first number 25H is stored in register C and the second number 05H is stored in
Register E. The result after multiplication of two numbers is to be stored in the HL pair.
Assume program starts from memory location 8000H.
Algorithm:
1. Initialize the first number in C register.
2. Initialize the second number in E register.
3. Multiplication the second data with register C and store the result HL pair.
D. Procedure:(Program)
G. Conclusions:
The multiplication of two 8-bit numbers is performed using 8051 microcontroller where
multiplication is 8 – bit.
H. Precautions:
1. Properly connect the 8051 microcontroller kit with power supply terminals.
2. Switch on the power supply after checking connections.
3. Handle the Trainer kit carefully.
EXPERIMENT No. : 04
A. Aim: To write an Assembly Language Program to find the largest number in an array
of data using 8051 microcontroller kit.
C. Theory:
Algorithm
D. Program:
8014 HLT
Output at 8300 : FE H
G. Conclusions:
H. Precautions:
1. Properly connect the 8051 microcontroller kit with power supply terminals.
2. Switch on the power supply after checking connections.
3. Handle the Trainer kit carefully.
EXPERIMENT No. : 05
A. Aim: Write a program to make an LED chaser following the pattern given using EDSIM51
Software. Each transition will take place after a prescribed delay.
Theory:
This program displays the binary pattern from 0 to 255 (and back to 0) on the LEDs
Interfaced with port 1.A 1 in the pattern is represented by the LED on, while a 0 in the pattern is
represented by the LED off. However, logic 0 on a port 1 pin turns on the LED, therefore it is
necessary to write the inverse of the pattern to the LEDs. The easiest way to do this is to send the
data FFH to 0 (and back to FFH) to the LEDs. Since port 1 is initially at FFH all we need to do is
E. Conclusions:
F. Precautions:
4. Properly connect the 8051 microcontroller kit with power supply terminals.
5. Switch on the power supply after checking connections.
6. Handle the Trainer kit carefully.
EXPERIMENT No. : 06
A. AIM: Write a program to display series of numbers on seven segment display with
AT8051 Microcontroller.
B. Apparatus Used: EDSIM51 Software, AT89S51 Microcontroller etc.
C. Theory:-
A 7-Segment display is a useful electronic component use to
produce numeric, alphabetic and some non-alphabetic symbols using a specific arrangement of
LEDs as shown in figure here.
Digit H G F E D C B A
1 1 1 1 1 1 0 0 1
2 1 0 1 0 0 1 0 0
3 1 0 1 1 0 0 0 0
4 1 0 0 1 1 0 0 1
When running this program, best viewed with Update Freq. set to 100
; a crude delay
delay:
MOV R0, #200
DJNZ R0, $
RET
D. Observation: Write/ Plot Your Own With Observation Table (If Required).
F. Conclusions:
G. Precautions:
1. Properly connect the AT89S52 Ultra Development Kit with USB Cable.
2. Handle the Trainer kit carefully.
EXPERIMENT No. : 7
A. Aim: Write a program to interface Digital to Analog Converter use EDsim51 software for
positive ramp generator.
B. Apparatus Used:
Block Diagram
D. Program:
Note: When running this program, best viewed with Update Freq. set to 1.
Functional Description:-
E. Observation:
G. Conclusions:
H. Precautions:
7. Properly connect the 8051 microcontroller kit with power supply terminals.
8. Switch on the power supply after checking connections.
9. Handle the Trainer kit carefully.
EXPERIMENT No. : 8
G. Aim: Write a program to interface 4x3 Keypad with 8051. Use EDsim51 software to test
and verify the code.
H. Apparatus Used:
Schematic:
J. Program:
start:
; scan row0
SETB P0.3 ; set row3
CLR P0.0 ; clear row0
CALL colScan ; call column-scan subroutine
JB F0, finish ; | if F0 is set, jump to end of
program
; | (because the pressed key was found and its number is in R0)
; scan row1
SETB P0.0 ; set row0
CLR P0.1 ; clear row1
CALL colScan ; call column-scan subroutine
JB F0, finish ; | if F0 is set, jump to end of
program
; | (because the pressed key was found and its number is in R0)
; scan row2
SETB P0.1 ; set row1
CLR P0.2 ; clear row2
CALL colScan ; call column-scan subroutine
JB F0, finish ; | if F0 is set, jump to end of
program
; | (because the pressed key was found and its number is in R0)
; scan row3
SETB P0.2 ; set row2
CLR P0.3 ; clear row3
CALL colScan ; call column-scan subroutine
JB F0, finish ; | if F0 is set, jump to end of
program
; | (because the pressed key was found and its number is in R0)
finish:
JMP $ ; program execution arrives here when key is found - do nothing
; column-scan subroutine
colScan:
JNB P0.4, gotKey ; if col0 is cleared - key found
INC R0 ; otherwise move to next key
JNB P0.5, gotKey ; if col1 is cleared - key found
INC R0 ; otherwise move to next key
JNB P0.6, gotKey ; if col2 is cleared - key found
INC R0 ; otherwise move to next key
RET ; return from subroutine - key not found
gotKey:
SETB F0 ; key found - set F0
RET ; and return from subroutine
Note: When running this program, best viewed with Update Freq. set to 1.
Functional Description:-
K. Observation:
M. Conclusions:
N. Precautions:
10. Properly connect the 8051 microcontroller kit with power supply terminals.
11. Switch on the power supply after checking connections.
12. Handle the Trainer kit carefully.