Description
Some MCUs are fast enough to run the FOC algorithms from the current sense interrupt.
This was already discussion here in the forum, but it was 3 years ago, maybe the opinions have changed.
This could have several benefits:
Constant dt:
FOC will run at constant dt, this will simplify PID and Filter math and help with performance as there is no need to measure the timestamp and calculate dt (this would be needed).
Better timing:
It makes sure FOC runs on recent phase current data, and duty cycles is applied within the same pwm cycle.
Overcurrent protection
This can be used for cycle by cycle software overcurrent protection.
Sensorless
It allows injection for HFI sensorless algorithm.
HFI also needs to identify V1 and V7, and run different code for each with low side current sensing.
Solution:
Allow the user to set up a callback function as parameter to the current sense class, that will be executed in the current sense interrupt. User should manage the callback to run loopfoc().
The code should not overrun, the interrupts should be disabled before and enabled after the callback.