Room Thermostat with Servo Controlled by PIC Microcontroller

This paper describes the design of room thermostat with Microchip PIC microcontroller. Thermostat is designated for two-pipe heating system. The microprocessor controls thermostatic valve via electric actuator with mechanical gear unit. The room thermostat uses for its activity measurements of air temperature in the room and calorimetric measurement of heat, which is served to the radiator. These features predestinate it mainly for underfloor heating regulation. The thermostat is designed to work in a network. Communication with heating system’s central control unit is proceeded via RS485 bus with proprietary communication protocol. If the communication failure occurs the thermostat is able to work separately. The system uses its own real time clock circuit and memory with heating programs. These programs are able to cover the whole heating season. The method of position discontinuous PSD control is used in this equipment.


Introduction
The content of this article describes the design of a room thermostat, based on the principle of calorimetric measurements of heat energy supplied to individual rooms, connected to a central source of heat in twopipe hot water heating systems.
In this work use of the equithermal regulation of the heat source is supposed.Nowadays it's probably one of the best and most widely used solution that ensures the change of water temperature depending on the outdoor temperature [1].This solution allows to work with the lowest possible temperature of heating water ensuring full functionality of the system.Designed system is very suitable for connection to heat pumps using geothermal heat.

State of Art
Industrially manufactured thermostats regulate the supply of heat from the central source to the individual radiator by measuring the temperature in the controlled room.These thermostats, even when using the principle of PID regulation, are unable to regulate heating bodies with high thermal inertia such as floor heating without significant temperature overshoot.Control of the heating system is generally divided into the heat source control (usually boilers) and appliances control (radiators).This work focuses on appliances control.

Regulation by Thermostats
Thermostats are direct-acting proportional controllers with a small proportionality band usually 2K.Head reacts to changes in immediate and required temperature.The desired temperature is set manually on handwheel.Their activity does not require any additional energy.For the control function using the thermostats must be correct hydraulic balance of the heating system in all modes.

Electronic Control with Actuators
Thermostatic valve in our case is controlled by an actuator.It consists of the electric motor, which is complemented by a mechanical gearbox, the appropriate servo amplifier and the feedback element, which is a potentiometer usually.Thermostatic valve actuator is controlled by the heating system's electronic controller.At present, this solution seems to be the best, but un-fortunately the most expensive.High mass radiators such as floor heating, for its extremal thermal inertia and capacity, requires the use of PID control -which in microprocessor design changes to PSD control [2].
High quality thermostats also uses PSD regulation, however, it does not measure power delivered into the radiator.It only uses the conversion curve to regulate temperature.This concept cause no problems while using small volume radiators with low thermal inertia with only small overshoots in room temperature.
However, these thermostats fail in regulation of floor heating when the temperature of floor slabs is measured.The first reason is the problem how to measure properly the representative temperature of high volume heater.The temperature distribution on the floor surface is inhomogenous.Another reason is the large thermal inertia of the floor slabs.
The greatest cause of the problem can be seen in the fact that every heating system exhibits fluctuations in the quantity and temperature of the supplied heating water.The cause can be found in the hydraulic unbalance of the heating system and the limited capacity of the heat source (boiler) to maintain a constant temperature of heating water while consumption fluctuates.
For reasons mentioned in the previous point, we have decided to construct a thermostat that measures the room temperature along with the temperature of floor slabs, calculates the necessary power and regulates the supply of thermal energy to the radiator on the basis of calorimetric measurements of heat supplied by the heating water.
The main expected benefit of the new solution is use of the control room underfloor heating as the only source of heat with a quality that is comparable to that of the finest classical controllers managing small radiators.

