Temperature logging and regulation in a central heating system

Continuing my series of articles about a central heating system mentioned here, the next step was to find a way to remotely monitor temperatures throughout the system, without having to run down into the basement boiler room to see what’s going on. Since I began tinkering with Arduino at the time, I opted for Atmel’s Atmega micro-controllers, mostly because they’re very cheap, popular and you can easily find help for anything you need. I will briefly describe the whole system and let you work out the schematics for yourself, not just because I’m too lazy to draw them.

1. Temperature monitoring and logging

Since I needed more than 6 temperature sensors in the system, the right choice for the job was Dallas DS18B20 digital One-wire sensor, which makes it possible to hook up “a large number” of sensors using just one I/O pin on the Atmega. The sensors also support temperatures of up to +125 degrees Celsius, which suits my needs perfectly. OneWire sensors also have excellent Arduino support. I’ve installed 8 sensors in total, 4 at different heights on the accumulation tank, one on the hot feed, two on the cold return (one before and one after the mixing valve), and the last one was installed in the boiler itself, because it already came with a temperature sensor slot. Thermal grease and thermal-conductive glue worked wonders. For the purposes of logging, I chose remote logging via the local network, so the project also required an Ethernet module. During the first year, while the whole setup was connected using an Arduino board, I used the expensive, Wiznet 5100 based Arduino Ethernet Shield, but once I made the “final product” on a custom circuit board, I switched to the cheaper Microchip ENC28J60 based modules (at the moment, the entire module costs under USD 4.00). These modules have excellent support through the EtherCard library. I’ve written a sketch which would poll the sensors and read the temperatures from al eight sensors every 10 seconds, and log the data to a server as a HTTP GET request, which looks something like:

 http://192.168.1.10/tlog/post.php?t0=57.56&t1=43.13&t2=34.31&t3=30.69&t4=56.13&t5=26.31&t6=60.13&t7=34.31

PHP script post.php stores the data into a MySQL database. I use Google Charts to draw temperature line charts: glinechart

2. Controlling the circulator pump

Now that I know all of the temperatures in the system at any given moment, I figured it would be neat to switch on the circulator pump automatically when the heat storage tank is sufficiently full (e.g. to one quarter) and switch it off as soon as the boiler is not able to maintain the temperature going into the heat storage tank. Although this requires just one relay, I got a 4-relay shield with opto-isolators. The opto-isolators will later prove extremely important because the relays have to switch AC motors, so once I made a printed circuit board for my circuit without them, the whole thing mysteriously started freezing up whenever one of the motors was switched on/off, and no amount of TVS’s, filters and other stuff was able to fully eliminate all the bugs.

relay-shield-4

But let’s go back to my relay shield. The circulator pump required one, I reserved two for regulation, and one was left unused. When the pump was switched on, it would start running only if the temperature at the top of the heat storage tank was above 60 degrees (heat charger maintains that temperature), and would automatically stop if the temperature were to drop below 60 (in order to maintain layering of hot water in the heat storage tank and slow down the discharge which is much more stable when the circulator is not running).

3. Regulation

This bit was much more complicated, both electrically, electronically and in terms of programming. I wanted to control the mixing valve in order to maintain constant hot feed temperature, which would also ensure constant cold return temperature. Truth be told, I had no idea at this point what I was supposed to do and how, but I was willing to experiment. I got a “dumb” actuator suitable for my mixing valve.

actuator_label actuator

As it says on the label, the actuator cannot be controlled automatically using steps and you can’t instruct it to go to a certain position – it’s powered by 230VAC and has only three leads, two phase leads controlling the direction and one neutral lead. The only thing I knew is that it takes the actuator 140 seconds to get from 0 to 90 degrees. .

I made precise measurements to see how long it took the actuator to full open or close, divided this by 10 and got ten steps I can use to control the actuator. Of course, without a way to get feedback as to whether the actuator has actually reached a position, this was extremely imprecise, but usable if you rely on limit switches in the actuator. I stored the assumed position of the actuator into the EEPROM so that my system knew where the actuator was even after a reset.

The regulation system kicked in every few minutes, comparing temperatures and opening/closing the mixing valve.

4. Circulator pump pulse drive

