Arduino-FOC
Arduino-FOC copied to clipboard
Set phase state (stm32)
I need this functionality for backemf sensing, since it's a nice isolated change I'm putting it up for review now.
Tested on the B-G431B, this is the only board I have. I'm not sure if this has the desired effect on boards with software 6pwm.
I'm not very happy with the API design, it relies on the user calling _setPWM shortly after _setPhaseState. Maybe remove BLDCDriver::setPhaseState(sa, sb, sc) and modify the signature of setPwm(Ua, Ub, Uc) to include the phase state, for example setPwm(float Ua, float Ub, float Uc, int stateA, int stateB, int stateC). 9 times out of 10 you'll want to atomically change the pwm and phase state anyway. Maybe I'm overthinking things.
For testing, use Trapezoid_120. I believe Trapezoid_150 is broken but that's out of scope for this pull request.