Thursday, November 11, 2010

Coding up the Controller

A brief catch-up.....

Since late June I have been developing a series of applications for domestic energy monitoring and control based on the popular Arduino open source platform. These applications come under the general banner of "Navitrino" which is an open source project to develop low cost hardware for performing energy control and monitoring tasks within the home.

Navitrino has so far been limited to Arduinos and its clones, because they are cheap, available and easily programmed, but with the portability of C code and the introduction of interesting new ARM based hardware like the mbed, there is no reason why Navitrino can't ultimately be ported to different platforms. For the moment the Arduino is perfectly adequate to develop applicatons and the various sensing and communication techniques which make up the Navitrino project.

To recap, what's been developed and discussed in earlier posts, Navitrino is a low cost, real time monitoring and control application currently running on Arduino hardware. The project has been aimed at DIY domestic energy monitoring and applications such as solar water heating control, central heating control, electricity and gas monitoring and solar pV monitoring.

Whilst I am focussing on gas central heating control - because of my particular circumstances, Trystan, Suneil and Glyn at have been developing electricity monitoring, solar heating and pV monitoring and other temperature monitoring applications. To allow synergy between our work, we have chosen a common platform to work with, and regularly communicate to work on new ideas together. Other partners from Europe have joined up with openenergymonitor to contribute some of their own open source energy related developments.

Progress on Navitrino Central Heating Controller Application.

Meanwhile, I have been slowly improving my Navitrino central heating controller code - once I managed to get a functioning real time clock running last weekend. Now that the basics of the controller are working under the RTOS task scheduling framework, adding new rules and exceptions and making various control decisions is relatively easy.

From a control perspective, I split the day into 3 parts: day, evening and night. This allows specific temperature regimes based on the occupancy of the house. For example, during the weekday day period, we are generally at work so I have the controller keep the house at 17C, so that it doesn't get too cool and then take ages to warm up. At weekends the house is more likely to be occupied, and the comfortable temperature is required at around 7:30am rather than 5:30am.

For the evening period, the controller reads the setting from a potentiometer - which allows you to set the evening temperature at whatever you feel comfortable - I set it for about 19C. The evening period starts at 5pm, so the house is fairly warm for when I get home from work.

If we choose to light the woodstove in the evening, the living room heats up and the thermostat function of the controller makes sure that the boiler is kept off.

At night - after about 12 midnight, the controller allows the house to cool back to 17C, and then it holds it within +/- 0.2C of 17C - so that it only uses a little gas on the coldest nights.

There are already a couple of exceptions programmed into this scheme. As Elaine works from home on Thursdays and Fridays, I use the "day of the week" variable from the RTC to detect if we are Thurs, Fri, Sat or Sun and increase the day period temperature to 18C - which is a more comfortable daytime temperature for when the house is occupied.

Additionally I have introduced some hysteresis into the temperature decision making, so that when we reach 17C for example, the boiler doesn't keep switching on and off as we hover each side of 17.00C. I allow a band of 0.2C either side of the set temp before the boiler switches, so it will come on at 16.8C and off at 17.2C. This gives a longer burn time for the boiler and allows the pipes to heat up properly. It's overall less wasteful on gas than having the boiler constantly stop-starting.

I've also got the water temperature sensing working - so it advises you on the LCD to "Wait" if the water has not yet reached the minimum temperature for a comfortable bath/shower. Once up to temperature - it advises you that the water is hot.

This weekend I hope to wire in the two relays that correctly select either hot water and/or central heating so that it correctly controls the valves and will allow me to schedule hot water only for my 6:00am weekday showers, and get the hot water "boost" button to work correctly. If the heating is going to come on regularly during the night it may well be worthwhile selecting the Hot Water option to come on whilst the boiler is running, to top up the temperature of the hot water tank, rather than turning the boiler on specially to re-heat the water.

Additionally I want to see whether sensing the outside temperature at 4am can help improve the decision making in order to get the house up to temperature on time on the colder mornings. On Thursday it was below freezing until 4am, and suddenly with a depression coming over, the outside temperature shot up to 8C by 6am. These sorts of overnight sudden changes in temperature are not easy to predict - especially when the room temerature sensor is effectively isolated from outside changes by the lag of the thermal mass of the building.

The next job will be to have a look at the 1-wire code so that I can extend the sensor network to include more temperature sensors and pulse counters. Additionally I hope to get the code debugged to allow the SDcard for datalogging this weekend.

No comments: