Hi, I'm having some trouble with the braking force on sensorless BLDC mode on my VESC, and FOC gives stuttering acceleration but great braking, so I was thinking it could be possible to combine the codes for FOC braking in mcpwm_foc.c into the overall BLDC codes, replacing the codes for braking in mcpwm.c

The catch would be that to setup the VESC it would be necessary to run the BLDC detection, then run FOC detection and apply settings.

Would anybody have any advice before I attempt this (possibly stupid) endeavor?

FOC working well in braking is because when you simply select FOC mode, the FOC code already knows where the rotor is. If you switch, it will have to start learning. I think a switch between the modes would cause a significant (0.5 to 2 second) gap in the ability to drive the motor.

So live switching between the two modes is more complicated than you'd think at first.