You are on page 1of 18

EXPERIMENT NO.

: 01

BLINKING THE LED's ON


AES-51 DEVELOPMENT BOARD

AIM

• Writing a program to blink the LED's on the AES51 development board.

OBJECTIVES

• Understanding the outputs of the 8051 microcontroller


• Understanding How to program the AES 51 development board with a PC

APPARATUS

• AES51 Development Board.


• Serial Cable
• PC
• ASM51 Assembler
• Terminal Emulator (TE.exe)
• Text editor
THEORY
The 8051 microcontroller has 32 pins that can be used for input/output operations. They are
divided into 4 ports. So each port has 8pins and these ports has 8bit registers assigned to them.
When we want to turn a LED connected to a pin of the 8051 we have to make that pin output
5volts.

PROCEDURE

1. AES 51 board was connected to the PC and turned on.


2. Self test was performed to ensure functionality of the board.
3. Program was written using the text editor and saved as .ASM file.
4. Then the .ASM file was dragged and dropped on to the ASM51.EXE file.
5. After we got the .HEX file and .LST file for the program.
6. Then the Terminal emulator was opened and the Baud rate and other settings were
configured as below

Serial Port : COM1


Baud Rate : 9600
Parity :N
Data Bits :8
Stop Bits :1
Echo :N
Add Linefeeds(in) :N
Strip Linefeeds (out) :Y
Prompt Line :Y
Prompt Character :>

7. Then the AES 51 board was reset and the space bar was pressed.
8. Then typed “RX” and pressed enter.
9. Then alt+s was pressed.
10. Then the .HEX file was dropped onto the Terminal Emulator after the prompt was shown.
11. After that CALL 7000H was typed on the TE and pressed enter to run the program.
OBSERVATIONS

List file for the LED blinking program :

0090 1 P1 DATA 90H ; initialize the P1 register


2
7000 3 ORG 7000H ; Start location of the program
4
7000 7590F0 5 START: MOV P1,#11110000B ; turn off all LEDs
7003 111B 6 ACALL DELAY ; Delay for waiting some time
7
7005 7590E0 8 MOV P1,#11100000B ; turn on one LED
7008 111B 9 ACALL DELAY
700A 7590C0 10 MOV P1,#11000000B ; turn on 2 LEDs
700D 111B 11 ACALL DELAY
700F 759080 12 MOV P1,#10000000B ; turn on 3 LEDs
7012 111B 13 ACALL DELAY
7014 759000 14 MOV P1,#00000000B ; turn on all 4 LEDs
7017 111B 15 ACALL DELAY
16
7019 80E5 17 SJMP START ; Jump back to start
18
701B 7B32 19 DELAY: MOV R3, #50
701D 7A32 20 LOOP3: MOV R2, #50
701F 7964 21 LOOP2: MOV R1, #100
7021 D9FE 22 LOOP1: DJNZ R1, LOOP1
7023 DAFA 23 DJNZ R2, LOOP2
7025 DBF6 24 DJNZ R3, LOOP3
7027 22 25 RET ; Return to the line under where delay was
called
26
27 END
VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND
DISCUSSION

When we want to turn a LED connected to a output pin of the 8051 we have to make that pin
output 5 volts.
In the AES-51 board the LEDs are connected to the port 1. And they are connected through NOT
gates. Because of this difference in AES-51 development board we have to Make the bit value of
the corresponding pin to be 0 instead of 1.

To address the port 1 as P1 in our code we must first initialize the port 1 register
In order to do that we must write the code as P1 DATA 90H at the start of the program.

We can set bit value of each pin one by one to turn on the connected LED
As AES-51 is using NOT gates for output we have to clear the each bit
As a example when we want to turn on the LED connected to pin 0 of port one
we have to write the code as CLR P1.0
When we want to turn off the LED we must write SETB P1.0

But we have a easier way to set values for all the bits of the register by writing one line of code.
So for this experiment we use that method. Instead of writing code for each pin.
As a example when we want to turn on the LED connected to the first pin of the port 1,
we must write the code as MOV MOV P1,#01111111B

Then to animate the LED blinking We have to wait for some time before turning on the next LED so
for this purpose we use a software delay.
EXPERIMENT NO. : 02

DISPLAYNG CHARACTERS ON
LCD DISPLAY OF AES-51
DEVELOPMENT BOARD

AIM

• Displaying characters on LCD display of AES-51 development board.

OBJECTIVES

• Understanding the interfacing of the LCD with 8051 microcontroller


• Displaying ASCII characters on the AES-51 LCD
• Displaying 3 digit number on the AES-51 LCD

THEORY

