Application Report
SLAA517–May 2012
Implementation of a Single-Phase Electronic Watt-Hour
Meter Using the MSP430F6736
Bart Basile, Stefan Schauer, Kripasagar Venkat ....................................................................................
ABSTRACT
This application report describes the implementation of a single phase electronic electricity meter using
the Texas Instruments MSP430F673x metering processor. It also includes the necessary information with
regard to metrology software and hardware procedures for this single chip implementation.
WARNING
Failure to adhere to these steps and/or not heed the safety
requirements at each step may lead to shock, injury, and damage
to the hardware. Texas Instruments is not responsible or liable in
any way for shock, injury, or damage caused due to negligence or
failure to heed this advice.
Project collateral and source code discussed in this application report can be downloaded from the
following URL: http://www.ti.com/lit/zip/slaa517.
Contents
1 Introduction .................................................................................................................. 2
2 System Diagrams ........................................................................................................... 2
3 Hardware Implementation .................................................................................................. 4
4 Software Implementation ................................................................................................... 6
5 Energy Meter Demo ....................................................................................................... 13
6 Results and Calibration ................................................................................................... 21
7 References ................................................................................................................. 26
List of Figures
1 Typical Connections Inside Electronic Meters .......................................................................... 3
2 1-Phase 2-Wire Star Connection Using MSP430F6736 ............................................................... 4
3 A Simple Capacitive Power Supply for the MSP430 Energy Meter .................................................. 5
4 Analog Front End for Voltage Inputs ..................................................................................... 5
5 Analog Front End for Current Inputs ..................................................................................... 6
6 Foreground Process ........................................................................................................ 7
7 Background Process ...................................................................................................... 10
8 Phase Compensation Using PRELOAD Register ..................................................................... 11
9 Frequency Measurement ................................................................................................. 12
10 Pulse Generation for Energy Indication ................................................................................ 13
11 Top View of the Single Phase Energy Meter EVM.................................................................... 14
12 Top View of the EVM With Blocks and Jumpers ...................................................................... 15
MSP430 is a trademark of Texas Instruments.
All other trademarks are the property of their respective owners.
1SLAA517–May 2012 Implementation of a Single-Phase Electronic Watt-Hour Meter Using the
MSP430F6736Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated
Introduction www.ti.com
13 Top View of the EVM With Test Setup Connections ................................................................. 16
14 Top-Front View of the EVM With Test Setup Connections .......................................................... 17
15 Source Folder Structure .................................................................................................. 19
16 Toolkit Compilation in IAR................................................................................................ 20
17 Metrology Project Build in IAR ........................................................................................... 21
18 E-Meter Mass Calibration ................................................................................................ 22
19 Meter Status................................................................................................................ 23
20 Meter 1 Features .......................................................................................................... 23
21 Meter 1 Errors (for manual correction).................................................................................. 24
22 Meter Calibration Factors................................................................................................. 25
23 Measurement Accuracy Across Current................................................................................ 26
List of Tables
1 Header Names and Jumper Settings on the F6736 EVM............................................................ 17
2 Energy Measurement Accuracy With Error in (%) .................................................................... 25
1 Introduction
The MSP430F6736 device is the latest metering system-on-chip (SoC), that belongs to the MSP430F67xx
family of devices. This family of devices belongs to the powerful 16-bit MSP430F6xxx platform bringing in
a lot of new features and flexibility to support robust single, dual and 3-phase metrology solutions. This
application report, however, discusses the implementation of 1-phase solution only. These devices find
their application in energy measurement and have the necessary architecture to support them.
The F6736 has a powerful 25 MHz CPU with MSP430CPUx architecture. The analog front end consists of
up to three 24-bit ΣΔ analog-to-digital converters (ADC) based on a second order sigma-delta architecture
that supports differential inputs. The sigma-delta ADCs (ΣΔ24) operate independently and are capable to
output 24-bit result. They can be grouped together for simultaneous sampling of voltage and currents on
the same trigger. In addition, it also has an integrated gain stage to support gains up to 128 for
amplification of low-output sensors. A 32-bit x 32-bit hardware multiplier on this chip can be used to further
accelerate math intensive operations during energy computation. The software supports calculation of
various parameters for single phase energy measurement. The key parameters calculated during energy
measurements are: RMS current and voltage, active and reactive power and energies, power factor and
frequency. A complete metrology source code is provided that can be downloaded from the following URL:
http://www.ti.com/lit/zip/slaa517.
2 System Diagrams
Figure 1 shows typical connections of electronic electricity (energy/e-) meters in real life applications. The
AC voltages supported are 230 V, 120 V, 50 Hz, 60 Hz and the associated currents. The labels Line (L)
and Neutral (N) are indicative of low voltage AC coming from the utilities.
2 Implementation of a Single-Phase Electronic Watt-Hour Meter Using the SLAA517–May 2012
MSP430F6736 Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated
www.ti.com System Diagrams
Figure 1. Typical Connections Inside Electronic Meters
More information on the current and voltage sensors, ADCs, and so forth are discussed in the following
sections.
Figure 2 depicts the block diagram that shows the high-level interface used for a single-phase energy
meter application using the F6736. A single-phase two wire star connection to the mains is shown in this
case with tamper detection. Current sensors are connected to each of the current channels and a simple
voltage divider is used for corresponding voltages. The CT has an associated burden resistor that has to
be connected at all times to protect the measuring device. The choice of the CT and the burden resistor is
done based on the manufacturer and current range required for energy measurements. The choice of the
shunt resistor value is determined by the current range, gain settings of the SD24 on the power dissipation
at the sensors. The choice of voltage divider resistors for the voltage channel is selected to ensure the
mains voltage is divided down to adhere to the normal input ranges that are valid for the MSP430™ SD24.
For these numbers, see the MSP430x5xx/MSP430x6xx Family User's Guide (SLAU208) and the device-
specific data sheet.
3SLAA517–May 2012 Implementation of a Single-Phase Electronic Watt-Hour Meter Using the
MSP430F6736Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated
USCIA1
UART or SPI
V1-/
Vref(O) USCIA0
Vref(I)
USCIA2
LF Crystal
32kHz
XIN
XOUT
24-bit SD
Analog to
Digital
I In
V In
From utility
CT
V1+
I1+
I1-
I2+
I2-
N(L) L(N)
RST
VSS
VCC
MSP430F6736
Application interfaces
LOAD
V1-
VREF
PULSE1
PULSE2
USCIB0
UART or SPI
UART or SPI
I
2
C or SPI
Sx,COMx
MAX
A
B
C
kWhREACTEST kW
Hardware Implementation www.ti.com
Figure 2. 1-Phase 2-Wire Star Connection Using MSP430F6736
L and N refer to the line and neutral voltages and are interchangeable as long as the device is subject to
only one voltage and not both simultaneously at its pins. The other signals of interest are the PULSE1 and
PULSE2. They are used to transmit active and reactive energy pulses used for accuracy measurement
and calibration.
3 Hardware Implementation
This section describes various pieces that constitute the hardware for the design of a working 1-phase
energy meter using the F6736.
3.1 Power Supply
The MSP430 family of devices is ultra low-power microcontrollers from Texas Instruments. These devices
support a number of low-power modes and improved power consumption during active mode when the
CPU and other peripherals are active. The low-power feature of this device family allows the design of the
power supply to be extremely simple and cheap. The power supply allows the operation of the energy
meter powered directly from the mains. The next sub-sections discuss the various power supply options
that are available to support your designs.
3.1.1 Resistor Capacitor (RC) Power Supply
Figure 3 shows a simple capacitor power supply for a single output voltage of 3.3 V directly from the
mains voltage of 110 V and 220 V and 50 Hz and 60 Hz VRMS AC.
4 Implementation of a Single-Phase Electronic Watt-Hour Meter Using the SLAA517–May 2012
MSP430F6736 Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated
3.
0K
www.ti.com Hardware Implementation
Figure 3. A Simple Capacitive Power Supply for the MSP430 Energy Meter
Appropriate values of resistor R20 and capacitor C28 are chosen based on the required output current
drive of the power supply. Voltage from mains is directly fed to a RC based circuit followed by a
rectification circuitry to provide a DC voltage for the operation of the MSP430. This DC voltage is
regulated to 3.3 V for full speed operation of the MSP430. For the circuit above, the approximate drive
provided about 12 mA. The design equations for the power supply are shown in the Capacitor Power
Supplies section of MSP430 Family Mixed-Signal Microcontroller (SLAA024). If there is a need to slightly
increase the current drive (< 20 mA), the capacitor values of C28 can be increased. If a higher drive is
required, especially to drive RF technology, additional drive can be used either with an NPN output buffer
or a transformer and switching-based power supply.
3.2 Analog Inputs
The MSP430 analog front end that consists of the ΣΔ ADC is differential and requires that the input
voltages at the pins do not exceed ± 920 mV (gain=1). In order to meet this specification, the current and
voltage inputs need to be divided down. In addition, the SD24 allows a maximum negative voltage of -1 V,
therefore, AC signals from mains can be directly interfaced without the need for level shifters. This sub-
section describes the analog front end used for voltage and current channels.
3.2.1 Voltage Inputs
The voltage from the mains is usually 230 V or 110 V and needs to be brought down to a range of 1 V.
The analog front end for voltage consists of spike protection varistors (not shown) followed by a simple
voltage divider and a RC low-pass filter that acts like an anti-alias filter.
Figure 4. Analog Front End for Voltage Inputs
5SLAA517–May 2012 Implementation of a Single-Phase Electronic Watt-Hour Meter Using the
MSP430F6736Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated
13
oh
m
13
oh
m
Software Implementation www.ti.com
Figure 4 shows the analog front end for the voltage inputs for a mains voltage of 230 V. The voltage is
brought down to approximately 700 mV RMS, which is 990 mV peak and fed to the positive input,
adhering to the MSP430 ΣΔ analog limits. A common mode voltage of zero can be connected to the
negative input of the ΣΔ. In addition, the ΣΔ has an internal reference voltage of 1.2 V that can be used
externally and also as a common mode voltage if needed. GND is referenced to the Neutral voltage or
Line voltage depending on the placement of the current sensor.
It is important to note that the anti-alias resistors on the positive and negative sides are different because,
the input impedance to the positive terminal is much higher and, therefore, a lower value resistor is used
for the anti-alias filter. If this is not maintained, a relatively large phase shift of several degrees would
result.
3.2.2 Current Inputs
The analog front-end for current inputs is a little different from the analog front end for the voltage inputs.
Figure 5 shows the analog front end used for the current channels I1 and I2.
Figure 5. Analog Front End for Current Inputs
Resistors R14 and R18 are the burden resistors that would be selected based on the current range used
and the turns-ratio specification of the CT (not required for shunt). The value of the burden resistor for this
design is around 13 Ω. The anti-aliasing circuitry consisting of R and C follows the burden resistor. The
input signal to the converter is a fully differential input with a voltage swing of ± 920 mV maximum with
gain of the converter set to 1. Similar to the voltage channels, the common mode voltage is selectable to
either analog ground (GND) or internal reference on channels connected to LSP3 and LSP4.
4 Software Implementation
The software for the implementation of 1-phase metrology is discussed in this section. The first subsection
discusses the set up of various peripherals of the MSP430. Subsequently, the entire metrology software is
described as two major processes: foreground process and background process.
4.1 Peripherals Set Up
The major peripherals are the 24-bit sigma delta (SD24) ADC, clock system, timer, LCD, watchdog timer
(WDT), and so forth.
6 Implementation of a Single-Phase Electronic Watt-Hour Meter Using the SLAA517–May 2012
MSP430F6736 Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated
fmfs
OSR
=
RESET
HW setup
Clock, SD24_B, Port pins, Timer,
USCI, LCD
Calculate RMS values for current,
voltage; Active and Reactive
Power
Main Power OFF?
1 second of Energy
accumulated? Wait for
acknowledgement from
Background process
Go to LPM0
Y
N
Y
N
Wake-up
Send Data out through SPI/
UART to PC
www.ti.com Software Implementation
4.1.1 SD24 Set Up
The F673x family has up to three independent sigma delta data converters. For a single phase system at
least two ΣΔs are necessary to independently measure one voltage and current. The code accompanying
this application report addresses the metrology for a 1-phase system with limited discussion to anti-
tampering, however, the code supports the measurement of the neutral current. The clock to the SD24
(fM ) is derived from DCO running at 16 MHz. The sampling frequency is defined as , the OSR is
chosen to be 256 and the modulation frequency, fM, is chosen as 1.1 MHz, resulting in a sampling
frequency of 4.096 ksps. The SD24s are configured to generate regular interrupts every sampling instant.
The following are the ΣΔ channels associations:
• SD0P0 and SD0N0 → Voltage V1
• SD1P0 and SD1N0 → Current I1
• SD2P0 and SD2N0 → Current IN (Neutral)
4.2 The Foreground Process
The foreground process includes the initial set up of the MSP430 hardware and software immediately after
a device RESET. Figure 6 shows the flowchart for this process.
Figure 6. Foreground Process
7SLAA517–May 2012 Implementation of a Single-Phase Electronic Watt-Hour Meter Using the
MSP430F6736Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated
( )
2
1
Sample
count
v n
n
V KRMS v
Sample count
å
=
= *
( )
2
1
Sample
count
i n
n
I KRMS i
Sample count
å
=
= *
( ) ( )
1
Sample
count
v n i n
n
P KACT p
Sample count
´
å
=
=
( ) ( )90
1
Sample
count
v n i n
n
P KREACT p
Sample count
´
å
=
=
Software Implementation www.ti.com
The initialization routines involves the set up of the analog to digital converter, clock system, general
purpose input/output (GPIO) port pins, timer, LCD and the USCI_A1 for universal Asynchronous
receiver/transmitter (UART) functionality. A check is made to see if the main power is OFF and the device
goes into LPM0. During normal operation, the background process notifies the foreground process
through a status flag every time a frame of data is available for processing. This data frame consists of
accumulation of energy for 1 second. This is equivalent to accumulation of 50 or 60 cycles of data
samples synchronized to the incoming voltage signal. In addition, a sample counter keeps track of how
many samples have been accumulated over the frame period. This count can vary as the software
synchronizes with the incoming mains frequency. The data samples set consist of processed current,
voltage, active and reactive energy. All values are accumulated in separate 48-bit registers to further
process and obtain the RMS and mean values.
4.2.1 Formulae
This section briefly describes the formulae used for the voltage, current and energy calculations.
4.2.1.1 Voltage and Current
As discussed in the previous sections simultaneous voltage and current samples are obtained from three
independent ΣΔ converters at a sampling rate of 4096 Hz. Track of the number of samples that are
present in 1 second is kept and used to obtain the RMS values for voltage and current for each phase.
v(n)= Voltage sample at a sample instant ‘n’
I(n)= Current sample at a sample instant ‘n’
Sample count= Number of samples in 1 second
Kv = Scaling factor for voltage
KI = Scaling factor for current
4.2.1.2 Power and Energy
Power and energy are calculated for a frame’s worth of active and reactive energy samples. These
samples are phase corrected and passed on to the foreground process that uses the number of samples
(sample count) and use the formulae listed below to calculate total active and reactive powers.
v90 (n) = Voltage sample at a sample instant ‘n’ shifted by 90°
8 Implementation of a Single-Phase Electronic Watt-Hour Meter Using the SLAA517–May 2012
MSP430F6736 Submit Documentation Feedback
Copyright © 2012, Texas Instruments Incorporated
E P Sample countACT ACT= ´
www.ti.com Software Implementation
Kp = Scaling factor for power
The consumed energy is then calculated based on the active power value for each frame in similar way as
the energy pulses are generated in the background process except that:
For reactive energy, the 90° phase shift approach is used for two reasons:
• This allows us to measure the reactive power accurately down to very small currents.
• This conforms to intern
本文档为【TI Emeter 1phase】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
该文档来自用户分享,如有侵权行为请发邮件ishare@vip.sina.com联系网站客服,我们会及时删除。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。