First of all, I must explain that my circulator pump was bought in 1986, and it was left in its original packaging until 2010 when it was installed, meaning that it doesn’t work that well. It’s also “dumb”, because it only offers three speeds which are selected using a switch, so there is no other way of regulating its speed. And I so needed a way to regulate its speed because most of the problems I had could be solved if only I could reduce the flow. The problem grew even more acute when the circulator simply stopped working at the lowest speed, so I had to switch it to run faster.

That’s when I decided to try a sort of pulse width modulation, only a really, really slow version of it – the circulator would run for 30 seconds, which is enough to supply hot water to the radiators, and then the pump would stop for 60 seconds, allowing the radiators to radiate some heat and cool down the water before sending it back to the storage tank. The line chart in this case looks like this:

pulse2

The mixing valve is open to 80%, which explains the variance between the cold return feed (dark blue) and heat storage tank return (light blue). The hot feed to the radiators is some 60 degrees, and the return temperature is much lower. I have been using this system for two years and not once did I have the need to let the circulator run constantly.

5. Source code and schematics

Like I said, the “end product” on a printed circuit board with power, relays, OneWire Bus, serial LCD, Ethernet module, even a RTC chip (DS1307) proved to be much more unreliable than a prototype made using an Arduino board, so I can’t give you the schematic. Just don’t make the same mistake as I did – use opto-isolators to separate the relays from the MCU, and if you have four AC motors in the vicinity like I have (boiler ventilator, main circulator pump, heat charger circulator pump, mixing valve actuator), you can be sure that everything will go to shit if you forget them.

Arduino source code with comments in English can be found on my Github. The author makes no responsibility that the code will work or that it will be appropriate for any use. It’s quite likely that it won’t even compile, but it might give you a few pointers to help you along in whatever you’re doing.

The Trouble with Valves (Central Heating, Part 2)

In my first article I briefly wrote about how the installation of my central heating system with a wood-fired boiler, a heat storage tank and a storage tank charger went. After the installation was finished, the system was filled with water to 1.5 bar, we lit the first fire and waited to see what would happen. Everything went smoothly, once the temperature in the boiler hit 30°C a thermostat switched on the circulation pump in the storage tank loop and the heating up of the boiler continued. At 60°C the charger began adding cold water from the bottom of the storage tank to the return feed (the loading of the heat storage began). We waited for a while for the top of the heat storage to heat up to 60°C, switched on the circulation pump in the heating loop and after the initial few minutes of heating, we wound up with cold radiators.

The problem was the fact that the installation crew didn’t really know what they should do, so they installed a four-way mixing valve (4WV) between the circulation pump, the hot feed and the cold return. Such a valve is usually installed in heating systems without storage and a charger. In such installations, the 4WV serves to balance the feed and cold return temperatures, or rather enables the mixing of hot feed water with the cold return from the radiators so as not to shock the boiler with cold water.

You can see what this looks like in this rough non-technical doodle depicting a four-way mixing valve open to one third.

4WV-13

When the valve is half-open, we can see that the hot and cold water are mixed in both in the boiler/storage loop and the radiator loop. The valve can also be fully opened, in such cases the hot feed and the cold return from the storage are directly connected to the radiator loop, or closed, when the two loops are fully separated. These are the only two cases when there is no mixing, in all other cases the valve additionally heats up the water that returns to the heat storage.

In order to clear up why this is wrong in heat storage installations, we will discuss how they function, as they are completely different in terms of return temperature. To retain proper layering in the heat storage, the temperature difference between the hot feed and the cold return should be as high as possible. The heat storage tank looks something like this.

tank

The boiler is connected sketch left, sketch right are the hot feed and the cold return for the radiators. Both the loading of the storage and its discharging are done in exactly the same manner, on the left we draw cold water from the bottom of the tank and return hot water to the top. On the right, we draw hot water from the top and return water cooled in radiators to the bottom return feed. When natural circulation is present in the system (i.e. the circulation pump is off and the boiler room/storage tank loop is located below the radiator loop) this works perfectly, hot water is drawn into the radiators where it is cooled down and then returned via the cold return.

The following line chart represents the loading of the storage tank in ideal conditions, the circulation pump in the radiator loop is switched off, only the pump in the heat charger is on. The temperature sensors are located in four positions on the storage tank (number 1 is at the top of the tank, number 4 is at the bottom). Hot water circulates slowly through the system, cold water returns to the tank. The spikes in the return temperature occur when additional radiators are turned on.

