4.2.2 Program Robot Pemadam Api
Untuk implementasi perangkat lunak, penulis mengimplementasikan dari perangcangan perangkat lunak dari robot pemadam api dimana penulis akan
mengimplementasikan program yang akan digunakan atau ditanamkan ke mikrokontroler ATMEL 89S51.
4.2.2.1 Potongan Code Motor Dc
Gambar 4.14 Robot Berputar Kekiri
RobotKanan: Setb LeftMotor
Setb RightMotor Mov A,R7
Lcall SetKecepatanKiri
Mov A,R6 Lcall
SetKecepatanKanan
Ret RobotKiri:
Setb LeftMotor Setb RightMotor
Mov A,R7 Lcall
SetKecepatanKanan Mov A,R6
Lcall SetKecepatanKiri
Ret RobotKanan2:
Setb LeftMotor Clr RightMotor
Mov A,KecepatanMaju-KecepatanBelok Lcall
SetKecepatanKiri Mov A,KecepatanMaju
Lcall SetKecepatanKanan
Ret RobotKiri2:
Clr LeftMotor Setb RightMotor
Mov A,KecepatanMaju Lcall
SetKecepatanKiri Mov A,KecepatanMaju-KecepatanBelok
Lcall SetKecepatanKanan
Ret RobotPutarKiri:
Mov A,R7 ;Gerak putar kiri
Lcall SetKecepatan
; Clr LeftMotor
; Setb RightMotor
;
Ret RobotPutarKanan:
Mov A,R7 Lcall
SetKecepatan Clr RightMotor
Setb LeftMotor Ret
RobotGerakLurus: Setb LeftMotor
Setb RightMotor Mov A,R7
Lcall SetKecepatan
Ret RobotGerakBerhenti:
Mov A,0 Lcall
SetKecepatan Ret
4.2.2.2 Potongan Code Untuk Mencari Api
Gambar 4.15 Robot Mencari Api
Start: Lcall
Init_Serial Lcall
StartPWM Mov CounterApiLama,0
Mov R7,2 Lcall
RobotPutarKiri ScanApi:
Lcall HitungApi
Mov A,CounterApi Cjne A,ApiUVTRON,+3
Jc ScanApi
Ljmp ApiKetemu ApiKetemu:
Mov R7,2 Lcall
RobotPutarKanan Mov B,10
Lcall DelayLewati
Mov R7,3 Lcall
RobotGerakLurus Lcall
Delay_1detik Clr Kipas
LoopPadamkanApi: Lcall
HitungApi Mov A,CounterApi
Jnz LoopPadamkanApi Clr ET0
Setb Kipas Setb LeftEnable
Setb RightEnable Ljmp
4.2.2.3 Potongan Code Sensor Api
Gambar 4.16 Robot Mendeteksi Api
HitungApi: Mov A,Status
;Hapus flag Status ada api Clr A.0
; Mov Status,A
; Mov CounterApi,00
;Clear Counter Api Mov CounterApi+1,00
; Mov R7,10
LoopHitungApi: Push B
Mov B,10 Loop2HitungApi:
Push B Mov B,0
KembalikeDelay2: Djnz B,CekSensorApi
Mov B,200 KembalikeDelay3:
Djnz B,CekSensorApi2 Pop B
Djnz B,Loop2HitungApi
Pop B Djnz R7,LoopHitungApi
Ret CekSensorApi:
Jnb UVTRON,AdaUVTRON Ljmp KembalikeDelay2
AdaUVTRON: Lcall
IncCounterApi Jnb UVTRON,
Mov A,Status Setb A.0
Mov Status,A Ljmp KembalikeDelay2
CekSensorApi2: Jnb UVTRON,AdaUVTRON2
Ljmp KembalikeDelay3 AdaUVTRON2:
Lcall IncCounterApi
Jnb UVTRON, Mov A,Status
Setb A.0 Mov Status,A
Ljmp KembalikeDelay3 IncCounterApi:
Inc CounterApi Mov A,CounterApi
Jnz NoInc2Api Inc CounterApi+1
NoInc2Api: Ret
31
BAB III PERANCANGAN ROBOT
Dalam bab 3 ini penulis membahas tentang perancangan perangkat keras dan perancangan perangkat lunak.
3.1 Perancangan Perangkat Keras
Peracangan perangkat keras yang berupa perancangan kerangka robot, perancangan rangkaian mikrokontroler ATMEL 89S51, perancangan rangkaian
driver motor, rangkaian kipas angin, perancangan mikrokontroler dengan sensor
api dan perancangan seluruh rangkaian.
3.1.1 Perancangan Kerangka Robot
Pada perancangan kerangka robot penulis menggunakan palstik mica sebagai kerangka robot, alasan penulis menggunakan plastik mica adalah karena
bahan tersebut sangat ringan dan mudah dibentuk. Dalam pembuatan kerangka robot penulis memerlukan beberapa alat bantu
seperti bor, alat ukur, gerenda dan gergeraji supaya kerangka robot terbentuk dengan baik dan terukur. Di bawah adalah gambar dari kerangka robot.
Gambar 3.1 Roda robot