Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:31 26 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Syntax of "ON" command

Author Message
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 761
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
 
greybeard
Senior Member

Joined: 04/01/2010
Location: Australia
Posts: 161
Posted: 10:36pm 21 Nov 2012
Copy link to clipboard 
Print this post

At a guess the trailing comma on the 'on coilstate....' line after state4,
 
Zonker

Guru

Joined: 18/08/2012
Location: United States
Posts: 761
Posted: 03:36pm 24 Nov 2012
Copy link to clipboard 
Print this post

Yes... Nubbie mistake, works fine now... Thanks for the help...!
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024