ايران ويج

نسخه‌ی کامل: سوال درباره step motor
شما در حال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب بندی مناسب.
من یک step motor دارم که 4*4 و step 1.8 پنج سیمه هست با ترانزیستور

c945 راه اندازیش کردم و وصلش کردم به یه mega32 برنامه به این صورته که

شما درجه رو میدی و موتور همون مقدار میچرخه. مشکل اینجاست که مثلا

360 درجه رو که میزنم حدود 10 یا 15 درجه بیشتر میچرخه .

حالا میخواستم بدونم اگه مشکل از برنامه نباشه (که نیست) از جی میتونه باشه

ضمنا موتور موقع چرخش نوسان داره

من از حالتی استفاده میکنم که در هر لحظه از زمان فقط یکی از پایه ها 1

هست و بقیه صفرن . روش کار هم اینطوریه که یه متغیر بایتی در نظر میگیرم

و اونو مقدار اولیه میدم و بعد شیفتش میدم به چپ یا راست . ضمنا تاخیر

بین هر چرخش اول 50 میلی ثانیه بود که باز هم همین مشکل رو داشت
اینم برنامه خودتون ببینید :


کد php:
$regfile "m32def.dat"
$crystal 8000000
Config Lcdpin 
Pin Db4 Pb.0 Db5 Pb.1 Db6 Pb.2 Db7 _
 Pb.3 
Pb.5 Rs Pb.4
Config Porta 
Output
Dim I 
As Byte As Byte As Byte
Cls
Dim B 
As Word
Dim C 
As Word
Dim D 
As Word
Dim K 
As Byte
Dim X 
As Byte
Config Kbd 
Portd Debounce 100 Delay 70
Cls

Main0
:
Do
Getkbd()
Loop Until K 16
Do
Getkbd()
Loop Until K <> 16
If 15 Then
Goto Cal_isr
End 
If
If 
14 Then
1
Locate 2 
Lcd "Rotate right"
Goto Main0
End 
If
If 
13 Then
2
Locate 2 
Lcd "Rotate left"
Goto Main0
End 
If
10
K
Locate 1 
Lcd B
Goto Main0


Cal_isr
:
7.2
B Mod 7.2

'---------------------------------- baghi mande---------------------
Select Case D
Case 0
Goto Main

Case 1
If X = 1 Then
E = 128
Rotate E , Left
Porta = E
Waitms 100
Goto Main
End If
If X = 2 Then
E = 16
Rotate E , Right
Porta = E
Waitms 100
Goto Main
End If

Case 2
If X = 1 Then
E = 128
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
Goto Main
End If
If X = 2 Then
E = 16
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Goto Main
End If

Case 3
If X = 1 Then
E = 128
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
End If
If X = 2 Then
E = 16
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Goto Main
End If


Case 4
If X = 1 Then
E = 128
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
Rotate E , Left
Porta = E
Waitms 100
End If
If X = 2 Then
E = 16
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Rotate E , Right
Porta = E
Waitms 100
Goto Main
End If

Case 5
If X = 1 Then
Porta = 1
Waitms 100
Porta = 2
Waitms 100
Porta = 4
Waitms 100
Porta = 8
Waitms 100
Porta = 1
Waitms 100
End If
If X = 2 Then
Porta = 1
Waitms 100
Porta = 8
Waitms 100
Porta = 4
Waitms 100
Porta = 2
Waitms 100
Porta = 1
Waitms 100
Goto Main
End If

Case 6
If X = 1 Then
Porta = 1
Waitms 100
Porta = 2
Waitms 100
Porta = 4
Waitms 100
Porta = 8
Waitms 100
Porta = 1
Waitms 100
Porta = 2
Waitms 100
End If
If X = 2 Then
Porta = 1
Waitms 1000
Porta = 8
Waitms 100
Porta = 4
Waitms 100
Porta = 2
Waitms 100
Porta = 1
Waitms 100
Porta = 8
Waitms 100
Goto Main
End If

Case 7
If X = 1 Then
Porta = 1
Waitms 100
Porta = 2
Waitms 100
Porta = 4
Waitms 100
Porta = 8
Waitms 100
Porta = 1
Waitms 100
Porta = 2
Waitms 100
Porta = 4
Waitms 100
End If
If X = 2 Then
Porta = 1
Waitms 100
Porta = 8
Waitms 100
Porta = 4
Waitms 100
Porta = 2
Waitms 100
Porta = 1
Waitms 100
Porta = 8
Waitms 100
Porta = 4
Waitms 100
Goto Main
End If
End Select
'
------------------------------ adad asli----------------------
Main:
Select Case X
Case 1
For 1 To C
128
For 1 To 4
Rotate E 
Left
Porta 
E
Waitms 100
Next I
Next A
Cls 
Locate 1 Lcd "stop_stop"
Do : Loop

Case 2
For 1 To C
16
For 1 To 4
Rotate E 
Right
Porta 
E
Waitms 100
Next I
Next A
Cls 
Locate 1 Lcd "stop_stop"
Do : Loop
End Select