Using AccelStepper on Electron vs. Photon, significant speed differences

Hey all,
I’ve been trying to troubleshoot an interesting issue regarding driving a stepper using the accelstepper library on the Photon vs Electron. I’m working on a device that should be able to use either dev board, and I’ve noticed some very significant speed differences where the Electron will drive a motor much, much more slowly compared to the Photon, using identical speed settings. The electron also seems to “max out” at a speed that is way too slow even if I manually increase the speed value.

This is a (very) simplified version of my code that I have flashed to both Photon and Electron, I am using the Pololu A4988 stepper driver:

AccelStepper myStepper(1, D0, D1); // “1” represents “DRIVER” mode

void loop(){

Not sure where this issue is coming from. Any help would be greatly appreciated! Also would be happy to provide more detail if necessary.


Due to the way how the cloud communication is done on an Electron the loop() frequency is about 100Hz vs. 1000Hz on Photons.
It’s not advisable to rely on the speed at which loop() is called.

However, you can try SYSTEM_THREAD(ENABLED) to decouple the cloud tasks from your application code and see what you get.

1 Like

Thanks ScruffR,
I gave that a quick shot and it looks like it fixed the motor speed issue. I’ll have to test the rest of the device today to make sure it’s not screwing up any of my network calls.

Really appreciate it! I likely would not have come to that conclusion in a long time, really good to know about the Electron.

1 Like