LINE FOLLOWER
KALI INI SAYA INGIN SHARE SEDIKIT MENGENAI LINE FOLLOWER YANG TELAH SAYA BUAT.
SPESIFIKASI:
ATMEGA 32
DENGAN 7 SENSOR DEPAN DENGAN ADC DAN 2 SENSOR SAMPING DENGAN KOMPARATOR
DRIVER MOTOR MOSFET
MOTOR HAIRDRYER
RATIO GEAR 1: 4
BATTREY LIPO 11,1V
DENGAN EEPROM EXTERNAL 24C64
salam pecinta robot line follower kawan,,,hhee
kali ini saya ingin menceritakan sedikit mengenai cara pengerjaan dari pembuatan line follower saya ini,, line follower ini merupakan line follower ke 4 yang pernah saya buat,, line follower ini berukuran 18,5cm x 16cm,, lumayan besar n berat..hhee
untuk membuat design layoutnya sangat mudah n gampang saya menggunakan software eagle yang sangat mudah dapat di download di internet. bagian bagian dari line follower ini dapat di lihat sebagai berikut:
SENSOR
bagian sensor menggunakan 7 buah sensor dengan photodiode sebagai penerima dan led berwana biru sebagai pemancar, penempatan sensornya bisa dilihat pada gambar dimana penempatannya seperti huruf v, cara pembuatan bentuknya cukup dengan menggunakan cutter dan bor, untuk fnishing menggunakan kikir.sehingga di dapatkan bentuk yang saya inginkan yang kata temen2 sich kaya bulan sabit,hohohho
pada bagian top berisi 2 led berwarna biru,, ini untuk hiasan aj,,hohoho biar kelihatan isi mata robotnya n makin mantep aj,,hihi
DRIVER MOTOR
bagian driver motor menggunakan mosfet tipe irf640 dan irf9640, menggunakan driver mosfet dikarenakan arus yamg dapat di alirkan lebih besar di bandingkan dengan menggunakan ic l293d maupun ic L298, selain itu driver mosfet ini sudah memiliki mode auto breake yang menyebabkan motor dapat berhenti/ngerem saat pwm 0, keuntungannya robot dapat menikung dengan lebih stabil dan kelembaman menjadi lebih berkurang,, untuk skema sama dengan yang lain,, dapat di lihat di bagian bawah.
bagian driver motor menggunakan mosfet tipe irf640 dan irf9640, menggunakan driver mosfet dikarenakan arus yamg dapat di alirkan lebih besar di bandingkan dengan menggunakan ic l293d maupun ic L298, selain itu driver mosfet ini sudah memiliki mode auto breake yang menyebabkan motor dapat berhenti/ngerem saat pwm 0, keuntungannya robot dapat menikung dengan lebih stabil dan kelembaman menjadi lebih berkurang,, untuk skema sama dengan yang lain,, dapat di lihat di bagian bawah.
BOARD MINSIS
ini merupakan bagian board utama, yang berisi mikrocontroler sebagai otaknya, ic op-amp, eeprom 24c64 dan beberapa komponen lainnya, dimana dari bagian top terlihat lumayan simple di karenakan kebanyakan menggunakan komponen smd,,dengan sedikit hiasan seperti di cat dan di isi stiker maka hasilnya dpat terlihat lbih bagus,, di bagian belakang terdapat sayap yang terbuat dari pcb juga, yang tentunya dapat di pasang n dicopot,, hohoho sayap ini berisi led yang dapat di atur pada port mikro.
ini merupakan bagian board utama, yang berisi mikrocontroler sebagai otaknya, ic op-amp, eeprom 24c64 dan beberapa komponen lainnya, dimana dari bagian top terlihat lumayan simple di karenakan kebanyakan menggunakan komponen smd,,dengan sedikit hiasan seperti di cat dan di isi stiker maka hasilnya dpat terlihat lbih bagus,, di bagian belakang terdapat sayap yang terbuat dari pcb juga, yang tentunya dapat di pasang n dicopot,, hohoho sayap ini berisi led yang dapat di atur pada port mikro.
RANGKAIAN SEBELUM DI RAKIT
oohh iyaa,,,sedangkan motor yang digunakan hannya menggunakan motor hairdryer yang murah meriah yang harganya cukup 20ribuan,,murahkan,,,??? yaw klo rpmnya kurang tau soalnya gx isi di nameplatenya,, tpi torsinya mantepp,, yaw klo penasaran ,, untuk performa bisa di lihat di video,,
wah dikarenakan di inginkan biar terliat simple ya untuk merakitnya menjadi lebih susah,,namun dengan berhati hati jadilahline folower seperti di bawah ini.
PEMEGANG GEAR
pemegang gear ini menggunakan acrilic, saya menggunakan software corel draw untuk membuatnya, setelah design jadi yaw tinggal bawa ke tukang acrilicnya biar di potong sesuai design, n hasil dari tukang acrilicnya lumayan presisi koq,,hhee
GAMBAR GEARNYA KALO UDAH DIRAKIT
SKEMA DRIVER MOSFET
jika ada yang beminat memesan bisa hub. saya di no. hp. 085737688250
bukti pengiriman
untuk lebih jelasnya bisa dilihat videonya ni kawan, klo untuk metode2nya sama seperti kawan kawan pecinta line follower yang lain kqq...
langsung saja ke TKP...
VIDEONYA:
tampilan lengkap line follower blue Dragon
PID
PAH PLANNING
MAZE SOLVING
PROGRAM DENGAN BASCOM AVR
$regfile = "m16def.dat"
$crystal = 16000000
Config Porta = Input
Config Portc.1 = Output
Config Portc.2 = Output
Config Portc.3 = Output
Config Portc.4 = Output
Config Portc.5 = Output
Config Portc.6 = Output
Config Portc.7 = Output
'********************************* SENSOR_SAMPING ******************************
Config Pind.7 = Input
Config Pinc.0 = Input
S_samping_kanan Alias Pind.7
S_samping_kiri Alias Pinc.0
'************************************ SWICTH ***********************************
Config Pind.0 = Input
Config Pind.1 = Input
Config Pinb.1 = Input
Config Pinb.0 = Input
Set Portb.0
Set Portb.1
Set Portd.0
Set Portd.1
Tombol1 Alias Pinb.1
Tombol2 Alias Pinb.0
Tombol3 Alias Pind.0
Tombol4 Alias Pind.1
'****************************** *MUSIC********** *******************************
Config Portb.4 = Output
Musicpin Alias Portb.4
'******************************** PORT MOTOR ***********************************
Tccr1a = &H01
Tccr1b = &H04
Config Portd.6 = Output
Config Portd.2 = Output
Dirkiri Alias Portd.6
Dirkanan Alias Portd.2
'*********************************** LED LCD ***********************************
Led_lcd Alias Portc.1
Reset Led_lcd
'********************************** TYPE DATA **********************************
Dim Kp As Byte , Kd As Byte , Ki As Byte , N_sensor As Integer
Dim D1 As Integer , P As Integer , I As Integer , Pid As Integer
Dim N_error As Integer , Error As Integer , Last_error As Integer
Dim Pv As Integer , Sensor(8) As Integer , Arah As Byte , Jumlah_jalur As Byte
Dim Kecepatan As Byte , S_p As Byte , Nilai As Byte
Dim Y As Byte , Z As Byte , Alamat As Word , N As Byte
Dim Kepekaan As Integer , Kanan As Integer , Kiri As Integer , Last_sensor As Bit
Dim N_kanan As Bit , N_kiri As Bit , N_lurus As Bit , Putih As Byte
Dim Arahjalur(255) As Byte , Jalur As Byte , Almt As Word
Dim S As Integer , M As Integer , T As Byte , Lastkiri As Bit , Lastkanan As Bit
Dim Sens As Integer
Dim Datas(14) As Byte , Starts As Byte , Count2 As Byte , Ir_data As Byte
'******************************* DECLARASI SUB *********************************
Declare Sub Settingkecepatan
Declare Sub Aturkpkdki
Declare Sub Settingkepekaan
Declare Sub Baca_adc
Declare Sub Geetadc
Declare Sub Mati
Declare Sub Maju_dikit
Declare Sub Cari_arah
Declare Sub Sederhanaan
Declare Sub Tombol
Declare Sub Atur_path
Declare Sub Mundur
Declare Sub B_kanan
Declare Sub B_kiri
Declare Sub Lurus
Declare Sub Mulai
Declare Sub Berhenti_hitung
Declare Sub Belok(byval Arah As Byte)
Declare Sub Baca_mase
'Declare Sub Simpan_mase
'Declare Sub Load_path
Declare Sub Suara1
Declare Sub Suara2
Declare Sub Suara3
Declare Sub Suara4
Declare Sub Suara5
Declare Sub R_kanan
Declare Sub R_maju
Declare Sub R_kiri
Declare Sub R_mundur
'****************************** CONFIGURASI PORT LCD *******
Config Lcdpin = Pin , Db4 = Portc.5 , Db5 = Portc.4 , Db6 = Portc.3 , Db7 = Portc.2 , E = Portc.6 , Rs = Portc.7
Config Lcd = 16 * 2 : Cursor Off
'************************* CONFIGURASI ADC *****************
Config Adc = Single , Prescaler = Auto
'****************************** CONFIGURASI PWM ************
Config Timer1 = Pwm , Pwm = 8 , Prescale = 256 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
'************************************** PEMBUKAN *******************************
Portc.6 = 0
Call Mati
Cls
Locate 1 , 1 : Lcd "<<BLUE DRAGON>>"
' Locate 2 , 1 : Lcd "BEBIT DE ARTHA"
Wait 2
Readeeprom Kp , 1
Readeeprom Kd , 2
Readeeprom Ki , 3
Readeeprom Kecepatan , 4
Readeeprom Kepekaan , 5
Cls
Locate 1 , 1 : Lcd "Kp=" ; Kp ; "
Locate 2 , 1 : Lcd "kd=" ; Kd ; "
Locate 2 , 10 : Lcd "ki=" ; Ki ; "
Waitms 500
Cls
Locate 1 , 1 : Lcd "kecepatan = " ; Kecepatan ; "
Locate 2 , 1 : Lcd "kepekaan = " ; Kepekaan ; "
Waitms 500
Cls
'================================================
'MENU 1
' ===============================================
Atur:
Cls
Locate 1 , 4 : Lcd "<< MENU >>"
Lowerline
Lcd "SET PAD PID MASE"
Do
If Tombol1 = 0 Then
Bitwait Tombol1 , Set
Call Suara2
Waitms 100
Goto Atur2
End If
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
Call Suara2
Waitms 300
Goto Path
End If
If Tombol3 = 0 Then
Bitwait Tombol3 , Set
Call Suara2
Call Mulai
Goto Prog_pid
End If
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Call Suara2
Goto Mase
End If
Loop
'================================================
'SUB MENU
'================================================
Atur2:
Cls
Locate 1 , 2 : Lcd "<<PENGATURAN>>"
Lowerline
Lcd "BACK PID SPD ADC"
Do
Call Tombol
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
Waitms 200
Cls
Call Aturkpkdki
End If
If Tombol3 = 0 Then
Bitwait Tombol3 , Set
Call Suara2
Waitms 200
Cls
Call Settingkecepatan
End If
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Call Suara2
Call Baca_adc
End If
Loop
'********************* SETTING PID ***************************
Sub Aturkpkdki
Cls
Locate 1 , 3 : Lcd " P control"
N = Kp
Gosub Setting
Kp = N
Locate 1 , 3 : Lcd " D control"
N = Kd
Gosub Setting
Kd = N
Locate 1 , 3 : Lcd " I control"
N = Ki
Gosub Setting
Ki = N
Do
Call Tombol
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Writeeeprom Kp , 1
Writeeeprom Kd , 2
Writeeeprom Ki , 3
Cls
Lcd " SAVING..!!!"
Wait 1
Goto Atur2
End If
Loop
End Sub
Setting:
Do
Call Tombol
If Tombol3 = 0 Then
Call Suara1
Waitms 100
Incr N
If N => 255 Then
N = 255
End If
End If
If Tombol2 = 0 Then
Call Suara1
Waitms 100
Decr N
If N <= 0 Then
N = 0
End If
End If
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Call Suara2
Exit Do
End If
Locate 2 , 7 : Lcd N ; " "
Loop
Return
'===============================================
'setting kecepatan
'===============================================
Sub Settingkecepatan:
Cls
N = Kecepatan
Locate 1 , 3 : Lcd " KECEPATAN"
Gosub Setting
Kecepatan = N
Do
Call Tombol
If Tombol4 = 0 Then
Call Suara2
Bitwait Tombol4 , Set
Writeeeprom Kecepatan , 4
Cls
Lcd " SAVING..!!"
Waitms 700
Cls
Goto Atur2
End If
Loop
End Sub
'================================================
'setting nilai kepekaan
'================================================
Sub Settingkepekaan
Cls
Locate 1 , 4 : Lcd "KEPEKAAN "
Do
Call Tombol
If Tombol3 = 0 Then
Call Suara1
Waitms 40
Kepekaan = Kepekaan + 5
If Kepekaan > 1023 Then
Kepekaan = 1023
End If
End If
If Tombol2 = 0 Then
Call Suara1
Waitms 40
Kepekaan = Kepekaan - 5
If Kepekaan <= 0 Then
Kepekaan = 0
End If
End If
If Tombol4 = 0 Then
Call Suara2
Cls
Writeeeprom Kepekaan , 5
Lcd " SAVING..!! "
Waitms 200
Cls
Goto Atur
End If
Locate 2 , 6 : Lcd Kepekaan ; " "
Loop
End Sub
'================================================
'BACA NILAI SENSOR
'================================================
Sub Baca_adc
Cls
Do
Gosub Geetadc
Locate 1 , 1 : Lcd Sensor(7) ; " "
Locate 1 , 5 : Lcd Sensor(6) ; " "
Locate 1 , 9 : Lcd Sensor(5) ; " "
Locate 1 , 13 : Lcd Sensor(4) ; " "
Locate 2 , 1 : Lcd Sensor(3) ; " "
Locate 2 , 5 : Lcd Sensor(2) ; " "
Locate 2 , 9 : Lcd Sensor(1) ; " "
Waitms 50
Cursor Off
Call Tombol
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Call Settingkepekaan
End If
Loop
End Sub
'================================================
'BACA ADC
'================================================
Geetadc:
For Z = 1 To 8
Y = Z - 1
Start Adc
Sensor(z) = Getadc(y)
Next Z
Return
'================================================
'MAPPING NILAI SENSOR
'================================================
Baca_sensor:
Gosub Geetadc
N_sensor = 0
If Sensor(1) >= Kepekaan Then
N_sensor = N_sensor + 1
End If
If Sensor(2) >= Kepekaan Then
N_sensor = N_sensor + 2
End If
If Sensor(3) >= Kepekaan Then
N_sensor = N_sensor + 4
End If
If Sensor(4) >= Kepekaan Then
N_sensor = N_sensor + 8
End If
If Sensor(5) >= Kepekaan Then
N_sensor = N_sensor + 16
End If
If Sensor(6) >= Kepekaan Then
N_sensor = N_sensor + 32
End If
If Sensor(7) >= Kepekaan Then
N_sensor = N_sensor + 64
End If
Select Case N_sensor '1 , 2 , 4 , 8 , 16 , 32 ,64
Case 1 : Pv = -7
Case 3 : Pv = -6
Case 2 : Pv = -5
Case 7 : Pv = -4
Case 6 : Pv = -2
Case 4 : Pv = -2
Case 12 : Pv = -1
Case 8 : Pv = 0
Case 24 : Pv = 1
Case 16 : Pv = 2
Case 48 : Pv = 3
Case 112 : Pv = 4
Case 32 : Pv = 5
Case 96 : Pv = 6
Case 32 : Pv = 7
End Select
Return
'================================================
'PID CONTROL
'================================================
Pid_control:
Gosub Baca_sensor
If N_sensor = 0 Then
If Pv <= 0 Then Pv = -8
If Pv > 0 Then Pv = 8
End If
Error = S_p - Pv
P = Kp * Error
I = Error + Last_error
I = I * Ki
I = I / 5
D1 = Error - Last_error
D1 = D1 * Kd
Last_error = Error
Pid = P + D1
Pid = Pid + I
Kanan = Kecepatan + Pid
Kiri = Kecepatan - Pid
Dirkiri = 1
Dirkanan = 1
If Kiri <= 0 Then Kiri = 0
If Kiri => 255 Then Kiri = 255
If Kanan <= 0 Then Kanan = 0
If Kanan => 255 Thenkanan = 255
Pwm1a = Kiri
Pwm1b = Kanan
If Tombol1 = 0 Then
Call Mati
Call Berhenti_hitung
Bitwait Tombol1 , Reset
Call Suara4
Waitms 300
Goto Atur
End If
Return
'================================================
'MENU PID CONTROL
'================================================
Prog_pid:
Do
Gosub Pid_control
Loop
'************************************************************
' MENU PATH PLANNING
'************************************************************
Path:
Cls
Do
Call Tombol
Locate 1 , 1 : Lcd " PATH PLANNING"
Locate 2 , 1 : Lcd " SET GO!!"
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
Call Suara2
Nilai = 7
For Jalur = 1 To 50
Readeeprom Arahjalur(jalur) , Nilai
Incr Nilai
Next Jalur
Jalur = 1
Cls
Gosub Atur_jalur
End If
If Tombol3 = 0 Then
Bitwait Tombol3 , Set
Call Suara2
' Call Load_path
Nilai = 7
For Jalur = 1 To 50
Readeeprom Arahjalur(jalur) , Nilai
Incr Nilai
Next Jalur
Cls
Locate 1 , 3 : Lcd "START JALUR"
N = 1
Gosub Setting
Jalur = N
Call Mulai
Set Led_lcd
Goto Path_run
End If
Loop
Atur_jalur:
Locate 1 , 1 : Lcd " JALUR ARAH"
Do
Locate 2 , 4 : Lcd ; Jalur ; " "
If Tombol2 = 0 Then
Call Suara1
Waitms 150
Decr Jalur
If Jalur < 1 Then
Jalur = 1
End If
End If
If Tombol3 = 0 Then
Call Suara1
Waitms 150
Incr Jalur
If Jalur > 50 Then
Jalur = 50
End If
End If
If Tombol4 = 0 Then
Call Suara1
Waitms 150
Incr Arahjalur(jalur)
If Arahjalur(jalur) > 3 Then
Arahjalur(jalur) = 0
End If
End If
If Tombol1 = 0 Then
Bitwait Tombol1 , Set
Call Suara4
Waitms 200
Gosub Atur_path
End If
If Arahjalur(jalur) = 1 Then
Locate 2 , 10 : Lcd " KIRI "
Elseif Arahjalur(jalur) = 2 Then
Locate 2 , 10 : Lcd "LURUS "
Elseif Arahjalur(jalur) = 3 Then
Locate 2 , 10 : Lcd "KANAN "
Elseif Arahjalur(jalur) = 0 Then
Locate 2 , 10 : Lcd "STOP "
Else
Locate 2 , 10 : Lcd "PILIH "
End If
Loop
Return
'================================================
'SETTING PATH PLANNING
'================================================
Atur_path:
Cls
Do
Locate 1 , 1 : Lcd "BACK RESET SAVE"
If Tombol1 = 0 Then
Bitwait Tombol1 , Set
Call Suara4
Cls
Lcd "LOADING....!!"
Wait 1
Goto Path
End If
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
For Jalur = 1 To 50
Arahjalur(jalur) = 0
Next Jalur
Goto Path
End If
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Waitms 200
Cls
Jumlah_jalur = Jalur
Nilai = 7
Locate 1 , 1 : Lcd " << SAVING >> "
For Jalur = 1 To 50
Writeeeprom Arahjalur(jalur) , Nilai
Incr Nilai
Next Jalur
Goto Path
End If
Loop
Return
'================================================
'RUNNING PATH PLANNING
'================================================
Path_run:
Putih = 140
Do
Sens = Kepekaan + 180
Gosub Pid_control
If S_samping_kanan = 1 And S_samping_kiri = 1 Then
Call Mati
Goto Eksekusi
End If
If Sensor(2) => Sens And Sensor(4) <= Putih And Sensor(6) => Sens Then
If Last_sensor = 1 Then
Dirkanan = 1
Dirkiri = 1
Pwm1a = Kecepatan
Pwm1b = Kecepatan
While S_samping_kanan = 0 And S_samping_kiri = 0
Gosub Baca_sensor
Wend
Call Mati
Goto Eksekusi
Else
Goto Path_run
End If
End If
Sens = Kepekaan + 180
If Sensor(2) => Sens And Sensor(4) => Sens And Sensor(6) => Sens Then
Last_sensor = 1
Else
Last_sensor = 0
End If
Call Tombol
Loop
'================================================
'EKSEKUSI KEMUNGKINAN
'================================================
Eksekusi:
If Arahjalur(jalur) = 1 Then
Call B_kiri
End If
If Arahjalur(jalur) = 2 Then
Call Lurus
End If
If Arahjalur(jalur) = 3 Then
Call B_kanan
End If
If Arahjalur(jalur) = 0 Then
Call Mundur
Call Mati
Call Berhenti_hitung
Bitwait Tombol1 , Reset
Waitms 300
Goto Atur
End If
Incr Jalur
Goto Path_run
'===============================================
'MAZE SOLVING
'===============================================
Mase:
Call Mulai
Putih = 150
Jalur = 1
'***********************************************************
Do
Cls
Call Tombol
N_kanan = 0
N_kiri = 0
N_lurus = 0
Do
Set Led_lcd
Gosub Pid_control
If N_sensor = 127 Then
' Call Mundur
Call Mati
Call Berhenti_hitung
Goto Mapping
End If
Gosub Baca_sensor
If Sensor(1) < Putih And Sensor(2) < Putih And Sensor(3) < Putih And Sensor(4) < Putih And Sensor(5) < Putih And Sensor(6) < Putih And Sensor(7) < Putih And Last_sensor = 1 Then
Dirkanan = 1
Dirkiri = 1
Pwm1a = Kecepatan
Pwm1b = Kecepatan
Waitms 80
Call Mati
Waitms 100
Exit Do
End If
If S_samping_kanan = 1 And S_samping_kiri = 1 Then
Exit Do
End If
If Sensor(3) > Kepekaan Or Sensor(4) > Kepekaan Or Sensor(5) > Kepekaan Then
Last_sensor = 1
Else
Last_sensor = 0
End If
Loop
Call Mati
If S_samping_kiri = 1 Then N_kiri = 1
If S_samping_kanan = 1 Then N_kanan = 1
Gosub Geetadc
If S_samping_kanan = 1 Or Sensor(4) > Kepekaan Then
N_lurus = 1
End If
Reset Led_lcd
Call Cari_arah
Arahjalur(jalur) = Arah
If Arahjalur(jalur -1) = 5 Then
Call Sederhanaan
End If
Incr Jalur
Jumlah_jalur = Jalur
Call Belok(arah)
Loop
'===============================================
'PROGRAM SESUDAH PENYEDERHANAAN
'===============================================
Mapping:
Cls
Locate 1 , 5 : Lcd "START "
Locate 2 , 1 : Lcd " << PRESS 3 >>"
Do
Call Tombol
Reset Led_lcd
If Tombol3 = 0 Then Exit Do
Loop
Call Suara2
Kecepatan = Kecepatan + 20 'menambah speed lf setelah pnyderhanaan
Call Mulai
Do
Cls
For Jalur = 1 To Jumlah_jalur
Do
Gosub Pid_control
' If N_sensor = 0 And Last_sensor > Kepekaan Then
' Exit Do
' End If
If S_samping_kanan = 1 And S_samping_kiri = 1 Then
Exit Do
End If
' If Sensor(4) => Kepekaan And S_samping_kiri = 1 Then
' Exit Do
' End IF
' If Sensor(4) => Kepekaan And S_samping_kanan = 1 Then
' Exit Do
' End If
If N_sensor = 127 Then
Call Mundur
Call Mati
Kecepatan = Kecepatan - 20
Call Berhenti_hitung
Goto Atur
End If
Loop
Call Mati
Call Belok(arahjalur(jalur))
Next Jalur
Do
Gosub Pid_control
If N_sensor = 127 Then
Call Mundur
Call Mati
Kecepatan = Kecepatan - 20 'mengembalikan speed sperti semula
Call Berhenti_hitung
Goto Atur
End If
Loop
Loop
'===============================================
'KEKSEKUSI ARAH TUJUAN
'===============================================
Sub Belok(byval Arah As Byte)
If Arah = 1 Then
Call B_kiri
End If
If Arah = 2 Then
Call Lurus
End If
If Arah = 3 Then
Call B_kanan
End If
If Arah = 5 Then
Call B_kiri
End If
End Sub
'===============================================
'PENYEDERHANAAN
'===============================================
Sub Sederhanaan
'KIRI=1
'LURUS=2
'KANAN=3
Select Case Arahjalur(jalur -2)
Case 1:
Select Case Arahjalur(jalur)
Case 1:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 2
Case 3:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 5
Case 2:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 3
End Select
Case 3:
Select Case Arahjalur(jalur)
Case 1:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 5
Case 3:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 2
Case 2:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 1
End Select
Case 2:
Select Case Arahjalur(jalur)
Case 1:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 3
Case 3:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 1
Case 2:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 5
End Select
End Select
End Sub
'===============================================
'PENENTUAN ARAH
'===============================================
Sub Cari_arah
If N_kiri = 1 Then
Arah = 1
Goto Balik
End If
If N_lurus = 1 Then
Arah = 2
Goto Balik
End If
If N_kanan = 1 Then
Arah = 3
Goto Balik
End If
If N_kanan = 0 And N_kiri = 0 And N_lurus = 0 Then
Arah = 5
End If
Balik:
End Sub
'================================================
'TOMBOL KEMBALI KE MENU UTAMA
'================================================
Sub Tombol
If Tombol1 = 0 Then
Bitwait Tombol1 , Set
Call Suara4
Call Mati
Reset Led_lcd
Waitms 100
Cls
Goto Atur
End If
End Sub
'================================================
'EKSEKUSI GERAKAN
'================================================
Sub Maju_dikit
Dirkanan = 1
Dirkiri = 1
Pwm1a = 50
Pwm1b = 50
Waitms 70
End Sub
Sub B_kanan
Sens = Kepekaan + 280
Call Mati
Call Mundur
Dirkanan = 1
Dirkiri = 0
Pwm1a = 90
Pwm1b = 90
While Sensor(1) < Sens
Gosub Geetadc
Wend
While Sensor(2) < Sens
Gosub Geetadc
Wend
Dirkanan = 0
Dirkiri = 1
Pwm1a = 80
Pwm1b = 80
Waitms 40
End Sub
Sub Lurus
Dirkanan = 1
Dirkiri = 1
Pwm1a = 60
Pwm1b = 60
Call Suara1
Waitms 90
End Sub
Sub B_kiri
Sens = Kepekaan + 280
Call Mati
Call Mundur
Dirkanan = 0
Dirkiri = 1
Pwm1a = 90
Pwm1b = 90
While Sensor(7) < Sens ' And Sensor(5) < Kepekaan
Gosub Geetadc
Wend
While Sensor(6) < Sens ' And Sensor(5) < Kepekaan
Gosub Geetadc
Wend
Dirkanan = 1
Dirkiri = 0
Pwm1a = 80
Pwm1b = 80
Waitms 40
End Sub
Sub Mati
Set Dirkiri
Set Dirkanan
Pwm1a = 0
Pwm1b = 0
End Sub
Sub Mundur
Dirkanan = 0
Dirkiri = 0
Pwm1a = Kecepatan + 20
Pwm1b = Kecepatan + 20
Waitms 60
Call Suara1
End Sub
Sub Mulai
Set Dirkanan
Set Dirkiri
Call Suara3
Cls
Call Mati
Locate 1 , 1 : Lcd "Starting Battle"
Locate 2 , 3 : Lcd "Go!!!!!!!!!!"
Wait 1
Set Led_lcd
Cls
Config Timer2 = Timer , Prescale = 1024
Load Timer2 , 21
Enable Interrupts
Enable Timer2
On Ovf2 1dtk
Start Timer2
M = 0
S = 0
End Sub
Sub Berhenti_hitung
Stop Timer2
Call Suara3
Cls
Reset Led_lcd
Locate 1 , 2 : Lcd "DRIVE SELESAI"
Locate 2 , 2 : Lcd "Time : " ; T ; ":" ; S ; ":" ; M ; " "
Bitwait Tombol1 , Reset
Call Suara2
Waitms 700
End Sub
'===============================================
'HITUNG WAKTU
'===============================================
1dtk:
Incr M
If M > 60 Then
Incr S
M = 0
End If
If S > 59 Then
Incr T
S = 0
End If
Return
'================================================
' MUSIC MELODY
'================================================
Sub Suara1
Sound Musicpin , 50 , 700
End Sub
Sub Suara2
Sound Musicpin , 100 , 330
Sound Musicpin , 170 , 500
End Sub
Sub Suara3
Sound Musicpin , 110 , 758
Sound Musicpin , 98 , 850
Sound Musicpin , 110 , 758
End Sub
Sub Suara4
Sound Musicpin , 25 , 6000
Waitms 35
Sound Musicpin , 25 , 6000
End Sub
Sub Suara5
Sound Musicpin , 20 , 200
Sound Musicpin , 60 , 400
End Sub
pemegang gear ini menggunakan acrilic, saya menggunakan software corel draw untuk membuatnya, setelah design jadi yaw tinggal bawa ke tukang acrilicnya biar di potong sesuai design, n hasil dari tukang acrilicnya lumayan presisi koq,,hhee
GAMBAR GEARNYA KALO UDAH DIRAKIT
sedangkan gearnya menggunakan gear tamiya bisa di rakit sedemikian agar mendapatkan perbandingan ratio yang di inginkan,, klo banyak punya gear yang gx ke pake,, bisa di pake juga tu,, dri pada gx ke pakai,, jadi kecepatan dan torsi kita tentuin sendiri. untuk pemegang gearnya menggunakan as dinamo dan menggunakan bearing untuk pemegang asnya, sedangkan ban dan veleg menggunakan sparepart tamiya juga kawan,,
SKEMA DRIVER MOSFET
jika ada yang beminat memesan bisa hub. saya di no. hp. 085737688250
bukti pengiriman
untuk lebih jelasnya bisa dilihat videonya ni kawan, klo untuk metode2nya sama seperti kawan kawan pecinta line follower yang lain kqq...
langsung saja ke TKP...
VIDEONYA:
tampilan lengkap line follower blue Dragon
PID
PAH PLANNING
MAZE SOLVING
PROGRAM DENGAN BASCOM AVR
$regfile = "m16def.dat"
$crystal = 16000000
Config Porta = Input
Config Portc.1 = Output
Config Portc.2 = Output
Config Portc.3 = Output
Config Portc.4 = Output
Config Portc.5 = Output
Config Portc.6 = Output
Config Portc.7 = Output
'********************************* SENSOR_SAMPING ******************************
Config Pind.7 = Input
Config Pinc.0 = Input
S_samping_kanan Alias Pind.7
S_samping_kiri Alias Pinc.0
'************************************ SWICTH ***********************************
Config Pind.0 = Input
Config Pind.1 = Input
Config Pinb.1 = Input
Config Pinb.0 = Input
Set Portb.0
Set Portb.1
Set Portd.0
Set Portd.1
Tombol1 Alias Pinb.1
Tombol2 Alias Pinb.0
Tombol3 Alias Pind.0
Tombol4 Alias Pind.1
'****************************** *MUSIC********** *******************************
Config Portb.4 = Output
Musicpin Alias Portb.4
'******************************** PORT MOTOR ***********************************
Tccr1a = &H01
Tccr1b = &H04
Config Portd.6 = Output
Config Portd.2 = Output
Dirkiri Alias Portd.6
Dirkanan Alias Portd.2
'*********************************** LED LCD ***********************************
Led_lcd Alias Portc.1
Reset Led_lcd
'********************************** TYPE DATA **********************************
Dim Kp As Byte , Kd As Byte , Ki As Byte , N_sensor As Integer
Dim D1 As Integer , P As Integer , I As Integer , Pid As Integer
Dim N_error As Integer , Error As Integer , Last_error As Integer
Dim Pv As Integer , Sensor(8) As Integer , Arah As Byte , Jumlah_jalur As Byte
Dim Kecepatan As Byte , S_p As Byte , Nilai As Byte
Dim Y As Byte , Z As Byte , Alamat As Word , N As Byte
Dim Kepekaan As Integer , Kanan As Integer , Kiri As Integer , Last_sensor As Bit
Dim N_kanan As Bit , N_kiri As Bit , N_lurus As Bit , Putih As Byte
Dim Arahjalur(255) As Byte , Jalur As Byte , Almt As Word
Dim S As Integer , M As Integer , T As Byte , Lastkiri As Bit , Lastkanan As Bit
Dim Sens As Integer
Dim Datas(14) As Byte , Starts As Byte , Count2 As Byte , Ir_data As Byte
'******************************* DECLARASI SUB *********************************
Declare Sub Settingkecepatan
Declare Sub Aturkpkdki
Declare Sub Settingkepekaan
Declare Sub Baca_adc
Declare Sub Geetadc
Declare Sub Mati
Declare Sub Maju_dikit
Declare Sub Cari_arah
Declare Sub Sederhanaan
Declare Sub Tombol
Declare Sub Atur_path
Declare Sub Mundur
Declare Sub B_kanan
Declare Sub B_kiri
Declare Sub Lurus
Declare Sub Mulai
Declare Sub Berhenti_hitung
Declare Sub Belok(byval Arah As Byte)
Declare Sub Baca_mase
'Declare Sub Simpan_mase
'Declare Sub Load_path
Declare Sub Suara1
Declare Sub Suara2
Declare Sub Suara3
Declare Sub Suara4
Declare Sub Suara5
Declare Sub R_kanan
Declare Sub R_maju
Declare Sub R_kiri
Declare Sub R_mundur
'****************************** CONFIGURASI PORT LCD *******
Config Lcdpin = Pin , Db4 = Portc.5 , Db5 = Portc.4 , Db6 = Portc.3 , Db7 = Portc.2 , E = Portc.6 , Rs = Portc.7
Config Lcd = 16 * 2 : Cursor Off
'************************* CONFIGURASI ADC *****************
Config Adc = Single , Prescaler = Auto
'****************************** CONFIGURASI PWM ************
Config Timer1 = Pwm , Pwm = 8 , Prescale = 256 , Compare A Pwm = Clear Up , Compare B Pwm = Clear Up
'************************************** PEMBUKAN *******************************
Portc.6 = 0
Call Mati
Cls
Locate 1 , 1 : Lcd "<<BLUE DRAGON>>"
' Locate 2 , 1 : Lcd "BEBIT DE ARTHA"
Wait 2
Readeeprom Kp , 1
Readeeprom Kd , 2
Readeeprom Ki , 3
Readeeprom Kecepatan , 4
Readeeprom Kepekaan , 5
Cls
Locate 1 , 1 : Lcd "Kp=" ; Kp ; "
Locate 2 , 1 : Lcd "kd=" ; Kd ; "
Locate 2 , 10 : Lcd "ki=" ; Ki ; "
Waitms 500
Cls
Locate 1 , 1 : Lcd "kecepatan = " ; Kecepatan ; "
Locate 2 , 1 : Lcd "kepekaan = " ; Kepekaan ; "
Waitms 500
Cls
'================================================
'MENU 1
' ===============================================
Atur:
Cls
Locate 1 , 4 : Lcd "<< MENU >>"
Lowerline
Lcd "SET PAD PID MASE"
Do
If Tombol1 = 0 Then
Bitwait Tombol1 , Set
Call Suara2
Waitms 100
Goto Atur2
End If
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
Call Suara2
Waitms 300
Goto Path
End If
If Tombol3 = 0 Then
Bitwait Tombol3 , Set
Call Suara2
Call Mulai
Goto Prog_pid
End If
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Call Suara2
Goto Mase
End If
Loop
'================================================
'SUB MENU
'================================================
Atur2:
Cls
Locate 1 , 2 : Lcd "<<PENGATURAN>>"
Lowerline
Lcd "BACK PID SPD ADC"
Do
Call Tombol
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
Waitms 200
Cls
Call Aturkpkdki
End If
If Tombol3 = 0 Then
Bitwait Tombol3 , Set
Call Suara2
Waitms 200
Cls
Call Settingkecepatan
End If
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Call Suara2
Call Baca_adc
End If
Loop
'********************* SETTING PID ***************************
Sub Aturkpkdki
Cls
Locate 1 , 3 : Lcd " P control"
N = Kp
Gosub Setting
Kp = N
Locate 1 , 3 : Lcd " D control"
N = Kd
Gosub Setting
Kd = N
Locate 1 , 3 : Lcd " I control"
N = Ki
Gosub Setting
Ki = N
Do
Call Tombol
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Writeeeprom Kp , 1
Writeeeprom Kd , 2
Writeeeprom Ki , 3
Cls
Lcd " SAVING..!!!"
Wait 1
Goto Atur2
End If
Loop
End Sub
Setting:
Do
Call Tombol
If Tombol3 = 0 Then
Call Suara1
Waitms 100
Incr N
If N => 255 Then
N = 255
End If
End If
If Tombol2 = 0 Then
Call Suara1
Waitms 100
Decr N
If N <= 0 Then
N = 0
End If
End If
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Call Suara2
Exit Do
End If
Locate 2 , 7 : Lcd N ; " "
Loop
Return
'===============================================
'setting kecepatan
'===============================================
Sub Settingkecepatan:
Cls
N = Kecepatan
Locate 1 , 3 : Lcd " KECEPATAN"
Gosub Setting
Kecepatan = N
Do
Call Tombol
If Tombol4 = 0 Then
Call Suara2
Bitwait Tombol4 , Set
Writeeeprom Kecepatan , 4
Cls
Lcd " SAVING..!!"
Waitms 700
Cls
Goto Atur2
End If
Loop
End Sub
'================================================
'setting nilai kepekaan
'================================================
Sub Settingkepekaan
Cls
Locate 1 , 4 : Lcd "KEPEKAAN "
Do
Call Tombol
If Tombol3 = 0 Then
Call Suara1
Waitms 40
Kepekaan = Kepekaan + 5
If Kepekaan > 1023 Then
Kepekaan = 1023
End If
End If
If Tombol2 = 0 Then
Call Suara1
Waitms 40
Kepekaan = Kepekaan - 5
If Kepekaan <= 0 Then
Kepekaan = 0
End If
End If
If Tombol4 = 0 Then
Call Suara2
Cls
Writeeeprom Kepekaan , 5
Lcd " SAVING..!! "
Waitms 200
Cls
Goto Atur
End If
Locate 2 , 6 : Lcd Kepekaan ; " "
Loop
End Sub
'================================================
'BACA NILAI SENSOR
'================================================
Sub Baca_adc
Cls
Do
Gosub Geetadc
Locate 1 , 1 : Lcd Sensor(7) ; " "
Locate 1 , 5 : Lcd Sensor(6) ; " "
Locate 1 , 9 : Lcd Sensor(5) ; " "
Locate 1 , 13 : Lcd Sensor(4) ; " "
Locate 2 , 1 : Lcd Sensor(3) ; " "
Locate 2 , 5 : Lcd Sensor(2) ; " "
Locate 2 , 9 : Lcd Sensor(1) ; " "
Waitms 50
Cursor Off
Call Tombol
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Call Settingkepekaan
End If
Loop
End Sub
'================================================
'BACA ADC
'================================================
Geetadc:
For Z = 1 To 8
Y = Z - 1
Start Adc
Sensor(z) = Getadc(y)
Next Z
Return
'================================================
'MAPPING NILAI SENSOR
'================================================
Baca_sensor:
Gosub Geetadc
N_sensor = 0
If Sensor(1) >= Kepekaan Then
N_sensor = N_sensor + 1
End If
If Sensor(2) >= Kepekaan Then
N_sensor = N_sensor + 2
End If
If Sensor(3) >= Kepekaan Then
N_sensor = N_sensor + 4
End If
If Sensor(4) >= Kepekaan Then
N_sensor = N_sensor + 8
End If
If Sensor(5) >= Kepekaan Then
N_sensor = N_sensor + 16
End If
If Sensor(6) >= Kepekaan Then
N_sensor = N_sensor + 32
End If
If Sensor(7) >= Kepekaan Then
N_sensor = N_sensor + 64
End If
Select Case N_sensor '1 , 2 , 4 , 8 , 16 , 32 ,64
Case 1 : Pv = -7
Case 3 : Pv = -6
Case 2 : Pv = -5
Case 7 : Pv = -4
Case 6 : Pv = -2
Case 4 : Pv = -2
Case 12 : Pv = -1
Case 8 : Pv = 0
Case 24 : Pv = 1
Case 16 : Pv = 2
Case 48 : Pv = 3
Case 112 : Pv = 4
Case 32 : Pv = 5
Case 96 : Pv = 6
Case 32 : Pv = 7
End Select
Return
'================================================
'PID CONTROL
'================================================
Pid_control:
Gosub Baca_sensor
If N_sensor = 0 Then
If Pv <= 0 Then Pv = -8
If Pv > 0 Then Pv = 8
End If
Error = S_p - Pv
P = Kp * Error
I = Error + Last_error
I = I * Ki
I = I / 5
D1 = Error - Last_error
D1 = D1 * Kd
Last_error = Error
Pid = P + D1
Pid = Pid + I
Kanan = Kecepatan + Pid
Kiri = Kecepatan - Pid
Dirkiri = 1
Dirkanan = 1
If Kiri <= 0 Then Kiri = 0
If Kiri => 255 Then Kiri = 255
If Kanan <= 0 Then Kanan = 0
If Kanan => 255 Thenkanan = 255
Pwm1a = Kiri
Pwm1b = Kanan
If Tombol1 = 0 Then
Call Mati
Call Berhenti_hitung
Bitwait Tombol1 , Reset
Call Suara4
Waitms 300
Goto Atur
End If
Return
'================================================
'MENU PID CONTROL
'================================================
Prog_pid:
Do
Gosub Pid_control
Loop
'************************************************************
' MENU PATH PLANNING
'************************************************************
Path:
Cls
Do
Call Tombol
Locate 1 , 1 : Lcd " PATH PLANNING"
Locate 2 , 1 : Lcd " SET GO!!"
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
Call Suara2
Nilai = 7
For Jalur = 1 To 50
Readeeprom Arahjalur(jalur) , Nilai
Incr Nilai
Next Jalur
Jalur = 1
Cls
Gosub Atur_jalur
End If
If Tombol3 = 0 Then
Bitwait Tombol3 , Set
Call Suara2
' Call Load_path
Nilai = 7
For Jalur = 1 To 50
Readeeprom Arahjalur(jalur) , Nilai
Incr Nilai
Next Jalur
Cls
Locate 1 , 3 : Lcd "START JALUR"
N = 1
Gosub Setting
Jalur = N
Call Mulai
Set Led_lcd
Goto Path_run
End If
Loop
Atur_jalur:
Locate 1 , 1 : Lcd " JALUR ARAH"
Do
Locate 2 , 4 : Lcd ; Jalur ; " "
If Tombol2 = 0 Then
Call Suara1
Waitms 150
Decr Jalur
If Jalur < 1 Then
Jalur = 1
End If
End If
If Tombol3 = 0 Then
Call Suara1
Waitms 150
Incr Jalur
If Jalur > 50 Then
Jalur = 50
End If
End If
If Tombol4 = 0 Then
Call Suara1
Waitms 150
Incr Arahjalur(jalur)
If Arahjalur(jalur) > 3 Then
Arahjalur(jalur) = 0
End If
End If
If Tombol1 = 0 Then
Bitwait Tombol1 , Set
Call Suara4
Waitms 200
Gosub Atur_path
End If
If Arahjalur(jalur) = 1 Then
Locate 2 , 10 : Lcd " KIRI "
Elseif Arahjalur(jalur) = 2 Then
Locate 2 , 10 : Lcd "LURUS "
Elseif Arahjalur(jalur) = 3 Then
Locate 2 , 10 : Lcd "KANAN "
Elseif Arahjalur(jalur) = 0 Then
Locate 2 , 10 : Lcd "STOP "
Else
Locate 2 , 10 : Lcd "PILIH "
End If
Loop
Return
'================================================
'SETTING PATH PLANNING
'================================================
Atur_path:
Cls
Do
Locate 1 , 1 : Lcd "BACK RESET SAVE"
If Tombol1 = 0 Then
Bitwait Tombol1 , Set
Call Suara4
Cls
Lcd "LOADING....!!"
Wait 1
Goto Path
End If
If Tombol2 = 0 Then
Bitwait Tombol2 , Set
For Jalur = 1 To 50
Arahjalur(jalur) = 0
Next Jalur
Goto Path
End If
If Tombol4 = 0 Then
Bitwait Tombol4 , Set
Waitms 200
Cls
Jumlah_jalur = Jalur
Nilai = 7
Locate 1 , 1 : Lcd " << SAVING >> "
For Jalur = 1 To 50
Writeeeprom Arahjalur(jalur) , Nilai
Incr Nilai
Next Jalur
Goto Path
End If
Loop
Return
'================================================
'RUNNING PATH PLANNING
'================================================
Path_run:
Putih = 140
Do
Sens = Kepekaan + 180
Gosub Pid_control
If S_samping_kanan = 1 And S_samping_kiri = 1 Then
Call Mati
Goto Eksekusi
End If
If Sensor(2) => Sens And Sensor(4) <= Putih And Sensor(6) => Sens Then
If Last_sensor = 1 Then
Dirkanan = 1
Dirkiri = 1
Pwm1a = Kecepatan
Pwm1b = Kecepatan
While S_samping_kanan = 0 And S_samping_kiri = 0
Gosub Baca_sensor
Wend
Call Mati
Goto Eksekusi
Else
Goto Path_run
End If
End If
Sens = Kepekaan + 180
If Sensor(2) => Sens And Sensor(4) => Sens And Sensor(6) => Sens Then
Last_sensor = 1
Else
Last_sensor = 0
End If
Call Tombol
Loop
'================================================
'EKSEKUSI KEMUNGKINAN
'================================================
Eksekusi:
If Arahjalur(jalur) = 1 Then
Call B_kiri
End If
If Arahjalur(jalur) = 2 Then
Call Lurus
End If
If Arahjalur(jalur) = 3 Then
Call B_kanan
End If
If Arahjalur(jalur) = 0 Then
Call Mundur
Call Mati
Call Berhenti_hitung
Bitwait Tombol1 , Reset
Waitms 300
Goto Atur
End If
Incr Jalur
Goto Path_run
'===============================================
'MAZE SOLVING
'===============================================
Mase:
Call Mulai
Putih = 150
Jalur = 1
'***********************************************************
Do
Cls
Call Tombol
N_kanan = 0
N_kiri = 0
N_lurus = 0
Do
Set Led_lcd
Gosub Pid_control
If N_sensor = 127 Then
' Call Mundur
Call Mati
Call Berhenti_hitung
Goto Mapping
End If
Gosub Baca_sensor
If Sensor(1) < Putih And Sensor(2) < Putih And Sensor(3) < Putih And Sensor(4) < Putih And Sensor(5) < Putih And Sensor(6) < Putih And Sensor(7) < Putih And Last_sensor = 1 Then
Dirkanan = 1
Dirkiri = 1
Pwm1a = Kecepatan
Pwm1b = Kecepatan
Waitms 80
Call Mati
Waitms 100
Exit Do
End If
If S_samping_kanan = 1 And S_samping_kiri = 1 Then
Exit Do
End If
If Sensor(3) > Kepekaan Or Sensor(4) > Kepekaan Or Sensor(5) > Kepekaan Then
Last_sensor = 1
Else
Last_sensor = 0
End If
Loop
Call Mati
If S_samping_kiri = 1 Then N_kiri = 1
If S_samping_kanan = 1 Then N_kanan = 1
Gosub Geetadc
If S_samping_kanan = 1 Or Sensor(4) > Kepekaan Then
N_lurus = 1
End If
Reset Led_lcd
Call Cari_arah
Arahjalur(jalur) = Arah
If Arahjalur(jalur -1) = 5 Then
Call Sederhanaan
End If
Incr Jalur
Jumlah_jalur = Jalur
Call Belok(arah)
Loop
'===============================================
'PROGRAM SESUDAH PENYEDERHANAAN
'===============================================
Mapping:
Cls
Locate 1 , 5 : Lcd "START "
Locate 2 , 1 : Lcd " << PRESS 3 >>"
Do
Call Tombol
Reset Led_lcd
If Tombol3 = 0 Then Exit Do
Loop
Call Suara2
Kecepatan = Kecepatan + 20 'menambah speed lf setelah pnyderhanaan
Call Mulai
Do
Cls
For Jalur = 1 To Jumlah_jalur
Do
Gosub Pid_control
' If N_sensor = 0 And Last_sensor > Kepekaan Then
' Exit Do
' End If
If S_samping_kanan = 1 And S_samping_kiri = 1 Then
Exit Do
End If
' If Sensor(4) => Kepekaan And S_samping_kiri = 1 Then
' Exit Do
' End IF
' If Sensor(4) => Kepekaan And S_samping_kanan = 1 Then
' Exit Do
' End If
If N_sensor = 127 Then
Call Mundur
Call Mati
Kecepatan = Kecepatan - 20
Call Berhenti_hitung
Goto Atur
End If
Loop
Call Mati
Call Belok(arahjalur(jalur))
Next Jalur
Do
Gosub Pid_control
If N_sensor = 127 Then
Call Mundur
Call Mati
Kecepatan = Kecepatan - 20 'mengembalikan speed sperti semula
Call Berhenti_hitung
Goto Atur
End If
Loop
Loop
'===============================================
'KEKSEKUSI ARAH TUJUAN
'===============================================
Sub Belok(byval Arah As Byte)
If Arah = 1 Then
Call B_kiri
End If
If Arah = 2 Then
Call Lurus
End If
If Arah = 3 Then
Call B_kanan
End If
If Arah = 5 Then
Call B_kiri
End If
End Sub
'===============================================
'PENYEDERHANAAN
'===============================================
Sub Sederhanaan
'KIRI=1
'LURUS=2
'KANAN=3
Select Case Arahjalur(jalur -2)
Case 1:
Select Case Arahjalur(jalur)
Case 1:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 2
Case 3:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 5
Case 2:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 3
End Select
Case 3:
Select Case Arahjalur(jalur)
Case 1:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 5
Case 3:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 2
Case 2:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 1
End Select
Case 2:
Select Case Arahjalur(jalur)
Case 1:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 3
Case 3:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 1
Case 2:
Arahjalur(jalur) = 0
Arahjalur(jalur -1) = 0
Jalur = Jalur - 2
Arahjalur(jalur) = 5
End Select
End Select
End Sub
'===============================================
'PENENTUAN ARAH
'===============================================
Sub Cari_arah
If N_kiri = 1 Then
Arah = 1
Goto Balik
End If
If N_lurus = 1 Then
Arah = 2
Goto Balik
End If
If N_kanan = 1 Then
Arah = 3
Goto Balik
End If
If N_kanan = 0 And N_kiri = 0 And N_lurus = 0 Then
Arah = 5
End If
Balik:
End Sub
'================================================
'TOMBOL KEMBALI KE MENU UTAMA
'================================================
Sub Tombol
If Tombol1 = 0 Then
Bitwait Tombol1 , Set
Call Suara4
Call Mati
Reset Led_lcd
Waitms 100
Cls
Goto Atur
End If
End Sub
'================================================
'EKSEKUSI GERAKAN
'================================================
Sub Maju_dikit
Dirkanan = 1
Dirkiri = 1
Pwm1a = 50
Pwm1b = 50
Waitms 70
End Sub
Sub B_kanan
Sens = Kepekaan + 280
Call Mati
Call Mundur
Dirkanan = 1
Dirkiri = 0
Pwm1a = 90
Pwm1b = 90
While Sensor(1) < Sens
Gosub Geetadc
Wend
While Sensor(2) < Sens
Gosub Geetadc
Wend
Dirkanan = 0
Dirkiri = 1
Pwm1a = 80
Pwm1b = 80
Waitms 40
End Sub
Sub Lurus
Dirkanan = 1
Dirkiri = 1
Pwm1a = 60
Pwm1b = 60
Call Suara1
Waitms 90
End Sub
Sub B_kiri
Sens = Kepekaan + 280
Call Mati
Call Mundur
Dirkanan = 0
Dirkiri = 1
Pwm1a = 90
Pwm1b = 90
While Sensor(7) < Sens ' And Sensor(5) < Kepekaan
Gosub Geetadc
Wend
While Sensor(6) < Sens ' And Sensor(5) < Kepekaan
Gosub Geetadc
Wend
Dirkanan = 1
Dirkiri = 0
Pwm1a = 80
Pwm1b = 80
Waitms 40
End Sub
Sub Mati
Set Dirkiri
Set Dirkanan
Pwm1a = 0
Pwm1b = 0
End Sub
Sub Mundur
Dirkanan = 0
Dirkiri = 0
Pwm1a = Kecepatan + 20
Pwm1b = Kecepatan + 20
Waitms 60
Call Suara1
End Sub
Sub Mulai
Set Dirkanan
Set Dirkiri
Call Suara3
Cls
Call Mati
Locate 1 , 1 : Lcd "Starting Battle"
Locate 2 , 3 : Lcd "Go!!!!!!!!!!"
Wait 1
Set Led_lcd
Cls
Config Timer2 = Timer , Prescale = 1024
Load Timer2 , 21
Enable Interrupts
Enable Timer2
On Ovf2 1dtk
Start Timer2
M = 0
S = 0
End Sub
Sub Berhenti_hitung
Stop Timer2
Call Suara3
Cls
Reset Led_lcd
Locate 1 , 2 : Lcd "DRIVE SELESAI"
Locate 2 , 2 : Lcd "Time : " ; T ; ":" ; S ; ":" ; M ; " "
Bitwait Tombol1 , Reset
Call Suara2
Waitms 700
End Sub
'===============================================
'HITUNG WAKTU
'===============================================
1dtk:
Incr M
If M > 60 Then
Incr S
M = 0
End If
If S > 59 Then
Incr T
S = 0
End If
Return
'================================================
' MUSIC MELODY
'================================================
Sub Suara1
Sound Musicpin , 50 , 700
End Sub
Sub Suara2
Sound Musicpin , 100 , 330
Sound Musicpin , 170 , 500
End Sub
Sub Suara3
Sound Musicpin , 110 , 758
Sound Musicpin , 98 , 850
Sound Musicpin , 110 , 758
End Sub
Sub Suara4
Sound Musicpin , 25 , 6000
Waitms 35
Sound Musicpin , 25 , 6000
End Sub
Sub Suara5
Sound Musicpin , 20 , 200
Sound Musicpin , 60 , 400
End Sub
motong ya pake apa tuh gan
ReplyDeleteThis comment has been removed by the author.
Deletemantap mas
ReplyDeletetumben liat LF yg kya gini
btw dijualkah?
hehehehehe
mau beli mas??hoho
Deletekeren mas,,, bisa buat yg kyk beat magnum di film lest' and go ga'?
ReplyDeletepasti bisa mas,,, klo ada niat dan usaha pasti mimpinya mas jadi kenyataan,,, :D
Deletegan ikut serta dong Pm brpa harganya klo dijual...?
ReplyDeletecek pm fb mas,,hhe
ReplyDeletePM harga gan???
ReplyDeletesilahkan cek mas,,,
Deletemas, nilai dari masing2 resistor yg ada di driver mosfet brp mas???
ReplyDeletediatas mosfet itu 33k, dan d basis tr 10k mas,,,
Deletemas, pada rangkaian diatas kan menggunakan ic 4011D, bedanya kalo tidak menggunakan IC 4011D apa mas???
ReplyDeleteport mikro yg di pake jadi lebih bnyak mas,, program juga nambah,, :)
Delete0o,,gitu mas,,:)
ReplyDeleteklo pwm aktif low it maksud nya gmn mas???
:)
mgkin yg dimaksud disana,, pas pwm low ( 0) kecepatan motor max.
Deletejdi kecepatan motor berbanding terbalik dengan nilai pwm :)
brapaan ?
ReplyDeleteharga Rp.1.200.000 mas,,,
ReplyDeletemas boleh minta desain layout buat pcbnya yang pake eagle gak mas? buat led dll nya hehe
ReplyDeletemaaf mas,, ini barang di komersilkan,, jadi belum bisa mas,, sekali lagi maaf,,hhee
Deletemas, resistor2 yg di driver mosfetnya itu brp ohm?
ReplyDeleteseri dgn mosfet itu 33k dan selain itu mke 10k mas...
DeleteThis comment has been removed by the author.
ReplyDeletemaaf mas, boleh minta schematic driver mosfetnya nggak?
ReplyDeletekeren mas robotnya... mantap
ReplyDeleteMasta mau tanya , Apakah ic 4011(nandGate) di gunakan untuk menggabung DIR dengan PWM sehingga output Ic 4011 menjadi PWM karena minsys (misalnya atmega32) hanya memiliki 2 pin PWM, sehingga dapat mengendalikan 2 motor dgn arah CW dan CCW hanya dengan 2 PIN PWM dngn bantuan IC 4011. Salam Masta :)
ReplyDeletePm harga mas
ReplyDeletesudah tidak produksi mas
DeleteMas boleh minta scematic PCB mas?
ReplyDeleteMakasih mas sebelumnya