Design of a Comfortable Home HVAC Thermostat

Part 2

M. Haidekker, July 2014


Continued from part 1.


Let us call the master cycle period $T$. I suggested $T=30$min before, and this turns out to be a practically useful value. I'll make an assumption: There exists a time duration $T_0 < T$ during which the HVAC needs to run to maintain the temperature. For example, running the furnace for $T_0=8$min every $T=30$min could maintain the temperature under certain conditions. In PWM terms, this would correspond to a 27% duty cycle. Clearly, those "certain conditions" are crucial as the duty cycle depends on the outside temperature. This is where closed-loop feedback control and the sensing of the room temperature becomes relevant.

P-CONTROL

What happens if we heat for the duration $T_0$ and the room is still too cold? Obviously, we need to keep the furnace on for a longer period of time. We could, for example, take a measurement immediately before starting the cycle and define the control deviation $\epsilon$ as $$ \epsilon = T_{SET} - T_{ROOM} $$ When the room is too cold, we get a positive value for $\epsilon$, and the value is larger if the difference between desired and measured temperature (i.e., the control deviation) is larger. This means that $\epsilon$ is a good indicator how much time we need to "tack on" to $T_0$ to get closer to the setpoint temperature. In fact, I propose to calculate the on-time as $$ T_{on} = T_0 + k_p \cdot \epsilon $$ where $k_p$ is the adjustable gain of the controller. A schematic sketch of the cycle is shown in Figure 1. Note that

Figure 1: Diagram of an on-off cycle of duration $T$. At the start of each cycle, the furnace or compressor is turned on and stays on for a duration of $T_0 + k_p \cdot \epsilon$. The red zones are cutoff zones where a cycle is either skipped or continued into the next to reduce startup stress.

How do we choose $k_p$? First, it is advantageous to re-interpret the on-time $T_{on}$ as a fraction of $T$: $$ T_{on} = T \cdot \left( P_0 + k_p \cdot \epsilon \right) $$ Here, $P_0 = T_0 / T$ is the base on-time as a fraction of the cycle time $T$, and $k_p$ is also seen as a fraction of $T$, meaning, $k_p$ has units of inverse degrees C under this definition. A good value of $k_p$ needs to be determined experimentally. I started with adding approximately 15% of the cycle duration $T$ per degree of control deviation. This value turned out to be too low, whereby the temperature takes a long time to equilibrate. Choosing a very high value of $k_p$ leads to undesirable behavior as the thermostat fluctuates between staying on too long and skipping a cycle. In the end, I settled on values between $k_p=0.2$ and $k_p=0.25$.

It is interesting to observe that the air conditioning requires much larger values of $k_p$. To get acceptable cooling behavior, I settled on $k_p=0.4$. The cause is the lower "gain" of the cooling unit: the furnace can raise the temperature almost twice as fast as the compressor can reduce the temperature by the same amount.

One special consideration is necessary. If the on-time $T_{on}$ is very close to zero or very close to $T$, it does not make sense to turn on the furnace or A/C unit for a few seconds (or turn them off for a few seconds between cycles). For the compressor, start-up stress is a major consideration. The furnace, on the other hand, follows a lengthy sequence of functions: first, it purges the air for 90 seconds to remove any potential leaked gas. Only then the flame is ignited. Both heating and cooling functions keep the main blower running for about a minute to clear the air ducts. It is reasonable to create a cutoff: If $T_{on} < T_{min}$, a cycle is skipped entirely. Conversely, if $T_{on} > T - T_{min}$, the HVAC is kept on through the next cycle, but a measurement is taken at the start of the cycle. These cutoff limits are shown in red in Figure 1. In practice, I chose $T_{min}=180$s as this is the shortest time that allows some noticeable heating action.

PI-CONTROL

Now we can consider integral control. The integral component of the controller computes the time integral of the control deviation in such a fashion that trends in the control deviation (e.g. room always remains a bit too cold) build up to an additional corrective action. The integral component is a slow correction of any residual error.

In the discrete world, the integral turns into a sum, that is, $$ \int_{t_0}^{t_1} f(t) \textrm{d}t \approx \sum_k f_k \cdot \Delta t $$ where $f(t)$ is a continuous function and $f_k = f(k \Delta t) \cdot \delta (t - k \Delta t)$ is the discrete sequence of function values sampled on integer multiples of the sampling interval $\Delta t$. To obtain an integral component, we can therefore sample the residual control deviation at the end of each cycle and accumulate it. Thus, we obtain the integral correction $T_I$ as $$ T_I = k_I \cdot T \cdot \sum_k \epsilon_k $$ where $k_I$ is the integral gain, which is usually chosen to be a very small value.

We can interpret $T_I$ as another time component that gets "tacked on" to the on-time and that depends on a repeated, systematic deviation of the temperature. For example, if the room is consistently too cold after heating stops, $T_I$ slowly increases. If we use for $T_{on}$ $$ T_{on} = T \cdot \left( P_0 + k_p \cdot \epsilon + k_I \sum_k \epsilon \right) $$ we can see that the on-time would slowly increase over time, thus correcting for the shortfall. In practice, it is straightforward to adjust $P_0$ at the end of each cycle by $k_I \epsilon$. In this fashion, $P_0$ dynamically adjusts and therefore carries the integral component.

TESTING WITH A REFRIGERATOR

We now use a simple model system, that is, a refrigerator. The refrigerator has its own two-point control system. The specific refrigerator used in this experiment cools a freezer compartment and lets the cold air diffuse into the fridge compartment. If the fridge is relatively empty, this leads to strong overshoot behavior as can be seen in Figure 2.

Figure 2: Cooling behavior of a fridge/freezer with conventional two-point control. the green line is the setpoint, and the red lines represent the lower and upper trip points of the two-point control. The fridge starts equilibrated to room temperature. Strong temperature swings appear as cold air from the freezer compartment diffuses into the fridge compartment.

Figure 3: Cooling behavior of a fridge/freezer with the proposed pseudo-linear control system. The green line indicates the setpoint. The fridge starts equilibrated to room temperature. Unlike two-point control, the new system creates a very accurate estimate of the run-time to keep temperature fluctuations at a minimum. However, the compressor switches more frequently than in the two-point system in Figure 2.

With the new system, as described above, temperature fluctuations are dramatically decreased (Figure 3), although overshoot is still present when a large temperature difference needs to be traversed. However, the superior control accuracy becomes evident.

With the proof of principle established, how can we design such a thermostat for one's home? This is not as bad as it sounds, because most of the functions can be done in software and the overall electronic circuit remains relatively simple. So... on to Part 3.