Pada kesempatan yang berbahagia kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat yaitu mesin antrian dengan menggunakan mikrokontroller dan bahasa bascom avr. Prinsip kerja alat ini sangatlah sederhana yaitu terdapat enam buah tombol untuk visitor yang mana akan disimpan didalam mikrokontroller dan upcounter aktif, terdapat 6 buah pilihan pelayanan yang visitor bisa pilih yaitu pelayanan a, b, c, d, e, f. misal visitor menekan tombol pada pelayanan a maka akan tertulis pada lcd 16x2 yaitu a1, begitu juga yang lainnya. kemudian terdapat 6 buah tombol pemanggilan yang terdapat pada CS layanan, jika CS pada layanan a menekan maka akan mengeluarkan nilai a1 tersebut pada Hyperterminal atau SERIAL UART, jika CS layanan a menekan lagi padahal tidak ada visitor lagi maka yang dikirimkan ke Hyperterminal adalah kosong. begitu juga dengan yang lainnya. berikut adalah skema dan programnya.
a. Minimum System
b. Modul Serial RS232
c. Push Button
d. Program Bascom AVR
$regfile = "m16def.dat"
$crystal = 11059200
$baud = 9600
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Cursor Off
Cls
Ddrb = &B00000000
Ddrd.2 = 0
Ddra = &B00000000
Portb = &B11111111
Porta = &B11111111
Portd.2 = 1
Dim Count As Integer
Count = 0
Dim X As Integer
X = 0
Dim A As Integer , B As Integer , C As Integer , D As Integer , E As Integer , F As Integer
A = 0
B = 0
C = 0
D = 0
E = 0
F = 0
Dim Cs1 As Integer , Cs2 As Integer , Cs3 As Integer , Cs4 As Integer , Cs5 As Integer , Cs6 As Integer
Dim Vs1 As Integer , Vs2 As Integer , Vs3 As Integer , Vs4 As Integer , Vs5 As Integer , Vs6 As Integer
Cs1 = 0
Cs2 = 0
Cs3 = 0
Cs4 = 0
Cs5 = 0
Cs6 = 0
Vs1 = 0
Vs2 = 0
Vs3 = 0
Vs4 = 0
Vs5 = 0
Vs6 = 0
Do
Upperline
Lcd "a" ; Vs1 ; " " ; "b" ; Vs2 ; " " ; "c" ; Vs3
Lowerline
Lcd "d" ; Vs4 ; " " ; "e" ; Vs5 ; " " ; "f" ; Vs6
If Pinb.0 = 0 Then
Waitms 200
Incr A
If A <= Vs1 Then
X = 0
End If
If A > Vs1 Then
A = Vs1
End If
If A <= Vs1 And X = 1 Then
Print " "
End If
If A <= Vs1 And X = 0 Then
Print "a" ; A
X = 1
End If
End If
If Pinb.1 = 0 Then
Waitms 200
Incr B
If B <= Vs2 Then
X = 0
End If
If B > Vs2 Then
B = Vs2
End If
If B <= Vs2 And X = 1 Then
Print " "
End If
If B <= Vs2 And X = 0 Then
Print "b" ; B
X = 1
End If
End If
If Pinb.2 = 0 Then
Waitms 200
Incr C
If C <= Vs3 Then
X = 0
End If
If C > Vs3 Then
C = Vs3
End If
If C <= Vs3 And X = 1 Then
Print " "
End If
If C <= Vs3 And X = 0 Then
Print "c" ; C
X = 1
End If
End If
If Pinb.3 = 0 Then
Waitms 200
Incr D
If D <= Vs4 Then
X = 0
End If
If D > Vs4 Then
D = Vs4
End If
If D <= Vs4 And X = 1 Then
Print " "
End If
If D <= Vs4 And X = 0 Then
Print "d" ; D
X = 1
End If
End If
If Pinb.4 = 0 Then
Waitms 200
Incr E
If E <= Vs5 Then
X = 0
End If
If E > Vs5 Then
E = Vs5
End If
If E <= Vs5 And X = 1 Then
Print " "
End If
If E <= Vs5 And X = 0 Then
Print "e" ; E
X = 1
End If
End If
If Pind.2 = 0 Then
Waitms 200
Incr F
If F <= Vs6 Then
X = 0
End If
If F > Vs6 Then
F = Vs6
End If
If F <= Vs6 And X = 1 Then
Print " "
End If
If F <= Vs6 And X = 0 Then
Print "f" ; F
X = 1
End If
End If
'=================================================
If Pina.0 = 0 Then
Waitms 200
Incr Vs1
End If
If Pina.1 = 0 Then
Waitms 200
Incr Vs2
End If
If Pina.2 = 0 Then
Waitms 200
Incr Vs3
End If
If Pina.3 = 0 Then
Waitms 200
Incr Vs4
End If
If Pina.4 = 0 Then
Waitms 200
Incr Vs5
End If
If Pina.5 = 0 Then
Waitms 200
Incr Vs6
End If
Loop
e. Cara Penggunaan alat
$crystal = 11059200
$baud = 9600
Config Lcdpin = Pin , Rs = Portc.0 , E = Portc.1 , Db4 = Portc.2
Config Lcdpin = Pin , Db5 = Portc.3 , Db6 = Portc.4 , Db7 = Portc.5
Config Lcd = 16 * 2
Cursor Off
Cls
Ddrb = &B00000000
Ddrd.2 = 0
Ddra = &B00000000
Portb = &B11111111
Porta = &B11111111
Portd.2 = 1
Dim Count As Integer
Count = 0
Dim X As Integer
X = 0
Dim A As Integer , B As Integer , C As Integer , D As Integer , E As Integer , F As Integer
A = 0
B = 0
C = 0
D = 0
E = 0
F = 0
Dim Cs1 As Integer , Cs2 As Integer , Cs3 As Integer , Cs4 As Integer , Cs5 As Integer , Cs6 As Integer
Dim Vs1 As Integer , Vs2 As Integer , Vs3 As Integer , Vs4 As Integer , Vs5 As Integer , Vs6 As Integer
Cs1 = 0
Cs2 = 0
Cs3 = 0
Cs4 = 0
Cs5 = 0
Cs6 = 0
Vs1 = 0
Vs2 = 0
Vs3 = 0
Vs4 = 0
Vs5 = 0
Vs6 = 0
Do
Upperline
Lcd "a" ; Vs1 ; " " ; "b" ; Vs2 ; " " ; "c" ; Vs3
Lowerline
Lcd "d" ; Vs4 ; " " ; "e" ; Vs5 ; " " ; "f" ; Vs6
If Pinb.0 = 0 Then
Waitms 200
Incr A
If A <= Vs1 Then
X = 0
End If
If A > Vs1 Then
A = Vs1
End If
If A <= Vs1 And X = 1 Then
Print " "
End If
If A <= Vs1 And X = 0 Then
Print "a" ; A
X = 1
End If
End If
If Pinb.1 = 0 Then
Waitms 200
Incr B
If B <= Vs2 Then
X = 0
End If
If B > Vs2 Then
B = Vs2
End If
If B <= Vs2 And X = 1 Then
Print " "
End If
If B <= Vs2 And X = 0 Then
Print "b" ; B
X = 1
End If
End If
If Pinb.2 = 0 Then
Waitms 200
Incr C
If C <= Vs3 Then
X = 0
End If
If C > Vs3 Then
C = Vs3
End If
If C <= Vs3 And X = 1 Then
Print " "
End If
If C <= Vs3 And X = 0 Then
Print "c" ; C
X = 1
End If
End If
If Pinb.3 = 0 Then
Waitms 200
Incr D
If D <= Vs4 Then
X = 0
End If
If D > Vs4 Then
D = Vs4
End If
If D <= Vs4 And X = 1 Then
Print " "
End If
If D <= Vs4 And X = 0 Then
Print "d" ; D
X = 1
End If
End If
If Pinb.4 = 0 Then
Waitms 200
Incr E
If E <= Vs5 Then
X = 0
End If
If E > Vs5 Then
E = Vs5
End If
If E <= Vs5 And X = 1 Then
Print " "
End If
If E <= Vs5 And X = 0 Then
Print "e" ; E
X = 1
End If
End If
If Pind.2 = 0 Then
Waitms 200
Incr F
If F <= Vs6 Then
X = 0
End If
If F > Vs6 Then
F = Vs6
End If
If F <= Vs6 And X = 1 Then
Print " "
End If
If F <= Vs6 And X = 0 Then
Print "f" ; F
X = 1
End If
End If
'=================================================
If Pina.0 = 0 Then
Waitms 200
Incr Vs1
End If
If Pina.1 = 0 Then
Waitms 200
Incr Vs2
End If
If Pina.2 = 0 Then
Waitms 200
Incr Vs3
End If
If Pina.3 = 0 Then
Waitms 200
Incr Vs4
End If
If Pina.4 = 0 Then
Waitms 200
Incr Vs5
End If
If Pina.5 = 0 Then
Waitms 200
Incr Vs6
End If
Loop
e. Cara Penggunaan alat
Jadi pada saat ditekan tombol visitor pada layar lcd akan upcounter, misal layanan a dan b ditekan, maka akan tertampil a1, b1, c0, d0, e0, f0. jika tombol CS layanan a ditekan maka akan tampil pada Hyperterminal atau serial UART interface adalah a0, a1. jika ditekan lagi akan kosong. jika visitor pada layanan a ada 5 orang maka saat tombol CS layanan a ditekan, akan menampilkan a2, a3, a4, a5. meneruskan dari sebelumnya. begitu juga yang lainnya.
No comments:
Post a Comment