Tuesday, February 14, 2012

measuring energy consumption

1. Theory of operation

The energy meter used in our house is a Siemens ZMD120AMtr53 which capable of measuring 3x230/400V (e.g. industrial power) electricity consumption in preprogrammed day and night shift. The energy company charges less for nighttime usage (EUR 0.08 cents) and considerably more during daytime use (0.14 cents)

The meter has three ways of communicating it's readings to interested users:
  •  dedicated DLMS port for programming and data readouts;
  •  IR test diode pulses (each 0.2 ms long) with a rate of 10000 = 1 kWh;
  •  via on-board LCD "graph" (regular users, simple inspection)
The formula for calculating present power consumption via short pulsing IR light is brought by the data sheet:

Example: Meter constant R = 1000
Power P = 36 kW
f-LED = R x P / 3600 = 1000 x 36 / 3600 = 10 imp/s

In my case, the meter was programmed to have the constant 10 times bigger to achieve more precise readings. Thus, once you have an impulse count in seconds, it's easy to calculate real-time power usage.

2. Selecting an IR sensor

A sample graph for 12h power consumption with RRD
There are several ways to detect IR radiation. Though some detectors might not be as suitable as others thus some consideration has to be made. Firstly, how far would you place the micro-controller? If the wiring will be considerably long (> 10 meters) it would be a good idea to use a sensor with an in-built OP amplifier to get a strong signal over the long wires. That's how I saw it and therefore a sensor TSL262R was chosen. If I would have planned to put the controller inside the same metal box where the meter was located, perhaps a simple IR photo resistor would have done the same good job.


3. Building a prototype

Prototyping is fun! Although I googled for some samples of other fine projects I came up with a more simple and straightforward solution. Firstly, as I formulated the problem very precisely, I ended up getting exactly what I needed. No additional calculations were expected from my 8-bit AVR microcontroller. It's quite the opposite I saw around. Thus I really count pulses and deliver the pulse count in selected timeframe to a logfile.


From software perspective, the key is utilizing the power of AVR chip's interrupts thus leaving more room for other interesting tasks.
volatile long pulseCount = 0;
// interrupt attached to IRQ 1 = pin3
attachInterrupt(1, onPulse, RISING);

and the function to perform is simply
void onPulse() {
 pulseCount++;

}

No comments:

Post a Comment