# Temperature Control Unit--Modeling and Implementation of a Particle Filter on a Microcontroller
## 4 Research Objects--The Mathematical Models
### Real Object--Heating and Cooling System  
To implement the particle filter algorithm for the real system, it was necessary to define a mathematical model of the tested object. In the literature, many examples involve the modeling and testing of the heating system [32; 33; 34], but in this study, two-inertial objects were established. The detailed course of the thermal process identification experiment in different versions can be found in [23]. The selected type of system is universal and is often used in the synthesis of a controller [35]; it is given by a transfer function,  
\[G(s)=\frac{K}{(1+sT_{1})(1+sT_{2})}, \tag{7}\]  
and the differential equation  
\[\ddot{y}(t)=-\bigg{(}\frac{1}{T_{1}}+\frac{1}{T_{2}}\bigg{)}\dot{y}(t)-\frac{ 1}{T_{1}T_{2}}y(t)+\frac{K}{T_{1}T_{2}}u(t), \tag{8}\]  
where \(t\) denotes continuous time, \(K\) is the gain of the object, and \(T_{1}\) and \(T_{2}\) are the time constants. The notation \(\dot{y}\) and \(\dot{y}\) stand for \(\frac{dy}{dt}\) and \(\frac{d^{2}y}{dt^{2}}\), respectively. Noises that affect the object have been ignored in the continuous-time model. To identify the parameters of the object, tests with various amplitude step controls were carried out, during which the gain and time constant for the experiments were adjusted. Separate tests were carried out for the heating and cooling processes as different dynamic properties were then demonstrated by the models. Constant parameters were selected for the heating process (denoted by subscript h), while in the case of cooling (subscript c), the gain depends on the initial temperature \(y(0)\) that at the beginning of the experiment should be ideally equal to the temperature measured outside. The resulting parameters in the two modes are as follows:* heating: \(K_{h}=0.0526\), \(T_{h,1}=36.32\), \(T_{h,2}=508.48\);
* cooling: \(K_{c}=0.2069-\frac{\psi(0)}{100}\), \(T_{c,1}=25.00\), \(T_{c,2}=148.00\). Only two modes are assumed, namely, heating or cooling, in which the controls \(u_{1}\) (diode power--for heating) and \(u_{2}\) (fan power--for cooling) work, respectively. The built model can be considered as a jump system [36; 37]. Continuous state-space equations, including phase variables, are given by  
\[\left\{ \begin{array}{l}\left[\dot{x}_{1}(t)\right]=\left[\begin{array}{cc}0 &1\\ -\frac{1}{1_{1}I_{2}}&-\left(\frac{1}{I_{1}}+\frac{1}{I_{2}}\right)\end{array} \right]\left[\begin{array}{c}x_{1}(t)\\ x_{2}(t)\end{array}\right]+\left[\begin{array}{c}0\\ \frac{K}{1_{1}I_{2}}\end{array}\right]u(t)\\ y(t)=\left[\begin{array}{cc}1&0\end{array}\right]\mathbf{x}(t)\end{array} \right. \tag{9}\]  
The system (9) is then discretized with sample time \(T_{s}=1\) second using the Euler extrapolation method, and the obtained discrete state-space equations (dependent on the model parameters), including the modeling errors (1), are shown below  
\[\left\{ \begin{array}{l}\left[\begin{array}{c}x_{1}^{(k+1)}\\ x_{2}^{(k+1)}\end{array}\right]=\left[\begin{array}{cc}1&T_{s}\\ -\frac{T_{s}}{I_{1}I_{2}}&1-T_{s}\left(\frac{1}{I_{1}}+\frac{1}{I_{2}}\right) \end{array}\right]\left[\begin{array}{c}x_{1}^{(k)}\\ x_{2}^{(k)}\end{array}\right]+\left[\begin{array}{c}0\\ \frac{KT_{s}}{T_{1}I_{2}}\end{array}\right]u^{(k)}+\left[\begin{array}{c}v_{ 1}^{(k)}\\ v_{2}^{(k)}\end{array}\right]\\ y^{(k)}=\left[\begin{array}{cc}1&0\end{array}\right]\mathbf{x}^{(k)}+n^{(k)} \end{array} \right. \tag{10}\]  
It is worth noting that particle filters are applied in the heating process as well--an example such a process can be found in [22]. In this paper, the complexity of the object has been limited to two state variables and one control signal due to implementation on a computationally weaker device. The noise of the process included in the PF (1) compensates for the nonlinearity omitted in the model. To simplify the above considerations, the process noise in the transition function and the related disturbance transfer function were omitted.