# Adapting PID controller parameters using expert rules

I use the following equation to calculate a control signal of a time-discrete PID controller:

$$u(k) = u(k-1) + K_{R} \cdot \left(1+ \frac{T_{0}}{2 \cdot T_{I} }+ \frac{T_{D}}{T_{0}}\right) \cdot e(k) -K_{R} \cdot \left(1 -\frac{T_{0}}{2 \cdot T_{I} } +\frac{2 \cdot T_{D}}{ T_{0}} \right) \cdot e(k-1) + K_{R} \cdot \frac{T_{D}}{T_{0}} \cdot e(k-2)$$ where

• $$u(k)$$ is the control variable
• $$u(k-1)$$ is the previous control variable
• $$K_{R}$$ is the gain factor
• $$T_{0}$$ is the sampling time
• $$T_{I}$$ is the integral time
• $$T_{D}$$ is the derivative time
• $$e(k)$$ is the error

Now I want to add a parameter adaption functionality to this, since there are slow physical changes happening in the system (dirt is depositing around the valve of a water-bearing heating system). My research so far, has revealed, that the most common approach to adaptive PID controllers is via. system identification, as shown below: From: "Runtime Evolution of Highly Dynamic Software" (2014)

A typical approach to PID tuning is rule based, e.g., something like Ziegler Nicols. However, this approach (and the other rule based ones) I follow a clear recipe:

• Set integral and derivative gain to 0
• Increase P until xxx ....
• Optimize integral gain
• Optimize derivative gain

Since in adaptive controllers, there is already a tuned controller who's parameters just have to be adapted, these methods cannot be applied, with the exception of the final step itself, for example:

• If oscillation is to high --> increase $$T_{d}$$ (view below) • If controller is instable --> decrease $$T_{d}$$ (view below) My question now is, is there a system of rules that I can apply for the adaptive control of my controller? Particularly great would be one that can translate to the formula I gave at the start ... Advice on good Python implementations would also be of great value to me.

Edit:

The pid controller controls a 3-way valve that mixes hot supply water into the circulation of a water-bearing radiator. A schematic I found on the internet is shown below. The values in my case: supply temperature (where it says 180°F) would be 40-70°C, inflow (where it says 110°F) would be around 20-40°C, outflow (where it says 90°F) would be around 5-10°C lower than the inflow. The valve itself is operated between 0% and 100% Below I've included an actual 6 hour snapshot of the processes (current control, not implemented by me). The purple timeseries is the setpoint, yellow is the inflow temperature (the controlled temperature). The Y axis shows "temperature": • Can you add the model for your process and write down a typical reference signal you want to follow? This will give uss more insight in what the possibilities are to identificatie your system parameters. Jul 7 '20 at 16:20
• @useless-machine sure, i made an edit Jul 8 '20 at 9:26
• thank you, but I wanted to have more information about the reference signal, the set-point, desired-value. Is it a constant or are you tracking a certain wave form. Do you expect perturbations. Can we perturb the reference signal to measure a system response. With this information we can search for an applicable system identification method. Jul 8 '20 at 18:36
• Ive included a snapshot of the data so you can get a feel for the system. As you can see there are perturbations. Sadly, we cannot perturb the reference signal to measure a response, since there is a lot of "natural" disturbance, the signal would have to be very strong, causing discomfort for the user ... Jul 9 '20 at 8:52

My question now is, is there a system of rules that I can apply for the adaptive control of my controller?

As far as I know there are no such rules. Creating an adaptive controller without checking the convergence and robustness can have an unwanted effect on the performance. This requires knowledge about the system dynamics and more advanced tools than just using trail-and-error or rules of thumb, such as the Ziegler and Nichols method.

I discovered follow a clear recipe:

• Set integral and derivative gain to 0
• Increase P until xxx ....
• Optimize integral gain
• Optimize derivative gain

This method you describe above is called trail-and-error. With the Ziegler and Nichols method you determine the system properties. Based on that, you can determine the gains of the desired controller.

This brings me to a simple solution that you could use. Determine the required system properties for the Ziegler and Nichols method during the day and than update them occasionally. It is important that this update is much lower frequent than all the system dynamics so that you can assume that is the same as restarting the system.