AES-51 development board has a built in LCD display and it's capable of showing ASCII characters.
The address of the LCD is 0fff3h and it's controlled by 2 bits. Bit 90h (pin 0 of port 1) is
command/data where high = command and low = data. Bit 91h (pin 1 of port 1) is LCD enable.
Both data and command must be available at the LCD port for one millisecond before enable can
be pulled from low to high. The power up and initialization of the LCD is handled by the system
firmware.
APPARATUS

• AES51 Development Board.


• Serial Cable
• PC
• ASM51 Assembler
• Terminal Emulator (TE.exe)
• Text editor

PROCEDURE

1. Program was written with the notepad according to the LAB sheet and saved as .ASM file
2. Then it was compiled using the ASM51.exe
3. Then the hex file for the program was written to the AES-51 board memory using the
terminal emulator.
4. Then it was executed by typing CALL 7000h in the terminal emulator
5. The character “A” was observed in the display.
6. Then the program was modified to show 3 characters.
7. After the program was executed and the result was observed.
8. Then the previous program was modified to show a given 3 digit number on the LCD
display.
9. Then the program was executed on the AES-51 development board and result was
observed.

OBSERVATIONS

• In the firs program given in the LAB sheet the characted “A” was displayed on the LCD
• After the program was modified to show “ABC” characters.
When the program was executed the characters were displayed correctly on the LCD
• In the third time the program was modified to show the given 3 digit number.
LST for Program 1: Display character “A” on LCD

7000 1 ORG 7000H

2
7000 124100 3 CALL 4100H ;clear the LCD
7003 7441 4 MOV A, #65 ;ASCII value for “A”
7005 C290 5 CLR 90H ;select data write
7007 90FFF3 6 MOV DPTR, #0FFF3H ;LCD address
700A F0 7 MOVX @DPTR, A ;Send data to LCD
700B 7800 8 MOV R0, #0
9
700D D8FE 10 DJNZ R0, $ ;delay 1ms
700F D8FE 11 DJNZ R0, $ ;1020 machine cycles
7011 C291 12 CLR 91H ;strobe enable by clear
7013 D291 13 SETB 91H ;then set bit
7015 22 14 RET
15 END
VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND
LST for Program 2 : Display characters “ABC” on LCD

7000 1 ORG 7000H


2
7000 124100 3 CALL 4100H ;clear the LCD
4
7003 7441 5 MOV A, #65 ;ASCII value for “A”
7005 110D 6 ACALL PRINT
7007 7442 7 MOV A, #66 ;ASCII value for “B”
7009 110D 8 ACALL PRINT
700B 7443 9 MOV A, #67 ;ASCII value for “C”
10
700D C290 11 PRINT: CLR 90H
700F 90FFF3 12 MOV DPTR, #0FFF3H
7012 F0 13 MOVX @DPTR, A
7013 7800 14 MOV R0, #0
15
7015 D8FE 16 DJNZ R0, $
7017 D8FE 17 DJNZ R0, $
7019 C291 18 CLR 91H
701B D291 19 SETB 91H
701D 22 20 RET
21 END

VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND


LST for Program 3 : Display number “147” on LCD
00F0 1 B DATA 0F0H ;initialize the B register
7000 2 ORG 7000H
3
7000 124100 4 ;clear LCD
5
7003 7493 6 MOV A,#147 ;given number into accumulator
7005 75F064 7 MOV B,#100
7008 84 8 DIV AB ;separate the first number
7009 2430 9 ADD A,#48 ;add 48 to get the ASCII value
700B F9 10 MOV R1,A ;save the value in R1
11
700C E5F0 12 MOV A,B ;move value from “B” to accumulator
700E 75F00A 13 MOV B,#10
7011 84 14 DIV AB ;separate the second number
7012 2430 15 ADD A,#48 ;add 48 to get the ASCII value
7014 FA 16 MOV R2,A ;save the value in R2
17
7015 E5F0 18 MOV A,B ;move value from “B” to accumulator
7017 2430 19 ADD A,#48 ;add 48 to get the ASCII value
7019 FB 20 MOV R3,A ;save the value in R3
21
701A E9 22 MOV A,R1 ;move value from R1 to accumulator
701B 1121 23 ACALL PRINT ;display the number on LCD
24
701D EA 25 MOV A,R2 ;move value from R2 to accumulator
701E 1121 26 ACALL PRINT ;display the number on LCD
27
7020 EB 28 MOV A,R3 ;move value from R3 to accumulator
29
7021 C290 30 PRINT: CLR 90H
7023 90FFF3 31 MOV DPTR, #0FFF3H
7026 F0 32 MOVX @DPTR, A
7027 7800 33 MOV R0, #0
34
7029 D8FE 35 DJNZ R0, $
702B D8FE 36 DJNZ R0, $
702D C291 37 CLR 91H
702F D291 38 SETB 91H
7031 22 39 RET
40 END

VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND


DISCUSSION

AES-51 development board has a built-in LCD display. This display is configured by the firmware to
display the ASCII character for the value in the memory location 0fff3h.
This is 16 bit but the accumulator is 8 bit so we can't directly put the value in the accumulator to
this memory location so we have to use indirect addressing.
So we put the memory location for the LCD into the data pointer (DPTR) and after that we send the
value in the accumulator to the location of the address in the data pointer (DPTR)
the code for this is :
MOV DPTR, #0FFF3H
MOVX @DPTR, A

There is a enable pin in the LCD to trigger it. This pin requires a high→ low pulse to trigger the LCD
and print the character. To send that pulse we use the pin 1 of port 1.
It's done in the code by
CLR 91H
SETB 91H
But this is a low → high pulse; we have to use this pulse because the pin 1 of port 1 is connected
to the enable pin of the LCD through a NAND gate. So at the end it's sent to the LCD as a
high→ low pulse.

Before printing the character “A” there are characters on the LCD so the character “A” was printed
after those characters. Because of this we have to clear the LCD before sending data to the LCD
so for that we use the built-in method for clearing the LCD.
it's located at memory location 4100H so at the beginning of the program we use
“CALL 4100H” to clear the LCD

When printing multiple characters to the LCD it's done by printing one character at a time.
So in the program for printing “ABC” we have to use a delay to print one character at a time

When displaying a 3 digit character on the LCD we have to separate the digits because we can only
print one at a time.
So we use DIV command to do this.
When we use this command the value in the accumulator is dived by the value in the B register
and the accumulator is loaded with the quotient and B register with the remainder
as a example;
we have 147 in the accumulator and 100 in the B register
when we use the command DIV AB
accumulator is left with 1 and the B register has the 47

This B register is a special register in the 8051 microcontroller and it's used to division and
multiplication purposes.
EXPERIMENT NO. : 03

CONVERTING A ANALOG VOLTAGE TO


IT'S CORRESPONDING DIGITAL OUTPUT
USING A/D CONVERTER

AIM

• Converting a analog voltage to it's corresponding digital output using A/D converter in
AES-51 development board.

OBJECTIVES

• Understanding the working of a A/D converter


• Using A/D converter to identify a unknown voltage
• Displaying the corresponding digital output for a voltage on the LCD
APPARATURES

• AES51 Development Board.


• Serial Cable
• PC
• ASM51 Assembler
• Terminal Emulator (TE.exe)
• Text editor
• Fixed resistor and variable resistor
• Screwdriver
• Multimeter
• Breadboard
• Wires

THEORY

A/D converter is used to output a digital value for a given analog voltage according to the
reference voltage set for the A/D converter.
In the AES-51 board ADC address is 0fff7h and the ADC control bit address is 93h (pin 3 of port 1).
ADC is started by writing anything to the address 0fff7h. And the 93h bit is kept high until the A/D
conversion is finished. After the conversion is finished 93h bit is set low to signal the completion of
the A/D conversion. At the end of this process the accumulator is loaded with the digital output
from the A/D conversion.
PROCEDURE

1. The program for the A/D conversion in the LAB sheet was examined.
2. Then it was combined with the previous program to display 3 digits on the LCD
3. Then a delay was used to update the LCD real-time with the ADC output.
4. This program was compiled using the AES51.exe and written to the AES-51 development
board using the terminal emulator.
5. Then the A/D input was connected to the ground and the LCD display was observed
6. After that A/D input was connected to the +5v and the LCD display was observed.
7. Then the fixed resistor and the variable resistor was connected as shown below.

+5v

ADC

8. Voltage across the variable resistor was measured using the multimeter while changing the
variable resistor.
9. A/D input of the AES-51 board was connected to the middle of the voltage divider and the
digital output was noted down for each multimeter reading.
10. Using the readings error percentage was calculated for each reading and the graph was
plotted.
OBSERVATIONS

• Digital output displayed on LCD when A/D was connected to ground = 000
• Digital output displayed on LCD when A/D was connected to +5V = 255

Voltage in (V) Digital output on LCD


4.62 241
4.2 225
4 213
3.8 197
3.6 193
3 155
2.6 131
2.54 132
2 103
1.6 78
LST file for the A/D conversion and display program:

00F0 1 B DATA 0F0H


