Electronic – What happens if PID loop is too fast

pid controller

I have a PID loop running at 100Hz and is working reasonably well, for now. However, if I double the speed to 200Hz it no longer works, which isn't much of a surprise. The question is, what changes should be made to the PID values to get it to work at 200Hz? Is it a linear change in values? Can it be calculated? What is the relationship between stability and loop speed?

Best Answer

When you execute a PID with higher sampling rate you can encounter two things:

  • The integrator may not work properly if the new delta is very tiny. This is due to the final resolution of floating point number. Using a double precision float numbers significantly improves this problem until certain point (sampling frequency).

  • The differentiator increases its output due to the input noise (also quantization noise). The output follows \$\dfrac{d\varepsilon}{dt}\$ so shorter sample time (higher freq.) means higher output for the same step change (quantization). A way to solve this phenomena is to use 1st order low pass filter on the D-part. However large filter times would also make the D-part unresponsive at high dynamics - right the opposite for what the D-Part is used for. Another countermeasure is to use a dead band on D-part input - a small change in the input signal is therefore neglected ( a good way to eliminate quantization noise)

Let we define a PID function as: $$y=K_p \cdot(\varepsilon+\dfrac{1}{T_i}\int\varepsilon dt+ T_d \dfrac{d\varepsilon}{dt})$$

Then discrete form: $$y=K_p\cdot(\varepsilon + \dfrac{\Delta T}{T_i}\Sigma\varepsilon + T_d\dfrac{\Delta\varepsilon}{\Delta T} )$$

Often is written also in this form: $$y=k_p\varepsilon + k_i\Sigma\varepsilon + k_d\Delta\varepsilon$$

If your PID routine uses last form, you should re-calcuate ki,kd at every change of kp or sample time.

Related Topic