Kali ini saya akan mejelaskan mengenai bagaimana cara membuat alat COUNTER UP dan COUNTER DOWN dengan input 24 volt atau kurang, jadi prinsip kerjanya begini jika ada tegangan masuk yaitu lebih dari 10 volt - 24 volt maka akan COUNTER DOWN, jika ingin COUNTER UP maka posisikan switch ke mode LOW. jika ingin COUNTER DOWN posisikan ke mode HIGH. di alat ini terdapat fitur eeprom jadi jika lampu mati, data yang terakhir akan ter-load kembali.
a. Minimum System + Skema
b. Program Bascom AVR
$regfile = "m8def.dat"
$crystal = 12000000
Config Lcdpin = Pin , Rs = Portd.2 , E = Portd.3 , Db4 = Portd.4
Config Lcdpin = Pin , Db5 = Portd.5 , Db6 = Portd.6 , Db7 = Portd.7
Config Lcd = 20 * 4
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Cls
Cursor Off
Dim Dataadc1 As Word
Dim Dataadc2 As Word
Dim Dataadc3 As Word
Dim Dataadc4 As Word
Dim Dataadc5 As Word
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
Dim Ax As Eram Integer
Dim Bx As Eram Integer
Dim Cx As Eram Integer
Dim Dx As Eram Integer
Dim Mark As Integer
Mark = 1
Ddrb.3 = 0
Set Portb.3
A = Ax
B = Bx
C = Cx
D = Dx
Do
Dataadc1 = Getadc(0)
Dataadc2 = Getadc(1)
Dataadc3 = Getadc(2)
Dataadc4 = Getadc(3)
Dataadc5 = Getadc(5)
Locate 1 , 1
Lcd "LANTAI 3 = " ; A
Locate 2 , 1
Lcd "LANTAI 2 = " ; B
Locate 3 , 1
Lcd "LANTAI 1 = " ; C
Locate 4 , 1
Lcd "PINTU UTAMA = " ; D
Waitms 200
If Dataadc1 < 1000 And Dataadc5 > 1000 Then
Waitms 200
A = A - 1
If A < 1 Then
A = 0
End If
End If
If Dataadc1 < 1000 And Dataadc5 < 1000 Then
Waitms 200
A = A + 1
If A > 8 Then
A = 8
End If
End If
If Dataadc2 < 1000 And Dataadc5 > 1000 Then
Waitms 200
B = B - 1
If B < 1 Then
B = 0
End If
End If
If Dataadc2 < 1000 And Dataadc5 < 1000 Then
Waitms 200
B = B + 1
If B > 8 Then
B = 8
End If
End If
If Dataadc3 < 1000 And Dataadc5 > 1000 Then
Waitms 200
C = C - 1
If C < 1 Then
C = 0
End If
End If
If Dataadc3 < 1000 And Dataadc5 < 1000 Then
Waitms 200
C = C + 1
If C > 8 Then
C = 8
End If
End If
If Dataadc4 < 1000 And Dataadc5 > 1000 Then
Waitms 200
D = D - 1
If D = 9 And Mark = 1 Then
Cls
Mark = 2
End If
If D < 1 Then
D = 0
End If
End If
If Dataadc4 < 1000 And Dataadc5 < 1000 Then
Waitms 200
D = D + 1
If D = 10 And Mark = 2 Then
Mark = 1
End If
If D > 24 Then
D = 24
End If
End If
If Pinb.3 = 0 Then
Goto Simpan
End If
Ax = A
Bx = B
Cx = C
Dx = D
Loop
Simpan:
A = 8
B = 8
C = 8
D = 24
Do
Dataadc1 = Getadc(0)
Dataadc2 = Getadc(1)
Dataadc3 = Getadc(2)
Dataadc4 = Getadc(3)
Dataadc5 = Getadc(5)
Locate 1 , 1
Lcd "LANTAI 3 = " ; A
Locate 2 , 1
Lcd "LANTAI 2 = " ; B
Locate 3 , 1
Lcd "LANTAI 1 = " ; C
Locate 4 , 1
Lcd "PINTU UTAMA = " ; D
Waitms 200
If Dataadc1 < 1000 And Dataadc5 > 1000 Then
Waitms 200
A = A - 1
If A < 1 Then
A = 0
End If
End If
If Dataadc1 < 1000 And Dataadc5 < 1000 Then
Waitms 200
A = A + 1
If A > 8 Then
A = 8
End If
End If
If Dataadc2 < 1000 And Dataadc5 > 1000 Then
Waitms 200
B = B - 1
If B < 1 Then
B = 0
End If
End If
If Dataadc2 < 1000 And Dataadc5 < 1000 Then
Waitms 200
B = B + 1
If B > 8 Then
B = 8
End If
End If
If Dataadc3 < 1000 And Dataadc5 > 1000 Then
Waitms 200
C = C - 1
If C < 1 Then
C = 0
End If
End If
If Dataadc3 < 1000 And Dataadc5 < 1000 Then
Waitms 200
C = C + 1
If C > 8 Then
C = 8
End If
End If
If Dataadc4 < 1000 And Dataadc5 > 1000 Then
Waitms 200
D = D - 1
If D = 9 And Mark = 1 Then
Cls
Mark = 2
End If
If D < 1 Then
D = 0
End If
End If
If Dataadc4 < 1000 And Dataadc5 < 1000 Then
Waitms 200
D = D + 1
If D = 10 And Mark = 2 Then
Mark = 1
End If
If D > 24 Then
D = 24
End If
End If
If Pinb.3 = 0 Then
Goto Simpan
End If
Ax = A
Bx = B
Cx = C
Dx = D
Loop
c. Cara Menggunakan Alat
Untuk menggunakan Alat ini yaitu pertama hubungkan alat dengan suplai diatas 5 volt, kemudian di tampilan LCD akan tertulis nilai awal. tekan tombol SET kemudian akan terisi nilai 8, 8, 8, 24. pada PIN SCREW hubungkan ke PLC atau device yang lainnya. jika ada input 24 volt atau kurang maka akan counter UP jika mode switch HIGH. jika mode switch LOW maka akan counter DOWN. begitu seterusnya.
No comments:
Post a Comment