I am testing the 3 stepper motors using the Arduino IDE loaded w/ sangaboard.cpp. The gears wouldn’t spin with the “StepperF_alt.h” . The motors DO run when I replace the setSpeed() and step() commands to be from Arduino’s <Stepper.h>.
Advice appreciated. Thank you.
You need to have all three files from the repository in the Arduino IDE. This should automatically happen if you have the three files in a directory and open the sangaboard.ino
in the Arduino IDE.
Then load the sangaboard.ino
onto your nano and it uses the .cpp
and .h
to compile to the correct code.
Thank you @WilliamW. I apologize for not being clear (note: To set context, i’ve been using the Arduino IDE for many years off-n-on so I am familiar with needing all the files, etc.).
When the sangaboard code wouldn’t move the motors, I wrote a test that used Arduino’s <Stepper.h> and was able to move the three motors. The motors do not move with Stepper_Alt.h which seems to be a modification of Stepper.h. Is it possible to use <Stepper.h>?
1 Like
Hmm. It should just work then, although I have not loaded a new one for a while. I believe that you do need the modified stepper library to use the Openflexure server.
Well…I put the champagne away after finishing the build…and find myself bumbling about the details of 28BYJ motors…which of course are as fascinating as any microbe might be…
I’ll look for unit tests and the like.
Wonder also if the torque required to move the small gear/big gear is more than what this tiny motor can handle? How to you make sure the actuator step ensures the gears will turn with the low low power of the 28BYJ motor? (Thank you and apologize for being clueless).
1 Like
They move quite slowly and appear to be strong enough. In practice no-one has raised an issue that the motors are missing steps, so there is no automated testing.
Tests for making the motion faster by gearing at 1:1 and 1:1.25 instead of the standard 2:1 are on GitLab, linked from Faster motion, different gearing - OpenFlexure Forum. That was done by tracking the image and checking that it moved as expected. There were no problems even with the required torque being more than twice as high as standard.
Thank you @WilliamW . re: Torque high enough. That is good to know. My challenge is when I was screwing down the large screw of the actuator, I noticed at points the screw grabs the large ring, requiring more torque on my part to rotate. I ended up trying to keep this screw very loose. This did allow the motors to turn the gears when I used <Steppers.h>.
Back to Sangaboard. The stepper motor vibrates…and I note the LEDs that light up on the IN pins are different than how they light up with the Sangaboard driver…which leads me to ask,
__Q: The 28BYJ has 2038 steps per resolution Yet, Sangaboard initiates motor instances:
#if defined(SANGABOARDv2)
motors[0] = new Stepper(8, 13, 12, 11, 10);
motors[1] = new Stepper(8, 9, 8, 7, 6);
motors[2] = new Stepper(8, 5, 4, 3, 2);
Telling the Stepper class there are only 8 steps per revolution (If I’ve got that right?).
Why is that? Thank you
Hi @happyday you are indeed delving deep into the 28byj-48! 8 is the number of half-steps per cycle, i.e. there are 8 different combinations of which pins are switched high/low. That’s different from the number of steps per revolution, but actually I don’t think that number appears anywhere, because we always just work in half-steps.
Half-steps means that instead of energising each coil in turn, we use a sequence, as recommended by the spec of at least some of the motors we’ve bought:
1 0 0 0
1 1 0 0
0 1 0 0
0 1 1 0
0 0 1 0
0 0 1 1
0 0 0 1
1 0 0 1
1 0 0 0
...
The motor moves by half a step between the lines with two pins energised and the lines with one pin energised, hence the name.
This is different from the sequence used by the unmodified Stepper.cpp
, which I think is designed for bipolar motors.
I notice that unipolar motors are now mentioned in the Stepper documentation, which I’m not sure they were when Fergus modified the file back in 2016! However, I can’t see (either from the docs or from the source) how Stepper.cpp would produce the right sequence of steps.
In order to understand what you’re doing, can you just confirm that you’re definitely using unmodified (i.e. 5 wire, unipolar, with a common centre tap) 28BYJ-48 motors, with ULN2003A Darlington pair driver boards? It may be that you have fancier driver boards that are designed for different input?
If the motors vibrate but don’t spin, it usually indicates that the wires are not connected in the order we were expecting - some trial and error there might fix it, though of course that’s never totally satisfying. I’ve definitely heard of motors being supplied with strange wiring…
The 2038 steps are after the mechanical gearing, when working at full steps. There are 4 steps per coil cycle normally, 8 as @r.w.bowman says with half-stepping, but there is also more than one coil cycle per revolution. This gives 32 or 64 steps/half steps per revolution of the actual motor. Then there is a mechanical gear reduction of a factor of nearly 64, so the output shaft has ~2000 or ~4000 steps/halfsteps per turn.