Believe it or not, the first priority of electric utilities is not power generation or distribution, or even customer service. It is billing. Consider that every month thousands of meter readers drive from home to home, manually reading millions of electricity meters. The collected data is then entered into billing systems, most often by workers reading the logbooks and keypunching the data. This veritable army of meter readers and office workers is, as much as anything, what keeps the utility financially alive.

But to the utility companies, this expense is pure overhead. The problem is the electricity meter itself – usually a spinning disk in a glass case with a mechanical counter attached. With such meters, automation is difficult. A new generation of electricity meters promises to change this. Based on a microcontroller rather than a spinning disk, the next generation electricity meter can be more accurate, more reliable and much more flexible than its mechanical counterpart.

In addition to counting and automatically reporting the number of kilowatt-hours used by the customer, the microcontroller-based meter can also keep track of when usage occurs, how much peak power was demanded, and whether the power factor is within acceptable limits. This article describes how such an electricity meter can be constructed from a modern, mixed signal microcontroller and a few additional parts.

Choosing the right microcontroller

In the past, microcontrollers have been limited to supporting roles in most real-world systems. There were two reasons for this: First, most microcontrollers had very limited speed and storage resources; and second, microcontroller devices were strictly digital – any analogue peripherals would represent another chip and more supporting components. Modern mixed signal microcontrollers put an end to these limitations. Combining high performance analogue circuitry, a high speed CPU core and a full range of communication and display peripherals, these microcontrollers serve well as the heart of a modern electricity meter.

Hardware components

Choosing a microcontroller is, of course, only the first step. Components must also be selected to scale the voltage and current waveforms in the load, to provide the physical layer for the communication channels, and to provide non-volatile data storage. Deriving the voltage waveform is simple – a voltage divider across the line serves nicely.

To provide the -1 V to +1 V required by many A/D converters, it is necessary to divide the voltage waveform on a 240 V circuit by a ratio of 400:1 to 600:1. A single-pole RC filter after the division performs anti-aliasing duty. Measuring the current in the load can be performed in several ways, but the two most popular are to use a current transformer or a current shunt. A current transformer develops a voltage in its secondary circuit proportional to the current in the primary circuit.

A current shunt (used in the adopted design) develops a voltage as a result of the IR drop across a resistance. To keep power dissipation low, the shunt resistor is often in the range of 250 to 500 µ?. In older power meters, communication was not an issue. When reading mechanical meters, the reader simply copied the value from the counter into a logbook.But modern meters use their communication channels to transfer billing information and configuration data using two mechanisms, non-contact and networked.

This design provides both. A non-contact reader transfers energy usage data without the device making physical contact with the meter. Often, this is done by a handheld instrument that transfers data using an infrared link. In this arrangement, a utility worker points a reader device at the meter, much as one might use a remote control to operate a television. A request packet is transmitted to the meter, which responds with the requested data. This usage data is stored on the reader until it can be transferred to the billing system. A networked meter is usually found in a multi-family dwelling, such as an apartment building. In such an installation, all meters in the building talk on a network to a controller that polls them once a month.

The controller then formats a set of messages containing the usage data for transmission to the billing authority. This meter uses RS-485 as a physical medium for networking. For non-volatile storage, the meter contains an I2C EEPROM device. Serial memory devices have provided reliable service over many years, and are available in sizes from 64 bits to 1 Mb or more. The device used in this design is 128 kb.

Behaviour

Once the hardware design is settled, the question of software arises. But before the first line of code can be written, the system designer must determine how the meter should behave. That is, what is the meter actually expected to do? Fortunately for the system designer, that question is largely answered in an international standard. IEC 61036 specifies a Class 1 (1% accuracy) or Class 2 (2% accuracy) electricity meter. This standard calls out not only accuracy, but mechanical, environmental, and safety parameters as well.

