lix
BAB IV
PEMBAHASAN
4.1 Program Rangkaian
Pada mikrokontroler AT89S51 dimasukkan program yang menjadi prinsip kerja dari mikrokontroller.
bil0 equ 20h bil1 equ 0ech
bil2 equ 18h bil3 equ 88h
bil4 equ 0c4h bil5 equ 82h
bil6 equ 2h bil7 equ 0e8h
bil8 equ 0h bil9 equ 80h
bilkosong equ 0ffh
utama: mov 70h,0h
mov 71h,0h mov 72h,0h
mov 60h,0h mov 61h,0h
mov r3,0
loop: Jb P0.0,terus
Johan Christian Siahaan : Perancangan Counter Digital Sebagai Penghitung Produk Akhir Berbasis Microcontroller, 2008 USU Repository © 2008
lx Jnb P0.0,
acall delay kosong:
mov 73h,bilkosong mov 74h,bilkosong
mov 75h,bilkosong mov 62h,bilkosong
mov 63h,bilkosong acall tampil
Jb P0.1,kosong Jnb P0.1,
acall delay terus:
mov r0,70h acall transfer
mov 73h,r1 mov r0,71h
acall transfer mov 74h,r1
mov r0,72h acall transfer
mov 75h,r1 mov r0,60h
acall transfer mov 62h,r1
mov r0,61h acall transfer
mov 63h,r1 acall tampil
Jnb P2.7,loop Jb P2.7,
inc r3 cjne r3,24,terus1
Johan Christian Siahaan : Perancangan Counter Digital Sebagai Penghitung Produk Akhir Berbasis Microcontroller, 2008 USU Repository © 2008
lxi mov r3,0
inc 60h mov r2,60h
cjne r2,0ah,terus1 mov 60h,0h
inc 61h terus1:
acall delay inc 70h
mov r2,70h cjne r2,0ah,loop
mov 70h,0h inc 71h
mov r2,71h cjne r2,0ah,loop
mov 71h,0h inc 72h
mov r2,72h cjne r2,0ah,loop
ljmp utama
transfer: cjne r0,0h,satu
mov r1,bil0 ret
satu: cjne r0,01h,dua
mov r1,bil1 ret
dua: cjne r0,02h,tiga
mov r1,bil2 ret
Johan Christian Siahaan : Perancangan Counter Digital Sebagai Penghitung Produk Akhir Berbasis Microcontroller, 2008 USU Repository © 2008
lxii tiga:
cjne r0,03h,empat mov r1,bil3
ret empat:
cjne r0,04h,lima mov r1,bil4
ret lima:
cjne r0,05h,enam mov r1,bil5
ret enam:
cjne r0,06h,tujuh mov r1,bil6
ret tujuh:
cjne r0,07h,delapan mov r1,bil7
ret delapan:
cjne r0,08h,sembilan mov r1,bil8
ret sembilan:
cjne r0,09h,transfer mov r1,bil9
ret
tampil: mov sbuf,62h
jnb ti, clr ti
Johan Christian Siahaan : Perancangan Counter Digital Sebagai Penghitung Produk Akhir Berbasis Microcontroller, 2008 USU Repository © 2008
lxiii mov sbuf,63h
jnb ti, clr ti
mov sbuf,73h jnb ti,
clr ti mov sbuf,74h
jnb ti, clr ti
mov sbuf,75h jnb ti,
clr ti acall delay
ret
delay: mov r7,255
dly: mov r6,255
djnz r6, djnz r7,dly
ret
Johan Christian Siahaan : Perancangan Counter Digital Sebagai Penghitung Produk Akhir Berbasis Microcontroller, 2008 USU Repository © 2008
lxiv
4.2 Prinsip Kerja Rangkaian