Interrupt driven stepping

104 views
Skip to first unread message

Johannes Stratmann

unread,
Oct 10, 2021, 6:06:46 AM10/10/21
to accelstepper
Hello,
Some time ago, I had checked the AccelStepper Lib and have seen that it uses polling and checking delta time for next pulse.
I'm using Mbed and wanted to use lib, there is also an existing fork. But then I decided to do the calculation from scratch, using a hardware timer in one shot mode and set the new period time in each cycle. No cyclic interrupts or polling, so CPU load is zero when no movement.
But I made some mistake in acc/dec ramps. I calculated acc/dec time and divided it by number of steps for the ramp and then decreased period time linear. This is wrong because the period is not the speed and the ramps are not linear and take too much time.
So I try to understand the calculation that is AccelStepper based on.
Has someone tried this approch with Timer with variable period time too?

Thanks for reading

je...@siddall.name

unread,
Oct 25, 2021, 2:56:24 PM10/25/21
to accelstepper
I took a slightly different approach to interrupt driven stepping and wrote a couple of new functions that step immediately when called.  Then I simply set an interrupt timer with the delay given by 1000000/speed() and called runNow() in the ISR.

Reply all
Reply to author
Forward
0 new messages