What is the actual roll of dt in PID loop and how to set dt value in PID loop.
I read about dt, it say dt is loop time means which loop..executation of loop time (20ms) or call PID loop in interrupt part (5s).
We use PIC24f controller and in that every 5s interrut generate using timer and call PID loop in interrup part which is 20ms executation time so, what is dt and how to relate with code and how to set value of dt.
1 Answers
The dt
is the delta-time term of the system, and looks like 5s in your system. It is the period of time over which the system measurements are sampled, integrated over, differentiated against, and it sets the frequency of adjustment.
Your dt
should be compatible with the rates of change and adjustment in the system under control. For example, a heater might use 5s-60s times, since the temperature change in 20ms might be indetectable, and it might be nonsensical to adjust the input power each 20ms, while a self-balancing robot might need much more rapid measurement and adjustment.
One guideline for dt
I've seen is that the sampling time should be 5-10 times faster than the process time constant, which gives you enough samples of the process to detect the changes. If you sample more frequently, you might be getting into the range where the size of the changes per unit time are near the limits of accuracy for the sensor. If you sample less frequently, then the system would change faster than the control system could notice.
The size of dt
also helps in understanding the meaning of the integral term kI
and the derivative term kD
as a conversion of of the type of error to the units of output. For example, if error is measured in degrees, and the sampling time is 5 seconds, and the output is in kilowatts, then the temperature change calculated by the PID loop has units of degrees/5s
and the kD
is a conversion of kilowatts/(degrees/5sec). Similarly the units of the integral accumulator are degrees*5s
and the kI
term is a conversion kilowatts/(degree*5*sec)
If you double the sampling frequency(halve the sampling time), you need to adjust kI
and kD
accordingly.

- 4,831
- 4
- 31
- 42