Moved from arduino/Arduino#3300 by @cxrodgers
I was having an intermittent issue where my arduino would occasionally lock up while stepping a stepper. It turned out that it was because I had neglected to call setSpeed explicitly. I had thought that it defaulted to some reasonable value, but upon examining the code, I see that it does not, meaning that step_delay will be whatever random value resides in that memory location.
https://github.com/arduino/Arduino/blob/master/libraries/Stepper/src/Stepper.cpp
Here was my forum posting on this topic.
http://forum.arduino.cc/index.php?topic=327132.0
I believe that the memory is typically set to zero, but when using dynamic memory allocation (for instance: stepper = new Stepper(...), there is no guarantee that this memory location will start at zero. Regardless, it seems dangerous to rely on the memory containing any particular value without being initialized.
I think step_delay should be initialized to zero in the constructor. Alternatively, I think it should be documented that a call to setSpeed is required before calling step.
Moved from arduino/Arduino#3300 by @cxrodgers
I was having an intermittent issue where my arduino would occasionally lock up while stepping a stepper. It turned out that it was because I had neglected to call setSpeed explicitly. I had thought that it defaulted to some reasonable value, but upon examining the code, I see that it does not, meaning that step_delay will be whatever random value resides in that memory location.
https://github.com/arduino/Arduino/blob/master/libraries/Stepper/src/Stepper.cpp
Here was my forum posting on this topic.
http://forum.arduino.cc/index.php?topic=327132.0
I believe that the memory is typically set to zero, but when using dynamic memory allocation (for instance:
stepper = new Stepper(...), there is no guarantee that this memory location will start at zero. Regardless, it seems dangerous to rely on the memory containing any particular value without being initialized.I think step_delay should be initialized to zero in the constructor. Alternatively, I think it should be documented that a call to
setSpeedis required before callingstep.