First the thermal model was defined as an equivalent resistor and capacitor network, so that it can be understood by an electrical engineer. The order of RC elements was first defined based on a measurement and then iteratively adjusted. The final structure is shown in the figure.

Figure: View of the boiler and group head with thermal model.

On the left side of the circuit is the power input ($P$) in the form of the heating element. The heater has an internal temperature that cannot be measured. The heat is then transferred ($R_\mathrm{th,HW}$) to the water, which is measured by a temperature probe inside the boiler. The water then heats up the boiler via a thermal resistance ($R_\mathrm{th,WB}$). A sensor on the outside of the boiler measures that temperature. Lastly, heat from the boiler is transferred to the group head ($R_\mathrm{th,BG}$). The process is isothermal, meaning that some heat goes into the environment ($R_\mathrm{th,GA}$).


The parameters for the model are listed in the table. The mass was evaluated in CAD. The specific heat capacity for water and brass are from literature [8, p. 629]. The values were later adjusted comparing a simulation against the measurements. The biggest changes between CAD and simulation are the capacities of the boiler and group head. This is probably due to further masses connected to the boiler and the fact that the inside of the coffee machine is heated up as well.

The simulation also revealed the values for the thermal resistance in the table.


Based on the parameters of the model we can describe the correlation between the temperatures. For simplicity, we will just look at the change of energy from the heater to the water.

\begin{equation} \dot{Q}H = \frac{\Delta T}{R\mathrm{th,HW}} = \frac{T_W - T_H}{R_\mathrm{th,HW}} = \frac{\frac{Q_W}{C_W} - \frac{Q_H}{C_H}}{R_\mathrm{th,HW}} = Q_W \frac{1}{C_W \cdot R_\mathrm{th,HW}} - Q_H \frac{1}{C_H \cdot R_\mathrm{th,HW}} \end{equation}

In the circuit analogy $\dot{Q}_H$ is a one current at the node of the capacitor. Kirchhoff's law applies here as well, meaning that the sum of all currents at one node must equal zero.

We now have all the information to fill in the parameters of the state-space representation.

\begin{equation} \begin{aligned} \dot{\vec{x}} &= A\vec{x} + B\vec{u}\ \vec{y} &= C\vec{x} + D\vec{u} \end{aligned} \end{equation}

Here, the state vector $\vec{x}$ holds the energies stored in the thermal capacitance.

\begin{equation} \vec{x} = \begin{bmatrix} Q_H\ Q_W\ Q_B\ Q_G \end{bmatrix} \end{equation}

$\vec{u}$ is the input of the system. Here, that is just the input power of the heating element. Thus, the input matrix $B$ just adds $\vec{u}$ to the energy stored in the heating element.

\begin{equation} B = \begin{bmatrix} 1\ 0\ 0\ 0 \end{bmatrix} \end{equation}

Because $\vec{u}$ is scalar $B$ is a vector instead of a matrix. The system matrix $A$ contains a thermal model based on the $\dot{Q}_H$ equation above.

\begin{equation} A = \begin{bmatrix} -\frac{1}{C_H \cdot R_\mathrm{th,HW}} &\frac{1}{C_W \cdot R_\mathrm{th,HW}} &0 &0\ \frac{1}{C_H \cdot R_\mathrm{th,HW}} &-\frac{1}{C_W \cdot R_\mathrm{th,HW}} - \frac{1}{C_W \cdot R_\mathrm{th,WB}} &\frac{1}{C_B \cdot R_\mathrm{th,WB}} &0\ 0 & \frac{1}{C_W \cdot R_\mathrm{th,WB}} &-\frac{1}{C_B \cdot R_\mathrm{th,WB}} - \frac{1}{C_B \cdot R_\mathrm{th,BG}} &\frac{1}{C_G \cdot R_\mathrm{th,WB}}\ 0 &0 & \frac{1}{C_B \cdot R_\mathrm{th,BG}} &\frac{1}{C_G \cdot R_\mathrm{th,WB}} - \frac{1}{R_\mathrm{th,GA}} \end{bmatrix} \end{equation}

The energies in thermal capacities are not human readable and cannot be measured directly. Instead the output of the system are temperatures. Hence, the output vector $\vec{y}$ contains the following temperatures.

\begin{equation} \vec{y} = \begin{bmatrix} T_H\ T_W\ T_B\ T_G \end{bmatrix} \end{equation}

The energies stored in the state vector are converted to temperatures using the output matrix $C$.

\begin{equation} C = \begin{bmatrix} \frac{1}{C_H} &0 &0 &0\ 0 &\frac{1}{C_W} &0 &0\ 0 &0 &\frac{1}{C_B} &0\ 0 &0 &0 &\frac{1}{C_G}\ \end{bmatrix} \end{equation}

Note that by the equation the output vector contains a temperature difference. In this model, the reference temperature is 0°C so that $\vec{y}$ contains valid temperatures. A change in the input has no immediate effect on the output. Thus, the feedthrough matrix $D$ contains all zeros.

To simulate the state-space model MATLAB Simulink was used. The model and observer are depicted in the figure.

Figure: Simulated temperatures and heating power vs time with a perturbation at 200 s.

The controller is first given some time to reach the set point. At 200 s the pump is activated for 25 s. The plot shows that the controller immediately reacts when the fresh water enters the boiler. There is still some unavoidable temperature drop. Additionally, the plot shows that the group head takes a long time to heat up.

A comparison between the simulation (solid line) and a measurement (dashed line) is plotted in the figure.

Figure: Comparison between simulation (solid line) and measurement (dashed line).

Overall the simulation matches the measurement almost. At 50 s there is a discrepancy between the simulated water temperature (orange line) and the measurement (green dashed line). This indicates an additional time constant missing from the model. As a workaround, the observer is bit looser on the water temperature measurement. As always the controller works well in the simulation. Next are results from the espresso machine controller implementation.