question about stepper code ... please help!
daidalos62
Posts: 21
hello all,
ok heres my question:
This code (below and attached) pushes a stepper perfectly but ONLY with pins 12 - 15 and 0 - 3. It will not work if the motor is connected to pins 4-7 or 8-11. This is a problem, because I'd like to run 3 motors from one stamp. BTW I'm running the Basic Stamp 2 IC module (the green one).
something is off within the code and I cant find it!
heres a quick reference and attached is the bs2 file.
x VAR WORD
stepper VAR NIB
steps VAR BYTE
DIRS.lowBYTE = %11111111
DIRS.highbyte = %11111111
'
o
main:
GOSUB clock
PAUSE 100
GOSUB counter
PAUSE 100
GOTO main
'
o
clock:
RANDOM steps
DEBUG DEC steps * 2, "to", CR
FOR x = 0 TO steps * 2
LOOKUP x//4, [noparse][[/noparse]%1000,%0100,%0010,%0001], stepper
OUTS.lowbyte.LOWNIB = stepper
PAUSE 2
NEXT
RETURN
'
o
counter:
RANDOM steps
DEBUG DEC steps * 2, "fro", CR
FOR x = 0 TO steps * 2
LOOKUP x//4, [noparse][[/noparse]%0001,%0010,%0100,%1000], stepper
OUTS.lowBYTE.LOWNIB = stepper
PAUSE 2
NEXT
RETURN
thanks guys!
ok heres my question:
This code (below and attached) pushes a stepper perfectly but ONLY with pins 12 - 15 and 0 - 3. It will not work if the motor is connected to pins 4-7 or 8-11. This is a problem, because I'd like to run 3 motors from one stamp. BTW I'm running the Basic Stamp 2 IC module (the green one).
something is off within the code and I cant find it!
heres a quick reference and attached is the bs2 file.
x VAR WORD
stepper VAR NIB
steps VAR BYTE
DIRS.lowBYTE = %11111111
DIRS.highbyte = %11111111
'
o
main:
GOSUB clock
PAUSE 100
GOSUB counter
PAUSE 100
GOTO main
'
o
clock:
RANDOM steps
DEBUG DEC steps * 2, "to", CR
FOR x = 0 TO steps * 2
LOOKUP x//4, [noparse][[/noparse]%1000,%0100,%0010,%0001], stepper
OUTS.lowbyte.LOWNIB = stepper
PAUSE 2
NEXT
RETURN
'
o
counter:
RANDOM steps
DEBUG DEC steps * 2, "fro", CR
FOR x = 0 TO steps * 2
LOOKUP x//4, [noparse][[/noparse]%0001,%0010,%0100,%1000], stepper
OUTS.lowBYTE.LOWNIB = stepper
PAUSE 2
NEXT
RETURN
thanks guys!
Comments
In trying to work with pins 4-7 or 8-11, I assume you're adjusting the OUTS statement to reflect the actual pins you want to use.
Have you tried using the nibble specifiers OUTA, OUTB, OUTC, OUTD with the same results?
It is possible that its a bum chip, but the chances of those two nibbles being bad on one chip are pretty small.
Cheers
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tom Sisk
http://www.siskconsult.com
·
I havent tried those yet, In fact I've never used the OUTA etc so I'll look at the manual and see what I can figure out.
And yes you were correct in your assumption - I would just enter highbyte in place of lowbyte in the case of the outs to switch from 0-3 to 12-15. I also tried HighNib but that didn't quite work. Must keep digging!!
anyone else ever run multiple steppers, 3 or 4, from one stamp?
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
My problem is with the code.... I cant figure out how to use pins 4-7 and 8-11. Theres more of a description above, and my current code is supplied via attachment. Basically, I was just changing the outs to read either the highbyte or lowbyte, but this only utilizes pins 0-3 and 12-15. The motor will not run if connected to any of the others.
So I was really just asking if anyone knew of an easier way to write the code to utilize the pins in sets of 4 to run the steppers.
DIRL = %11111111
DIRH = %11111111
Also, you’re using the same line for both Stepper Motor outputs:
OUTS.LOWBYTE.LOWNIB
What you need is a lin like:
OUTA = stepper
Or for controlling multiple Stepper Motors at the same time you would build your word variable from 4 binary nibble step patterns and simply do a:
OUTS = stepper
In the above case stepper is a WORD variable. For individual control using the same WORD variable you could use:
OUTA = stepper.NIB0
OUTB = stepper.NIB1
OUTC = stepper.NIB2
OUTD = stepper.NIB3
Using only the above statements you wanted you could alter individual Stepper Motors without affecting others. Take care.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
using outsA, outsB, outsC, and outsD I was able to get the desired results HOWEVER I think I may have a bum chip
The motors run well getting data from outsA, C, and D but not B. I can feel the motor is getting something, as it makes some noise and vibrates a little but its almost as if one of the pins isnt working or something....
grrrr
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support