AN2288
Application note
Single-phase energy meter with tamper detection
based on ST7FLITE2x
Introduction
This application note describes the design for a single-phase power / energy meter with
tamper detection. The design measures active power, voltage, current, power factor and line
frequency in a single-phase distribution environment and displays active energy, voltage,
current, power factor, line frequency, current date and time. It differs from ordinary single-
phase meters in that it uses two current transformers (CT) to measure active power in both
live and neutral wires. This enables the meter to detect, signal, and continue to measure the
active energy consumed reliably even when subject to external tamper attempts.
ST7FLITE20 is the microcontroller used to perform all the measurements in the meter. As
the ST7FLITE30 is pin-to-pin compatible with ST7FLITE20, the ST7LITE30 can also be
used in this application (replacing the ST7LITE20) but a revalidation is required for finding
the accuracy class of the meter.
The active energy consumed is available in the form of frequency-modulated pulse outputs
and the accumulated active energy on an LCD display module. Additional features for both
consumer types can also be incorporated. These include multiple tariff rates and improved
communications, through which meter readings can be taken with less time and with higher
accuracy.
May 2006
Rev 1
1/29
www.st.com
Contents
AN2288
Contents
1
2
3
Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1
Analog front end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4
Meter hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.1
Main blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1.1
4.1.2
4.1.3
4.1.4
4.1.5
4.1.6
4.1.7
4.1.8
4.1.9
4.1.10
4.1.11
4.1.12
5V power supply block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5V reference block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
Current transformer block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Voltage divider block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
Tamper detection block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
Gain switching block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
EEPROM block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
RTC block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
LCD module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
In-Circuit Programming block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
Calibration through PC GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
Microcontroller block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5
Software routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.1
5.2
5.3
5.4
5.5
5.6
5.7
Initialization routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Main routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
Lite timer time base2 interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
SPI interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
AVD interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
External interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
ART timer input capture interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . 23
6
Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.1
6.2
Load tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
Voltage tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2/29
AN2288
Contents
6.3
Frequency tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
7
8
9
Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
Calibration coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
Revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 28
3/29
Features
AN2288
1
Features
●
●
●
●
●
●
●
Cost-Effective and Flexible Single-Phase Energy Meter
ASSP is not used; microcontroller is doing all the measurements and calculations
Fulfils IEC 61036:1996 + A1: 2000, Static meter for active energy (classes 1 and 2) for
Ib=10A and Imax=55A
Meter starts at few mA
Detects, Signals and Continues to Measure Accurately under tamper Condition
Compact design with Internal Flash memory, SRAM and external EEPROM
External EEPROM used to store calibration parameters, tampering information and
accumulated kWh. This is more secure than using internal EEPROM, as it keeps the
data away from the risk being lost on a burnt microcontroller.
Flexibility to use External or Internal EEPROM by changing only the sales type to
ST7FLITE29 (embedded with 256 bytes of EEPROM) without changing the hardware
design
Gain multipliers (Operation Amplifier) are used for wider range of load with Ib=10A and
Imax=5.5Ib
Large line voltage operable range from 140V to 300V
Active power, current, voltage, power factor and line frequency measurements
RTC for displaying current date and time
LCD module for display accumulated kWh, Vrms, Irms, power factor, line frequency,
current date and time
Secure and reprogrammable Flash memory enables flexible firmware updates up to
10k cycles
Adjustable Active Energy Pulse Output goes up to 32 000 Impulses/kWh
Large Compensation of Phase difference generated by CTs by hardware (increasing or
decreasing capacitor values at current channel)
One-Time, Quick, and Accurate Digital Calibration gives added benefits like more
accurate calibration and no need for Trimming external components
●
●
●
●
●
●
●
●
●
●
4/29
AN2288
Overview
2
Overview
Power meters / Energy Meters are also known as kiloWatt-hour meters. As per definition,
energy consumed is a measure of work that is done over a known time period. Suppose, a
heater of 2kW is ON for half an hour, the consumed energy will be 2000W * 1800s =
3 600 000W-s (Watt-second), which is 1kWh.
The Active Energy Pulse output of 50% duty cycle is an indication of active power
consumed, as measured by the power meter. If the active power is higher, the frequency of
the pulse will also be higher. The pulse count gives the active energy measured by the
meter. The greater the number of pulse counts, the greater the amount of consumed active
energy. The pulse output frequency is easily configurable by software. The current software
has 3,200 impulses per kiloWatt-hour.
All the measurements can be calibrated by software, so there is no need for any trimming
components. With the firmware, phase difference created between voltage and current due
to current transformer can also be compensated. Because only one ADC is used to convert
both analog voltage and current signal into digital form and there is no dual sampling feature
available in the ST7FLITE20 microcontroller, the shift error (the sampling difference
between voltage and current) can also be compensated by the firmware. The calibration
procedure can be automated, which removes the time-consuming manual trimming required
in traditional, electromechanical meters. Digital calibration is fast and efficient, reducing the
overall production time and cost. Calibration coefficients, accumulated kWh and tampering
information are safely stored on the external EEPROM. This is more secure than internal
EEPROM since data would be lost in the event of a burnt microcontroller. Internal EEPROM
can be used in place of external EEPROM by changing only the microcontroller (without any
change in hardware design), if the consumer or supplier prefers.
The most important part of the meter is the firmware which includes tampering detection
functionality in a single-phase meter. The firmware can be modified and updated at any time
by using In-Circuit Programming, even when the meter is installed and running. The
firmware is entirely written in C except some time critical routines which are written in
assembly, which makes modifications easy to implement.
5/29