Display Jam Dan Suhu
;Percobaan jam digital dan display suhu dari rangkaian ADC
;Pada listing program berikut merupakan program untuk menampilkan data jam
;dan data suhu dari rangkian ADC dari look up tabel
;========================================================
;Project Jam Dan Display Suhu
;Dengan menggunakan LCD Character
;Visit elektronika-elektronika.blogspot.com
;=========================================================
pencacah20 equ 70h
menit equ 72h
jam equ 73h
menit1 equ 74h
menit10 equ 75h
jam1 equ 76h
jam10 equ 77h
detik equ 78h
detik1 equ 79h
detik10 equ 7ah
dataADC equ 7bh
dispclr equ 00000001b
funcset equ 00111000b
entrmod equ 00000110b
dispon equ 00001100b
org 0h
ljmp start
org 3h
reti
org 0bh
ajmp timerinterrupt
org 13h
reti
org 23h
reti
start: mov pencacah20,#20
mov detik,#60
mov jam,#60
mov menit,#60
mov dataADC,#0
acall perbaruitampilan
anl TMOD,#11110000b
orl TMOD,#00000001b
mov th0,#03ch
mov tl0,#0afh
setb ET0
setb EA
setb TR0
acall init_lcd
;
scandisplay:
mov r1,#8ch
acall write_inst
mov r1,detik1
acall write_data
;
mov r1,#8bh
acall write_inst
mov r1,detik10
acall write_data
;
mov r1,#89h
acall write_inst
mov r1,menit1
acall write_data
;
mov r1,#88h
acall write_inst
mov r1,menit10
acall write_data
;
mov r1,#86h
acall write_inst
mov r1,jam1
acall write_data
;
mov r1,#85h
acall write_inst
mov r1,jam10
acall write_data
;
mov r1,#0c6h
lcall write_inst
mov a,dataADC
mov DPTR,#ratusan ;AMBIL DATA Ratuasan LOOK UP TABLE
movc A,@A+DPTR
mov r5,a
add a,#30h
mov R1,A
lcall write_data
;
mov r1,#0c7h
lcall write_inst
mov A,dataADC
mov DPTR,#puluhan ;AMBIL DATA puluhan LOOK UP TABLE
movc A,@a+DPTR
mov r6,a
add a,#30h
mov R1,A
lcall write_data
;
mov r1,#0c8h
lcall write_inst
mov a,dataADC
mov DPTR,#satuan ;AMBIL DATA satuan LOOK UP TABLE
movc a,@a+DPTR
mov r7,a
add a,#30h
mov R1,a
lcall write_data
;
sjmp scandisplay
;
write_inst:
clr P1.0
mov P0,R1
setb P1.1
acall delay
clr P1.1
ret
;
write_data:
setb P1.0
mov P0,R1
setb P1.1
acall delay
clr P1.1
ret
;
delay: mov R0,#0
delay1: mov R2,#0fh
djnz R2,$
djnz R0,delay1
ret
;
;============================================
;Subrutine untuk membaca data dari ADC dan
;disimpan di memori dataADC
;=============================================
;
ADC:
mov A,P2
mov dataADC,a
ret
;
;================================
;PROCEDURE INISIALISAS
; LCD KARAKTER 2 X 16
;===============================
init_lcd:
mov r1,#dispclr
acall write_inst
mov r1,#funcset
acall write_inst
mov r1,#dispon
acall write_inst
mov r1,#entrmod
acall write_inst
ret
;
timerinterrupt:
mov tl0,#0afh
mov th0,#03ch
djnz pencacah20,selesaiinterupsi
mov pencacah20,#20
;
acall jamdigital
selesaiinterupsi:
reti
;
jamdigital:
acall ADC
dec detik
mov a,#0
cjne a,detik,perbaruitampilan
mov detik,#60
;
satumenit:
dec menit
mov A,#0
cjne A,menit,perbaruitampilan
mov menit,#60
;
satujam:
dec jam
mov A,#0
cjne A,jam,perbaruitampilan
mov jam,#60
;
perbaruitampilan:
mov a,detik
mov b,#10
div ab
mov detik1,b
mov detik10,a
;
mov a,menit
mov b,#10
div ab
mov menit1,b
mov menit10,a
;
mov a,jam
mov b,#10
div ab
mov jam1,b
mov jam10,a
;
mov a,#30h
add a,detik1
mov detik1,a
;
mov a,#30h
add a,detik10
mov detik10,a
;
mov a,#30h
add a,menit1
mov menit1,a
;
mov a,#30h
add a,menit10
mov menit10,a
;
mov a,#30h
add a,jam1
mov jam1,a
;
mov a,#30h
add a,jam10
mov jam10,a
;
ret
;
;=========================================
;Daftar Look Up Table
;Konversi data ADC ke tampilan Suhu
;dengan ketelitian dua angka dibelakan koma
;==========================================
ratusan:
DB 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
DB 0,0,0,0,0,0,0,0,0,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