Witam.
Zbudowałem ostatnio próbną wersje sterownika silnika krokowego, po podłączeniu pod komputer z użyciem ubuntu i programu EMC2 mam problem ze sterowaniem obrotami silnika, zmienia się kierunek obrotów ale nie można płynnie sterować silnkiem. Nie jestem pewien czy oprogramowanie sterownika przeze mnie napisane będzie działać z tym programem i jak zrealizowane jest sterowanie dir, step i enable.
Poniżej listing z programu:
$regfile = "attiny2313.dat"
$crystal = 4000000
Config Portb = Output : Portb = &B00000000
Config Portd = Input : Portd = &B1111111
Dim X As Integer
Declare Sub Lewo
Declare Sub Prawo
Do
'pind.2 - enable pind.1 - dir pind.0 - step
If Pind.2 = 0 And Pind.0 = 0 And Pind.1 = 0 Then Gosub Lewo
If Pind.2 = 0 And Pind.0 = 0 And Pind.1 = 1 Then Gosub Prawo
If Pind.2 = 1 Then Portb = &B00000000
Loop
Sub Lewo:
Incr X
Waitms 4
If X > 4 Then
X = 1
End If
If X = 1 Then
Portb = &B00000011
End If
If X = 2 Then
Portb = &B00000110
End If
If X = 3 Then
Portb = &B00001100
End If
If X = 4 Then
Portb = &B00001001
End If
Return
End Sub
Sub Prawo:
Incr X
Waitms 4
If X > 4 Then
X = 1
End If
If X = 1 Then
Portb = &B00001100
End If
If X = 2 Then
Portb = &B00000110
End If
If X = 3 Then
Portb = &B00000011
End If
If X = 4 Then
Portb = &B00001001
End If
Return
End Sub
Return
End
Proszę o podpowiedź i sprawdzenie poprawności programu.
Pozdrawiam Tomek12_86.
Dodano po 1 [godziny] 7 [minuty]:
Czy ktoś może podzielić się jakąś myślą w sprawie tego programu?
Zbudowałem ostatnio próbną wersje sterownika silnika krokowego, po podłączeniu pod komputer z użyciem ubuntu i programu EMC2 mam problem ze sterowaniem obrotami silnika, zmienia się kierunek obrotów ale nie można płynnie sterować silnkiem. Nie jestem pewien czy oprogramowanie sterownika przeze mnie napisane będzie działać z tym programem i jak zrealizowane jest sterowanie dir, step i enable.
Poniżej listing z programu:
$regfile = "attiny2313.dat"
$crystal = 4000000
Config Portb = Output : Portb = &B00000000
Config Portd = Input : Portd = &B1111111
Dim X As Integer
Declare Sub Lewo
Declare Sub Prawo
Do
'pind.2 - enable pind.1 - dir pind.0 - step
If Pind.2 = 0 And Pind.0 = 0 And Pind.1 = 0 Then Gosub Lewo
If Pind.2 = 0 And Pind.0 = 0 And Pind.1 = 1 Then Gosub Prawo
If Pind.2 = 1 Then Portb = &B00000000
Loop
Sub Lewo:
Incr X
Waitms 4
If X > 4 Then
X = 1
End If
If X = 1 Then
Portb = &B00000011
End If
If X = 2 Then
Portb = &B00000110
End If
If X = 3 Then
Portb = &B00001100
End If
If X = 4 Then
Portb = &B00001001
End If
Return
End Sub
Sub Prawo:
Incr X
Waitms 4
If X > 4 Then
X = 1
End If
If X = 1 Then
Portb = &B00001100
End If
If X = 2 Then
Portb = &B00000110
End If
If X = 3 Then
Portb = &B00000011
End If
If X = 4 Then
Portb = &B00001001
End If
Return
End Sub
Return
End
Proszę o podpowiedź i sprawdzenie poprawności programu.
Pozdrawiam Tomek12_86.
Dodano po 1 [godziny] 7 [minuty]:
Czy ktoś może podzielić się jakąś myślą w sprawie tego programu?
