[CountedPWM][Stepper][StepperPWM] Enhanced PWM module to implement a non-blocking Stepper driver
A CountedPWM
driver has been implemented to generate a predefined number of pulses without CPU intervention. It uses two hardware timers mutually linked. The first timer (let's call it "pulse timer") is the one that generates the square wave of the signal; the second timer (the "counter timer") is the one that counts how many pulses the "pulse timer" generated. So, for this method to work, the "pulse timer" has to be set as input clock of the "counter timer" (in this way the second timer counts the pulses of the first timer) while the "counter timer" has to be set as gated input for the "pulse timer" (in this way when the polarity of the "counter timer" changes, it disables the first timer, stopping the generation of the pulses).
The CountedPWM
driver is used to implement an enhancement of the Stepper
driver, called StepperPWM
. This driver has the advantage that can drive the stepper motor without keeping the CPU busy during the movements.
Another enhancement to the whole Stepper class is the support of both common-anode and common-cathode configurations.