MCU_FOC class, for SimpleFOC integration

Hi,

While developing a true Field-oriented-control stepper driver using SimpleFOC, I have more or less reached the point where it makes sense to look at Klipper integration.

This thread is a continuation from this

SFOC mainly revolve around floating numbers e.g. angles in rad and velocity in rad/s.

Do you see the potential for a Klipper MCU_FOC class complimenting the existing MCU_Stepper class ?

For performance reasons, it would be great to offload the MCU from steps to angles conversion. Another possibility is to not use floats but go all binary. This will break the SimpleFOC link though…

Thinking about this. I think the fastest way to showcasing Klipper and SimpleFOC compatibility will be to use and think of the step format as a variable rad’s resolution, which can be set according to the encoder (closed loop). So instead of the MCU sending step pulses to a proprietary stepper driver, we will send move commands to the motor instance. This of course involved some conversion, and I have no idea how it will perform.

Example:

Using the MT6835 angle sensor in ABZ mode (Quad-Encoder) has a resolution of 16bit (65536) per revolution. Using the step format, we will then have to make Klipper believe, that there is 65536 steps per revolution or if e.g. using a 8mm per rotation screw, 8192 steps per millimeter. In this case the steps is just a format.

Hmm… maybe we could then just move the conversion to the mainframe, on top of existing Klipper implementation?