|
|
BACK
NEXT
Step 1st
Build the circuit as shown in figure 2.5.2. As you seen on figure 2.5.2.
P3.0 trough P3.7 is connected to DB0 - DB7 ADC0804, and P2.0- P2.7.
is connected to transistor driver, and P3.0 trough P3.7. is connected
to 7 Segmen. Remember, that all we want to do with this lesson is write
data ADC, to 8 x 7 Segmen.
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-51o edit the program.
( Download File asm : exp253.zip,
Download Complete Circuit File : ADC.pdf)
org 0h hundreds_100 equ 30h tens_10 equ 31h ones_1 equ 32h dataadc equ 33h 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_100,a mov a,b mov b,#10d div ab mov tens_10,a mov ones_1,b ret ;=============================================== ;this subroutine is used to convert data ADC to ;8 x 7 segmen ;=============================================== Display2sevensegmen: mov P2,#11111111b ; P1 = 11111111b mov DPTR,#hundreds ; DPTR = [hundreds ] mov A,DataADC ; A = [DataADC] movc A,@A+DPTR ; A = [A+DPTR] mov DPTR,#Data7segmen; DPTR = [Data7Segmen] movc A,@A+DPTR ; A = [A+DPTR] mov P0,A ; P0 = A clr P2.1 ; P2.1 = 0, displaying hundreds Acall delay ; mov DPTR,#tens ; DPTR = [ tens ] mov A,DataADC ; A = [DataADC] movc A,@A+DPTR ; A = [A+DPTR] mov DPTR,#Data7segmen; DPTR = [Data7Segmen] movc A,@A+DPTR ; A = [A+DPTR] setb P2.1 ; P2.1 = 1 mov P0,A ; P0 = A clr P2.2 ; P2.2 = 0, displaying hundreds Acall delay ; mov DPTR,#ones ; DPTR = [ ones] mov A,DataADC ; A = DataADC movc A,@A+DPTR ; A =[ A+DPTR] mov DPTR,#Data7segmen; DPTR = [Data7Segmen] movc A,@A+DPTR ; A = [A+DPTR] setb P2.2 ; P2.2 = 1 mov P0,A ; P0 = A clr P2.3 ; P2.3 = 0, displaying ones Acall delay ; setb P2.3 mov P0,#11111011b clr P2.4 ; P2.4 = 0, displaying coma Acall delay ; mov DPTR,#fraction mov A,DataADC movc A,@A+DPTR mov DPTR,#Data7segmen movc A,@A+DPTR setb P2.4 mov P0,A clr P2.5 ; P2.5 = 0, displaying fraction Acall delay ret ; setb P2.5 mov P0,#10100011b clr P2.6 ; P2.6 = 0, displaying o Acall delay ; setb P2.6 mov P0,#11000011b clr P2.7 ; P2.7 = 0, displaying C Acall delay ; delay: mov R0,#0 delay1:mov R2,#0fh djnz R2,$ djnz R0,delay1 ret ; fraction : db 0,4,8,2,6,0,4,7,1,5,9,3,7,1,5,9,3,7,1,5,8,2,6,0,4 db 8,2,6,0,4,8,2,5,9,3,7,1,5,9,3,7,1,5,9,3,6,0,4,8,2,6 db 0,4,8,2,6,0,4,7,1,5,9,3,7,1,5,9,3,7,1,5,8,2,6,0 db 4,8,2,6,0,4,8,2,5,9,3,7,1,5,9,3,7,1,5,9,3,6,0,4,8,2 db 6,0,4,8,2,6,0,4,7,1,5,9,3,7,1,5,9,3,7,1,5,8,2,6 db 0,4,8,2,6,0,4,8,2,5,9,3,7,1,5,9,3,7,1,5,9,3,6,0,4,8 db 2,6,0,4,8,2,6,0,4,7,1,5,9,3,7,1,5,9,3,7,1,5,8,2 db 6,0,4,8,2,6,0,4,8,2,5,9,3,7,1,5,9,3,7,1,5,9,3,6,0,4 db 8,2,6,0,4,8,2,6,0,4,7,1,5,9,3,7,1,5,9,3,7,1,5,8,2,6 db 0,4,8,2,6,0,4,8,2,5,9,3,7,1,5,9,3,7,1,5,9,3,6,0,4,8,2,6,0 ; Ones : db 0,0,0,1,1,2,2,2,3,3,3,4,4,5,5,5,6,6,7,7,7,8,8,9,9 db 9,0,0,1,1,1,2,2,2,3,3,4,4,4,5,5,6,6,6,7,7,8,8,8,9,9 db 0,0,0,1,1,2,2,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 db 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 ; data7segmen: db 11000000b,11111001b,10100100b,10110000b,10011001b db 10010010b,10000010b,11111000b,10000000b,10010000b end
Step
3rd
Safe your assembly program above, and name it with adc4.asm (for example)
Compile the program that you have been save by using MIDE-51, see the
software instruction.
Step 4th
Download your hex file ( adc4.hex ) into the microcontroller
by using Microcontroller ATMEL ISP software, see the instruction.After
download this hex file you'll see the action of ADC ( of course if your
cable connection and your program are corrected )
BACK
NEXT
|
|
Lesson 1:
T
o o l
1.1. Programmer
1.2. Edsim
51
1.3. MIDE-51
1.4. ATMEL
ISP
Lesson 2:
Input Output
2.1.LED
2.2.Swicht
2.3.7
Segmen
2.4.LCD
Character
2.5.ADC
2.6.DAC
2.7.Motor
Stepper
2.8.Keypad
Lesson 3:
Timer Counter
3.1.Basic
3.2.Mode
0
3.3.Mode
1
3.4.Mode
2
3.5.Mode
3
Lesson 4:
Serial Comm.
4.1.Basic
4.2.LED
4.3.Rotate
LED
4.2 ADC
4.3.LCD
Lesson 5:
Interuption
5.1.Basic
5.2.Timer
5.2.External
|