Design and Implementation
Basic equation of PID controller is given by where K is amplification of PID controller, T I is integration constant, T D is derivation constant, e(t) is the control deviation, u(t) is the output value of the controller [1], [7], [8], [9].
Proportional gain corresponds to the action of the controller, the integration constant T I is introduced to suppress permanently settled deviations and derivative constant T D is used to accelerate the transitions and  stability improvement.Some disadvantageous properties are related to the integration constant -it worsens the stability of the system and extends the period of oscillation -it slows down the regulatory process.Derivative constant improves stability and reduces the period of oscillations -accelerates transient states.
When calculating the output level at the digital PID controller integration I is replaced by summation S and derivative by the difference.This substitution may be ambiguous, so we get different relationships for conversion between continuous and discrete PID controller PSD.
Substitution of the continuous signal in the integration can be performed by various methods as shown in Fig. 1 or Fig. 2. Approximate replacement derivative is then possible as shown in Fig. 2b).
We can derive an algorithm of the discrete PSD controller (using integral compensation trapezoids) as follows: The question how to set parameters of the PSD regulator now comes to front.Ziegler and Nichols method is probably the fastest method to set the PID controller.This model sets the parameters using the critical point of the frequency response, where the critical amplification K crit and critical period oscillations T crit is determined.
Sampling period of the system has been taken to T = 2 min.That means that every 2 min program recalculates the output u(k) using Eq. ( 2) from the measured and given temperature of the heated room.
To measure all temperatures (outdoor and indoor air temperature, the temperature of the floor plate, the temperature of the incomming and outcomming heating water) we use digital thermometers Dallas DS18S20 [3].Their advantages include the ability of more thermometers to communicate over common 1wire bus, connected to a single pin of the processor.This is possible thanks to the existence of a unique 64bit ROM code in each thermometer.Their measurement range is from −55 • C to +125 • C. In the range of −10 • C to +85 • C they provide measurement error less than ±0, 5 • C. Resolution of 1/16 • C is estimated by the program.Since thermometers are used for measurements of the temperature of the inlet and outlet heating water (in the calorimeter), where the proposed temperature gradient in present heating systems can also move only around 10 • C, all thermometers had to be recalibrated in order to maintain maximum accuracy.
All thermostats have been re-calibrated according to the Pt100 platinum thermometer connected as recommended in book [4], [5], [6].This thermometer has an error of ±(0, 1 + 0, 0017t) All thermometers corresponding to the room thermostats are connected by common 1-Wire bus.This bus is connected to the input-output pin RA4 with the open collector output on the processor.The bus is connected with the pull-up resistor of its resistance 4, 7 kΩ to supply with voltage of +5 V.
The basis of the calorimeter are two DS18S20 digital thermometers for temperature of the inlet and outlet heating water measurements and flowmeter Trasco -KA1387-1, see Fig. 3.
The mechanical counter in the flowmeter is replaced by a magnetic sensor and supporting electronics.It provides output 5 V/600 Ω with frequency 38,5 pulse/l.Minimum flow at horizontal mounting is 30 l/h, for vertical mounting 60 l/h.At the minimum flow the error rate is ±3 %.After overcoming the flow rate 120 l/h and 15 l/h (again depending on mounting direction) is the measurement error better than ±2 %.Nominal flow is 1,500 l/h.Usually flow in heating systems through the branches (radiators) range from 90 l/h to 350 l/h.The output of the flow meter is connected directly to the pin of the room thermostat microcontroller.For accurate timing of two consecutive pulses the timer TMR1 with an 100 kHz external crystal is used, which together with the microcontroller forms a free-running synchronous timer.The TMR1 timer is connected to the CCP1 module in CAPTURE mode, which ensures capturing 16 bit TMR1 value at the time of arrival of the pulse from the flow meter.This solution has the advantage that TMR1 runs on and we obtain its value at the time of arrival of the pulse from the flow meter without having to stop and clear TMR1.In the intervals between pulses longer than 655,35 ms TMR1 overflow occurs from 0xFFFF to 0x0000.Such overflow is added to the total time in the variable of type unsigned long int, so the processor is able to measure time between two pulses up to 11,93 hours, which is important for monitoring faults in hydraulic circuits of the heating system.
Based on the time measured between two pulses from the flowmeter the thermostat processor calculates the actual flow.Quality measurements of water temperature and flow allows the room thermostat microcontroller to calculate the amount of heat supplied by generally known Eq. ( 3): where m is the mass of heating medium (water), c = 4, 187 kJkg −1 K −1 is the specific heat capacity of water and ∆t is the temperature difference.
If the heating system is supposed to be fully functional and well-regulated, each branch with radiator has to be fitted by valve with differential pressure regulator.
Combined valves with differential pressure regulator VPD115B-200 and VPD115B-60 by Siemens has been used in this work [10].
Deviation of the actuator is 0, 8 mm.The set-up consists of the commutator engine supplied by 3 V, feedback potentiometer, five-speed gearbox with a gear ratio of 735:1.With such a high gear ratio in combined valve acts as a self-locking gear.It has the advantage that after setting the valve to the desired position it is no longer necessary to supply any energy and valve position does not change spontaneously.
As a real-time circuit the DS1307 circuit produced by Dallas has been used [11].This circuit automatically counts seconds, hours, minutes, day of the week, day of the month, month and year until 2100.Communication on the I2C bus in the thermostat microcontroller is ensured by the MSSP module in I2C control mode.This means that the processor acts as MASTER all the time and RTC acts as SLAVE.Bitrate is set to 98304 bits per second.
Communication between room thermostat processor and the central control unit is provided by the module of the universal synchronous/asynchronous receiver/transmitter (USART) circuit located in the thermostat processor which is connected to the bus via RS485 bus drivers (SN75176 circuit) [12].Bus RS485 connects all thermostats and heat control units

Conclusion
We have decribed a new regulatory system for family houses heating.The regulatory system proposed above has been successfully tested on non-solder contact area.Nowadays this system works successfully as the main regulatory system in Petr Kramar's family house.As the next step we are preparing the economical comparison with commercial systems.

Fig. 4 :
Fig. 4: Dependency between differential pressure above the valve and flow through the valve.