This module defines the Stepper Motor interface. It is compatible with stepper motor drivers that use 2 pins to control the motor, like an Easy Driver from Brian Schmalz or the STR driver series from Applied Motion. It can also control an enable pin if one is available and connected.
The implementation is synchronous and thus blocking while the stepper motor is in motion. However it is possible to send the commands via threading and the performance of the library will be very good given a low CPU load. On a busy system though you will notice some jitter especially at higher speeds. It is possible to reduce this effect to some extent by using smoothing and/or microstepping on stepper drivers that support such features.
EasyDriver Sensor image provided by SparkFun* under CC BY 2.0.
while (doWork) {
cout << "1 Revolution forward and back at 60 rpm" << endl;
sensor.setSpeed(60);
sensor.stepForward(200);
upm_delay_us(1000000);
sensor.stepBackward(200);
upm_delay_us(1000000);
cout << "1 Revolution forward and back at 150 rpm" << endl;
sensor.setSpeed(150);
sensor.stepForward(200);
upm_delay_us(1000000);
sensor.stepBackward(200);
upm_delay_us(1000000);
cout << "1 Revolution forward and back at 300 rpm" << endl;
sensor.setSpeed(300);
sensor.stepForward(200);
upm_delay_us(1000000);
sensor.stepBackward(200);
upm_delay_us(1000000);
}