Skip to content
Snippets Groups Projects

[CountedPWM][Stepper][StepperPWM] Enhanced PWM module to implement a non-blocking Stepper driver

Merged Emilio Corigliano requested to merge stepper-driver-update into main
  1. Jun 14, 2023
    • Emilio Corigliano's avatar
      [CountedPWM][Stepper][StepperPWM] Created `StepperPWM` and `CountedPWM`... · 3fdae051
      Emilio Corigliano authored
      [CountedPWM][Stepper][StepperPWM] Created `StepperPWM` and `CountedPWM` classes and enhanced `Stepper` class.
      
      - 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.
      
      Co-authored-by: default avatarAlberto Nidasio <alberto.nidasio@skywarder.eu>
      Co-authored-by: default avatarRiccardo Musso <riccardo.musso@skywarder.eu>
      3fdae051
Loading