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.

Thanks

Hey.
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…

Hi,

I am working on a similar project using ESP32 + BLDC motor + two sensors (incremental hall sensors for motor velocity control + absolute magnetic sensor for external shaft angle position). Has anyone developed a dual loop control system using SimpleFOC? For example, I would like to execute a move() using angle+velocity control. Any example code I can use? Thanks.

Best,
Charlie

BLDCMotor::move, line 372,

      shaft_velocity_sp = P_angle( shaft_angle_sp - shaft_angle );

I think all you need to do is replace that use of shaft_angle with the encoder reading (in radians) multiplied by the gear ratio.