Future Request! SimpleFoc (Field Oriented Control) stepper strategy, not step/dir in time but movement in space and time

I’m not sure if you’ve seen the description at Code overview - Klipper documentation and in particular Code overview - Klipper documentation .

Briefly, moves are tracked in the “trapq” using mm, mm/s, and mm/s^2. The “iterative solver” then finds the appropriate clock time for every step. Finally, the “step compression” converts those step times into a series of quadratic equations (ie, queue_step commands containing interval, add, count). The mcu then produces the step pulses at the times in the given schedule. Be sure to read the documents above for the full description.

Using more advanced micro-controller control of the motor coils has been discussed several times in the past. (Both FOC and other approaches.) In particular, there has been interest in possibly using the desired carriage velocity and acceleration in determining the motor coil currents.

To summarize some previous discussions, there were two proposed approaches to doing the above - the first could be thought of as a “fixed frequency position/velocity/acceleration” system, and the second as “micro-controller derivatives of position change to obtain velocity/acceleration”. Roughly, the first involved changing the Klipper host to avoid the “iterative solver” and to provide the micro-controller with a list of position/velocity/acceleration tuples at a fixed frequency (eg, 5000 times a second). Roughly, the second would involve little change to the host and instead the micro-controller could inspect the existing queue_step commands to estimate the velocity/acceleration of the stepper (by observing the time difference between requested steps).

I don’t know of anyone who has done any notable work on the above. It was just discussions as far as I’m aware.

The mechaduino code I mentioned previously implements a bit of the second strategy - it takes the existing queue_step commands and determines the desired stepper position from them. A fixed frequency loop then alters the stepper motor coil current based on the desired position. The code was primitive however.

FYI, the latest Klipper code has support for SAME51 (and SAME54) chips, including canbus support.

Cheers,
-Kevin

1 Like