In short, this document describes what it is to be an electricity meter, and it has been adopted in one form or another as the national standard in nearly every country. But IEC 61036 does not specify communication protocols that must be followed. This is a problem, since there is no single international standard for physical media, message protocol or semantics for communication between a host computer and an electricity meter.For the present design the Chinese standard, DL/T 645, was settled on. This document describes the physical layer, packet format and rules for transmission that a meter (and a host computer) must follow.

Software

The meter software can be broadly divided into two functional blocks. The first is the DSP subsystem. It receives the voltage and current samples from the ADC channels and calculates the voltage, current, power and accumulated energy usage.The second block is the accounting subsystem. It takes the calculated energy from the DSP subsystem and accumulates it into one of several tariff registers. The accounting subsystem also manages communication, storage and the display.

The process of measuring energy begins with the DSP subsystem. Every time a sample set is received from the ADC channels (in this design, every 48 µs) the voltage and current samples are multiplied and accumulated. The product of instantaneous voltage and current is instantaneous power, and this can be accumulated to calculate the energy usage. The waveforms are also lowpass filtered to find the zero crossing.

On every zero crossing, the accounting subsystem is notified. When alerted, the accounting subsystem dumps the accumulated energy from the DSP into a larger accumulator, and clears the DSP accumulator. When enough energy has been accumulated, it then updates the accumulated energy registers in the EEPROM. The accounting subsystem cannot update the EEPROM on every zero crossing because most EEPROM devices wear out after some number of write cycles.

Communication

There are four tasks that the communication subsystem must perform. First, some process must receive the stream of bytes from the communication driver and determine when valid messages have been received. Second, some process must receive the validated messages and determine what they mean and what action should be taken. Third, when data is ready to be transmitted, some process must ensure that the raw data is formatted in a manner suitable for the communication packet.

Finally, a process must physically build the packet and send it, byte by byte, to the communication driver. In this design, these four tasks are named the message checker, message decoder, message formatter and message builder, respectively. When a valid message has been received and decoded, it is likely that the request will be for the meter to either send some measured value (energy, voltage, power, etc.) or to send or set some operational parameter (meter constant, serial number, etc.). In either of these cases, the request is referred to the register manager. This software component is responsible for reading, writing and maintaining the hundreds of registers that are defined in the DL/T 645 protocol.

Display

The display manager determines what data elements to display and how to display them. In the chosen microcontroller, making something appear on the display could not be simpler: The software just updates a register, and the display controller hardware in the chip does the rest. The display controller selects an item to display (in the current design, the meter displays time of day, date, and accumulated energy) and formats it for the LCD. It then waits a prescribed number of seconds before selecting the next item and formatting that for the LCD.

Schedule

An advantage of a microcontroller-based electricity meter is that it can assign energy usage to one of several tariff periods, defined on time of day and date. In the adopted design, the tariff periods are determined by a task called the schedule manager. Every minute, the schedule manager checks whether a new tariff period is in effect. If it is, the schedule manager updates a RAM variable that contains the tariff period’s number.

Obviously, the schedule manager requires an accurate clock, and the electricity meter design provides this in one of two ways. First, the microcontroller contains a 32-bit UNIXcompatible system clock, complete with battery backup. While simple and cost effective, the crystal that controls the clock is not temperature-compensated, and may drift when exposed to changes in temperature.

If a more accurate clock is required, an external, temperature-compensated time-of-day clock can be used. These devices contain a built-in temperature sensor and hardware that adjusts the clock operating frequency to compensate for the natural drift that affects all crystal oscillators over temperature. Using a temperaturecompensated clock, accuracies of 30 seconds/month are achievable over the entire industrial temperature range.

Conclusion

The methods for metering electricity are changing quickly. Within a few years, the wheel-based meter will be as quaint as the dial telephone. A new generation of microcontroller devices is paving the way for an electricity infrastructure that promises greater billing accuracy, more security and more options for electricity service providers.

The complete electricity meter reference design on which this article is based, including Bill of Materials,can be downloaded at www.maxim-ic.com/solutions/electricity_metering_system