Alexwijn / SAT

The Smart Autotune Thermostat (SAT) is a custom component for Home Assistant that works with an OpenTherm Gateway (OTGW).
GNU General Public License v3.0
43 stars 8 forks source link

Change tuning using configuration interface #12

Closed gmeik closed 7 months ago

gmeik commented 8 months ago

The default tuning is too aggressive for my underfloor heating system. The gain is so high that the floor heating system saturates (thermostatic valve closes) on a setpoint change of +0.5 °C. This is not necessary or useful because the overall response of the heating system is very slow. It would be a nice enhancement if it was possible to set the tuning to manual values from the configuration interface or using a service (without the need to re-create the SAT to enter different tuning values). I should have some idea what I am doing, being an advanced process control engineer. ;) Similarly for the minimum setpoint. It was estimated a bit too low, and the only way I could change this was by re-creating the thermostat. But maybe I missed something...

Could you also explain the control algorithm in more detail in the documentation? I mean the structure of the PID controller, what are its inputs and outputs and how the 'Heating curve coefficient' works.

And I would be happy to help in some way, e.g. by providing data/user experience/control experience.

sergeantd83 commented 8 months ago

Hi @gmeik thanks for trying SAT! SAT CONTROL algorithm is a transfer function. We use a Laplace transform to calculate the heat losses of the home, as input values we use the outside temperature and the room setpoint. Then we use a series PID algorithm with input values room temperature and room setpoint in order to calculate the error. We use the integral part and the derivative adhoc. That means we enable the integral part only in deadband to anticipate the heating curve value ( Laplace transform ) and the derivative part is used only outside the deadband. Moreover we calculated the fixed Ti and Td values based on the transfer function of the in series PID controller. One question: Did you set your heating system during initial configuration as underfloor?

Edit:

Heating curve graph representation: Underfloor graph Radiators graph

Parameters: a Heating Curve Coefficient b Room Setpoint

gmeik commented 8 months ago

One question: Did you set your heating system during initial configuration as underfloor?

Yes, it is set it to underfloor. Let me tell the detailed story. I want to use less heating power at night and more power at day, because this increases the level of comfort (floor temperature at day). Otherwise the floor is only barely warm. And I have no plans to increase heat loss to increase floor temperature. :) So I'm changing the setpoint up and down by 0.5 °C. My previous (DIY) PI controller directly PWM'ed the boiler, so it was basically a power / fired duty controller. The boiler is limited to its lowest fired duty setting, 6 kW, which is still excessive, because the house needs at most ~4 kW. The overall heat transfer coefficient of the house was estimated from historical data, so I added a feedforward from ambient temperature to the output with a gain of -3%/°C. The standard/mixed PI controller had a fixed gain of 8% per °C and integral time of 28800 seconds. This controller heated up the floor slowly in the morning, but it did not saturate of the floor heating system and temperature control was pretty stable, about 0.5 °C deviation from setpoint does not lead to discomfort combined with floor heating. It also didn´t stop the heating completely on a sunny day, preventing cold floor.

And thanks a lot for the explanation! I understand what you write, including the heating curve. What I don´t understand yet is

  1. How does the output of the PID controller connect to the heating curve? Are they added together?
  2. What is the reasoning behind the variable tuning calculation of the PID controller? I see in the Python code the kp/ki/kd are calculated from a coefficient, but what does it mean? The end result seems a too high gain, so the floor heating system saturates for only +0.5 °C setpoint change...
sergeantd83 commented 8 months ago
  1. How does the output of the PID controller connect to the heating curve? Are they added together?

The Contor Setpoint formula ( transfer function ) actually is: CS = HCV * ( 1 + PID OUTPUT ) HCV = Heating curve value ( Laplace transform ) ( 1 + PID OUTPUT ) = In series PID controller with K=1 )

As a result the PID controller acts as a factor in the formula.

What is the reasoning behind the variable tuning calculation of the PID controller?

When you have higher outside temperature the calculated CS is lower and vice versa because everything is related to OT.

The end result seems a too high gain, so the floor heating system saturates for only +0.5 °C setpoint change...

Can you explain further please?

Edit:

The code is written in such way that if you choose the manual gains tuning, it can easily convert to CS = HCV + Proportional + Integral + Derivative.

sergeantd83 commented 8 months ago

Can you please provide some informations?

  1. kP of your previous ( DIY ) controller?
  2. Your current heating curve coefficient you use?
  3. Your Overshoot protection value ( it is stored as an attribute in the SAT thermostat ), have you ever calculated the min output of your boiler at 0%? If yes is it the same as the calculated overshoot protection from SAT?
gmeik commented 8 months ago

The kP of the previous controller was 8% per °C. That is: 8% power output. The coefficient is set to 1.0. The overshoot protection value is 37 °C. That is where the system settles at 0% output (6 kW fired duty).

sergeantd83 commented 8 months ago

The proportional gain for automatic gains is kP = 1.65 * HCV. Can you modify the value 1.65 and inform us which one is the best for your system?

gmeik commented 7 months ago

I made an extreme change to the proportional gain calculation: kP = 0.10 * HCV (since 14 November). At the same time, I adjusted the heating curve coefficient to 1.8, this gives a good match between supply temperature and outside temperature. Thermostat As you can see, the temperature matches the setpoint quite well for an outside temperature range of 4 - 14 °C. The result is also comfortable to the users (we are used to 18 °C). EDIT: the setpoint changes between day and night are mostly intended to get a warmer floor at day, as mentioned before.

The response of the system itself is very slow. That is the nature of heating loops embedded in concrete. If I change the setpoint to 20 °C, I guess it would take a day to get there.

Maybe kP = 0.10 * HCV cannot be applied universally to floor heating systems. But I am convinced kP = 1.65 * HCV is excessive for low temperature floor heating systems. Imagine HCV = 30, then kP = 1.65 * 30 = 49.5 and a 0.5 °C error would result in a control output of 30 + 25 = 55 °C (ignoring derivative / integral parts). That is higher than any reasonable outside temperature would require, and completely saturates the system for a time...

Why does kP depend on HCV, and not on the heating curve coefficient? Controller tuning should be system-dependent, not temperature-dependent... Can we discuss this?

Suggestion: kP = x * Coefficient where x is an 'aggressiveness' factor, which could be user-changed between 1 (very gentle, usable for slow floor heating sytems) and 20 (aggressive, more usable for fast radiator systems) or so. The kD needs to be adjusted as well, I need to look into that.

We can solve this using manual tuning of course. But it is called a smart auto-tune thermostat, so let's make it work for floor heating as well!

sergeantd83 commented 7 months ago

@gmeik thanks for the recommendations. We already added in the the latest commit the “aggressiveness factor”. If you want you can test it.

Alexwijn commented 7 months ago

Did this resolve the issue?

gmeik commented 7 months ago

I'm still trying it out, but it seems to solve the issue indeed. As a starting point I use an aggressiveness factor of 1.