Thursday, 22 March 2012

Processing the gas meter monitor readings

I left the gas meter monitor running for a Saturday afternoon and captured the output to a file, then transferred the data into a spreadsheet to experiment.  If you read my previous post, you'll know that the meter monitor records three types of event, all timestamped to a one second resolution: 1) when the gas starts flowing and the meter wheels begin rotating, 2) when the shiny zero passes by on the least-significant digit, and 3) when the gas stops flowing and the meter wheels stop rotating.

The data is just a sequence of numbers - you can't "see" anything in it.  To see some patterns in the gas usage, it needs to be displayed in graph form.  The first graph I plotted was of time (horziontal) against accumulated count of zeros passed:

The points on this graph are the zero-passing events only - this is the data I would get if I'd used a simple reed switch to detect the magnet on the wheel.  

The graph is far straighter than I was expecting - there's hardly any variation visible, despite the sun coming out and going in again during the afternoon (which affects the temperature in the living room a lot), and the front door being opened a few times.

The next graph plots a point each time the wheel stops turning, showing the number of zeros passed during that on-cycle:

You may be able to see that the cycles occur at a fairly regular rate - around one every 315 seconds.  When the boiler is on, it uses gas at a constant rate.  What varies is the amount of time that the boiler remains on during each cycle.

Now at least you can see a bit of variation in the graph.  At the beginning of the recording, the heating hadn't been on for long and it was still bringing the house up to temperature, so the cycles were longer.  Later on, the front door was open for a while a couple of times, dropping the temperature in the hall.

It's obvious looking at the graph that the count of zeros is a whole number by the way the line snaps to equally spaced levels.  There are probably details being lost in the gaps between those levels.

The following graph plots a point for each stop event, showing the percentage of time since the last stop that the gas flowed for:

This graph doesn't directly take into account the amount of gas used - only the amount of time that the gas was flowing.  However, because our central heating boiler is not the "modulating" type, it uses gas at a fairly constant rate, so the shape of this graph is fairly close to the shape of a gas-used graph.

However I won't give up there, as I'd like the gas meter monitor processing to be suitable for other types of boiler, and for households where gas is also used for cooking, so here's one last graph which I think is as close as I can get to real-time gas usage:

This one was the most complicated to calculate - for each on-cycle, the average time between successive zero-crossings is calculated, then the periods between the cycle starting and the first zero, and the last zero and the cycle stopping, are compared to the average period between zeros to calculate a fractional zero count to add to the whole number of zeros passed.  The shape is very similar to the previous graph, but in this case the area under the graph should approximate to the total gas used for the period, as the y-axis is measured in "zeros passed".

If gas were being used at varying flow rates then this graph would be less accurate.  I think the only way I could improve on this would be to try to determine the speed at which the meter wheel is turning, by learning the pattern of varying light levels as the digits 0 to 9 pass by the sensor, and then matching against that as the wheel turns to determine the rate of turning.  Maybe for a future revision...