Stepper Control Questions
CharlieC
Posts: 14
I am·learning how to use the BS2 and a stepper.· I am using a stepper that seems to be the same as the one that parallax sells and the homework board.· (attached picture)
It seems to be working fine and I (almost) understand the code (stollen and modifyed from parallax stepper docs - attached), but I have a couple questions.
1)· The stepper is rated at 12 volts and I am feeding it with only 9v from Vin.· Can this damage the motor?· Can this damage the bs2?· I've see in various docs that I need a separate power supply for motors.· I have assumed that this means separate from the regulated power going to the actual bs2 chip.
2)· In the code, the StpsPerRev is accurately set at 48.· I figured that if I increase this number, it will just cause the stepper to move beyond a full revolation (times five in this code), and this is true if I increase it· up to 51.· But anything beyond 51 causes the stepper to turn continiously.· Why?
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Charlie Chisholm
That part, at least,·I'm sure of.
It seems to be working fine and I (almost) understand the code (stollen and modifyed from parallax stepper docs - attached), but I have a couple questions.
1)· The stepper is rated at 12 volts and I am feeding it with only 9v from Vin.· Can this damage the motor?· Can this damage the bs2?· I've see in various docs that I need a separate power supply for motors.· I have assumed that this means separate from the regulated power going to the actual bs2 chip.
2)· In the code, the StpsPerRev is accurately set at 48.· I figured that if I increase this number, it will just cause the stepper to move beyond a full revolation (times five in this code), and this is true if I increase it· up to 51.· But anything beyond 51 causes the stepper to turn continiously.· Why?
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Charlie Chisholm
That part, at least,·I'm sure of.
Comments
If it runs continuously when you pulse it more than 51 times there is an error in yiour code somewhere.· Your loop to run the stepper should look something like this:
for x = 1 to whatever
pulsout pin, 10············ 'pulse width of 10 = 20 us
next
'go to next instruction.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Sid Weaver
NEW! 4 MB EEPROM
http://hometown.aol.com/newzed/page4.html
·
·· Seeing that you are using a 9V battery to power your board and the stepper motor, I'm actually kind of surprised that it's turning the stepper motor at all.· You really should get a separate power supply for the stepper motor, and make sure there is a common ground.
·· As for the stepper motor turning contiuously, I didn't look at your code, but one thing you could check is to see if the stepper motor is causing the BS2 to brown-out.· You can do this by adding the following code before your main loop:
You should see the text, "Program Running..." on the screen once.· If you see it printing more than once, then the program is restarting due to brown-out.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
csavage@parallax.com
You will probably drain your battery quick. If you can find a 9volt (or 12volt) "wallwart" power supply that you can savotage, that would be prefered.
I don't know anything about your code, so I can't really help you there. I've come to parallax looking for a solution to a specific problem so am super new to this product.
In the code, I had ....
idx··········· VAR· byte····· · ' for the counter
stpsPerRev CON 48·········· ' steps per revolution
for looping through the 1 to 48 positions.
In the code, I had modified the loop to be
for idx = 1 to stpsPerRev * 5· ' for five revolutions
So as long as I left stpsPerRev at 48, (or below 52), I was fine.· But going beyond 51, I would·over-run the idx with a number beyond it's max 255·
It was interesting that I tried your suggestion, Chris, and found that it was only starting the program once, but when I put a DEBUG inside the idx loop to indicate it's value, the display got very bizaar indeed.· Obvious memory location over-run.
I will now separate the power supplies (removing· the question of damaging the motor or the BS2) and move on to the next learning experience.
Thanks
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Charlie Chisholm
That part, at least,·I'm sure of.