ST AN2288 Application note

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 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
3 Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
3.1 Analog front end . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
4 Meter hardware . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
4.1 Main blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1.1 5V power supply block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1.2 2.5V reference block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
4.1.3 Current transformer block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1.4 Voltage divider block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
4.1.5 Tamper detection block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1.6 Gain switching block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
4.1.7 EEPROM block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
4.1.8 RTC block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.1.9 LCD module . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
4.1.10 In-Circuit Programming block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
4.1.11 Calibration through PC GUI . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
4.1.12 Microcontroller block . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
5 Software routines . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.1 Initialization routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.2 Main routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
5.3 Lite timer time base2 interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
5.4 SPI interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
5.5 AVD interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.6 External interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
5.7 ART timer input capture interrupt routine . . . . . . . . . . . . . . . . . . . . . . . . . 23
6 Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.1 Load tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
6.2 Voltage tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
2/29
AN2288 Contents
6.3 Frequency tests . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
7 Conclusions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
8 Calibration coefficients . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
9 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
Theory AN2288

3 Theory

The main objective of this application note is to demonstrate that a low cost energy meter can be implemented without use of an external dedicated device (ASSP). Only a single 10­bit SAR ADC is used to perform voltage and current measurements. The ADC on ST7FLITE20 device accepts input from 0 to Vdd. Since the Vdd is +5V, the operable range of the ADC is 0 to +5V. Since the ADC is operable in the positive range only, the AC input signals of voltage and current have to shifted up and centered around +2.5V. This is achieved by biasing one end of the secondaries of current transformers and one end of potential divider with +2.5V. The input waveform of current and voltage to ADC is shown in figure1.
Figure 1. AC input signals to ADC
V
Vdd
Voltage Waveform
Vdd/2
t
Current Waveform
Four ADC input channels are used, three for current and one for voltage measurement. One of the current channels is multiplexed with two current gain factors x128 and x512. The sampling rate for each channel is 5kHz. This higher rate of sampling is there to reduce the quantization noise. The active energy consumed is calculated based on instantaneous value of power. The sampling rate is 5kHz, so, with a 50Hz sinewave the number of samples per cycle is 100. The sampling time is 200µs. After every 200µs, one current and voltage sample is taken and multiplied to get an instantaneous power sample. The discrete summation of these power samples over time gives the active energy.
When the phase difference between voltage and current is 0, the active power will be at the maximum which is equal to total power, and the reactive power will be 0.
If v(t) = Vsin(ωt) and i(t) = Isin(ωt - φ), the instantaneous power:
VI 2() φ()cos 2ωt φ()cos()=
Pt() vt() it()×=
After averaging, we get cos(2ωt - φ)=0 for a cycle of sinewave. So, the theoretical average power (P) is VIcos(φ)/2. If ik and vk are respectively the instantaneous values of the current and the voltage, the discrete formula of average power with regular, simultaneous, voltage and current samples is:
N-1
1N()vk ik×
=
P
d
K=0
6/29
AN2288 Theory
So, the average active energy over a time period with N samples is:
sampling
N-1
K=0
vk ik×
Edt
=
There is delay (δ) between each voltage and current sample, due to this the real phase shift angle (α) between v(t) and i(t) is different than theoretical phase shift angle (φ). So, there is a discrete error (ε
):
d
P
P ε
+=
d
ε
d
=
VI×
-------------
2N×
d
N-1
K=0
2α 2Kωt φ+()cos
The average ε
will be 0. So, Ed = E.
d
There is also error due to non-simultaneous sampling, which is shift error (ε
The total active energy including not simultaneous sampling will be:

3.1 Analog front end

The ADC used in this application is only one 10-bit SAR ADC for current as well as voltage sampling. The voltage is reduced by potential divider and lifted up by Vdd/2 (e.g. 2.5V) and then given to one of the ADC channels of ST7Lite20 microcontroller to get the digital converted value after every 200us. The Lite2 timer RTC2 interrupt is used to get 200us.
The current value is measured using a current transformer with a 1:5000 turn ratio and with 36 Ohm shunt resistance. The voltage induced across the current transformer is lifted up by 3V
/4 (e.g. 3.75V) to make the induced voltage unipolar (because the microcontroller
DD
works in one direction only). Two analog switches are used for tampering detection phenomena. The output of both switches are connected, but the inputs are different, one from phase line and the other one from neutral line. The output goes to gain multipliers e.g. operational amplifiers. There are four gain multipliers implemented by three operation amplifiers and with one analog switch. The gain factors are x2, x8, x32 and x128. The x32 and x128 are multiplexed using one op-amp and one analog switch. The output of the gain multipliers goes to the ADC channels of the microcontroller. The active channel for current is selected based on current range.
ε
P
P
E
ns
ns
ns
ns
VI×
-----------
δφ()sin
2
P εnsε
++=
P ε
+=
ns
E
ε
+=
d
):
ns
N1
δ
--- -
+=
N
K0=
d
d
2α 2Kωt φ+()cos
7/29
Theory AN2288
Figure 2. Analog Front End (AFE) for current
Phase In
Phase Out
Neutral In
Neutral Out Current Transformer
36 Ohm
36 Ohm
analog switches
+3.75V
Control by MCU
Figure 3. Analog Front End for voltage
Phase
x2
x8
x32
x128
analog switch
Gain multipliers
Controlled by MCU
To MCU ADC
To MCU ADC
+3.75V
8/29
AN2288 Meter hardware

4 Meter hardware

The block diagram of meter hardware is shown below:
Figure 4. Energy meter block diagram
Neutral line
Phase line
Power LED
RTC
EEPROM
EE­PROM/RTC
Op-Amps for gain x2, x8, x32 & x128
Phase voltage
SPI
ICP
Analog switch for gain factor b/w x32 & X128
Control for switching between x32 & x\128
ST7FLITE20
ADC
control for switching between CTs
LCD module
CT
Analog switches
Power supply
CT
Used for reference
Tamper LED
Energy pulse output LED
AC to DC capacitive power sup­ply (5V)
3.75V
Voltage follower
CT = Current Transformer ICP = In-Circuit Programming
9/29
Loading...
+ 20 hidden pages