I made a first experiment to have DMA generate a configurable waveform.
https://github.com/PaulStoffregen/StepperPulse/blob/master/k66_dma_stepper.ino...
I think there is an opportunity for DMA to solve the following problem :
Stepper-motor-drivers have a STEP signal which is pulsed for each step, and a DIR (Direction) signal which controls the clock/counterclock direction of stepping.
Now all stepper-drivers require that a DIR signal is stable some 'setup' time before the stepper pulse, and remains stable some 'hold' time after the step pulse.
Further, they also have minimum timings for the step pulse signal.
See for example this page with an inventory of common used stepper/servo motor drivers and the timings they expect.
So per step , you actually need 3 events :
* setup DIRection - wait setup time
* set STEP pulse (high or active low, depending on driver) - wait max(step pulse time, DIR hold time)
* end STEP pulse
Example of these timings for the A3967-Driver :
We could pre-calculate the bit patterns needed on the output pins for these 3 events, in the step timer interrupt.
Then DMA could take care of outputting them with the right timing, with no further interrupts needed.
The alternative is an extra timer-interrupt, firing 3 times per step.
EDIT : Don't spend too much time on this - I've found a simple and elegant solution using the fact that we're 'oversampling' the timer-interrupts anyway. As soon as we've detected we need to make step, DIR is set (taking care of the setup timing constraint), then the next interrupt STEP is set, then the next one STEP will be cleared automatically because of the way we calculate it.
Attachments
Last edited: