Pada kesempatan kali ini saya akan menjelaskan mengenai bagaimana cara membuat sebuah alat untuk kendali motor high current dan high torque, motor yang dipakai pada contoh adalah motor dengan arus sekitar 12A, kontroller yang digunakan adalah ATMega dan program bascom avr, driver yang digunakan adalah IBT-2. alat ini bisa diaplikasikan sebagai kendali palang pintu atau pagar rumah juga bisa. untuk skema dan programnya seperti berikut ini
a. Minimum System
b. Driver Motor IBT-2
c. Program Bascom AVR Video 1
$regfile = "m16def.dat"
$crystal = 12000000
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
Cls
Cursor Off
'setting pwm
Config Timer1 = Pwm , Pwm = 8 , Prescale = 64 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down
Config Portd.5 = Output
Config Portd.4 = Output
'hubungkan L_PWM ke portD.4
'hubungkan R_PWM ke portD.5
'nilai 100 adalah kecepatan motor
'nilai 0 adalah motor diam
Do
$crystal = 12000000
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
Cls
Cursor Off
'setting pwm
Config Timer1 = Pwm , Pwm = 8 , Prescale = 64 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down
Config Portd.5 = Output
Config Portd.4 = Output
'hubungkan L_PWM ke portD.4
'hubungkan R_PWM ke portD.5
'nilai 100 adalah kecepatan motor
'nilai 0 adalah motor diam
Do
'arah CW
Pwm1a = 0
Pwm1b = 100
Wait 5
'arah CCW
Pwm1a = 100
Pwm1b = 0
Wait 5
Pwm1a = 0
Pwm1b = 0
Wait 5
Loop
Pwm1a = 100
Pwm1b = 0
Wait 5
Pwm1a = 0
Pwm1b = 0
Wait 5
Loop
d. Program Bascom AVR Video 2
$regfile = "m16def.dat"
$crystal = 12000000
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
Cls
Cursor Off
'setting pwm
Config Timer1 = Pwm , Pwm = 8 , Prescale = 64 , Compare A Pwm = Clear Down , Compare B Pwm = Clear Down
Config Portd.5 = Output
Config Portd.4 = Output
Ddrb.0 = 0
Ddrb.1 = 0
Ddrb.2 = 0
Ddrb.3 = 0
Set Portb.0
Set Portb.1
Set Portb.2
Set Portb.3
Tbforward Alias Pinb.0
Tbreverse Alias Pinb.1
Tbup Alias Pinb.2
Tbdown Alias Pinb.3
Dim A As Integer
A = 0
Dim Z As Word
Start Adc
Do
Z = Getadc(0)
Upperline
Lcd Z
Waitms 200
If Tbforward = 0 Then
Goto Forward
End If
If Tbreverse = 0 Then
Goto Reverse
End If
Loop
Forward:
Do
Z = Getadc(0)
Upperline
Lcd Z
If Z > 100 Then
Do
Z = Getadc(0)
Upperline
Lcd Z
If Tbreverse = 0 Then
Waitms 200
Goto Reverse
End If
Pwm1a = 0
Pwm1b = 0
Loop
End If
If Tbreverse = 0 Then
Waitms 200
Goto Reverse
End If
Pwm1a = 0
Pwm1b = A
If A > 250 Then
A = 250
End If
If A < 1 Then
A = 0
End If
If Tbup = 0 Then
Waitms 200
A = A + 5
End If
If Tbdown = 0 Then
Waitms 200
A = A - 5
End If
Loop
Reverse:
Do
Z = Getadc(0)
Upperline
Lcd Z
If Z > 100 Then
Do
Z = Getadc(0)
Upperline
Lcd Z
If Tbforward = 0 Then
Waitms 200
Goto Forward
End If
Pwm1a = 0
Pwm1b = 0
Loop
End If
If Tbforward = 0 Then
Waitms 200
Goto Forward
End If
Pwm1a = A
Pwm1b = 0
If A > 250 Then
A = 250
End If
If A < 1 Then
A = 0
End If
If Tbup = 0 Then
Waitms 200
A = A + 5
End If
If Tbdown = 0 Then
Waitms 200
A = A - 5
End If
Loop
e. VIDEO HASILNYA
No comments:
Post a Comment