Bipolar stepper motor sequence
Forums:
Hello there,
I'm trying to make two 4-wire bipolar stepper motors work using two PicoBorg Reverses in daisy chaining. So far they work. Or at least they move. But I get the feeling something is wrong as they vibrate too much and sometimes even skip steps.
For this I wanted to understand how the sequencing works. I see in many places that the sequence of a stepper motor is written as:
1000 0100 0010 0001
or similarly, according to whatever the desired configuration is.
However on the PicoBorg code I only see this line:
sequence = [[1.0, 1.0], [1.0, -1.0], [-1.0, -1.0], [-1.0, 1.0]]
And I wonder how exactly does one translate into the other. Could somebody explain this to me, please? I would like to be able to play around with other sequences (hi-torque, half-step, etc.)
FYI, I believe the wiring is correct, even though I don't have the manual of these motors. I tried all possible combinations of wires and the one I have now (and the exact inverse one) was the only one that worked. Like I said, the motor do move in one direction, they don't get stuck. They just vibrate a lot.
Cheers!
piborg
Sun, 12/27/2015 - 19:45
Permalink
PicoBorg Reverse stepper sequence
Hi,
The sequence looks a little different from the typical examples because of the way the PicoBorg Reverse works.
With the typical examples you have four independent outputs: A, B, C, and D.
In order to move the stepper these are either turned on or off to change which coils are powered inside the motor.
This is how the PicoBorg is able to control a 5 or 6 wire stepper with its four on/off outputs.
With PicoBorg Reverse we have four output signals still, but they are in pairs: M1+, M1-, M2+, M2-.
This time we cannot set all four signals individually, but what we can do instead is drive the power through the coil the other way.
This is how the PicoBorg Reverse is able to control a 4 wire stepper as well as the more common 5 and 6 wire ones.
It should be noted that if you are using a 5 or 6 wire stepper the center connections (sometimes called "common") should not be connected, just the A, B, C, and D wires.
To explain how they compare I will describe a single pair, say A and C, vs M1+ and M1-.
M1+ needs to be a higher voltage than M1-.
We set M1 to 1.0, this means M1+ is at the battery voltage and M1- is at 0V.
M1+ needs to be a lower voltage than M1-.
We set M1 to -1.0, this means M1+ is at 0V and M1- is at the battery voltage.
M1+ and M1- need to be at the same voltage.
We set M1 to 0.0, this means M1+ and M1- are at 0V.
The example sequence should be the same as the full step drive sequence described on Wikipedia:
https://en.wikipedia.org/wiki/Stepper_motor#Phase_current_waveforms
Any of these sequences can be coded by changing the sequence line you have spotted.
Basically the sequence line is a list of the M1 and M2 motor outputs for each step.
The first value in each pair is the value for M1, the second for M2.
For example the pair
[1.0, -1.0]
means M1+ and M2- on, M1- and M2+ off.Assuming M1+ and M1- are connected to A and C this would be:
1001
.Given the stepper is rotating but not quite properly I would suggest trying a larger delay.
For example try 1/10th of a second:
stepDelay = 0.1
The delay required is different for each stepper model, but stepping too fast usually causes missed steps, excessive noise, excessive vibrations, or if far too small it may not even rotate.
0.1 is probably much larger than required, but if that works properly you can experiment with smaller values until you find the smallest number which works properly.
daizumi
Mon, 12/28/2015 - 18:16
Permalink
Thank you very much for the
Thank you very much for the thorough explanation! I get the logic now. :)
Unfortunately that means (I think) that the sequence wasn't the problem.
To test, I simplified the pbrStepper.py example to the point where it does nothing other than looping through sequence, but the behavior is always the same, and quite a weird one. It will always fail at an unpredictable point and in a different way (either gets stuck one step, or moves one step backwards).
With
stepDelay = 1
, I could determine that the missed/wrong steps happen first after around 15 steps (15 seconds), then 12, then 7, the 5, then 4, etc. At the same time the motors and the PicoBorg Reverse get hotter and hotter. In less than a minute I burn my fingers if I touch the motor or the mosfet on the PBR.Could it be that I have the wrong power source? I'm using a 12V, 1.7A stepper motor and a 12V, 3A stepper motor, both powered from a single 12V, 7A transformer. Am I doing something wrong there?
Thanks again!
piborg
Mon, 12/28/2015 - 20:34
Permalink
Missing steps
It sounds like the missed steps are probably due to the controller getting too hot then, not the delay time being wrong.
When the board detects a mosfet is getting too hot it temporarily shuts that output off until it has cooled down enough, this would then cause the sequence to be wrong as that output is effectively at 0.0 until the next step.
I think when it makes a step the wrong way it is probably due to missing two steps in a row, making the next step easier if the motor turns the opposite way.
The transformer should fine driving both steppers, I do not believe it will be the source of the trouble.
Holding the steps for a while will cause the board and motor to warm up as the controller is applying full power to maintain that position.
The way to keep the motor cooler is to either turn the motor off when you are not rotating it, or lower the power output.
I would suggest you try a lower power and see if the motor behaves correctly.
To lower the output power simply reduce the values from 1.0 to a smaller number.
For example to get 50% power:
sequence = [[0.5, 0.5], [0.5, -0.5], [-0.5, -0.5], [-0.5, 0.5]]
While you will need the full 12V to get maximum torque from the stepper it is likely it will rotate fine at lower outputs.
As you lower the value the stepper will probably start to rotate slower.
If you start getting more missed steps it is likely the value has been made too low and the stepper is not getting enough power any more.
I have attached a slightly better version of the standard script to this forum post.
There are two differences from the standard copy:
daizumi
Sat, 01/02/2016 - 10:59
Permalink
It worked!
Lowering the power solved the problem of the missed steps. I tried a few percentages and 75-80% (around 9V) seems to be the safest for the steppers I'm using.
I wonder though why this is the case. Both my motors and the PicoBorg Reverse are rated for 12V or more. It doesn't seem logical that I have to sacrifice a quarter of the torque. I wonder also if after a few hours of (intermittent) use they will start missing steps again, even at 75% power. I guess I'll have to test that.
Thanks for the improved script, that came in handy!
daizumi
Mon, 01/04/2016 - 10:29
Permalink
Hmm... Not really
My steppers are missing steps again. :( They work better with lower voltage, of course, but eventually (after a minute or two of continuous spinning) the PBR and the motors get super hot and the missed steps start happening again.
I showed it to an engeneer (who doesn't know anything about programming though) and he could tell from the sound of the steppers that something was wrong, even before the missed steps. Indeed, like I suggested in my first post, there's an odd vibration and noise.
This is really frustrating. What can I be doing wrong?
petecz
Sat, 01/28/2017 - 11:52
Permalink
Piborg Reverse half step sequence
Attached is a modified program (again) to half step a Nema 24. Sequence works like this :-
Step -> 1 2 3 4 5 6 7 8
Coil 1 (M1+) A 1 1 1 0 0 0 0 0
Coil 2 (M2+) B 0 0 1 1 1 0 0 0
Coil 1 (M1-) C 0 0 0 0 1 1 1 0
Coil 2 (M2-) D 1 0 0 0 0 0 1 1
Step 1 = [1.0,-1.0]
Step 2 = [1.0,0.0]
Step 3 = [1.0,1.0]
Step 4 = [0.0,1.0]
Step 5 = [-1.0,1.0]
Step 6 = [-1.0,0.0]
Step 7 = [-1.0,-1.0]
Step 8 = [0.0,-1.0]
Hope this is useful to someone !
Pete