Regenerative Braking

I will reply here to your question in the Lishui/Ebics thread so we stop being off topic there :rofl:
This code is simple.

If the torque is in same direction as the motors movement, you are in motor mode, otherwise you are in generation mode.
If you exceed the battery current in motor mode or exceed the regen current in generation mode, you need to limit the current.

SimpleFOC can already control the Q axis current, it just needs to be able to limit the battery regen current.

I think in some use cases you might also want to limit the voltage, like when using field weakening, because the generated voltage will be higher than BEMF, and can be too high for the battery I guess.

1 Like