sq7bti / iAccelStepper

interrupt driven stepper controller inherited from AccelStepper
GNU General Public License v2.0
14 stars 6 forks source link

Further help porting this to other boards #5

Open ee-boi opened 1 year ago

ee-boi commented 1 year ago

Hi - I stumbled across this library while trying to find a solution to move the Accelstepper run() method out of the main polling loop. I believe your adaptation of the Accelstepper library is the exact solution for this, and one many people would benefit from if it could be adapted to other boards (arduino, ARM cortex M).

I saw the other comment on adapting this for arduino, and while I vaguely understand the concept, I do not currently have the technical ability/knowledge to port this to another board.

If possible, can you help with further support for this effort? I am happy to learn more and attempt per your suggestions/advice as I imagine you are busy.

I really think this library could be very, very useful to many other folks with other popular boards like arduino, & ARM. I particularly am interested in adapting this code base to the SAMD21 or SAMD51 ARM cortex M series. Any and all help is appreciated. Thank you and great work here, would love to connect further on this topic if possible.

sq7bti commented 1 year ago

The actual code was very simply adopted from the AccelStepper code, by substituting the code that needs to be run in loop() by an ISR routine, namely by the timer handler. If you have another MCU where the timer ISR can be reprogrammed to do a custom task, it should be straight forward to do the same. Check which timers are still free to use (most of the Arduino ports for other MCU's makes use of the timer for time keeping, etc.) and make use of it. Depending on the resolution and size of these timers, the main routine (the one that recalculates how long should it wait for another step) needs certain adaptation, but that should be fairly easy, once you know the time-base of the timer and expected acceleration speeds, maximum rotation speed etc. I see there are even some code examples how to make use of the timer interrupts on github: https://www.arduino.cc/reference/en/libraries/samd_timerinterrupt/ https://github.com/khoih-prog/SAMD_TimerInterrupt/blob/main/examples/ISR_16_Timers_Array/ISR_16_Timers_Array.ino