laurb9 / StepperDriver

Arduino library for A4988, DRV8825, DRV8834, DRV8880 and generic two-pin (DIR/STEP) stepper motor drivers
MIT License
556 stars 228 forks source link

Error in #define #86

Closed trlafleur closed 4 years ago

trlafleur commented 4 years ago

The order of parameters is wrong between the #define and the use of the macro, so the macro expansion is wrong.

In BasicStepperDriver.h you have..

/*
 * calculate the step pulse in microseconds for a given rpm value.
 * 60[s/min] * 1000000[us/s] / microsteps / steps / rpm
 */
#define STEP_PULSE(steps, microsteps, rpm) (60.0*1000000L/steps/microsteps/rpm)

But in BasicStepperDriver.cpp you use it as:


163         step_pulse = cruise_step_pulse = STEP_PULSE(rpm, motor_steps, microsteps);
238         t = steps * STEP_PULSE(rpm, motor_steps, microsteps);