Tutorial Microcontroller MCS-51 ATMEL ISP
 

 

Super MCS51 Trainer

Standart MCS51 Trainer

Standart AVR Trainer

Programmer USBASP

Standart ARM Trainer

 

 

5.2. Displaying data ADC 0804 in 8x7 Segmen as a Decimal
In this lesson will be learn how to display data ADC on 8 x 7 segmen, for a simple task, we assume ADC have input ranges 0 - 5 volt, and then will display data as desimal that must be 3 digit 0 - 255, and each digit would be placed on 3rd, 2nd and 1st 7 segmen.

Figure 2.14. Connecting ADC and display to 7 segmen

 

Step 1st
Build the circuit as shown in figure 2.14. As you seen on figure 2.14. P0.0 trough P0.7 is connected to DB0 - DB7 ADC0804, and P2.0- P2.7. is connected to D0 - D7, and P3.0, P3.1. is connected to RS and EN each. Remember, that all we want to do with this lesson is write data ADC, in the first line of LCD Character

Step 2nd
In this step, you must tipe the assembly program to make your LCD Character shown the data, we assume that you have already known the editor, we used MIDE-51 to edit the program.

       org 0h
start: call ADC
call Bin2Dec
call Display2SevenSegmen sjmp start
; ;================================================= ;this subroutine is used to take data from ADC and
;keep to Accumulator ;=================================================
ADC: mov A,P0
nop
nop
ret ; ;========================================================
;this subroutine is used to convert binary data from ADC
;become decimal 3 digit
;======================================================== Bin2Dec:
mov b,#100d
div ab
mov hundreds,a
mov a,b
mov b,#10d
div ab
mov tens,a
mov ones,b
ret ;===============================================
;this subroutine is used to convert data ADC to
;8 x 7 segmen
;===============================================
Display2SevenSegmen:
Mov P2,#11111111b mov A, Hundreds mov DPTR,#Data7segmen movc A,@A+DPTR mov P0,A clr P2.5 call delay ; mov A,tens mov DPTR,#Data7segmen movc A,@A+DPTR setb P1.5 mov P0,A clr P2.6 call delay ; mov A,ones mov DPTR,#Data7segmen movc A,@A+DPTR setb P1.6 mov P0,A clr P2.7 call delay ret ; delay: mov R0,#0
delay1:mov R2,#0fh
djnz R2,$
djnz R0,delay1
ret ; Data7segmen:
db11000000b,11111001b,10100100b,10110000b,10011001b
db10010010b,10000010b,11111000b,10000000b,10010000b
end

NEXT