2
7000 3 ORG 7000H
4
5
7000 124100 6 START: CALL 4100H
7
7003 D293 8 SETB 93H ;set 93h bit high
7005 90FFF7 9 MOV DPTR, #0FFF7H ;put 0FFF7H into DPTR
7008 F0 10 MOVX @DPTR, A ;put value to 0FFF7H to start ADC
7009 2093FD 11 JB 93H, $ ;wait for ADC finish
700C E0 12 MOVX A, @DPTR ;put digital output to accumulator
13
14
700D 75F064 15 MOV B,#100 ;program to display the value
7010 84 16 DIV AB
7011 2430 17 ADD A,#48
7013 F9 18 MOV R1,A
19
7014 E5F0 20 MOV A,B
7016 75F00A 21 MOV B,#10
7019 84 22 DIV AB
701A 2430 23 ADD A,#48
701C FA 24 MOV R2,A
25
701D E5F0 26 MOV A,B
701F 2430 27 ADD A,#48
7021 FB 28 MOV R3,A
29
7022 E9 30 MOV A,R1
7023 112F 31 ACALL PRINT
32
7025 EA 33 MOV A,R2
7026 112F 34 ACALL PRINT
35
7028 EB 36 MOV A,R3
7029 112F 37 ACALL PRINT
38
702B 1140 39 ACALL DELAY
702D 80D1 40 SJMP START
41
702F C290 42 PRINT: CLR 90H ;program to print character on LCD
7031 90FFF3 43 MOV DPTR, #0FFF3H
7034 F0 44 MOVX @DPTR, A
7035 7800 45 MOV R0, #0
46
7037 D8FE 47 DJNZ R0, $
7039 D8FE 48 DJNZ R0, $
703B C291 49 CLR 91H
703D D291 50 SETB 91H
703F 22 51 RET
52
7040 7B0A 53 DELAY: MOV R3, #10 ; delay to refresh the ADC
7042 7A32 54 LOOP3: MOV R2, #50
7044 7964 55 LOOP2: MOV R1, #100
7046 D9FE 56 LOOP1: DJNZ R1, LOOP1
7048 DAFA 57 DJNZ R2, LOOP2
704A DBF6 58 DJNZ R3, LOOP3
704C 22 59 RET
60
61 END
VERSION 1.2h ASSEMBLY COMPLETE, 0 ERRORS FOUND
CALCULATIONS
Resolution of the A/D chip = 8

Refarance voltage = +5v

Step size = 5 = 5 = 0.01953125V


28
256

Voltage in (V) Digital output on LCD Calculated V in (V) Error %


4.62 241 4.707031 1.88379
4.2 225 4.394531 4.63170
4 213 4.160156 4.00391
3.8 197 3.847656 1.25411
3.6 193 3.769531 4.70920
3 155 3.027344 0.91146
2.6 131 2.558594 1.59255
2.54 132 2.578125 1.50098
2 103 2.011719 0.58594
1.6 78 1.523438 4.78515
DISCUSSION
A/D conversion is the process of converting a analog signal to a set of digital values.
To do this process A/D converted IC uses a 3 step process

1) Sampling
This is the process of dividing the continuous analog signal to small steps.
The size of these steps varies with the resolution of the A/D IC and the reference voltage provided
to the IC. Resolution is the number of bits in the digital output of the IC
as a example the A/D IC in the AES-51 board has 8 bits resolution

Step size = V reference


2resolution

2) Quantizing
The process of calculating the digital output according to the given analog signal is known as
Quantizing.

Digital out = V in
step size

3) Encoding
The process of recording the digital output for the given analog signal to memory is known as
encoding

In the AES-51 board we has the A/D converter IC ADC0804. It has 8 resolution bits and one analog
input. So it has digital output range of 0-255.
similar to the LCD on the AES-51 the A/D converter has it's own memory location it's addressed as
0fff7h. As this is 16 bit we have to use indirect addressing for transfer data between accumulator
and the 0fff7h memory location.

When we want to start the A/D conversion we have to put any value into this 0fff7h memory
location and set the 93h bit as high. Then the A/D conversion starts. At the end of the conversion
the 93h bit is set as low and the digital output from the A/D conversion is sent to the accumulator.

In this experiment we have used the program we designed for displaying the 3 digits on LCD in the
previous experiment. And it was combined with the A/D conversion program given in the LAB
sheet.
And after that we needed a way to update the digital output in real-time so we used a delay to
continuously refresh the ADC program and the output to the LCD.

While observing the digital output to each analog input we had to disconnect the A/D input pin to
keep the multimeter reading correct. Because when we connect the A/D input there builds a
parallel resistance to the variable resistor in the voltage divider.

You might also like