cancel
Showing results for 
Search instead for 
Did you mean: 

What is the best way to replace the position PID controller with a custom controller?

Edward1
Associate

My company is looking to modernize our positioner electronics and have been prototyping with a NUCLEO-G431RB and an IHM07M1 in 3-shunt mode.

While the nested velocity + position PID strategy might work for our positioner given enough tuning, we have already developed a functionally equivalent position controller with well-tested performance for our existing positioner + electronics and would like to use it instead of the provided position PID.

I ported our controller over, instantiated it, added a pointer to it to PosCtrl_Handle_t, and am calling its update function instead of PID_Controller() to generate torque commands in TC_PositionRegulation(). I'm also bypassing most of the trajectory controller functionality since we don't really want/need it.

This works fine, but the issues are:

  1. TC_PositionRegulation() isn't declared weak, so it can't be overridden with our own implementation in a different file
  2. Inserting our own position controller requires modifying some core functions and data structures; these changes are overwritten any time the code is generated again from CubeMX

Is there a better/recommended way to do this?

1 REPLY 1
AErma.2
Associate II

Hi Edward. weak prefix point to Compiler that other fuction implementation with out WEAK must be compiled and linked to firmware, so juct make oun inplimentation of Pos controller.