stepper progam problem
Archiver
Posts: 46,084
Can anyone tell me please, what's up with this program?
The motor merely twitches, although occasionally makes a few steps
before doing so! Motor driven via ULN 2803A
'{$STAMP BS2}
'unipolar via the ULN 2803A
T CON 200
index VAR Byte
sequence VAR Byte
DIRD = 1111 'high 4 bits are outputs
main:
FOR index = 0 TO 3
LOOKUP index,[noparse][[/noparse]0001,0010,0100,1000], sequence
OUTD = sequence
PAUSE T
NEXT
GOTO main:
The motor merely twitches, although occasionally makes a few steps
before doing so! Motor driven via ULN 2803A
'{$STAMP BS2}
'unipolar via the ULN 2803A
T CON 200
index VAR Byte
sequence VAR Byte
DIRD = 1111 'high 4 bits are outputs
main:
FOR index = 0 TO 3
LOOKUP index,[noparse][[/noparse]0001,0010,0100,1000], sequence
OUTD = sequence
PAUSE T
NEXT
GOTO main:
Comments
to enable just one phase at a time. This can work, but usually you
would usually enable two-phases per step (unless half-stepping, but then
your code would have eight steps). There is also an error in the line
DIRD = 1111
It should be
DIRD = %1111
You can download docs (written by yours truly) with working code from
our web site at this link:
http://www.parallax.com/dl/docs/prod/motors/27964.pdf
Your task will be to match the phase wires to the code (which may also
be part of your current problem).
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: free22preach [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=QsAjp4D3ip57dCrsROZjGgYJiWe6pgW_4bB1pUjRWZfxSQaK5mFxZ4hnwhwBtZyYavagsqd9eSIWsyVQ0JbS02RxbXY]PandL.Haskew@b...[/url
Sent: Monday, June 28, 2004 12:46 PM
To: basicstamps@yahoogroups.com
Subject: [noparse][[/noparse]basicstamps] stepper progam problem
Can anyone tell me please, what's up with this program?
The motor merely twitches, although occasionally makes a few steps
before doing so! Motor driven via ULN 2803A
'{$STAMP BS2}
'unipolar via the ULN 2803A
T CON 200
index VAR Byte
sequence VAR Byte
DIRD = 1111 'high 4 bits are outputs
main:
FOR index = 0 TO 3
LOOKUP index,[noparse][[/noparse]0001,0010,0100,1000], sequence
OUTD = sequence
PAUSE T
NEXT
GOTO main:
sloppy!
Paul
Original Message
From: "Jon Williams" <jwilliams@p...>
To: <basicstamps@yahoogroups.com>
Sent: Tuesday, June 29, 2004 12:27 AM
Subject: RE: [noparse][[/noparse]basicstamps] stepper progam problem
> Aside from sloppy formatting (a BIG peeve of mine), the program appears
> to enable just one phase at a time. This can work, but usually you
> would usually enable two-phases per step (unless half-stepping, but then
> your code would have eight steps). There is also an error in the line
>
> DIRD = 1111
>
> It should be
>
> DIRD = %1111
>
> You can download docs (written by yours truly) with working code from
> our web site at this link:
>
> http://www.parallax.com/dl/docs/prod/motors/27964.pdf
>
> Your task will be to match the phase wires to the code (which may also
> be part of your current problem).
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: free22preach [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=_8cx23Jrp5kQsqZxJYJkZKZW4KLjUDPsBg1vB_XVJQ0Xgb5msmuuSe7BGhy8h6BXmBaKf27q3ZsjtvVo4QySshSR5JbT]PandL.Haskew@b...[/url
> Sent: Monday, June 28, 2004 12:46 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] stepper progam problem
>
>
> Can anyone tell me please, what's up with this program?
> The motor merely twitches, although occasionally makes a few steps
> before doing so! Motor driven via ULN 2803A
>
> '{$STAMP BS2}
> 'unipolar via the ULN 2803A
> T CON 200
> index VAR Byte
> sequence VAR Byte
> DIRD = 1111 'high 4 bits are outputs
>
> main:
> FOR index = 0 TO 3
> LOOKUP index,[noparse][[/noparse]0001,0010,0100,1000], sequence
> OUTD = sequence
> PAUSE T
> NEXT
> GOTO main:
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
> Yahoo! Groups Links
>
>
>
>
>
>
http://www.parallax.com/dl/docs/prod/stamps/pbasicstyle.pdf
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Paul Haskew [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=1giRVfp-UbcXQup948KfVPAT2oxUFPO3bcZRtlw8kePoti-_k_80Rf5H6SZqnbtfJODBpmwFZxhcNik4Yb46hFgP2w]PandL.Haskew@b...[/url
Sent: Tuesday, June 29, 2004 3:44 AM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] stepper progam problem
Many thanks Jon for the helpful rebuke & %! Really trying to be less
sloppy!
Paul
Original Message
From: "Jon Williams" <jwilliams@p...>
To: <basicstamps@yahoogroups.com>
Sent: Tuesday, June 29, 2004 12:27 AM
Subject: RE: [noparse][[/noparse]basicstamps] stepper progam problem
> Aside from sloppy formatting (a BIG peeve of mine), the program
> appears to enable just one phase at a time. This can work, but
> usually you would usually enable two-phases per step (unless
> half-stepping, but then your code would have eight steps). There is
> also an error in the line
>
> DIRD = 1111
>
> It should be
>
> DIRD = %1111
>
> You can download docs (written by yours truly) with working code from
> our web site at this link:
>
> http://www.parallax.com/dl/docs/prod/motors/27964.pdf
>
> Your task will be to match the phase wires to the code (which may also
> be part of your current problem).
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: free22preach [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=1giRVfp-UbcXQup948KfVPAT2oxUFPO3bcZRtlw8kePoti-_k_80Rf5H6SZqnbtfJODBpmwFZxhcNik4Yb46hFgP2w]PandL.Haskew@b...[/url
> Sent: Monday, June 28, 2004 12:46 PM
> To: basicstamps@yahoogroups.com
> Subject: [noparse][[/noparse]basicstamps] stepper progam problem
>
>
> Can anyone tell me please, what's up with this program?
> The motor merely twitches, although occasionally makes a few steps
> before doing so! Motor driven via ULN 2803A
>
> '{$STAMP BS2}
> 'unipolar via the ULN 2803A
> T CON 200
> index VAR Byte
> sequence VAR Byte
> DIRD = 1111 'high 4 bits are outputs
>
> main:
> FOR index = 0 TO 3
> LOOKUP index,[noparse][[/noparse]0001,0010,0100,1000], sequence
> OUTD = sequence
> PAUSE T
> NEXT
> GOTO main:
habits die hard!) Will you please explain what is happening here, stpIdx =
stpIdx + 1 // 4,
and stpIdx = stpIdx + 3 // 4. What remainders are returned for the Stamp to
count forwards/backwards. Sorry to be so dim...but it will be useful to have
some understanding for future reference.
Thanks so much Paul
Haskew
Original Message
From: "Jon Williams" <jwilliams@p...>
To: <basicstamps@yahoogroups.com>
Sent: Tuesday, June 29, 2004 1:04 PM
Subject: RE: [noparse][[/noparse]basicstamps] stepper progam problem
> This will help:
> http://www.parallax.com/dl/docs/prod/stamps/pbasicstyle.pdf
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: Paul Haskew [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=474TEOelSd8XYl3PasP-iVGjvitZA-j69K1EG9t74B2huPXFF9ZOwEHYvtQGiA8MjMEBtVM2XuGIssa1mqg5-jtfPKKWDA]PandL.Haskew@b...[/url
> Sent: Tuesday, June 29, 2004 3:44 AM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] stepper progam problem
>
>
> Many thanks Jon for the helpful rebuke & %! Really trying to be less
> sloppy!
>
> Paul
>
Original Message
> From: "Jon Williams" <jwilliams@p...>
> To: <basicstamps@yahoogroups.com>
> Sent: Tuesday, June 29, 2004 12:27 AM
> Subject: RE: [noparse][[/noparse]basicstamps] stepper progam problem
>
>
> > Aside from sloppy formatting (a BIG peeve of mine), the program
> > appears to enable just one phase at a time. This can work, but
> > usually you would usually enable two-phases per step (unless
> > half-stepping, but then your code would have eight steps). There is
> > also an error in the line
> >
> > DIRD = 1111
> >
> > It should be
> >
> > DIRD = %1111
> >
> > You can download docs (written by yours truly) with working code from
> > our web site at this link:
> >
> > http://www.parallax.com/dl/docs/prod/motors/27964.pdf
> >
> > Your task will be to match the phase wires to the code (which may also
>
> > be part of your current problem).
> >
> > -- Jon Williams
> > -- Applications Engineer, Parallax
> > -- Dallas Office
> >
> >
> >
Original Message
> > From: free22preach [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=474TEOelSd8XYl3PasP-iVGjvitZA-j69K1EG9t74B2huPXFF9ZOwEHYvtQGiA8MjMEBtVM2XuGIssa1mqg5-jtfPKKWDA]PandL.Haskew@b...[/url
> > Sent: Monday, June 28, 2004 12:46 PM
> > To: basicstamps@yahoogroups.com
> > Subject: [noparse][[/noparse]basicstamps] stepper progam problem
> >
> >
> > Can anyone tell me please, what's up with this program?
> > The motor merely twitches, although occasionally makes a few steps
> > before doing so! Motor driven via ULN 2803A
> >
> > '{$STAMP BS2}
> > 'unipolar via the ULN 2803A
> > T CON 200
> > index VAR Byte
> > sequence VAR Byte
> > DIRD = 1111 'high 4 bits are outputs
> >
> > main:
> > FOR index = 0 TO 3
> > LOOKUP index,[noparse][[/noparse]0001,0010,0100,1000], sequence
> > OUTD = sequence
> > PAUSE T
> > NEXT
> > GOTO main:
>
>
> To UNSUBSCRIBE, just send mail to:
> basicstamps-unsubscribe@yahoogroups.com
> from the same email address that you subscribed. Text in the Subject and
Body of the message will be ignored.
>
> Yahoo! Groups Links
>
>
>
>
>
remainder of a division and will keep a value in a 0 to N-1 range, where
N is the modulus parameter (divisor). In the stepper program we need to
loop through steps 0 - 3, so this comes in handy.
This line of code:
stpIdx = stpIdx + 1 // 4
replaces this:
stpIdx = stpIdx + 1
IF (stpIdx = 4) THEN stpIdx = 0 ' $PBASIC 2.5 syntax
Clearly, there former is easier. It's even better when going the other
way. This....
stpIdx = stpIdx + 3 // 4
replaces...
IF (stpIdx = 0) THEN
stpIdx = 3
ELSE
stpIdx = stpIdx - 1
ENDIF
Again, the former is easier. The second one is a little trickier until
you look closely -- notice that we're adding one less than the number of
possible elements, so the effect is like subtracting one. This is a
much cleaner approach in a small micro, but to be candid I also use it
in my PC programs as well.
When in doubt, run test code using DEBUG. Try this:
Setup:
idx1 = 0
idx2 = 3
Main:
DEBUG DEC idx1, TAB, DEC idx2, CR
PAUSE 500
idx1 = idx1 + 1 // 4
idx2 = idx2 + 3 // 4
GOTO Main
I hope this helps.
-- Jon Williams
-- Applications Engineer, Parallax
-- Dallas Office
Original Message
From: Paul Haskew [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=8XuSdidq5R-xrpVlGLCnvC-tRTNTaeTYEO9lKUVNvAwSmUNtSqrGwsYcs8vbqRPNN0GZlaJheQ4dEtrenEhb9gA]PandL.Haskew@b...[/url
Sent: Thursday, July 01, 2004 9:28 AM
To: basicstamps@yahoogroups.com
Subject: Re: [noparse][[/noparse]basicstamps] stepper progam problem
Jon , feel better already! One last query on your stepper code ('cos bad
habits die hard!) Will you please explain what is happening here, stpIdx
= stpIdx + 1 // 4, and stpIdx = stpIdx + 3 // 4. What remainders are
returned for the Stamp to count forwards/backwards. Sorry to be so
dim...but it will be useful to have some understanding for future
reference.
Thanks so much
Paul Haskew
Original Message
From: "Jon Williams" <jwilliams@p...>
To: <basicstamps@yahoogroups.com>
Sent: Tuesday, June 29, 2004 1:04 PM
Subject: RE: [noparse][[/noparse]basicstamps] stepper progam problem
> This will help:
> http://www.parallax.com/dl/docs/prod/stamps/pbasicstyle.pdf
>
> -- Jon Williams
> -- Applications Engineer, Parallax
> -- Dallas Office
>
>
>
Original Message
> From: Paul Haskew [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=8XuSdidq5R-xrpVlGLCnvC-tRTNTaeTYEO9lKUVNvAwSmUNtSqrGwsYcs8vbqRPNN0GZlaJheQ4dEtrenEhb9gA]PandL.Haskew@b...[/url
> Sent: Tuesday, June 29, 2004 3:44 AM
> To: basicstamps@yahoogroups.com
> Subject: Re: [noparse][[/noparse]basicstamps] stepper progam problem
>
>
> Many thanks Jon for the helpful rebuke & %! Really trying to be less
> sloppy!
>
> Paul
>
Original Message
> From: "Jon Williams" <jwilliams@p...>
> To: <basicstamps@yahoogroups.com>
> Sent: Tuesday, June 29, 2004 12:27 AM
> Subject: RE: [noparse][[/noparse]basicstamps] stepper progam problem
>
>
> > Aside from sloppy formatting (a BIG peeve of mine), the program
> > appears to enable just one phase at a time. This can work, but
> > usually you would usually enable two-phases per step (unless
> > half-stepping, but then your code would have eight steps). There is
> > also an error in the line
> >
> > DIRD = 1111
> >
> > It should be
> >
> > DIRD = %1111
> >
> > You can download docs (written by yours truly) with working code
> > from our web site at this link:
> >
> > http://www.parallax.com/dl/docs/prod/motors/27964.pdf
> >
> > Your task will be to match the phase wires to the code (which may
> > also
>
> > be part of your current problem).
> >
> > -- Jon Williams
> > -- Applications Engineer, Parallax
> > -- Dallas Office
> >
> >
> >
Original Message
> > From: free22preach [noparse]/noparse]mailto:[url=http://forums.parallaxinc.com/group/basicstamps/post?postID=8XuSdidq5R-xrpVlGLCnvC-tRTNTaeTYEO9lKUVNvAwSmUNtSqrGwsYcs8vbqRPNN0GZlaJheQ4dEtrenEhb9gA]PandL.Haskew@b...[/url
> > Sent: Monday, June 28, 2004 12:46 PM
> > To: basicstamps@yahoogroups.com
> > Subject: [noparse][[/noparse]basicstamps] stepper progam problem
> >
> >
> > Can anyone tell me please, what's up with this program?
> > The motor merely twitches, although occasionally makes a few steps
> > before doing so! Motor driven via ULN 2803A
> >
> > '{$STAMP BS2}
> > 'unipolar via the ULN 2803A
> > T CON 200
> > index VAR Byte
> > sequence VAR Byte
> > DIRD = 1111 'high 4 bits are outputs
> >
> > main:
> > FOR index = 0 TO 3
> > LOOKUP index,[noparse][[/noparse]0001,0010,0100,1000], sequence
> > OUTD = sequence
> > PAUSE T
> > NEXT
> > GOTO main: