ich hab nen bipolaren Schrittmotor über L293D so angesteuert:
Code:
$regfile = "m32def.dat"
$framesize = 32
$swstack = 32
$hwstack = 32
$crystal = 1600000
Dim A As Byte
Config Pina.0 = Input
Config Pina.2 = Input
Porta.0 = 1
Porta.2 = 1
Config Portc.0 = Output
Config Portc.1 = Output
Config Portc.2 = Output
Config Portc.3 = Output
Portc.0 = 1
Portc.1 = 1
Portc.2 = 1
Portc.3 = 1
A = 0
Do
If Pina.0 = 0 Then
Waitms 300
If A < 4 Then
A = A + 1
Else
A = 1
End If
End If
If Pina.2 = 0 Then
Waitms 300
If A > 1 Then
A = A - 1
Else
A = 4
End If
End If
If A = 1 Then
Gosub Macheschritt1
End If
If A = 2 Then
Gosub Macheschritt2
End If
If A = 3 Then
Gosub Macheschritt3
End If
If A = 4 Then
Gosub Macheschritt4
End If
Loop
Declare Sub Macheschritt1
Declare Sub Macheschritt2
Declare Sub Macheschritt3
Declare Sub Macheschritt4
Sub Macheschritt1
Portc.0 = 0
Portc.1 = 1
Portc.2 = 0
Portc.3 = 1
Waitms 20
End Sub
Sub Macheschritt2
Portc.0 = 0
Portc.1 = 1
Portc.2 = 1
Portc.3 = 0
Waitms 20
End Sub
Sub Macheschritt3
Portc.0 = 1
Portc.1 = 0
Portc.2 = 1
Portc.3 = 0
Waitms 20
End Sub
Sub Macheschritt4
Portc.0 = 1
Portc.1 = 0
Portc.2 = 0
Portc.3 = 1
Waitms 20 '
End Sub
End
Weis nicht ob die Verzögerungen notwenig sind. Ich glaub so könntest du auch das langsam Hochfahren lösen. Über zwei Taster hab ich ihn einen Schritt nach links bzw. rechts machen lassen.
Lesezeichen