I’ve got a stepper motor rigged up and it’s all working fine, however, all the libraries I’ve found are blocking. I’m looking for a non-blocking library as I want to use the motor in conjunction with sensors and the cloud (my use case is simple - turn the stepper motor at a defined speed until a cloud function or sensor is triggered and then stop or reverse the motor. I guess it should also accelerate / deaccelerate if that’s necessary).
I came across the stepper library installed in the particle cloud IDE simply named ‘Stepper’, and looking through the code it appears to be non-blocking. I clicked ‘verify’ and the code compiles fine. However, when deploying to the photon it immediately crashes with a red flash SOS signal. 5 red flashes is apparently a ‘usage fault’.
Has anyone else had any problems using this library out of the box? If not, how do I go about finding the fault?
Thanks guys! Out of interest how did you spot the issue? Is there a debugging tool you can use or was it a case of going through the code line by line till you find the problem?
Kenneth, pulled the latest version but it’s failing to compile… it’s looking for a non-existant application.h in Stepper.cpp on line 48
Recreated the app again and it compiled this time - very odd!
Unfortunately the version of the library available via Particle Build is still 0.0.2 and doesn’t have ScruffR’s fix in it. Do you have to re-publish the library or does it just take time to update?
Yep that did the trick, though I ran into the application issue again:
stepper-demo.cpp:2:29: fatal error: Stepper/Stepper.h: No such file or directory #include "application.h"
^
compilation terminated.
make[1]: *** [../build/target/user/platform-6stepper-demo.o] Error 1
make: *** [user] Error 2
Had to relaunch the IDE and recreate the app to fix the issue.
For now I've set speed=100 as I don't have a pot to hand. The stepper motor turns successfully, but the program crashes after half a revolution (no SOS flashes). What's the best way of approaching debugging an issue like that? Sorry for all the questions.. new to this style of coding and development!
I’ve tried a few things in the past days but now I’m even more confused. Without the stepper motor plugged in it the board runs fine. When I plug the stepper in the board restarts after a certain amount of time.
I’ve been using a breadboard voltage regulator power supply that allows up to 700mA. I wondered if it was exceeding the current and stopping a consistent flow of electricity getting to the photon, hence the restart. I purchased a 2A 5V power supply and connected that to the photon and stepper motor driver board. Within half a revolution it blew the power supply!
From what I’ve read online the stepper motor only draws around 92mA - don’t understand why the power supply blew
I’m using a 28BYJ-48 with ULN2003 driver board. They were connected to the same 5V 2A power supply when it blew. I’ve now tried powering the Photon via USB and everything works perfectly. I think the limit on a USB port is 500mA, so can’t see how it could have exceeded 2A.
It does seem odd, to actually blow a 2A supply this way. I wouldn’t think this should happen (again)
But the thing with 5V DC power supplies is that the rating does not tell you anything about the quality of the DC.
You might need an extra filtering stage to get pulsing 5V DC into “good quality DC”.
This should still not harm the supply, but might upset your circuit.
Cheers for confirming. I’ll try and order another power supply (it was quite cheap… only about £4) and see if it does the same. If it does I’ll take a look into the filtering and take it from there
I have tried this setup and it seems that you need 5v logic to control the ULN2003. I had to use a logic level converter to turn the photon’s 3.3v into 5v in order to satisfactorily drive this motor. I would love to figure out a way to do away with this complex setup and use the 3.3v logic directly in the stepper driver.