Posted: 09:25pm 21 Nov 2012 |
Copy link to clipboard |
Print this post |
|
I have a needle guage that works as a very small 2 coil stepper motor that is geared down to move the needle. It was taken fron a car dashboard guage. It takes very little voltage and current to drive it, so i think i can drive the coils directly from the MM's I/O pins... The program throws a syntax exception when it gets to the "ON" instruction, and i can't figure out why... I assume you can use a variable here (coilstate) and branch to the right pin setting pattern needed to create the next drive movement... Could be a "nubbie" mistake.. any ideas ?
Thanks for any help with this..!!
For n=17 To 20: Pin(n)=0: SetPin n,8: Next n ' setup pins as output LOW
SetTick 100, takestep
coilstate=1
Do
Input "direction , steps "; D$,S
Loop
takestep:
If S > 0 Then
If D$ = "F" Or D$ = "f" Then coilstate = coilstate + 1
If D$ = "B" Or D$ = "b" Then coilstate = coilstate - 1
If coilstate <= 0 Then coilstate = 4
If coilstate >= 5 Then coilstate = 1
On coilstate GoTo state1, state2, state3, state4,
state1:
Pin(20)=1: Pin(19)=0: Pin(18)=0: Pin(17)=0: GoTo stepdone
state2:
Pin(20)=0: Pin(19)=0: Pin(18)=1: Pin(17)=0: GoTo stepdone
state3:
Pin(20)=0: Pin(19)=1: Pin(18)=0: Pin(17)=0: GoTo stepdone
state4:
Pin(20)=0: Pin(19)=0: Pin(18)=0: Pin(17)=1
stepdone:
S = S-1
EndIf
IReturn
|