# Temperature Control Unit--Modeling and Implementation of a Particle Filter on a Microcontroller
## 3 The Platform  
Our tests were carried out on a temperature control system, prepared as a dedicated platform built of commercially available elements. The platform consists of three related parts:  
* A case--made of steel, plexiglass, printable elements;
* Hardware--microcontroller, sensors, H-bridge, and others;
* Software--code written in the C programming language. The case (Figure 2) was designed in the Autodesk Inventor and was printed using ABS material. The general idea was to build a chamber that would be partially independent of the external environment and relatively small. As air volume has a great impact on the heating and cooling time of the air inside the chamber; only a small amount of free space was left for additional new measurement instruments. Besides the aspects of functionality, we decided to consider a visual aspect and used plexiglass windows, which enabled us to look inside the case. The dimensions of the box are shown in Figure 3. The total outer case size is 120 \(\times\) 80 \(\times\) 70 mm. For measurement and control purposes, we decided to use the STM32F4 Discovery evaluation board, which is quite old and nowadays does not offer a great performance compared to other boards. We decided that if the solution works fine on this microcontroller, it can work even better on modern embedded platforms. Besides the board, we used two DS18B20 thermometers using a 1-wire interface, one L298N H-bridge controlled by PWM (pulse width modulation), one 40 \(\times\) 40 \(\times\) 10 12 V PC fan, one 10 W light-emitting diode (LED), and a PL2303 HX converter, which allowed us to communicate with the board through the USART interface. One thermometer and one LED were put inside the chamber. The fan was placed on one side of the case. It allowed two goals to be reached: at low speed, it forced the airflow inside the case to equalize the temperature in the case, whereas at high speed, it cooled down the chamber. The microcontroller, H-bridge, and second thermometer were placed outside the case. We decided to use the led diode as a heater because it produces a large amount of heat and does not need a powerful power supply, which was confirmed in our internal tests in the past. The output power of the diode can be programmed to work between 0% and 100%. The power of the diode was reduced by a resistor, as suggested by the manufacturer. The fan can also be controlled, but in the range  
Figure 2: The figure shows fully the built case. One can see internal peripherals (light-emitting diode (LED), thermometer) and an external thermometer placed on the top of the case. of 30% to 100% percent. The whole system is shown in Figure 4. The peripherals, which are an integral part of the case, are shown in the Figure 2.  
An algorithm written in the C programming language controls the system. We used the STM32 CubeIDE environment for board programming and Hercules software for com  
Figure 4: Complete set of platform elements (placed in the case): STM32F4 evaluation board and peripherals such as two thermometers, light-emitting diode (LED), fan, and H-bridge. Figure 3: Technical sheet of the case. Only significant dimensions are shown. munication over the USART interface. The code was divided into several parts that work together. The PF algorithm was rewritten from our original code in C# language [18] and modified to work with the object. For the purpose of the estimation algorithm, the system was modelled by several mathematical models explained in the next section. The experiment can be in one of three states: heating, normal (keeping), and cooling down, according to the control inputs. Different models are used when the temperature decreases or when it increases. The switch of the models is based on the indoor temperature, the user-expected temperature, and the tolerance range: \(\pm 0.26\) (the value results from the highest resolution of DS18B20, which is 0.065). The measured temperature has an accuracy of 0.065.