DIWAKAR SHARMA Embedded - System - Lab - Manual
DIWAKAR SHARMA Embedded - System - Lab - Manual
SESSION: 2023-2024
Lab Manual
EMBEDDED SYSTEM DESIGN
BACHELOR OF TECHNOLOGY
IN
ELECTRONICS AND COMMUNICATION
List of Experiments
PROGRAM:
MOV R0,#50H // Initialize the source memory pointer
MOV R1,#60H // Initialize the destination memory pointer
MOV R2,#05H // Initialize Iteration counter
BACK: MOV A,@R0 // Get the data from source memory pointer and Load
// into Accumulator
XCH A,@R1 // Exchange data between Accumulator and
// destination memory pointer
MOV @R0,A // Store the data into source memory pointer
INC R0 // Increment the source memory pointer
INC R1 // Increment the destination memory pointer
Before execution:
D:0x50H: 01 02 03 04 05 00
D:0X60H: 06 07 08 09 10 00
After execution:
D:0x50H: 06 07 08 09 10 00
D:0X60H: 01 02 03 04 05 00
EXPERIMENT NO.: 2
APPRATUS:
4. 8051 micro controller kit.
5. PC for connecting the DYNA51 kit.
6. Keil-U-Vision software for compilation of program.
Program :
Org 0000h
mov a,#10h
mov b,#5h
add a,b
mov r1,a
clr a
mov b,#00h
mov a,#20h
mov b,#10h
subb a,b
mov r2,a
clr a
mov b,#00h
mov a,#2h
mov b,#2h
mul ab mov
r3,a clr a
mov b, #00h
mov a,#21h
mov b,#2h
div ab
mov r4,a
mov r5,b
end
EXPERIMENT NO.: 3
APPRATUS:
7. 8051 micro controller kit.
8. PC for connecting the DYNA51 kit.
9. Keil-U-Vision software for compilation of
program. 10.LCD PIO CARD for DYNA51.
Theory: This program keeps checking P1.0 for low signal. Once a low signal
arrives, program checks for AAh at PORT 0. If the data is AAh a counter will
start.
PROGRAM:
ORG 00H
/*INITIALIZING THE COUNTER AND PORTS*/
MAIN: MOV P0, #0FFH
MOV P1, #0FFH
MOV P2, #00H
MOV R0, #00H
/*WAITING FOR THE ARRIVAL OF LOW SIGNAL AT PORT 1.0*/
WAIT: JB P1.0, WAIT // CONDITIONAL BIT JUMP
ACALL VERIFY_DATA // CONDITIONAL CALL
SJMP WAIT // UNCONDITIONAL JUMP
//CHECKING THE DATA AT P0 FOR 0AAh
VERIFY_DATA:MOV A, P0
CJNE A, #0AAH, RETURN // CONDITIONAL BYTE JUMP
INC R0
MOV P2, R0
ACALL DELAY // UNCONDITIONAL CALL
RETURN:RET // RETURN
/*JUST A DELAY SUBROUTINE */
DELAY:NOP
MOV R2,#25
APPRATUS:
11.8051 micro controller kit.
12. PC for connecting the DYNA51 kit.
13. Keil-U-Vision software for compilation of
program. 14.LCD PIO CARD for DYNA51.
Program:
ORG 00H
MOV DPTR, #LCDString ; Load the address of the LCD string
CALL LCD_Init ; Initialize the LCD
CALL Keypad_Init ; Initialize the keypad
MAIN:
CALL Read_Keypad ; Read the keypad
MOV A, R0 ; Store the pressed key in A
Display_LCD:
MOV A, @DPTR ; Load the character from the string
CJNE A, #00H, Display_Char
; End of the string, loop back to read keypad
SJMP MAIN
Display_Char:
CALL Send_Data ; Send character to LCD
INC DPTR ; Move to the next character in the string
SJMP MAIN
END
EXPERIMENT NO: 5
APPRATUS:
15.8051 micro controller kit.
16. PC for connecting the DYNA51 kit.
17. Keil-U-Vision software for compilation of
program. 18.LCD PIO CARD for DYNA51.
Theory: Read an analog voltage at the input of ADC given as the knob position
using 8051 microcontrollers. An Analog to Digital Converter (ADC) is a very
useful feature that converts an analog voltage on a pin to a digital number.
The binary counter is initially reset to 0000; the output of integrator reset to 0V
and the input to the ramp generator or integrator is switched to the unknown
analog input voltage VA. The analog input voltage VA is integrated by the
inverting integrator and generates a negative ramp output. The output of
comparator is positive and the clock is passed through the AND gate. This results
in counting up of the binary counter.
OPERATING PROCEDURE FOR ADC CARDS:
3. Connect ADC card to 26 pin frc connector of Dyna-51EB.
4. Connect +12V ,-12V and GND supply lines to the ADC card.
5. Connect 16X2 LCD card (J1) to PORT 3 of Dyna-51EB in 4 bit
mode.
6. Download the program adc.hex (given in the CD) through flash magic.
Apply the analog input at the phono jack
Program
ORG 0000H
L
J
M
P
M
A
I
N
O 0
R 3
G 0
0 H
MAIN: NOP
EN EQU P2.0
RS EQU P2.2
// RW EQU P1.1
DAT EQU P2
LCALL LCD_INT
LCALL CLEAR
LCALL LINE1
MOV DPTR, #MYDATA
LCALL LOOP
LCALL LINE2
MOV DPTR, #MYDAT2
LCALL LOOP
LCALL LINE5
lcall dispH
again: lcall adconvert
LCALL LINE3
lcall adisph
LCALL LINE4
lcall adispl
SJMP again
;==================================================================
=======
W_NIB: PUSH ACC ;Save A for low nibble
ORL DAT,#0F0h ;Bits 4..7 <- 1
ORL A,#0Fh ;Don't affect bits 0-3
ANL DAT,A ;High nibble to display
SETB EN
CLR EN
POP ACC ;Prepare to send
SWAP A ;...second nibble
ORL DAT,#0F0h ; Bits 4...7 <- 1
ORL A,#0Fh ; Don't affect bits 0...3
ANL DAT,A ;Low nibble to display
SETB EN
CLR EN
RET
;==================================================================
=======
LCD_INT: CLR RS
// CLR RW
CLR EN
SETB EN
MOV DAT,#028h
CLR EN
LCALL SDELAY
MOV A,#28h
LCALL COM
MOV A,#0Ch
LCALL COM
MOV A,#06h
LCALL COM
LCALL CLEAR
MOV A,#080H
LCALL COM
RET
;==================================================================
=======
CLEAR: CLR RS
MOV A,#01h
LCALL COM
RET
;==================================================================
=======
DATAW: SETB RS
// CLR RW
LCALL W_NIB
LCALL LDELAY
RET
;==================================================================
=======
SDELAY: MOV R6,#1
HERE2: MOV R7,#255
HERE: DJNZ R7,HERE
DJNZ R6,HERE2
RET
;==================================================================
=======
LDELAY: MOV R6,#1
HER2: MOV R7,#255
HER: DJNZ R7,HER
DJNZ R6,HER2
RET
;==================================================================
=======
COM: CLR RS
// CLR RW
LCALL W_NIB
LCALL SDELAY
RET
;==================================================================
=======
LINE1: MOV A,#80H
LCALL COM
RET
LINE2: MOV A,#0C0H
LCALL COM
RET
LINE3: MOV A,#0c9H
LCALL COM
RET
LINE4: MOV A,#0cah
LCALL com
RET
LINE5: MOV A,#0cbh
LCALL com
RET
;==================================================================
=======
LOOP: CLR A
MOVC A,@A+DPTR
JZ GO_B2
LCALL DATAW
LCALL SDELAY
INC DPTR
SJMP LOOP
GO_B2: RET
ADisph:
M
O
V
a
ADispl: ,
r
3
L
C
A
L
L
D
A
T
A
W
L
C
A
L
L
S
D
E
L
A
Y
ret
M
O
V
a W
, L
r C
4 A
L L
C L
A S
L D
L E
D L
A A
T Y
A ret
;==================================================================
=======
MYDATA: DB " PIO-ADC-01 ",0
MYDAT2: DB " ADC i/p= ",0
dispH:
MOV a,#48H ;ascii for H
LCALL DATAW
LCALL SDELAY
ret
;==================================================================
====
adconvert:
;
START EQU P1.0 ; Pin 6 Start
EOC EQU P1.3 ; Pin 7 EOC
OE EQU P1.1 ; Pin 9 Output Enable
ALE EQU P1.2 ; Pin 22 ALE
adata EQU P0 ; Data Lines
;
; Read one byte of data from adc.
; Performs a analog conversion cycle.
; address of channel in register "ADDRESS",
; Returns data in BUFFER
; Destroys A.
MOV adata,#0FFH ; Data lines for input
SETB OE ; Disable output
SETB ALE ; Latch the address
NOP
nop
nop
NOP
SETB START ; Start the conversion
NOP
NOP
NOP
CLR START
NOP
NOP
EOCLOOP:
JNB EOC, EOCLOOP; Do until EOC high CLR
OE ; Output Enable
MOV a,adata ; Get data in buffer
SETB OE
CLR ALE
Result:
The Digital data corresponding to the analog input is shown in the LCD.
Viva Questions:
1. Why 8051 is called 8 bit microcontroller?
2. How much on chip ram is available on 8051?
3. What is special Function Registers (SFR)?
4. Which bit of the flag register is set when output overflows to the sign bit?
5. Explain whether Port 0 of 8051 cab be used as input output port?
EXPERIMENT NO: 6
AIM: - Write an assembly language program to implement the basic wave form
generation using DAC, output is displayed on a CRO and demonstrate on 8051
microcontroller board.
APPRATUS:
1. 8051 micro controller kit.
2. PC for connecting the DYNA51 kit.
3. Keil-U-Vision software for compilation of program.
4. DAC PIO CARD for DYNA51.
ORG 0H
; Define your DAC-related constants and ports
DAC_CTRL EQU P1 ; DAC control port
DAC_DATA EQU P2 ; DAC data port
TRIANGLE_RANGE EQU 255 ; Range of the triangle waveform
DELAY_COUNT EQU 100 ; Delay for waveform frequency control
MAIN:
MOV A, #0 ; Initialize A to 0
LOOP:
ACALL Generate_Triangle
ACALL Delay
INC A
AIM: - Write an Arduino IDE program for Blinking an LED with a delay of
2 seconds and demonstrate on 8051 microcontroller Ardunio board.
Materials:
● Arduino board (e.g., Arduino Uno)
● LED
● Resistor (220-330 ohms)
● Breadboard
● Jumper wires
Procedure:
1. Hardware Setup:
● Connect the cathode (shorter leg) of the LED to a current-limiting resistor
(220-330 ohms).
● Connect the other end of the resistor to a digital pin (e.g., Pin 13) on
the Arduino board.
● Connect the anode (longer leg) of the LED to the GND (ground) pin
on the Arduino board.
● Ensure the hardware connections are secure.
2. Arduino IDE Programming:
● Open the Arduino IDE on your computer.
● Write the following code:
const int ledPin = 13; // Pin 13 is the default built-in LED pin
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
digitalWrite(ledPin, HIGH); // Turn the LED on
delay(2000); // Wait for 2 seconds
digitalWrite(ledPin, LOW); // Turn the LED off
delay(2000); // Wait for 2 seconds
}
3. Upload the Code:
Connect your Arduino board to your computer using a USB cable.
Select the correct board and port from the "Tools" menu in the Arduino IDE.
Click the "Upload" button to upload the code to the Arduino board.
4. Observation:
You should see the LED on your Arduino board blinking with a 2-second delay.
Conclusion:
You have successfully programmed an Arduino board to blink an LED with a 2-
second delay, demonstrating the basic functionality of an Arduino microcontroller.
EXPERIMENT NO: 8
Procedure:
3. Hardware Setup:
● Connect the cathode (shorter leg) of the LED to a current-limiting resistor
(220-330 ohms).
● Connect the other end of the resistor to a digital pin (e.g., Pin 13) on
the Arduino board.
● Connect the anode (longer leg) of the LED to the GND (ground) pin on
the Arduino board.
● Ensure the hardware connections are secure.
4. Arduino IDE Programming:
● Open the Arduino IDE on your computer.
● Write the following code:
void setup() {
// Set the LED pins as outputs
pinMode(redLED, OUTPUT);
pinMode(yellowLED, OUTPUT);
pinMode(greenLED, OUTPUT);
}
void loop() {
// Red light digitalWrite(redLED,
HIGH);
digitalWrite(yellowLED, LOW);
digitalWrite(greenLED, LOW);
delay(4000); // 4 seconds
// Green light
You should see the Red LED for 4 seconds, Green LED for 5 seconds,
Yellow for 2seconds.
Conclusion:
You have successfully programmed an Arduino board to blink Red LED for 4
seconds, Green LED for 5 seconds, Yellow for 2seconds.
EXPERIMENT NO: 9
AIM: - Write an Arduino IDE program for Blinking an 5 LEDs with a delay
of 2 seconds in a sequence.
Materials:
● Arduino board (e.g., Arduino Uno)
● LED
● Resistor (220-330 ohms)
● Breadboard
● Jumper wires
Procedure:
5. Hardware Setup:
● Connect the cathode (shorter leg) of the LED to a current-limiting resistor
(220-330 ohms).
● Connect the other end of the resistor to a digital pin (e.g., Pin 13) on the
Arduino board.
● Connect the anode (longer leg) of the LED to the GND (ground) pin
on the Arduino board.
● Ensure the hardware connections are secure.
6. Arduino IDE Programming:
● Open the Arduino IDE on your computer.
● Write the following code:
void setup() {
// Set the LED pins as outputs
for (int i = 0; i < numLeds; i++) {
pinMode(ledPins[i], OUTPUT);
}
}
void loop() {
for (int i = 0; i < numLeds; i++) {
digitalWrite(ledPins[i], HIGH); // Turn the LED on
delay(2000); // Wait for 2 seconds
digitalWrite(ledPins[i], LOW); // Turn the LED off
}
}
3. Upload the Code:
Connect your Arduino board to your computer using a USB cable.
Select the correct board and port from the "Tools" menu in the Arduino IDE.
Click the "Upload" button to upload the code to the Arduino board.
4. Observation:
AIM: - Write an Arduino IDE program for connecting a servo motor to Arduino
board and rotate in clockwise and anti-clockwise direction using switches.
Materials:
● Arduino board (e.g., Arduino Uno)
● LED
● Resistor (220-330 ohms)
● Breadboard
● Jumper wires
Procedure:
7. Hardware Setup:
● Connect the cathode (shorter leg) of the LED to a current-limiting resistor
(220-330 ohms).
● Connect the other end of the resistor to a digital pin (e.g., Pin 13) on
the Arduino board.
● Connect the anode (longer leg) of the LED to the GND (ground) pin on
the Arduino board.
● Ensure the hardware connections are secure.
8. Arduino IDE Programming:
● Open the Arduino IDE on your computer.
● Write the following code:
void setup() {
// Set the LED pins as outputs
for (int i = 0; i < numLeds; i++) {
pinMode(ledPins[i], OUTPUT);
}
void loop() {
for (int i = 0; i < numLeds; i++) {
digitalWrite(ledPins[i], HIGH); // Turn the LED on
delay(2000); // Wait for 2 seconds
digitalWrite(ledPins[i], LOW); // Turn the LED off
}
}