سلام
من یک پروژه در حال ساخت دارم. این یک بازوی رباتیک است با 4 درجه آزادی. از AVR و کامپایلر بسکام استفاده نموده ام. 4 عدد هم سرو موتور هم برای چرخش دارم. دستگاه تکمیل شده اما خوب کار نمی کنه. با فشردن هر کلید چند موتور همزمان فعال میشه و بی نظم و دیوانه وار می چرخه. قبل از مونتاژ بر روی برد برد، یک موتور به خوبی و با زوایای دلخواهم به چرخش و حرکت در میومد اما حالا با 4 موتور نمی تونم اینکار رو انجام بدم. بیشتر وقت ها پس از فشردن چند کلید، دستگاه خوذ به خود خاموش میشه. منبع تغذیه ام، پاور کامپیوتر است. لطفاً کمک کنید و بفرمائید چه باید کنم. خوشبختانه استادم تا دوشنبه بهم فرصت داد تکمیلش کنم. با سپاس از توجهتون
$regfile = "m32def.dat"
$crystal = 8000000
Config Portb = Output
Config Portc = Input
Config Porta = Input
Config Timer0 = Timer , Prescale = 1024 '8000000/(1024*156)=50Hz
Config Timer1 = Timer , Prescale = 8
Config Debounce = 20
Dim Motor_time1 As Word
Dim Motor_time2 As Word
Dim Motor_time3 As Word
Dim Motor_time4 As Word
Motor_time1 = 1500
Motor_time2 = 1600
Motor_time3 = 1700
Motor_time4 = 1800
Motor1 Alias Portb.2 : Motor2 Alias Portb.3 : Motor3 Alias Portb.4 : Motor4 Alias Portb.5
Stop Timer1
Enable Ovf0
Enable Interrupts
Enable Timer0
On Ovf0 Make_pwm
Timer0 = 178
First:
Do
If Pinc.7 = 1 Then
Set Portb.1
Set Portb.7
Else
Reset Portb.7
Reset Portb.1
End If
Debounce Pina.0 , 1 , Incc1
Debounce Pina.1 , 1 , Decc1
Debounce Pina.2 , 1 , Incc2
Debounce Pina.3 , 1 , Decc2
Debounce Pina.4 , 1 , Incc3
Debounce Pina.5 , 1 , Decc3
Debounce Pina.6 , 1 , Incc4
Debounce Pina.7 , 1 , Decc4
Loop
Incc1:
If Pinc.6 = 0 Then
Set Portb.0
Waitms 100
If Motor_time1 < 6000 Then
Motor_time1 = Motor_time1 + 20
End If
Reset Portb.0
End If
Goto First
Decc1:
If Pinc.5 = 0 Then
Set Portb.0
Waitms 100
If Motor_time1 > 200 Then
Motor_time1 = Motor_time1 - 20
End If
Reset Portb.0
End If
Goto First
Incc2:
Set Portb.0
Waitms 100
If Motor_time2 < 6000 Then
Motor_time2 = Motor_time2 + 20
End If
Reset Portb.0
Goto First
Decc2:
Set Portb.0
Waitms 100
If Motor_time2 > 200 Then
Motor_time2 = Motor_time2 - 20
End If
Reset Portb.0
Goto First
Incc3:
Set Portb.0
Waitms 100
If Motor_time3 < 6000 Then
Motor_time3 = Motor_time3 + 20
End If
Reset Portb.0
Goto First
Decc3:
Set Portb.0
Waitms 100
If Motor_time3 > 200 Then
Motor_time3 = Motor_time3 - 20
End If
Reset Portb.0
Goto First
Incc4:
Set Portb.0
Waitms 100
If Motor_time4 < 6000 Then
Motor_time4 = Motor_time4 + 20
End If
Reset Portb.0
Goto First
Decc4:
Set Portb.0
Waitms 100
If Motor_time4 > 200 Then
Motor_time4 = Motor_time4 - 20
End If
Reset Portb.0
Goto First
End
Make_pwm:
Timer0 = 178
Timer1 = 0
Start Timer1
Set Motor1
Do
Loop Until Timer1 >= Motor_time1
Reset Motor1
Timer1 = 0
Set Motor2
Do
Loop Until Timer1 >= Motor_time2
Reset Motor2
Timer1 = 0
Set Motor3
Do
Loop Until Timer1 >= Motor_time3
Reset Motor3
Timer1 = 0
Set Motor4
Do
Loop Until Timer1 >= Motor_time4
Reset Motor4
Return
من یک پروژه در حال ساخت دارم. این یک بازوی رباتیک است با 4 درجه آزادی. از AVR و کامپایلر بسکام استفاده نموده ام. 4 عدد هم سرو موتور هم برای چرخش دارم. دستگاه تکمیل شده اما خوب کار نمی کنه. با فشردن هر کلید چند موتور همزمان فعال میشه و بی نظم و دیوانه وار می چرخه. قبل از مونتاژ بر روی برد برد، یک موتور به خوبی و با زوایای دلخواهم به چرخش و حرکت در میومد اما حالا با 4 موتور نمی تونم اینکار رو انجام بدم. بیشتر وقت ها پس از فشردن چند کلید، دستگاه خوذ به خود خاموش میشه. منبع تغذیه ام، پاور کامپیوتر است. لطفاً کمک کنید و بفرمائید چه باید کنم. خوشبختانه استادم تا دوشنبه بهم فرصت داد تکمیلش کنم. با سپاس از توجهتون
$regfile = "m32def.dat"
$crystal = 8000000
Config Portb = Output
Config Portc = Input
Config Porta = Input
Config Timer0 = Timer , Prescale = 1024 '8000000/(1024*156)=50Hz
Config Timer1 = Timer , Prescale = 8
Config Debounce = 20
Dim Motor_time1 As Word
Dim Motor_time2 As Word
Dim Motor_time3 As Word
Dim Motor_time4 As Word
Motor_time1 = 1500
Motor_time2 = 1600
Motor_time3 = 1700
Motor_time4 = 1800
Motor1 Alias Portb.2 : Motor2 Alias Portb.3 : Motor3 Alias Portb.4 : Motor4 Alias Portb.5
Stop Timer1
Enable Ovf0
Enable Interrupts
Enable Timer0
On Ovf0 Make_pwm
Timer0 = 178
First:
Do
If Pinc.7 = 1 Then
Set Portb.1
Set Portb.7
Else
Reset Portb.7
Reset Portb.1
End If
Debounce Pina.0 , 1 , Incc1
Debounce Pina.1 , 1 , Decc1
Debounce Pina.2 , 1 , Incc2
Debounce Pina.3 , 1 , Decc2
Debounce Pina.4 , 1 , Incc3
Debounce Pina.5 , 1 , Decc3
Debounce Pina.6 , 1 , Incc4
Debounce Pina.7 , 1 , Decc4
Loop
Incc1:
If Pinc.6 = 0 Then
Set Portb.0
Waitms 100
If Motor_time1 < 6000 Then
Motor_time1 = Motor_time1 + 20
End If
Reset Portb.0
End If
Goto First
Decc1:
If Pinc.5 = 0 Then
Set Portb.0
Waitms 100
If Motor_time1 > 200 Then
Motor_time1 = Motor_time1 - 20
End If
Reset Portb.0
End If
Goto First
Incc2:
Set Portb.0
Waitms 100
If Motor_time2 < 6000 Then
Motor_time2 = Motor_time2 + 20
End If
Reset Portb.0
Goto First
Decc2:
Set Portb.0
Waitms 100
If Motor_time2 > 200 Then
Motor_time2 = Motor_time2 - 20
End If
Reset Portb.0
Goto First
Incc3:
Set Portb.0
Waitms 100
If Motor_time3 < 6000 Then
Motor_time3 = Motor_time3 + 20
End If
Reset Portb.0
Goto First
Decc3:
Set Portb.0
Waitms 100
If Motor_time3 > 200 Then
Motor_time3 = Motor_time3 - 20
End If
Reset Portb.0
Goto First
Incc4:
Set Portb.0
Waitms 100
If Motor_time4 < 6000 Then
Motor_time4 = Motor_time4 + 20
End If
Reset Portb.0
Goto First
Decc4:
Set Portb.0
Waitms 100
If Motor_time4 > 200 Then
Motor_time4 = Motor_time4 - 20
End If
Reset Portb.0
Goto First
End
Make_pwm:
Timer0 = 178
Timer1 = 0
Start Timer1
Set Motor1
Do
Loop Until Timer1 >= Motor_time1
Reset Motor1
Timer1 = 0
Set Motor2
Do
Loop Until Timer1 >= Motor_time2
Reset Motor2
Timer1 = 0
Set Motor3
Do
Loop Until Timer1 >= Motor_time3
Reset Motor3
Timer1 = 0
Set Motor4
Do
Loop Until Timer1 >= Motor_time4
Reset Motor4
Return
دیدگاه