Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat untuk stabilizer camera atau penstabil posisi kamera atau dengan nama lain GIMBAL dengan menggunakan motor servo dan mikrokontroller ATMega16, sensor yang digunakan memang sensor umum yaitu GY-61 sehingga hasilnya memang kurang memuaskan, jika ingin lebih bagus hasilnya pakai sensor accelerometer / kemiringan yang bagus kualitasnya. servo yang dipakai yaitu servo HI-TECH sebanyak 3 buah. untuk lebih jelasnya berikut adalah skema dan programnya.
a. Minimum System ATmega
b. Motor Servo 3 pcs
d. Sensor kemiringan / accelerometer
e, Program Bascom AVR
$regfile = "m16def.dat"
$crystal = 8000000
$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
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Servos = 3 , Servo1 = Portb.0 , Servo2 = Portb.1 , Servo3 = Portb.2 , Reload = 10
Config Portb.0 = Output
Config Portb.1 = Output
Config Portb.2 = Output
Enable Interrupts
Cls
Cursor Off
Dim X As Word
Dim Y As Word
Dim Z As Word
Dim Kpx As Single
Dim Kix As Single
Dim Kdx As Single
Dim Setpointx As Single
Dim Px As Single
Dim Pix As Single
Dim Pidx As Single
Dim Ix As Single
Dim Dx As Single
Dim Errorx As Single
Dim Errorxx As Single
Dim Sum_errx As Single
Dim Kpy As Single
Dim Kiy As Single
Dim Kdy As Single
Dim Setpointy As Single
Dim Py As Single
Dim Piy As Single
Dim Pidy As Single
Dim Iy As Single
Dim Dy As Single
Dim Errory As Single
Dim Errorxy As Single
Dim Sum_erry As Single
Start Adc
Kpx = 0.9 ' Proportional factor
Kix = 0.12 ' Integration factor
Kdx = 1.91 ' derrivative factor
Setpointx = 600
Kpy = 0.09 ' Proportional factor
Kiy = 0.02 ' Integration factor
Kdy = 0.91 ' derrivative factor
Setpointy = 600
Servo(3) = 80
Servo(2) = 45
Do
X = Getadc(0)
Y = Getadc(1)
Z = Getadc(2)
Errorx = Setpointx - X
Px = Errorx * Kpx
Sum_errx = Errorx + Errorxx
Ix = Kix * Sum_errx
Dx = Errorx - Errorxx
Pix = Px + Ix
Pidx = Pix + Dx
Pidx = Pidx * 7
Pidx = 210 - Pidx
If Pidx > 255 Then
Pidx = 255
End If
If Pidx < 1 Then
Pidx = 0
End If
Errory = Setpointy - Y
Py = Errory * Kpy
Sum_erry = Errory + Errorxy
Iy = Kiy * Sum_erry
Dy = Errory - Errorxy
Piy = Py + Iy
Pidy = Piy + Dy
Pidy = Pidy * 5
Pidy = Pidy - 95
If Pidy > 255 Then
Pidy = 255
End If
If Pidy < 1 Then
Pidy = 0
End If
'Locate 1 , 1
'Lcd "x=" ; X ; " " ; Pidx
'Locate 2 , 1
'Lcd "y=" ; Y ; " " ; Pidy
'Locate 1 , 9
'Lcd "z=" ; Z ; " "
'y
'Servo(1) = 60
'x
Servo(2) = Pidx
'Wait 1
'y
Servo(1) = Pidy
'x
'Servo(2) = 150
'Wait 1
'Print x ; " " ; Pidx
'Waitms 200
Errorxx = Errorx
Errorxy = Errory
Loop
$crystal = 8000000
$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
Config Adc = Single , Prescaler = Auto , Reference = Avcc
Config Servos = 3 , Servo1 = Portb.0 , Servo2 = Portb.1 , Servo3 = Portb.2 , Reload = 10
Config Portb.0 = Output
Config Portb.1 = Output
Config Portb.2 = Output
Enable Interrupts
Cls
Cursor Off
Dim X As Word
Dim Y As Word
Dim Z As Word
Dim Kpx As Single
Dim Kix As Single
Dim Kdx As Single
Dim Setpointx As Single
Dim Px As Single
Dim Pix As Single
Dim Pidx As Single
Dim Ix As Single
Dim Dx As Single
Dim Errorx As Single
Dim Errorxx As Single
Dim Sum_errx As Single
Dim Kpy As Single
Dim Kiy As Single
Dim Kdy As Single
Dim Setpointy As Single
Dim Py As Single
Dim Piy As Single
Dim Pidy As Single
Dim Iy As Single
Dim Dy As Single
Dim Errory As Single
Dim Errorxy As Single
Dim Sum_erry As Single
Start Adc
Kpx = 0.9 ' Proportional factor
Kix = 0.12 ' Integration factor
Kdx = 1.91 ' derrivative factor
Setpointx = 600
Kpy = 0.09 ' Proportional factor
Kiy = 0.02 ' Integration factor
Kdy = 0.91 ' derrivative factor
Setpointy = 600
Servo(3) = 80
Servo(2) = 45
Do
X = Getadc(0)
Y = Getadc(1)
Z = Getadc(2)
Errorx = Setpointx - X
Px = Errorx * Kpx
Sum_errx = Errorx + Errorxx
Ix = Kix * Sum_errx
Dx = Errorx - Errorxx
Pix = Px + Ix
Pidx = Pix + Dx
Pidx = Pidx * 7
Pidx = 210 - Pidx
If Pidx > 255 Then
Pidx = 255
End If
If Pidx < 1 Then
Pidx = 0
End If
Errory = Setpointy - Y
Py = Errory * Kpy
Sum_erry = Errory + Errorxy
Iy = Kiy * Sum_erry
Dy = Errory - Errorxy
Piy = Py + Iy
Pidy = Piy + Dy
Pidy = Pidy * 5
Pidy = Pidy - 95
If Pidy > 255 Then
Pidy = 255
End If
If Pidy < 1 Then
Pidy = 0
End If
'Locate 1 , 1
'Lcd "x=" ; X ; " " ; Pidx
'Locate 2 , 1
'Lcd "y=" ; Y ; " " ; Pidy
'Locate 1 , 9
'Lcd "z=" ; Z ; " "
'y
'Servo(1) = 60
'x
Servo(2) = Pidx
'Wait 1
'y
Servo(1) = Pidy
'x
'Servo(2) = 150
'Wait 1
'Print x ; " " ; Pidx
'Waitms 200
Errorxx = Errorx
Errorxy = Errory
Loop
f. VIDEO HASILNYA
No comments:
Post a Comment