MATLAB: Do I get unexpected results when I tune the PID controller block parameters while the simulation is running in Simulink 7.2 (R2008a)

simulink

The PID Controller block in the Simulink Library (Simulink Extras -> Additional Linear) has the integral and derivative gain blocks located before the integrator and derivative blocks respectively. This has two disadvantages when I am tuning the parameters while a simulation is running.
If I change the integral gain at any time instant, the integrator integrates from its state at the time instant the change is made. This produces unexpected behavior if I set the Integral gain to zero; the integrator continues to output the last value it had, which is then summed into the PID block’s output.
If I change the derivative gain, the derivative sees its input change discontinuously, which can cause the derivative block to generate a diagnostic message.

Best Answer

This is an expected behavior of the PID controller block in Simulink 7.2 (R2008a).
To work around this issue, create a new version of the PID block in addition to the existing one, where the gains follow the integrator and derivative blocks. Then the PID block would not produce unexpected results while being tuned.