Witam !
Napisałem prosty sterownik silnika krokowego który odbiera impulsy Dir i Step i odpowiednio steruje silnikiem. Jednak przy kompilacji wyskakuje błąd nie wiem jak go usunąć. Nie wiem także czy ten program będzie działał. Proszę o sprawdzenie go i ewentualnie wytłumaczenia na czym polega błąd.
portb. 0 1 2 3 - do tranzystorów sterujących silnikiem
Portd.5 - step
Portd.4 - dir
Portd.3 - klawisz ręcznego przesuwu
Portd.2 - klawisz ręcznego przesuwu
Napisałem prosty sterownik silnika krokowego który odbiera impulsy Dir i Step i odpowiednio steruje silnikiem. Jednak przy kompilacji wyskakuje błąd nie wiem jak go usunąć. Nie wiem także czy ten program będzie działał. Proszę o sprawdzenie go i ewentualnie wytłumaczenia na czym polega błąd.
$regfile = "attiny2313.dat"
$crystal = 10000000
Config Portb = Output 'port b jako wyście (silnik)
Config Portd = Input 'port d jako wyjście (z kompa i klawisze)
Portb = &B00000001
Portd = &B00000000
Do
Do
Loop Until Portd.5 = 0
Do
Loop Until Portd.5 = 1
'obroty lewo
If Portd.5 = 1 And Portd.4 = 1 Then
If Portb.0 = 1 Then Portb.1 = 1
Waitms 5
Portb.0 = 0
Else
If Portb.1 = 1 Then Portb.2 = 1
Waitms 5
Portb.1 = 0
Else
If Portb.2 = 1 Then Portb.3 = 1
Waitms 5
Portb.2 = 0
Else
If Portb.3 = 1 Then Portb.0 = 1
Waitms 5
Portb.3 = 0
End If
Else
If Portd.5 = 1 And Portd.4 = 0 Then 'obroty prawo
If Portb.0 = 1 Then Portb.3 = 1
Waitms 5
Portb.0 = 0
Else
If Portb.1 = 1 Then Portb.0 = 1
Waitms 5
Portb.1 = 0
Else
If Portb.2 = 1 Then Portb.1 = 1
Waitms 5
Portb.2 = 0
Else
If Portb.3 = 1 Then Portb.2 = 1
Waitms 5
Portb.3 = 0
End If
End If
If Portd.2 = 1 Then 'obsuga klawisza lewego
Waitms 5
If Portd.2 = 1 Then
If Portb.0 = 1 Then Portb.1 = 1
Waitms 5
Portb.0 = 0
Else
If Portb.1 = 1 Then Portb.2 = 1
Waitms 5
Portb.1 = 0
Else
If Portb.2 = 1 Then Portb.3 = 1
Waitms 5
Portb.2 = 0
Else
If Portb.3 = 1 Then Portb.0 = 1
Waitms 5
Portb.3 = 0
End If
Else
'obsługa klawisza prawego
If Portd.3 = 1 Then
Waitms 5
If Portd.3 = 1 Then
If Portb.0 = 1 Then Portb.3 = 1
Waitms 5
Portb.0 = 0
Else
If Portb.1 = 1 Then Portb.0 = 1
Waitms 5
Portb.1 = 0
Else
If Portb.2 = 1 Then Portb.1 = 1
Waitms 5
Portb.2 = 0
Else
If Portb.3 = 1 Then Portb.2 = 1
Waitms 5
Portb.3 = 0
End If
End If
Loop
portb. 0 1 2 3 - do tranzystorów sterujących silnikiem
Portd.5 - step
Portd.4 - dir
Portd.3 - klawisz ręcznego przesuwu
Portd.2 - klawisz ręcznego przesuwu