CETAK SUHU DENGAN INTERFACE PRINTER
;=======================================================
; PRINTOUT DATA SUHU DAN WAKTU PER MENIT
; elektronika-elektronika.blogspot.com
;=======================================================
;Pada listing program berikut akan dikerjakan beberapa hal al.
;1. Data suhu diambil melalui sensor LM35 dan diterjemahkan ke format digital
; dengan menggunakan ADC
;2. Waktu dibangkitkan melalui Timer 0 : mode timer 16 bit, dengan interupsi
; setiap 0.05 detik
;3. Pada subrutine jam digital, dideteksi apakah sudah 60 detik bila ya maka akan
; dipanggil subrutine cetak suhu dan waktu pada saat tersebut.
;
dispclr equ 00000001b
funcset equ 00111000b
entrmod equ 00000110b
dispon equ 00001100b
cursor equ 00001110b
blink equ 00001101b
geserL equ 00011011b
pencacah20 equ 60h
pencacah60 equ 61h
menit equ 62h
jam equ 63h
menit1 equ 64h
menit10 equ 65h
jam1 equ 66h
jam10 equ 67h
detik equ 68h
detik1 equ 69h
detik10 equ 6ah
PuluhanP equ 6bh
SatuanP equ 6ch
PecahanP equ 6dh
Puluhan equ 6eh
Satuan equ 6fh
Pecahan equ 50h
DataADC equ 51h
Strobe bit p1.4
Busy bit p1.5
;
org 0h
sjmp mulai
org 0bh
ljmp timerinterrupt
;
mulai: acall init_lcd
acall tulis1
acall tulis2
start: jb p1.6, start
bounch: jnb p1.6, bounch
acall Init_timer
acall init_lcd
acall tulis3
acall tulis4
next: acall adc
acall konversi
acall scandisplay
sjmp next
;
geser2left:
mov R7,#37
lagi: mov R1,#geserL
acall write_inst
acall delay
djnz R7,lagi
;
mov R6,#21
lagi1: mov R1,#geserL
acall write_inst
acall delay
djnz R6,lagi1
ret
;
Printout:
call Tulisan_Hasil
call enter
call Tulisan_Jam
call PrintDataJam
call enter
call Tulisan_Suhu
call PrintData_Suhu
call enter
call Tulisan_Nama
call enter
call enter
call enter
ret
;
printchar:
mov P3,A
jb busy,$
setb strobe
clr strobe
acall delay
Setb strobe
acall delay
ret
;
delay: mov R7,#100
del1: mov R6,#100
DJNZ R6,$
DJNZ R7,del1
ret
;
Tulisan_Hasil:
mov dptr,#Text_Hasil
lagiH: clr A
movc a,@a+dptr
cjne a,#'$',PrintH
sjmp OutH
PrintH: call Printchar
inc dptr
call delay
sjmp lagiH
OutH: ret
;
Tulisan_jam:
mov dptr,#Text_Jam
lagiJ: clr A
movc a,@a+dptr
cjne a,#'$',PrintJ
sjmp OutJ
PrintJ: call Printchar
inc dptr
call delay
sjmp lagiJ
OutJ: ret
;
Tulisan_Suhu:
mov dptr,#Text_Suhu
lagiT: clr A
movc a,@a+dptr
cjne a,#'$',PrintT
sjmp OutT
PrintT: call printchar
inc dptr
call delay
sjmp lagiT
OutT: ret
;
Tulisan_Nama:
mov dptr,#Text_Nama
lagiN: clr A
movc a,@a+dptr
cjne a,#'$',PrintN
sjmp OutN
PrintN: call printchar
inc dptr
call delay
sjmp lagiN
OutN: ret
;
PrintData_Suhu:
mov A,PuluhanP
call printchar
mov A,satuanP
call printchar
call printkoma
mov A,PecahanP
call printchar
call space
call printDerajat
call printCelcius
ret
;
ADC: mov A,P2
mov dataadc,a
ret
;
konversi:
mov R1,#0c5h
acall write_inst
mov a,dataadc
mov dptr,#data_Puluhan
movc a,@a+dptr
MOV R5,A
Add A,#30h
mov R1,A
acall write_data
;
mov R1,#0c6h
acall write_inst
mov a,dataadc
mov dptr,#data_Satuan
movc a,@a+dptr
mov r6,a
add A,#30h
mov R1,A
acall write_data
;
mov R1,#0c8h
acall write_inst
mov a,dataadc
mov dptr,#data_Pecahan
movc a,@a+dptr
mov r7,a
add A,#30h
mov R1,A
acall write_data
ret
;
Print_DataConvert:
call Convert_HextoBCD
mov A,Puluhan
add A,#30h
call printchar
mov A,Satuan
add A,#30h
call printchar
mov A,Pecahan
add A,#30h
call printchar
ret
;
Convert_HextoBCD: ;Subrutine ini berfungsi untuk konversi
mov B,#100 ; nilai Hexa untuk dikonversi ke nilai
DIV AB ; Desimal dalam bentuk terpisah
mov Puluhan,A ; Contoh: 125 akan dikonversi menjadi
mov A,B ; Ratusan = 1, Puluhan =2, Satuan = 5
mov B,#10 ; Untuk cetak data ke printer
DIV AB
mov Satuan,A
mov Pecahan,B
ret
;
PrintDataJam:
mov A,Jam10
call printchar
mov A,Jam1
call Printchar
call PrintTitikDua
mov A,menit10
call printchar
mov A,menit1
call printchar
call PrintTitikDua
mov A,detik10
call printchar
mov A,detik1
call printchar
call space
call space
ret
;
scandisplay:
mov r1,#08bh
acall write_inst
mov r1,detik1
acall write_data
;
mov r1,#08ah
acall write_inst
mov r1,detik10
acall write_data
;
mov r1,#088h
acall write_inst
mov r1,menit1
acall write_data
;
mov r1,#087h
acall write_inst
mov r1,menit10
acall write_data
;
mov r1,#085h
acall write_inst
mov r1,jam1
acall write_data
;
mov r1,#084h
acall write_inst
mov r1,jam10
acall write_data
sjmp scandisplay
;
timerinterrupt:
mov tl0,#0b0h
mov th0,#03ch
djnz pencacah20,selesaiinterupsi
mov pencacah20,#20
acall jamdigital
selesaiinterupsi:
reti
;
jamdigital:
inc detik
mov a,#60
cjne a,detik,perbaruitampilan
acall printout
mov detik,#0
;
satumenit:
inc menit
mov A,#60
cjne A,menit,perbaruitampilan
mov menit,#0
;
satujam:
inc jam
mov A,#24
cjne A,jam,perbaruitampilan
mov jam,#0
;
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
;
Init_Timer:
mov pencacah20,#20
mov pencacah60,#60
mov detik,#0
mov jam,#0
mov menit,#0
mov TMOD,#00000001b
mov tl0,#0b0h
mov th0,#03ch
setb ET0
setb EA
setb TR0
ret
;
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
;
Printchar1:
mov P2,A
jb busy,$
setb strobe
clr strobe
acall delay
setb strobe
ret
;
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
;
Enter:
mov A,#0dh
call printchar
call delay
mov A,#0ah
call printchar
ret
;
Space:
mov A,#' '
call printchar
ret
;
PrintTitikDua:
mov A,#':'
call printchar
ret
;
PrintKoma:
mov A,#','
call printchar
ret
;
PrintDerajat:
mov A,#'o'
call printchar
ret
;
PrintCelcius:
mov A,#'C'
call printchar
ret
;
tulis1: mov dptr,#tulisan1
mov R3,#37
mov R1,#80h
acall write_inst
tls1: clr a
movc a,@a+dptr
mov R1,A
inc dptr
acall write_data
djnz R3,tls1
ret
;
tulis2: mov dptr,#tulisan2
mov R3,#21
mov R1,#0c0h
acall write_inst
tls2: clr a
movc a,@a+dptr
mov R1,A
inc dptr
acall write_data
djnz R3,tls2
ret
;
tulis3: mov dptr,#tulisan3
mov R3,#11
mov R1,#0c0h
acall write_inst
tls3: clr a
movc a,@a+dptr
mov R1,A
inc dptr
acall write_data
djnz R3,tls3
ret
;
tulis4: mov dptr,#tulisan4
mov r3,#4
mov r1,#080h
acall write_inst
tls4: clr a
movc a,@a+dptr
mov r1,a
inc dptr
acall write_data
djnz r3,tls4
;
tulis5: mov dptr,#tulisan5
mov r3,#4
mov r1,#086h
acall write_inst
tls5: clr a
movc a,@a+dptr
mov r1,a
inc dptr
acall write_data
djnz r3,tls5
ret
;
tulisan1: db'Monitor Suhu Pasien Interface Printer'
tulisan2: db' Labcomputer'
tulisan3: db'Suhu: , oC'
tulisan4: db'Jam:'
tulisan5: db': :'
Text_Hasil: db'Hasil Pengukuran Suhu$'
Text_Jam: db'Jam:$'
Text_Suhu: db'Suhu:$'
Text_Nama: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0,0,1,1,1,2,2,3,3,3,4,4,5,5,5
DB 6,6,7,7,7,8,8,9,9,9,0,0,0,1,1,2,2,2,3,3
DB 4,4,4,5,5,6,6,6,7,7,8,8,8,9,9,0
;
data_pecahan:
DB 0,9,8,8,7,6,5,5,4,3,2,1,1,0,9,8,7,7,6,5
DB 4,4,3,2,1,0,0,9,8,7,6,6,5,4,3,3,2,1,0,9
DB 9,8,7,6,5,5,4,3,2,2,1,0,9,8,8,7,6,5,5,4
DB 3,2,1,1,0,9,8,7,7,6,5,4,4,3,2,1,0,0,9,8
DB 7,6,6,5,4,3,3,2,1,0,9,9,8,7,6,5,5,4,3,2
DB 2,1,0,9,8,8,7,6,5,5,4,3,2,1,1,0,9,8,7,7
DB 6,5,4,4,3,2,1,0,0,9,9,7,6,6,5,4,3,3,2,1
DB 0,9,9,8,7,6,5,5,4,3,2,2,1,0,9,8,8,7,6,5
DB 5,4,3,2,1,1,0,9,8,7,7,6,5,4,4,3,2,1,0,0
DB 9,8,7,6,6,5,4,3,3,2,1,0,9,9,8,7,6,5,5,4
DB 3,2,2,1,0,9,8,8,7,6,5,5,4,3,2,1,1,0,9,8
DB 7,7,6,5,4,4,3,2,1,0,0,9,8,7,6,6,5,4,3,3
DB 2,1,0,9,9,8,7,6,5,5,4,3,2,2,1,0
end
2 comments:
mas cara download file dokumennya gimana?gag bisa niy...maklum ndeso..
tolong diulas topik pengendalian motor stepper ato motor dc dengan 89s51 dunkx...klo bisa tentang robot "line Tracer" yang pake sensor ato otokopler gtu lah...plezzz yaw mas...help me...
mas subrutin puluhan,satuannya mana ya
Post a Comment