Dual control loops

Hi there,
I am using ESP32 and a BLDC gear motor with hall sensors with great success.
Now I want to use an external encoder (MA702) to close the position loop. I can’t use it as the main sensor because it is mounted on the external shaft, and after the gear. It means that the motor will revolve a few revolutions before the external encoder will move (or it will show movement, but it will be very small and will not compensate for the gear backlash)
I want to keep the halls as the main commutation sensor, but close the position loop on the MA702.
I think it is not possible today with SimpleFoc, am I right?

I think of implementing a second PID to do that.


Forgive me my ignorance but cant you; knowing gear ratio just apply formula to a getAngle?

I would add another control loop on top of what SimpleFOC does. You could run SimpleFOC in any mode, and use this new outer control loop to set the target value supplied to SimpleFOC’s move() function. You can use the PID classes of SimpleFOC if you want it to be another PID controller…