heating-punjenje

As we can see, the layering is perfect and while the top of the tank is at 60°C, only 30 cm lower the temperature is 40°C, the bottom is a little over 20°C.

The line chart representing the discharging of the same system using natural circulation (circulation pump off) is as follows.

discharging-praznjenje

Although the fire in the boiler went out and the boiler was switched off, the charger circuit continued to transfer heat to the tank (grey line), and the storage tank is discharging, cold water from the bottom pushes hot water up. The layering is preserved. (Nota bene: the line chart is for a warm day with only a few opened radiators, a 500 litre storage tank is not enough to keep my system warm for 12 hours).

In less then ideal conditions, when the circulation pump is switched on, the water circulates through the radiator loop much faster, doesn’t have time to cool down in the radiators (even at the slowest speed of the circulation pump) and the cold return is significantly warmer. Adding warm water to the bottom of the heat storage ruins the layering and after just a few minutes the water in the entire tank gets mixed up. Instead of 60°C at the top and 20°C at the bottom, we get a whole tank filled with lukewarm water at temperatures which aren’t high enough to heat up the radiators.

This is exactly what happened when I first switched on the circulation pump. In just five minutes I was left with a tank full of lukewarm water. The effect a four-way mixing valve has in such a system is either bad (loops are connected directly without mixing), worse (loops are connected in such a way that the cold return is mixed with the hot feed) or the worst (the loops are separated and the hot feed from the heat storage is connected directly to its cold return).

The four-way mixing valve was the main culprit and had to be removed. We replaced it with a three-way mixing valve which operates differently.

When the valve is fully opened, the loops are connected directly. This case is shown in the following figure, and is unacceptable for the system when the circulation pump is running.

3wv-closed

However, when the valve is half-open (or half-closed, depending on its outlook on life), we can send most of the cold return water back into the radiator loop and draw only a little hot water from the hot feed. By doing this, we will send only a small amount of warm water back into the cold return and the layering in the heat storage will hold out much better. In this example, the three-way mixing valve is half-open.

3WV-50

The following line chart represents a system with a three-way mixing valve.

heating-3WV

Early on the circulation pump is not running, the three-way mixing valve is fully opened, the hot feed and the cold return are directly connected to the radiator loop.

At 17:52 the circulation pump was switched on and we can see the return temperature spike, while the hot feed temperature is dropping. The temperature difference between the two drops from almost 35°C to barely 5°C. The bottom of the tank is heating up.

At 17:58 the three-way mixing valve is closed to about 1/3, meaning that 2/3 of the water from the cold return is mixed with 1/3 of water from the hot feed and sent back into the radiator loop. Although it is not evident in this chart, the temperature of all radiators has dropped because the pump has mixed up the layered water in them (the radiators were hot at the top and cold at the bottom) – the same thing that happens in the heat storage occurred in the radiators, they are now lukewarm from top to bottom.

At 18:22 the three-way mixing valve is opened to about a half (half of the water is sent back to the radiator loop, half is returned to the bottom of the heat storage). We see that the difference between the hot feed and the cold return is now rising as the radiators are heating up the rooms. The system is stabilizing.

The last chart shows how the loading of the storage tank continued with the circulation pump running and with a three-way mixing valve at 50%.

heating-3WVat50

The difference in temperatures of the hot feed and cold return is stable at about 10°C, the storage is loading, although the chart is not as smooth as it was when the circulation pump isn’t running. It is also evident that the system is much slower to react, it takes a lot longer for the radiators to heat up (obvious from the hot feed temperatures).

To sum up, in order for the heat storage to work well, it has to be connected to the radiator loop through a three-way mxiing valve, a four-way mixing valve is completely useless in this case. These charts also indicate a need for a control system which would monitor the temperatures in the loops, switch on the circulation pump when needed and control the mixing valve in order to preserve the layering in the heat storage whilst providing a high enough hot feed temperature to heat up the radiators.

This will be discussed in future articles, the next one with deal with the first building block of the system, the sensors and methods of recording temperatures. I’ll show you how to measure the temperatures, log them on a computer, monitor them via the internet and plot colourful line charts.

To be continued…