I did some work on an improved and very fast stepper library for the Maxuino project for interfacing Firmata to Max/MSP/Jitter and thought I would see if it was useful enough to everyone. I also implemented the changes to the standard stepper Library because of the following improvements:
- The library can give commands to several (tested up to six so far) steppers at the same time because of the removal of delays. The arduino can also continue to handle other inputs and outputs because the stepper doesn’t get stuck in a “while” loop but instead updates each cpu cycle.
- The steppers can be given new commands at any time to override the current position for more “live control” or the stepper returns a flag when it has finished so the arduino can then send a new command to avoid override.
- I moved to microseconds because millis was slowing the motors down.
The StepperDriver Library is made for the EasyDriver and Pololu stepper motor drivers and other that use the STEP and DIR control method. It also has a small difference of having an “empty” initiator for easy creation of an array of instances which can be configured later on the fly. I did not implement this into the standard Stepper library but it might be worth considering.
I would appreciate all feedback and thoughts as I hope to at least get the Stepper added to the Arduino distribution as an upgrade and thought the StepperDriver might also be such a candidate.
Stepper.zip (4.14 KB)
StepperDriver.zip (3.67 KB)