Вы находитесь на странице: 1из 41

Freescale Semiconductor, Inc.

Design Reference Manual

Document Number: DRM163


Rev. 0, 06/2015

MKM34Z256 One-Phase Power Meter


Reference Design
By: Ludek Slosarcik

Contents

1. Introduction
The electro-mechanical power meters have been
gradually replaced by electronic meters. Modern
electronic meters have a number of advantages over
their electro-mechanical predecessors. Their mechanical
construction is more cost-effective due to the fact that
there are no moving parts. In addition, electronic meters
have one-percent accuracy (or better) in the typical
dynamic range of power measurement of 1000:1,
whereas electro-mechanical meters have two-percent
accuracy in the dynamic range of 80:1. The higher the
accuracy and dynamic range of the measurement are,
the more precise the energy bills are.

2015 Freescale Semiconductor, Inc. All rights reserved.

1.

Introduction
1
1.1.
Specification ........................................................... 2
2. MKM34Z256 series MCU
3
3. Basic theory
4
3.1.
Active energy .......................................................... 5
3.2.
Reactive energy....................................................... 5
3.3.
Active power ........................................................... 5
3.4.
Reactive power ....................................................... 5
3.5.
RMS current and voltage ........................................ 6
3.6.
Apparent power....................................................... 6
3.7.
Power factor ............................................................ 6
3.8.
Total Harmonic Distortion ...................................... 7
4. Hardware design
7
4.1.
Power supply .......................................................... 8
4.2.
Digital circuits ........................................................ 9
4.3.
Analog circuits ...................................................... 14
5. Software design
16
5.1.
Block diagram ....................................................... 16
5.2.
Software tasks ....................................................... 18
5.3.
Performance .......................................................... 22
6. Application setup
22
7. FreeMASTER visualization
24
8. Accuracy and performance
28
8.1.
Room-temperature accuracy testing ...................... 29
8.2.
Extended temperature accuracy testing ................. 30
9. Summary
32
10. References
33
11. Revision history
33

Introduction

This design reference manual describes a solution for one-phase electronic power meter, based on the
MKM34Z256VLL7 MCU. This MCU is a part of the Freescale Kinetis-M series of MCUs. The KinetisM series MCUs address accuracy needs by providing a high-performance analog frontend (24-bit AFE),
combined with embedded Programmable Gain Amplifier (PGA). Along with high-performance analog
peripherals, these new devices integrate memories, input / output ports, digital blocks, and a variety of
communication options. The ARM Cortex-M0+ core and Memory-Mapped Arithmetic Unit
(MMAU), with support for 64-bit math, enable fast execution of metering algorithms. The one-phase
power meter reference design is intended for the measurement and registration of active and reactive
energies in one-phase two-wire networks. It is pre-certified according to the European EN50470-1,
EN50470-3, classes B and C, and also to the IEC 62053-21 and IEC 62052-11 international standards
for electronic meters of active energy classes 2 and 1.
The integrated Switched-Mode Power Supply (SMPS) enables efficient operation of the power meter
electronics, and it provides enough power for optional modules, such as nonvolatile memories (NVM)
for data logging and firmware storage, and the Arduino / FRDM plugin card for wireless communication
for Automatic Meter Reading (AMR) and remote monitoring. The power meter electronics are backed
up by a 3.6 V Li-SOCI2 battery when disconnected from the mains. This battery activates the power
meter, whenever the user button is pressed or a tamper event occurs.
The power meter reference design is intended for use in real applications, as suggested by its
implementation of a Human Machine Interface (HMI) and communication interfaces for remote data
collection.

1.1. Specification
The MKM34Z256 one-phase power meter reference design is intended for use in a real application. Its
metrology portion has undergone thorough laboratory testing, using the test equipment ELMA8303 [1].
Thanks to intensive testing, accurate 24-bit AFE, and continual algorithm improvements, the one-phase
power meter calculates active and reactive energies more accurately and over a higher dynamic range
than what is required by common standards. All information, including accuracies, operating conditions,
and optional features, are summarized in the following table:
Table 1. MKM34Z256 one-phase power meter specification
Type of meter
Type of measurement
Metering algorithm
Accuracy
Nominal voltage
Current range
Nominal frequency
Meter constant (imp / kWh, imp / kVArh)

Voltage sensor
Current sensor
Energy output pulse interface

One-phase residential active and reactive energy meter


Four-quadrant
Fast Fourier Transform
IEC50470-3 class C, 0.5 % (same for active and reactive energy)
230 VAC 20 %
0 80 A (5 A is nominal current, dynamic range is up to 105 A)
50 Hz 6
400, 500, 1000, 1250, 2000, 2500, 5000, 10000, 20000, 50000,
100000
V, A, kW, VAr, VA, kWh (import / export), kVArh (import / export),
Hz, THD, power factor, time, date
Voltage divider
Shunt resistor down to 200
Two red LEDs (active and reactive energy)

User interface (HMI)

128-segment LCD, one push-button, one user LED (red)

Tamper detection

Two hidden buttons (terminal area and main cover)

Functionality

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


2

Freescale Semiconductor, Inc.

MKM34Z256 series MCU

Table 1. MKM34Z256 one-phase power meter specification


IEC1107 infrared interface

4800 / 8-N-1 FreeMASTER interface

Isolated RS232 serial interface (optional only)

14400 / 8-N-1 FreeMASTER interface

Optoisolated pulse output (optional only)

Optocoupler (assigned to active or reactive energy)

Arduino shield modules (optional only)


Bluetooth
WiFi
External NVMs (optional only)
Flash
EEPROM
Internal battery
Power consumption @ 3.3 V and 22C:
Normal mode (powered from mains)
Standby mode (powered from battery)
Power-down mode (powered from battery)
1)

HC-05 RF wireless Bluetooth Bee V2.0 module + XBee V03 shield


Arduino WiFi shield, type A000058
W25X20CLSN, 256 KB
CAT25040VE, 4 KB
1/2AA, 3.6 V Lithium-Thionyl Chloride (Li-SOCI2) 1.2 Ah
14.6 mA 1)
83 A (transition from normal to power-down, duration only 3 sec.)
2.0 A (both covers closed, no tampering)

Valid for CORECLK = 47.972352 MHz and without any plugin communication module

2. MKM34Z256 series MCU


Freescales MKM34Z256 series MCU is based on the 90-nm process technology. It has on-chip
peripherals, computational performance, and power capabilities to enable the development of a low-cost
and highly integrated power meter (see Figure 1). It is based on the 32-bit ARM Cortex-M0+ core, with
CPU clock rated up to 75 MHz. The analog measurement frontend is integrated on all devices; it
includes a highly accurate 24-bit Sigma Delta ADC, PGA, high-precision internal 1.2 V voltage
reference (Vref), phase shift compensation block, 16-bit SAR ADC, a peripheral crossbar (XBAR),
programmable delay block (PDB), and a memory-mapped arithmetic unit (MMAU). The XBAR module
acts as a programmable switch matrix, enabling multiple simultaneous connections of internal and
external signals. An accurate Independent Real-Time Clock (IRTC) with passive and active tamper
detection capabilities is also available on all devices.
In addition to high-performance analog and digital blocks, the MKM34Z256 series MCU was designed
with an emphasis on achieving the required software separation. It integrates hardware blocks,
supporting the distinct separation of the legally relevant software from other software functions.
The hardware blocks controlling and/or checking the access attributes include:
ARM Cortex-M0+ core
DMA controller module
Miscellaneous control module
Memory protection unit
Peripheral bridge
General-purpose input / output module

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

Basic theory

Figure 1. KM3x_256 MCUs block diagram

The MKM34Z256 devices are highly capable and fully programmable MCUs, with application software
driving the differentiation of the product. Currently, the necessary peripheral software drivers, metering
algorithms, communication protocols, and a vast number of complementary software routines are
available directly from semiconductor vendors or third parties. Because the MKM34Z256 MCUs
integrate a high-performance analog frontend, communication peripherals, hardware blocks for software
separation, and are capable of executing a variety of ARM Cortex-M0+ compatible software, they are
ideal components for development of residential, commercial, and light industrial electronic power
meter applications.

3. Basic theory
The critical task for a digital processing engine or an MCU in an electricity-metering application is the
accurate computation of the active energy, reactive energy, active power, reactive power, apparent
power, RMS voltage, and RMS current. The active and reactive energies are sometimes referred to as
MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015
4

Freescale Semiconductor, Inc.

Basic theory

the billing quantities. The remaining quantities are calculated for informative purposes, and they are
referred to as non-billing. A description of the billing and non-billing metering quantities and calculation
formulas follows.

3.1. Active energy


The active energy represents the electrical energy produced, flowing, or supplied by an electric circuit
during a time interval. The active energy is measured in the unit of Watt Hours (Wh). The active energy
in a typical one-phase power meter application is computed as an infinite integral of the unbiased
instantaneous phase voltage u(t) and phase current i(t) waveforms.
Eq. 3-1

3.2. Reactive energy


The reactive energy is given by the integral (with respect to time) of the product of voltage and current,
and the sine of the phase angle between them. The reactive energy is measured in the unit of VoltAmpere-Reactive Hours (VARh). The reactive energy in a typical one-phase power meter is computed
as an infinite integral of the unbiased instantaneous shifted phase voltage u(t-90) and phase current i(t)
waveforms.
Eq. 3-2

3.3. Active power


The active power (P) is measured in Watts (W), and it is expressed as a product of the voltage and the
in-phase component of the alternating current. The average power of any whole number of cycles is the
same as the average power value of just one cycle. Therefore, we can easily find the average power of a
very long-duration periodic waveform simply by calculating the average value of one complete cycle
with period T.
Eq. 3-3

3.4. Reactive power


The reactive power (Q) is measured in units of volt-amperes-reactive (VAR), and it is a product of the
voltage and current, and the sine of the phase angle between them. The reactive power is calculated in
the same manner as the active power, but, in the reactive power, the voltage input waveform is shifted
90 degrees with respect to the current input waveform.
Eq. 3-4

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

Basic theory

3.5. RMS current and voltage


The Root Mean Square (RMS) is a fundamental measurement of the magnitude of an alternating signal.
In mathematics, the RMS is known as the standard deviation, which is a statistical measure of the
magnitude of a varying quantity. The standard deviation measures only the alternating portion of the
signal, as opposed to the RMS value, which measures both the direct and alternating components.
In electrical engineering, the RMS or effective value of a current is, by definition, such that the heating
effect is the same for equal values of alternating or direct current. The basic equations for a
straightforward computation of the RMS current and RMS voltage from the signal function are as
follows:
Eq. 3-5

Eq. 3-6

3.6. Apparent power


The total power in an AC circuit (both absorbed and dissipated) is referred to as the total apparent power
(S). The apparent power is measured in the units of volt-amperes (VA). For any general waveforms with
higher harmonics, the apparent power is given by the product of the RMS phase current and RMS phase
voltage.
Eq. 3-7

For sinusoidal waveforms with no higher harmonics, the apparent power can also be calculated using the
power triangle method, as a vector sum of the active power (P) and reactive power (Q) components.
Eq. 3-8

For a better accuracy, use Eq. 3-7 to calculate the apparent power of any general waveforms with higher
harmonics. In purely sinusoidal systems with no higher harmonics, both Eq. 3-7 and Eq. 3-8 provide the
same results.

3.7. Power factor


The power factor of an AC electrical power system is defined as the ratio of the active power (P)
flowing to the load to the apparent power (S) in the circuit. It is a dimensionless number ranging from 1
to 1.
Eq. 3-9

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


6

Freescale Semiconductor, Inc.

Hardware design

where angle
system.

is the phase angle between the current and voltage waveforms in the sinusoidal

Circuits containing purely resistive heating elements (filament lamps, cooking stoves, and so on) have a
power factor of one. Circuits containing inductive or capacitive elements (electric motors, solenoid
valves, lamp ballasts, and others) often have a power factor below one.

3.8. Total Harmonic Distortion


Total Harmonic Distortion (THD) is the summation of all harmonic components of the voltage or
current waveform, compared against the fundamental component of the voltage or current waves. The
following equation shows the calculation of the THD of a voltage signal:

Eq. 3-10

A similar formula can be applied for the calculation of a current signal. In both cases, the end result is a
percentage, comparing the harmonic components to the fundamental component of a signal. The higher
the percentage is, the more distortion is present in the mains signal.
The MKM34Z256 one-phase power meter reference design uses FFT-based metering algorithm [2] [3].
This particular algorithm calculates the billing and non-billing quantities, according to the formulas
given in this section. The algorithm requires only instantaneous voltage and current samples to be
provided at constant sampling intervals. This sampling process should provide a power-of-two
(or integer) number of samples during one input signal period. After modifying the application software,
it is also possible to use the filter-based metering algorithm, whose computing process is completely
different [4].

4. Hardware design
This section describes the power meter electronics, which are divided into three separate parts:
Power supply
Digital circuits
Analog signal-conditioning circuits
The power supply part is comprised of an 85 265 V AC / DC SMPS, low-noise 3.6 V linear regulator,
and power management. This power supply topology has been chosen to provide low-noise output
voltages for supplying the power meter electronics. A simple power-management block is present, and it
works autonomously; it supplies the power meter electronics from either the 50 Hz (60 Hz) mains or the
3.6 V Li-SOCI2 battery, which is also integrated. The battery serves as a backup supply in cases when
the power meter is disconnected from the mains, or when the mains voltage drops below 85 V AC. For
more information, see Power supply.
The digital part can be configured to support both basic and advanced features. The basic configuration
is comprised of only the circuits necessary for power meter operation; that means MCU
(MKM34Z256VLL7), debug interface, LCD interface, LED interface, IR (IEC1107), isolated opencollector pulse output, isolated RS232, push-button, and tamper detection. In contrast to the basic
MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015
Freescale Semiconductor, Inc.

Hardware design

configuration, all the advanced features are optional, and require the following additional components to
be populated: 256 KB SPI Flash for firmware upgrade, 4 KB SPI EEPROM for data storage, and
Arduino / FRDM interfaces for wireless communication and remote monitoring. For more information,
see, Digital circuits.
The MKM34Z256 devices enable differential analog signal measurements with common mode reference
of up to 0.8 V and input signal range of 250 mV. The capability of the device to measure analog
signals with negative polarity brings a significant simplification to the phase current and phase voltage
sensors hardware interfaces (see Analog circuits).
The power meter electronics were created using a four-layer printed circuit board (PCB). We chose the
more expensive four-layer PCB (when compared to a cheaper two-sided one) to validate the accuracy of
the 24-bit SD ADC on the metering hardware optimized for measurement accuracy. Figure 29 and
Figure 30 show the top and bottom views of the power meter PCB, respectively.

4.1. Power supply


You can use the 85 265 V AC / DC SMPS, which is directly populated on the PCB (see Figure 28), or
any other modules with different power supply topologies. If a different AC / DC power supply module
is used, then the AC (input) side of the module must be connected to the JP3 and JP4, and the DC
(output) side to the JP5 and JP6. The output voltage of the suitable AC / DC power supply module must
be 5.0 V 5 %.
The reference design is prepopulated with the 85 265 V AC / DC SMPS power supply, based on the
LNK306DN. This SMPS is not isolated, and it is capable of delivering continuous current of up to
360 mA at 5 V [5]. The SMPS supplies the SPX3819 low-dropout adjustable linear regulator, which
regulates the output voltage (VPWR) using two resistors (R35 and R36), according to the following
equation:
Eq. 4-1

The resistor values (R36 = 45.3 k and R35 = 23.7 k) are chosen to produce a regulated output
voltage of 3.6 V. The following supply voltages are all derived from the regulated output voltage
(VPWR):
VDD digital voltage for the MCU and digital circuits
VDDA analog voltage for the MCUs 24-bit SD ADC and 1.2 V VREF
SAR_VDDA analog voltage for the MCUs 16-bit SAR ADC
The regulated output voltage also supplies the circuits with a higher current consumption: 256 KB SPI
Flash (U3), isolated RS232 interface (U5 and U6), isolated pulse output (U4), and potential Arduino /
FRDM plugin modules attached to the J10 power connector. All these circuits operate in the Normal
mode, when the power meter is connected to the mains.
The battery voltage (VBAT) is separated from the regulated output voltage (VPWR) using the D11 and
D12 diodes. When the power meter is connected to the mains, then the electronics are powered through
the bottom D12 diode from the regulated output voltage (VPWR). If the power meter is disconnected
from the mains, then the D12 and upper D11 diodes start conducting, and the MCU, including a few
additional circuits operating in the Standby and Power-down modes, are supplied from the battery
MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015
8

Freescale Semiconductor, Inc.

Hardware design

(VBAT). The switching between the mains and battery voltage sources is performed autonomously, with
a transition time that depends on the rise and fall times of the regulated output supply (VPWR).
The analog circuits within the MCU usually require decoupled power supplies for the best performance.
The analog voltages (VDDA and SAR_VDDA) are decoupled from the digital voltage (VDD) by the
chip inductors L3 and L4, and the small capacitors next to the power pins (C34 C39). Using chip
inductors is especially important in mixed-signal designs, such as power meter applications, where
digital noise can disrupt precise analog measurements. The L3 and L4 inductors are placed between the
analog supplies (VDDA and SAR_VDDA) and the digital supply (VDD) to prevent the noise from the
digital circuitry from disrupting the analog circuitries.
NOTE
The digital and analog voltages VDD, VDDA, and SAR_VDDA are lower
than the regulated output voltage VPWR, due to a voltage drop on the
diode D12 (0.35 V).

4.2. Digital circuits


All the digital circuits are supplied from the VDD, VPWR, VAUX1, and VAUX2 voltages. The digital
voltage (VDD), which is backed up by the 1/2AA 3.6 V Li-SOCI2 battery (BT1), is active even when the
power meter electronics are disconnected from the mains. It powers the MCU (U2), three LEDs, and
also other two parts that should be switched off during the standby modes: isolated RS232 interface (U5,
U6), and isolated open-collector pulse output interface (U4). The regulated output voltage (VPWR)
powers the digital circuits that can be switched off during the Standby and Power-down operating modes
anyway. These are the 256 KB SPI Flash memory (U3) and the Arduino / FRDM plugin module (J10
power connector). To optimize power consumption of the meter electronics in the Standby and
Power-down modes, the auxiliary voltages (VAUX1, VAUX2) are sourced from two pins of the MCU.
The MCU uses these pins to power the 4 KB SPI EEPROM (U1) and the IR interface (Q1).

4.2.1. MKM34Z256VLL7
The MKM34Z256VLL7 MCU (U2) is the most noticeable component on the metering board
(see Figure 26). The following components are required for proper operation of this MCU:
Filtering ceramic capacitors C1, C3 C8
LCD charge pump capacitors C19 C22
External reset filters C15 and R17
32.768-kHz crystal Y1
The LCD (DS1) is an indispensable part of the power meter. Connector J4 is the SWD interface for
MCU programming.
CAUTION
The debug interface (J4) is not isolated from the mains supply. Use only
galvanically isolated debug probes for programming the MCU when the
power meter is supplied from the mains supply.

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

Hardware design

4.2.2. Output LEDs


The MCU uses two timer channels to control two bright red LEDs (see Figure 2); D2 for active energy,
and D3 for reactive energy. These LEDs are used at the time of the meter calibration or verification.
The timers outputs are routed to the respective device pins (PXBAR_OUT7 and PXBAR_OUT8)
through the peripheral crossbar module a programmable switch matrix, interconnecting internal and
external logic signals. The timers are chosen to produce a low-jitter and high-dynamic range pulse
output waveform; the method for low-jitter pulse output generation using software and timer is protected
by a patent.
D1
HSMS-C170

USER_LED

R3
3.9K

KWH_LED

D2
R7
WP7104LSRD
390.0 C
A

D3
R8
WP7104LSRD
A
KVARH_LED 390.0 C

VDD

VDD

VDD

Figure 2. Output LEDs control

The SMD user LED (D1) is driven by software through the output pin (PXBAR_OUT4). It blinks when
the power meter enters the calibration mode, and turns solid after the power meter is calibrated and
operating normally. All the output LEDs can work only in the Normal operation mode. These LEDs can
be also seen as a simple unidirectional communication interface.

4.2.3. 256 KB SPI Flash


The 256 KB SPI Flash (W25X20CLSN) can be used to store a new firmware application, and/or to load
profiles. The connection of the Flash memory to the MCU is made through the SPI1 module, as shown
in Figure 3.
The SPI1 module of the MKM34Z256VLL7 device supports communication speed of up to 12.5 Mbit/s.
This memory is powered from the regulated output voltage (VPWR), hence it operates when the power
meter is powered from the mains (Normal operation mode).
VPWR
8
U3
SPI1_MOSI 5
SPI1_SCK

R22 10K

DNP

FLASH_SS

C24
0.1UF
DNP

VCC
DI/IO0

DO/IO1

2 SPI1_MISO

CLK
CS

HOLD

VPWR

WP
GND
DNP

W25X20CLSNIG

GND

GND

Figure 3. 256 KB SPI Flash control

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


10

Freescale Semiconductor, Inc.

Hardware design

4.2.4. 4 KB SPI EEPROM memory


The 4 KB SPI EEPROM memory (CAT25040VE) can be used for parameter storage (backup of the
calibration parameters). The connection of the EEPROM memory to the MCU is made through the SPI0
module, as shown in Figure 4. Due to a very small supply current of this memory, it is powered directly
by the PTG1 pin of the MCU (VAUX1). Powering from the pin enables the MCU to switch off the
memory, and thus minimize current consumption in the Standby mode. The maximum communication
throughput is limited by the CAT25040VE device to 10 Mbit/s. The memory can work in both the
Normal and Standby operation modes.
VAUX1
TP1
8
SPI0_MOSI 5
R1 10K

1
3
7

C2
0.1UF
GND

SPI0_SS

SPI0_SCK 6

U1
SI

VCC

CS
WP

SO

SPI0_MISO

HOLD
SCK

VSS
4

CAT25040VE

GND

Figure 4. 4 KB SPI EEPROM control

4.2.5. Arduino / FRDM interfaces


The expansion headers J7 J11 (see Figure 5) are used to interface the power meter to the Arduino /
FRDM modules. Currently, they support only the Arduino Bluetooth XBee V03 + HC-05 module
(see Figure 6). In the future, they will also support the Arduino WiFi shield based on the 802.11b/g
communication, and also some of the Freescale Freedom wireless modules, such as the power line
modem. Headers J7, J8, J9, and J11 provide the interconnection, while header J10 provides power
supply from the MCU to the module itself. All of these modules accept supply voltage of 3.6 V or 5.0 V
with a maximum continuous current of up to 320 mA. Each individual Arduino shield needs different
MCU peripherals, therefore the J7 J9 connectors support connections to the SPI1, UART1, and the
I2C1 peripherals, as well as to several I / O lines for modules reset, handshaking, and control.

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

11

Hardware design

1
2

J5
HDR_1X2

VPWR

AREF

PTC1 [3]
PTF7/CLKOUT [3]
UART1_RTS [3]
UART1_CTS [3]
PTG0/TMR1 [3]
PTI0 [3]
UART1_TX [3]
UART1_RX [3]

GND
SPI1_SCK [3]
SPI1_MISO [3]
SPI1_MOSI [3]
FRDM_SS[3]
PTE5/TMR3 [3]
PTD0 [3]

20
18
16
14
12
10
8
6
4
2

16
14
12
10
8
6
4
2

[3] I2C1_SDA
[3] I2C1_SCL

J8

J7
CON_2X10

15
13
11
9
7
5
3
1

19
17
15
13
11
9
7
5
3
1

CON 2X8

Arduino/FRDM digital LSB

Arduino/FRDM digital MSB

PTI0 [3]
PTG0/TMR1 [3]

Arduino/FRDM power

1
3
5
7
9
11

HDR 2X3
Arduino ICSP

J11

J13
HDR_1X2

VPWR

VCC_3V6

GND
VCC_5V

1
2

1
2

VOUT
[3] RF_RST

SPI1_MOSI

GND

2
4
6
8
10
12

2
4
6
8
10
12
14
16

CON 2X6 SKT


J12
HDR_1X2

2
4
6

SPI1_MISO 1
SPI1_SCK 3
5
RF_RST

1
3
5
7
9
11
13
15
J10
CON 2X8

VOUT

J9

Arduino/FRDM analog

ADC0_SE5
ADC0_SE7
ADC0_SE8
ADC0_SE9

[3]
[3]
[3]
[3]

Figure 5. Arduino / FRDM control

Figure 6. Extension for the Arduino Bluetooth communication

NOTE
Only one Arduino shield or Freescale Freedom plugin can be operated at
one time inside the meter.

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


12

Freescale Semiconductor, Inc.

Hardware design

4.2.6. Isolated open collector pulse output interface


Figure 7 shows the schematic diagram of the Energy Open Collector (EOC) pulse output. This can be
used for switching loads with a continuous current of up to 50 mA, and with a collector-to-emitter
voltage of up to 70 V. The interface is controlled through the peripheral crossbar (PXBAR_OUT2) pin
of the MCU, and hence it can be controlled by a variety of internal signals, for example timer channels
generating pulse outputs. The isolated open collector pulse output interface is accessible on connector
J6. This interface can be assigned to the active or reactive energy LED only using the FreeMASTER
menu, by setting the EOC OUTPUT parameter in the SERVICE menu (see also FreeMASTER
visualization). The default configuration is assigning it to the kWh output.
U4
R23
[3] EOC

390.0
DNP

VDD

1
2

HDR 1X2
DNP

DNP

J6

SFH6106-4

Figure 7. Open collector pulse output control

NOTE
The J6 output connector is not bonded to the meters enclosure.
Therefore, the described interface is primarily used at the time of
development (uncovered equipment).

4.2.7. IR interface (IEC1107)


The power meter has a galvanically isolated optical communication port, as per IEC 1107 / ANSI /
PACT, so that it can be easily connected to a common handheld meter-reading instrument for data
exchange. The IR interface is driven by the LPUART. Due to a very low supply current of the NPN
phototransistor (Q1), it is powered directly from the PTD5 (VAUX2) pin of the MCU. Powering from
the pin enables the MCU to switch off the phototransistor circuit, and thus minimize current
consumption in the Standby mode. The IR interface schematic part is shown in the following figure:
TP10
R24
TP4

VAUX2

10K

1.0K

Q1
OP506B

C25
2200PF

R25
[3] LPUART_RX

TP5

GND

[3] LPUART_TX

GND
D4

R26 680

~2.65mA @ 3.3V

C
TSAL4400
GND

Figure 8. IR control

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

13

Hardware design

NOTE
Alternatively, this interface can be also used for waking up the meter
(from the Power-down to the Standby mode) by an external optical probe.
However, this feature has an impact on increasing the current consumption
in both operation modes.

4.2.8. Isolated RS232 interface


This communication interface is used primarily for real-time visualization using the FreeMASTER
tool [6]. The communication is driven by the UART3 module of the MCU. The communication is
optically isolated using the optocouplers U5 and U6. Besides the RXD and TXD communication signals,
the interface implements two additional control signals, RTS and DTR. These signals are usually used
for transmission control, but this function is not used in the application. As there is a fixed voltage level
on these control lines generated by the PC, it is used to power the secondary side of the U5 optocoupler
and the primary side of the U6 optocoupler. The communication interface, including the D5 D7, C26,
and R27 R30 components, required to power the optocouplers from the transition control signals, is
shown in Figure 9.
U5
R27
[3] UART3_TX

390.0
DNP
VDD

R28 4.7K
DNP

R29
1.0K
DNP
3

R30 470

C26
2.2uF
DNP

U6
[3] UART3_RX

SFH6106-4
DNP

D5

MMSD4148T1G
DNP
D6
MMSD4148T1G
DNP

J14
1
3
5
7
9

2
4
6
8
10

DNP
HDR_2X5
DNP
Max. 19200 Bd
4
GND

SFH6106-4
DNP

D7

MMSD4148T1G
DNP

Figure 9. RS232 control

NOTE
The J14 output connector is not bonded to the meters enclosure.
Therefore, the described interface is primarily used at the time of
development (uncovered equipment).

4.3. Analog circuits


An excellent performance of the metering AFE, including external analog signal conditioning, is crucial
for the power meter application. Due to the high dynamic range of the current measurement (typically
700:1) and the relatively low input signal range (from microvolts to several tens of millivolts), the phase
current measurement is utmost critical. All analog circuits are described in the following subsections.

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


14

Freescale Semiconductor, Inc.

Hardware design

4.3.1. Phase current measurement


Although the MKM34Z256 one-phase power meter reference design is optimized for shunt resistors, a
variety of current transformers and Rogowski coils can also be used. The only limitations are the sensor
output signal range (which must be within 0.5 V peak) and the dimensions of the enclosure.
The interface of a current sensor to the MKM34Z256VLL7 device is very straightforward; only the
anti-aliasing low-pass filters, attenuating signals with frequencies greater than the Nyquist frequency,
must be populated on the board (see Figure 10). The cutoff frequency of the analog filters implemented
on the board is 72.3 kHz; such a filter has the attenuation of 32.56 dB at Nyquist frequency of
3.072 MHz.
R11

SDADP0

L_OUT

22
C14
0.1UF

J2
2
1

C16

L_IN

GND

0.1UF
R19

SDADM0

B
A
CON_2_TB
DNP

22

Figure 10. Phase currents signal conditioning circuit

4.3.2. Phase voltage measurement


A simple voltage divider is used for the line voltage measurement. Due to power dissipation, it is better
to design this divider from several resistors connected serially (see Figure 11). One half of these
resistors consists of R13, R14, R15, and R16, the second half consists of resistor R12. The resistor
values were selected to scale down the 325.26 V peak input line voltage to the 0.2113 V peak input
signal range of the 24-bit SD ADC. The voltage drop and power dissipation on each of the R13-R16
MELF0204 resistors are below 57.5 V and 22 mW, respectively. The anti-aliasing low-pass filter of the
phase voltage measurement circuit is set to a cutoff frequency of 27.22 kHz. Such anti-aliasing filter has
an attenuation of 41.05 dB at Nyquist frequency of 3.072 MHz.
SDADP2

VIN[4]

C13
0.015 UF

GND
SDADM2
C17
0.015 UF

R12

R13

R14

R15

R16

390

150K 150K 150K 150K

Max. 22mW power losses and 57.5 V


voltage drop per resistor (@230 V)

R20
390

Phase voltage scaling:


325.269 Vpp equals 211.28mVpp

Use 0.1% 50ppm MELF0204 resistors


GND

Figure 11. Phase voltages signal conditioning circuit

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

15

Software design

4.3.3. Auxiliary measurements


Figure 12 shows the part of the schematic diagram of the battery voltage divider. This resistor divider
scales down the battery voltage to the input signal range of the 16-bit SAR ADC. The 16-bit SAR ADC
is configured for operation with an internal 1.0 V PMC band gap reference. The resistor values R9 =
1.6 M and R10 = 4.7 M were calculated to enable the measurement of the battery voltage up to
3.94 V, whilst keeping the battery discharge current low. For the selected resistor values, the current
flowing through the voltage divider is 571 nA at 3.6 V.
C12 0.1UF

VBAT_MSR

R9 1.6M
GND
R10 4.7M
VBAT

Figure 12. Battery voltage divider circuit

Status information on whether the power meter is connected or disconnected from the mains is critical
for transitioning between the power meter operating modes. The presence of the mains AC voltage is
signaled by the logic signal PWR_MSR (see Figure 13) that is derived from the regulated output
voltage (VPWR). If the power meter is connected to the mains (VPWR = 3.6 V), the PWR_MSR
transitions to 3.15 V, and the software reads this signal from the PTC5 pin as logic 1. On the other hand,
a power meter disconnected from the mains is read by the MCU device as logic 0.
R4

47K

VPWR
R5 330K
GND
C11 0.1UF
PWR_MSR

Figure 13. Supply voltage divider circuit

5. Software design
This section describes the software application of the MKM34Z256 one-phase power meter reference
design. The software application consists of measurement, calculation, calibration, user interface, and
communication tasks.

5.1. Block diagram


The application software is written in the C language, and compiled using the IAR Embedded
Workbench for ARM (version 7.40.1), with high optimization for execution speed. The software
application is based on the MKM34Z256 bare-metal software drivers [7] and the FFT-based metering
algorithm library [2].
The software transitions between operating modes, performs a power meter calibration after the first
startup, calculates all metering quantities, controls the active and reactive energies pulse outputs,
controls the LCD, stores and retrieves parameters from the NVMs, and enables application remote
monitoring and control. The application monitoring and control is performed using FreeMASTER.

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


16

Freescale Semiconductor, Inc.

Software design

The following figure shows the software architecture of the power meter, including interactions of the
software peripheral drivers and application libraries with the application kernel. All tasks executed by
the MKM34Z256 one-phase power meter software are briefly explained in the following subsections.
Communications and
FreeMASTER
IR interface
(IEC1107)

8x16 Segment LCD


Display

LPUART
Driver
Segment LCD
Controller Driver

FreeMASTER
Protocol Library
Isolated RS232
interface

HMI

Pulse Output Generation

kWh and kVARh


LEDs

GPIO & PORT


Drivers
Quad Timer (TMR)
Driver

UART3
Driver

Application
Kernel

UART1
Driver

Arduino/FRDM
shield interfaces

I2C1
Driver

Calibration Task
(executes after first POR)

SPI1
Driver

Operating Mode Control


(executes after each POR)

Data Processing
(executes periodically)

Clock Management

32.768 kHz External


Crystal

User LED

Independent Real
Time Clock (IRTC)
Driver

Calculation Billing and Nonbilling Quantities


(executes periodically)

Phase-Locked Loop
(PLL) Driver

Tamper monitoring
(event triggered execution)

Peripheral Crossbar
(XBAR) Driver

Isolated opencollector output

Phase Voltage Frequency Measurement


Quad Timer (TMR)
Driver

High-Speed
Comparator (CMP)
Driver

Peripheral Crossbar
(XBAR) Driver

Analog Measurements and Energy Calculations


FFT-Based
Metering Library

Analogue Front-End
(AFE) Driver

Auxiliary Measurements
Analog-to-Digital
Converter (ADC)
Driver

Phase Voltages and


Currents Signal
Conditioning Circuit

Battery Voltage
Conditioning Circuit

Supply Voltage
Conditioning Circuit

HMI Control
(execute periodically)

Device Initialization and Security


Communication Tasks
(event triggered execution)

Tampering

Tampers interface

Parameter Management
Tasks
(event triggered execution)

GPIO & PORT


Drivers

Watchdog (WDOG)
Driver

Voltage Reference
(VREF) Driver

System Integration
Module (SIM) Driver

Low Leakage
Wakeup (LLWU)
Driver

Power Management

Application
Reset

System Mode
Controller (SMC)
Driver

Power Management
Controller (PMC)
Driver

Reset Controller
Module (RCM) Driver

Low Power Timer


(LPTMR) Driver

Bare-metal drivers

Libraries

Non-volatile Memory
(NVM) Driver

EEPROM Library
SPI1 Driver

SPI0 Driver
Flash 1 KB sector
(0x1FC00-0x1FFFF)

Application SW

Parameter Storage

W25X20CLSN
256 KB SPI flash

CAT25040VE
4 KB SPI EEPROM

Figure 14. Software architecture

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

17

Software design

5.2. Software tasks


The software tasks are part of the application kernel. Theyre driven by events (interrupts) generated
either by the on-chip peripherals or the application kernel. The list of all tasks, trigger events, and calling
periods is summarized in the following table:
Table 2.
Task name

Description

Source file(s)

Controls
transitioning
Operating mode
between power
control
meter operating
modes
Reads non-billing
quantities, updates
LCD, refreshes
watchdog,
HMI control
measures line
frequency
Reads user button
state

1phmetFFT.c
1phmetFFT.h

List of software tasks


IRQ

Calling

priority

period

device reset

after every
device reset

lptmr_callback

LPTMR interrupt

Level 3
(lowest)

periodic
500 ms

button_callback

PTD7 falling edge


interrupt

afech2_callback

AFE CH2 conversion


complete IRQ

Level 0
(highest)

periodic
166.6 s

Level 2

periodic
20 or 16.6 ms
(50 or 60 Hz)

Function(s) name

Trigger source

main

Level 3
asynchronous
(lowest)

Data
processing

Reads digital values


from the AFE

Calculation

Zero-cross
detection,
calculation billing
and non-billing
quantities

cmp_callback

CMP1 interrupt (rising


edge)

Pulse
generation

LEDs dynamic pulse


output generation

qtim1_callback
qtim2_callback

TMR1 or TMR2 IRQ


compare flag

Level 0
asynchronous
(highest)

Tamper
monitoring

Reads tampers
state

irtc_callback

TAMPER1 or
TAMPER2 active low

Level 3
asynchronous
(lowest)

Power meter
calibration

Performs power
meter calibration

calib_afe

device reset

FreeMASTER
communication

Application
monitoring and
control
Recorder

calib.c
calib.h

freemaster_*.c
freemaster_*.h

after the first


device reset1)

LPUART or UART3 or
UART1 Rx / Tx
Level 1 asynchronous
interrupts
AFE CH2 conversion Level 0
periodic
FMSTR_Recorder
166.6 s
complete IRQ
(highest)
FMSTR_Init

Reads parameters
from the Flash and
CONFIG_Read
from the external
CAT25_Read
EEPROM
config.c
Parameter
Writes parameters
config.h
management
to the Flash and to
cat25.c
CONFIG_Save
the external
cat25.h
CAT25_Write
EEPROM
Writes backup to the
CAT25_Write
external EEPROM
1) A special load point must be applied by the test equipment

device reset

after every
device reset

after successful
calibration, controlled
by user, or switching
off

asynchronous

LPTMR interrupt

Level 3
(lowest)

periodic
10 minutes

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


18

Freescale Semiconductor, Inc.

Software design

5.2.1. Power meter calibration


The power meter is calibrated using a special test equipment [1]. The calibration task runs whenever a
non-calibrated power meter is connected to the mains. The user LED flashes periodically at this time.
The running calibration task measures the phase voltage and phase current signals generated by the test
equipment; it scans for a 230 V phase voltage and 5.0 A phase current waveforms with a 45 degree
phase shift. The voltage and current signals must be the first harmonic only. All these values should be
precise and stable during the calibration itself; the final precision of the power meter strongly depends
on it. If the calibration task detects such a load point, then the calibration task calculates the calibration
gains and phase shift using the following equations:
Eq. 5-1
Eq. 5-2
Eq. 5-3

where:
and

are calibrated gains

is the calculated phase shift caused by the parasitic inductance of the shunt resistor
,

are quantities measured by the non-calibrated meter

The calibration task terminates by storing the calibration gains and phase shifts into two non-volatile
memories; the internal Flash memory and the external EEPROM memory (backup storage). The whole
calibration process is terminated by resetting the MCU. The recalibration of the power meter can be
reinitiated later using the FreeMASTER tool.
NOTE
The user LED is permanently turned off after successful calibration.

5.2.2. Operating mode control


The transitioning of the power meter electronics between the operating modes helps to maintain a long
battery lifetime. The power meter software application supports the following operating modes:
Normal (electricity is supplied, the power meter is fully functional)
Standby (electricity is disconnected, and you can list through the menus)
Power-down (electricity is disconnected with no user interaction)
The following figure shows the transitioning between the supported operating modes. After the battery
or the mains is connected, the power meter transitions to the Device Reset state. If the electricity is
applied, then the software application enters the Normal mode, and all software tasks including
calibration, measurements, calculations, HMI control, parameter storage, pulse generation, tamper
management, and communication, are executed. In this mode, the MKM34Z256VLL7 device runs in the
RUN mode. The system core and Flash clock frequency is generated by the frequency-locked loop
MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015
Freescale Semiconductor, Inc.

19

Software design

(FLL), and it is 47.972 MHz. The AFE clock frequency is generated by the phase-locked loop (PLL),
and it is 12.288 MHz. The power meter electronics consume 14.6 mA in the Normal mode1.
pressing user
button refreshes
3 s timeout

Stand-By
Mode

electricity
applied

Device
Switched
OFF

inserted battery
or electricity
applied

electricity
disconnected and
3 s timeout elapsed

electricity disconnected
or user button pressed

Device
Reset

electricity
applied or
user button
pressed

battery supply
present

Power-down
Mode

electricity electricity
applied disconnected
battery removed
and electricity
disconnected

Normal
Mode

Figure 15. Operating modes

If the electricity is not applied, then the software application enters the Standby mode first. This mode
transitions between the Normal mode and the Power-down mode with a duration of only three seconds.
The power meter runs from the battery during this mode, and you can list through the menus. All
software tasks are stopped, except for the HMI control. In this mode, the MKM34Z256VLL7 device
functions in the VLPR mode. The system clock frequency is scaled down to 125 kHz from the 4-MHz
internal relaxation oscillator. Because of the slow clock frequency, the limited number of enabled onchip peripherals, and the Flash module operating in the low-power RUN mode, the power consumption
of the power meter electronics is approximately 83 A.
When the power meter runs from the battery but you dont list through the menus, then the software
transitions automatically to the Power-down mode. The MKM34Z256VLL7 device is forced to enter the
VLLS0 mode, where the recovery can be triggered by pressing the user button or connecting the mains.
The Power-down mode is characterized by a battery current consumption of 2.0 A.

5.2.3. Data processing


Reading the phase voltage and phase current samples from the analog frontend (AFE) occurs
periodically every 166.6 s. This task runs on the highest priority level, and it is triggered
asynchronously when the AFE result registers receive new samples.
This task reads the phase voltage and phase current samples from four AFE result registers, and writes
these values to the buffers, to be used by the calculation task.

This is valid for CORECLK = 47.972 MHz, and without any RF communication plugin module.
MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015

20

Freescale Semiconductor, Inc.

Software design

5.2.4. Calculations
This separate task monitors the mains zero-crossings, which is necessary for starting the main
calculation process, and for computing both the billing (energies) and the non-billing quantities. This is
done periodically at the beginning of each signal period. Therefore, the execution period of this task
depends on the input signal frequency.
At this time, all circle buffers are filled up with the AFE results from the previous signal period.
Firstly, the calculation task performs the interpolation using the METERLIBFFT1PH_Interpolation
function, and then it performs the non-billing quantities computation using the
METERLIBFFT1PH_CalcMain function, according to the metering algorithm used ([2] [3]). This
calculation process uses the calibration gains obtained during the calibration stage (see Power meter
calibration).
Finally, the billing quantities are computed using the METERLIBFFT1PH _CalcWattHours and
METERLIBFFT1PH _CalcVarHours functions, which also produce a low-jitter, high-dynamic range
pulse output waveform for two energy LEDs (kWh and KVArh). The energy LED driving is done by
two independent (separate) tasks.

5.2.5. HMI control


The Human Machine Interface (HMI) control task executes in a 500 ms loop on the lowest priority
(Level 3). It reads the real-time clock, calculates the mains frequency, runs the calibration task, reads all
non-billing quantities, refreshes the watchdog, and shows data on the LCD. The interaction with the user
is made through an asynchronous event, which occurs when the user button is pressed. By pressing the
user button, you are able to scroll through the menus and display all measured and calculated quantities
(see Table 4).

5.2.6. Tamper monitoring


There are two hidden mechanical push-buttons. One button is used for the terminal cover opening
detection, and the second button is used for the main cover opening detection. These asynchronous
events are read in the IRTC interrupt, stored in the memory, and shown on the LCD continuously. The
tamper event may be cleared only through the FreeMASTER menu, by applying the REMOTE
COMMAND / CLEAR TAMPER command with a proper password set (see FreeMASTER
visualization).

5.2.7. FreeMASTER communication


The FreeMASTER establishes data exchange with the PC. The communication is fully driven by the
LPUART, UART1, or UART3 Rx / Tx interrupts, which generate interrupt service calls with Level 1
priority. The assignment of the right UART port is done by the SCI_PORT program constant in the
freemaster_cfg.h file. For using the FreeMASTER on the Arduino / FRDM plugin card (see Arduino /
FRDM interfaces), the SCI_PORT constant must be set to 1. For usage on a basic isolated RS232
interface (see Isolated RS232 interface), this constant should be set to 3. For using the FreeMASTER
with an infrared interface (see IR interface (IEC1107)), this constant should be set to 4. The power
meter acts as a slave device, answering packets received from the master device (PC). The recorder
MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015
Freescale Semiconductor, Inc.

21

Application setup

function is called inside the afech2_callback interrupt service routine every 166.6 s. For more
information about using FreeMASTER, refer to FreeMASTER visualization.

5.2.8. Parameter management


The current software application uses the last 1024-byte sector of the internal MKM34Z256VLL7 Flash
memory for parameter storage. There is also an external 4 KB EPROM memory used for the same
purpose, but as a backup storage (optional only). The main purpose for using these non-volatile
memories is to save all the calibration parameters. By default, the parameters are written after a
successful calibration or before powering down, and they are read after each device reset. Storing and
reading of parameters can be also initiated through the FreeMASTER independently
(see FreeMASTER visualization).

5.3. Performance
Table 3 shows the memory requirements of the MKM34Z256 one-phase power meter software
application2.
Table 3. Memory requirements
Function

Description

Flash size

RAM size

[KB]

[KB]

Application framework

Complete application without all libraries and


FreeMASTER

20.266

4.518

FFT-based metering library

FFT-based metering algorithm library

13.448

EEPROM library

CAT25040VE EEPROM library

0.834

FreeMASTER

FreeMASTER protocol and serial communication driver

3.232

4.445

37.780

8.963

Grand total

The software application reserves about 4 KB of RAM for the FreeMASTER recorder. If the recorder is
not required, or a fewer number of variables will be recorded, you may reduce the size of this buffer by
modifying the FMSTR_REC_BUFF_SIZE constant (refer to the freemaster_cfg.h header file, line 76).
The device system clock is generated by the FLL (except for the AFE clock). In the Normal operating
mode, the FLL multiplies the clock of an external 32.768 kHz crystal by a factor of 1464, hence
generating a low-jitter system clock with a frequency of 47.972352 MHz. Such system clock frequency
is absolutely sufficient for executing a fully functional software application.

6. Application setup
Figure 16 shows the wiring diagram of the MKM34Z256 one-phase power meter.

Application is compiled using the IAR Embedded Workbench for ARM (version 7.40.1), with high optimization for
execution speed. The number of FFT samples is 64. Memory requirements are valid for the software Rev. 1.0.0.0
Alpha.
MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015
22

Freescale Semiconductor, Inc.

Application setup

Registering the active and reactive energy consumed by an external load is among the main capabilities
of the power meter. When you connect the power meter to the mains or when you press the user button,
the power meter transitions from the Power-down mode to either the Normal mode or the Standby
mode, respectively. In the Normal and Standby modes, the LCD is turned on, and it shows the last
quantity. List through the menus and display other quantities by pressing the user button. All
configuration and informative quantities accessible through the LCD are summarized in Table 4.
The signs of both powers (P and Q) in this table provide the information about the energy flow direction
(see Table 5).

Figure 16. MKM34Z256 one-phase power meter wiring diagram

Table 4. The menu item list


Value

Unit

Format

OBIS code

Auxiliary symbols

Line voltage

VRMS
ARMS
W
VAr
VA

#.##
#.###
#.## (+ forward, reverse)
#.## (+ lag, lead)
#.##
#.### (+ motor mode, generator
mode)
#.#
#.#
#.###

32.7.0

31.7.0
1.7.0
3.7.0
9.7.0
33.7.0

A
W
VA, r
VA
PF, i, c

14.7.0

thdU
thdi
Hz

Line current
Signed active power P
Signed reactive power Q
Apparent power S
Signed power factor
Total Harmonic Distortion of U
Total Harmonic Distortion of I
Frequency

%
%
Hz

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

23

FreeMASTER visualization

Table 4. The menu item list


Value
Active energy imported
Active energy exported
Reactive energy imported
Reactive energy exported
Date
Time
Software version + serial
number

Unit

Format

kWh

######.###

kVArh

######.###

MMMDD:YYYY+ WDAY
HH:MM:SS
#.#.#.# + ####

OBIS code

Auxiliary symbols

1.8.0
2.8.0
3.8.0
4.8.0

kWh
kVAh, r

vEr

Table 5. Energy flow direction


Quadrant

Power factor

Powers

Mode

I to U phase shift

+PF, i
PF, i
PF, c
+PF, c

+P, +Q

Motor mode with inductive load

Lagging current

P, +Q

Inductive acting generator mode

Leading current

P, Q

Capacitive acting generator mode

Lagging current

+P, Q

Motor mode with capacitive load

Leading current

II
III
IV

Figure 17 shows the values and special symbols on the power meter display.

Figure 17. MKM34Z256 one-phase power meter display description

Both energy LEDs (active and reactive) flash simultaneously with the internal energy counters during
the Normal operation mode. The active energy LED is the sum of both active energies (imported and
exported) and the reactive energy LED is the sum of both reactive energies (imported and exported).
All these active and reactive energy counters are periodically saved every 10 minutes into the external
EEPROM memory (backup storage). An applicable symbol for data saving flashes on the LCD at this
time. These energy quantities remain in the memory after resetting the power meter.
To remotely clear these energy counters, you must use the FreeMASTER application
(see FreeMASTER visualization) and apply the REMOTE COMMAND / CLEAR ENERGY command.

7. FreeMASTER visualization
The FreeMASTER data visualization software is used for data exchange [6]. The FreeMASTER
software running on a PC communicates with the MKM34Z256 one-phase power meter over a defined
interface. This communication is interrupt-driven, and it is active when the power meter is powered
from the mains. The FreeMASTER software enables remote visualization, parameterization, and

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


24

Freescale Semiconductor, Inc.

FreeMASTER visualization

calibration of the power meter. It runs visualization scripts, which are embedded into the FreeMASTER
project file.
There can be several types of defined interfaces used for communication between the meter itself and
the remote PC:
Infrared interface with USB-1 optical probe [8] (default interface)
Bluetooth interface (optional only) the Arduino shield [9] must be connected to the J7 J11
connectors inside the meter (see Figure 6)
Internal isolated RS232 interface (optional only, not bonded to the meters enclosure)
The FreeMASTER software running on the PC side is used for data exchange. Before running
a visualization script, the FreeMASTER software must be installed on your PC. After the installation,
you can start the visualization script by double-clicking the 1phmetFFT.pmp file in the current directory.
Once started, the following visualization script will appear on your computer screen:

Figure 18. FreeMASTER graphical user interface (GUI)

Now, you must set the proper serial communication port and communication speed in the Project /
Options / Comm menu (see Figure 19). The communication speed depends on the interface selected:
4800 Bd for the infrared interface, 9600 Bd for the Bluetooth interface, or 14400 Bd for the isolated
RS232 interface. If all the previous settings are correct, the communication between the power meter
and the PC can be initiated. To do this, click the Start / Stop communication button (the third red icon
on the upper left side of the GUI). Alternatively, you can use the CTRL+K key combination. The
message on the status bar signalizes the communication parameters and successful data exchange.

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

25

FreeMASTER visualization

Figure 19. FreeMASTER communication port settings

You can see the measured phase voltage, phase current, active, reactive, and apparent power, energies,
and additional status information of the power meter appearing on the PC screen. You can also visualize
some of the variables in a graphical representation by selecting the respective scope or recorder item
from the project tree (see the following figures).

Figure 20. FreeMASTER time domain recorder screen

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


26

Freescale Semiconductor, Inc.

FreeMASTER visualization

Figure 21. FreeMASTER frequency domain recorder screen

The visualization script enables you to monitor and parameterize the majority of the power meter
features. To eliminate inappropriate and unwanted changes, some of the key parameters are protected by
a five-digit system password (19186), accessible through the SERVICE / PASSWORD menu. These key
parameters are as follows:

Save parameters
Calibration
Clear energy
Clear tamper

All the remaining parameters and commands can be executed anytime, without the need for entering the
system password:
Read parameters
Set time and date
Set impulse number
SW reset
All the previous parameters (protected and unprotected) are accessible only through the REMOTE
COMMAND menu.
Changing the kWh or kVArh impulse number must be done by selecting an appropriate number between
400 and 100000, followed by the REMOTE COMMAND / SET IMPULSE NUMBER command (see the
following figure).

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

27

Accuracy and performance

Figure 22. FreeMASTER impulse number settings procedure

After applying impulse number settings, serial numbers settings, and isolated OC interface
configuration, it is also possible to save the changed value into the non-volatile memory of the MCU by
applying the REMOTE COMMAND / SAVE PARAMETERS command. Alternatively, this operation is
done automatically after disconnecting the power meter from the mains; there is a power failure
detection logic, which saves all necessary settings before losing the power supply inside the meter.
More advanced users can benefit from the FreeMASTERs built-in active-x interface, which serves for
exchanging data with other signal-processing and programming tools, such as Matlab, Excel, LabView,
and LabWindows.
CAUTION
You are unable to change any of the red-marked calibration values in the
Calibration section.

8. Accuracy and performance


The MKM34Z256 one-phase reference designs are fully calibrated using the test equipment
ELMA8303 [1], which comprises of a reference meter with a precision of 0.01 %. All power meters
were tested according to the EN50470-1 and EN50470-3 European standards for electronic meters of
active energy classes B and C, the IEC 62053-21 and IEC 62052-11 international standards for
electronic meters of active energy classes 2 and 1, and the IEC 62053-23 international standard for static
meters of reactive energy classes 2 and 3.
During the calibration and testing process, the power meter measured electrical quantities generated by
the test bench ELMA8303, calculated the active and reactive energies, and generated pulses on the
output LEDs; each generated pulse was equal to the active and reactive energy amount in kWh (kVArh)
/ imp. The deviations between the pulses generated by the power meter and the reference pulses
generated by the test equipment defined the measurement accuracy.

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


28

Freescale Semiconductor, Inc.

Accuracy and performance

8.1. Room-temperature accuracy testing


Figure 23 shows the calibration protocol of the typical Freescale MKM34Z256 one-phase power meter
(S/N: 0000). The protocol indicates the results of the power meter calibration performed at 25C.
The accuracy and repeatability of the measurement for various phase currents, and the angles between
phase current and phase voltage, are shown in the graphs.
The first graph (on the top) indicates the accuracy of the active and reactive energy measurement after
calibration. The x-axis shows the variation of the phase current, and the y-axis denotes the average
accuracy of the power meter, computed from five successive measurements. The two bold red lines
define the Class C (EN50470-3) accuracy margins for active energy measurement for power factor 1.
The second graph (on the bottom) shows the measurement repeatability, which means a standard
deviation of error in the measurements at a specific load point. Similarly to the power meter accuracy,
the standard deviation has also been computed from five successive measurements.
By analyzing the protocols of several MKM34Z256 one-phase power meters, this equipment measures
active and reactive energies at all power factors, at 25C ambient temperature, and in the current range
of 0.1 80 A, with the accuracy range of 0.2 %.
CAUTION
Even though the current range of the power meter is scaled to 105 A, it is
not recommended to operate the power meter in the 80 105 A range for a
longer time period, due to heating of the shunt resistor in this current
range.

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

29

Accuracy and performance

Figure 23. Calibration protocol at 25C

8.2. Extended temperature accuracy testing


In addition to room-temperature testing, the MKM34Z256 one-phase power meter has been evaluated over
the whole operating temperature range (40C to 85C). This testing was carried out with the power meter
placed in a heat chamber (see Figure 24). To speed up the measurement, only the active energy accuracy has
been evaluated. The isolated open-collector pulse output interface is used instead of the output LED to
provide active energy pulses to the test equipment for accuracy evaluation.

Figure 25 shows the accuracy of the power meter evaluated at an extended temperature range. The accuracy
margins defined by EN50470-3 for class C power meters and the extended temperature range are denoted by
the bold red lines. The active energy measured by the power meter at all temperatures fits within the
accuracy margins mandated by the standard.
MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015
30

Freescale Semiconductor, Inc.

Accuracy and performance

Figure 24. Power meter inside a heat chamber

Figure 25. Calibration protocol for extended temperature range


MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015
Freescale Semiconductor, Inc.

31

Summary

9. Summary
This design reference manual describes a solution for a one-phase electronic power meter, based on the
MKM34Z256VLL7 MCU.
Freescale offers both the Fast Fourier Transform (FFT) and Filter-based metering algorithms for use in
customer applications. The former calculates the metering quantities in the frequency domain, the latter
does the same in the time domain. This reference manual explains the basic theory of power metering,
and lists all the equations to be calculated by the power meter.
The hardware platform of the power meter is algorithm-independent, so the application firmware can
leverage any type of metering algorithm, based on customer preference. To extend the power meter uses,
the hardware platform comprises 256 KB SPI Flash for firmware upgrade, 4 KB SPI EEPROM for data
storage, and an expansion header for Arduino / Freescale Freedom daughter boards for AMR
communication and monitoring.
The application software is written in the C language, and compiled using the IAR Embedded
Workbench for ARM (7.40 and higher), with optimization for the execution speed. It is based on the
MKM34Z256 bare-metal software drivers [7] and the FFT-based metering library [2] [3] as default.
The application firmware automatically calibrates the power meter, calculates all metering quantities,
controls active and reactive energy pulse outputs and the LCD, stores and retrieves parameters from the
Flash memory, and allows monitoring the application, including recording selected waveforms through
the FreeMASTER. The application software of such complexity requires approximately 38 KB of Flash
and 9 KB of RAM. The system clock frequency of the MKM34Z256VLL7 device must be 12.288 MHz
(or higher) to calculate all metering quantities with an update rate of 6 kHz, and with 64 FFT points (32
harmonics in total) consecutively.
The power meter is designed to transition between three operating modes. It runs in the Normal mode
when it is powered from the mains. In this mode, the meter electronics consume 14.6 mA. The Standby
mode is entered when the power meter runs from the battery and the user lists through the menus. In this
particular mode, the 3.6 V Li-SOCI2 (1.2 Ah) battery is being discharged by 83 A. When the power
meter runs from the battery but no interaction with the user occurs, the power meter electronics
automatically transition to the Power-down mode. The Power-down mode is characterized by current
consumption as low as 2 A.
The application software enables you to monitor the measured and calculated quantities through the
FreeMASTER application running on your PC. All internal static and global variables can be monitored
and modified using the FreeMASTER. Some variables (for example phase voltage and phase current)
can be recorded in the RAM of the MKM34Z256VLL7 device, and sent to the PC afterwards. This
power meter capability helps you to understand the measurement process.
The MKM34Z256 one-phase power meters were tested according to the EN50470-1 and EN50470-3
European standards for electronic meters of active energy classes B and C, the IEC 62053-21 and IEC
62052-11 international standards for electronic meters of active energy classes 2 and 1, and the IEC
62053-23 international standard for static meters of reactive energy classes 2 and 3. After analyzing
several power meters, we can state that this equipment measures active and reactive energies at all
power factors, at 25C ambient temperature, in the current range of 0.1 80 A, with an accuracy range
of 0.2 %. Further accuracy testing was carried out on a power meter in a heat chamber. This particular
testing revealed that the temperature coefficient of the complete measurement chain of this equipment is
approximately 68 ppm / C.
MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015
32

Freescale Semiconductor, Inc.

Revision history

The MKM34Z256 one-phase power meter demonstrates excellent measurement accuracy and low
temperature coefficient. The capabilities of the MKM34Z256 one-phase power meter fulfill the most
demanding European and international standards for electronic meters.

10. References
1. Electricity Meter Test Equipment ELMA 8x01, Applied Precision Ltd.
(www.appliedp.com/en/elma8x01.htm).
2. FFT-Based Algorithm for Metering Applications (document AN4255).
3. Using FFT on the Sigma-Delta ADCs (document AN4847).
4. Filter-Based Algorithm for Metering Applications (document AN4265).
5. AN37 LinkSwitch-TN Family Design Guide, Power Integrations (document AN37).
6. FreeMASTER Data Visualization and Calibration Software (FreeMASTER).
7. MKM34Z256 Bare-metal Software Drivers (available at www.freescale.com/kinetis).
8. Optical sensor USB 1, ZPA Smart Energy, (information available at www.zpa.cz/files/files/USB1-angl-20-10-2009-web.pdf).
9. HC-05 RF wireless Bluetooth Bee V2.0 module + XBee V03 shield board (available at eBay)

11. Revision history


The following table lists ale substantive changes done to this document since the initial release.

Revision number

Date

Substantive changes

06/2015

Initial release

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

33

C2
0.1UF

GND

2
SPI0_MISO

FRDM_SS
SPI1_SCK
SPI1_MOSI
SPI1_MISO

EOC

LPUART_RX
LPUART_TX
UART3_TX
UART3_RX
UART1_RTS
UART1_CTS
UART1_RX
UART1_TX

I2C1_SDA
I2C1_SCL

RF_RST
PTE5/TMR3
PTG0/TMR1

SWD_RESET R18 820

VDD

1
2
3

J3

GND

C24
0.1UF
DNP

DNP

R22 10K

SPI1_SCK

SPI1_MOSI 5

VPWR

DNP

WP

CS

CLK

DI/IO0

U3

GND

7
VPWR

2 SPI1_MISO

OPTIONAL ONLY

W25X20CLSNIG

HOLD

DO/IO1

GND

VCC

256kB SPI FLASH

TP2

LCD13
LCD14
LCD15
LCD16
LCD17
LCD18
LCD19
LCD20
LCD38
LCD37
LCD36
LCD35

67
ADC0_SE7
68
ADC0_SE8
69
ADC0_SE9
70
FRDM_SS
71
SPI1_SCK
SPI1_MISO 72
73
SPI1_MOSI
PTF7/CLKOUT74

55
56
57
58
63
64
65
66

R17 4.7K

C15 0.1UF

USER_LED
/RESET
I2C1_SDA
I2C1_SCL
PTE4
PTE5/TMR3
SWD_IO
SWD_CLK

GND

47
48
49
50
51
52
53
54

PWR_MSR
VBAT_MSR
EOC

19
20
21
22
23
44
45
46

9
12
13
14
15
16
17
18

1
2
3
4
5
6
7
8

PTD0
GND
UART1_TX
R10 4.7M
UART1_RX
VBAT
UART1_CTS
UART1_RTS
VBAT voltage divider:
ADC input 0.838V @ 3.3V VAUX2
ADC0_SE5
USER_BTN

R9 1.6M

C12 0.1UF

HDR 1X3
1-2 = Arduino is reseted synchronously with the
main board (by HW)
2-3 = Arduino is reseted asynchronously (by SW)

/RESET
RF_RST
PTE4

LCD31
LCD32
LCD33
LCD34
LCD35
LCD36
LCD37
LCD38

LCD23
LCD24
LCD25
LCD26
LCD27
LCD28
LCD29
LCD30

VPWR voltage divider:


ADC input 3.151V @ 3.6V
R4 47K
PTC0
VPWR
TP11
PTC1
PTF7/CLKOUT
R5 330K
UART3_TX
GND
PTC1
UART3_RX
PTD0
C11 0.1UF
PTI0

CAT25040VE

SO

VSS

VCC

ADC0_SE7
ADC0_SE5
ADC0_SE9
ADC0_SE8

SCK

HOLD

WP

CS

SI

ARDUINO/FRDM RESET SELECTION

[2] FRDM_SS
[2] SPI1_SCK
[2] SPI1_MOSI
[2] SPI1_MISO

[2] EOC

[2] LPUART_RX
[2] LPUART_TX
[2] UART3_TX
[2] UART3_RX
[2] UART1_RTS
[2] UART1_CTS
[2] UART1_RX
[2] UART1_TX

[2] I2C1_SDA
[2] I2C1_SCL

[2] PTF7/CLKOUT
[2] PTC1
[2] PTD0
[2] PTI0
[2] RF_RST
[2] PTE5/TMR3
[2] PTG0/TMR1

[2] ADC0_SE7
[2] ADC0_SE5
[2] ADC0_SE9
[2] ADC0_SE8

GND

SPI0_SCK 6

R1 10K

10
62
VDD1
VDD2

PTH0/LCD_P15/LPUART0_CTS
PTH1/LCD_P16/LPUART0_RTS
PTH2/LCD_P17/LPUART0_RX
PTH3/LCD_P18/LPUART0_TX
PTH4/LCD_P19
PTH5/LCD_P20
PTH6/UART1_CTS/SPI1_PCS0/XBAR0_IN7
PTH7/UART1_RTS/SPI1_SCK/XBAR0_OUT7

PTG0/LCD_P7/TMR1/LPTMR0_ALT2
PTG1/LLWU_P2/LCD_P8/ADC0_SE10/LPTMR0_ALT0
PTG2/LLWU_P1/LCD_P9/ADC0_SE11/SPI0_PCS0
PTG3/LCD_P10/SPI0_SCK/I2C0_SCL
PTG4/LCD_P11/SPI0_MOSI/I2C0_SDA
PTG5/LCD_P12/SPI0_MISO/LPTMR0_ALT1
PTG6/LLWU_P0/LCD_P13/LPTMR0_ALT2
PTG7/LCD_P14

1
2
3
4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
21
22
23
24

GND

M550

4A/4B/4F/4G/4C/4E/4D/T11
5A/5B/5F/5G/5C/5E/5D/T12
6A/6B/6F/6G/6C/6E/6D/T13
7A/7B/7F/7G/7C/7E/7D/P1
8A/8B/8F/8G/8C/8E/8D/P2
9A/9B/9F/9G/9C/9E/9D/P3
10A/10B/10F/10G/10C/10E/10D/P4
20
14A/14B/14F/14G/14C/14E/14D/P7
13A/13B/13F/13G/13C/13E/13D/P6
12A/12B/12F/12G/12C/12E/12D/P5
11A/11B/11F/11G/11C/11E/11D/T14

LCD DISPLAY (8x16)

COM1
COM2
COM3
COM4
COM5
COM6
COM7
COM8
COL1/T1/T2/T3/T6/T7/T8/T9
1A/1B/1F/1G/1C/1E/1D/T4
2A/2B/2F/2G/2C/2E/2D/T5
3A/3B/3F/3G/3C/3E/3D/T10

DS1

MKM34Z256CLL7

LCD34
LCD33
LCD32
LCD31
LCD30
LCD29
LCD28
LCD27
LCD26
LCD25
LCD24
LCD23

SW2

GND

DNP

R21 330K
USER_BTN

VDD

VREFH
VREFL

37
38

2200PF

R6
4.7M

VDD

R2
4.7M

J1

2 GND

CON_2_TB
DNP

D2F-01L

SW1

GND

SDADM0

0.1UF

C16

0.1UF

C14

SDADP0

R19

GND

22

R11

CON_2_TB
DNP

J2

PHASE CURRENT SENSING

2
4
6
8
10

150K 150K
150K
150K

R16
R15
R14
R13

VIN[4]

VDD

VDD

VDD

GND

C20
0.1UF

GND

C21
0.1UF

C22
0.1UF

Place close to LCD bias and charge pump pins

GND

C19
0.1UF

LCD BIAS and CHARGE PUMP CAPACITORS

GND
Place close to SDADx2 MCU pins

Use 0.1% 50ppm MELF0204 resistors

Phase voltage scaling:


325.269 Vpp equals 211.28mVpp

Approv ed:
Martin Mienkina

Drawn by :
Ludek Slosarcik

Date:

Size
B

Friday , December 12, 2014

Sheet

SCH-28639 PDF: SPF-28639

MCU & AFE Section

of

KM34Z256 1-Ph Power Meter

Document Number

Page Title:

Rev
A

This document contains inf ormation proprietary to Freescale Semiconductor and shall not be used f or
engineering design, procurement or manuf acture in whole or in part without the express written permission
of Freescale Semiconductor.
PUBI: ____
FIUO: X
FCP: ____
ICAP Classif ication:
Drawing Title:
Designer:
Ludek Slosarcik

1. maje 1009
765 61 Roznov p. R. Czech republic, Europe
GND

Max. 22mW power losses and 57.5 V


voltage drop per resistor (@230 V)

R20
390

390

R12

0.1UF

SWD_RESET

SWD_IO
SWD_CLK

D1
HSMS-C170

Freescale Semiconductor RCSC

HDR 2X5

J4

D2
R7
WP7104LSRD
390.0 C
A

R3
3.9K

D3
R8
WP7104LSRD
A
KVARH_LED 390.0 C

KWH_LED

USER_LED

GND

C8
0.1UF

Place close
to VREFL pin

C23

1
3
5
7
9

SWD CONNECTOR

Connect shunt resistor to the


J2 as follows:
Pin 2 - green wire (L_OUT)
Pin 1 - red wire (L_IN)

0.015 UF

Place close
to VREFH pin

PHASE VOLTAGE SENSING

GND

C17

SDADM2

0.015 UF

C13

SDADP2

C1
0.1UF

GND

VREFH

OUTPUT LEDS

GND
Place close
to VBAT pin

GND

C7
0.1UF

VBAT

Place close to
SAR_VDDA pin

C6
0.1UF

SAR_VDDA

BYPASS CAPACITORS

Max. current 700nA @3.3V when tamper inactive

TAMPER2

C10
2200PF

GND

GND

C5
0.1UF

Place close
to VDDA pin

C4
0.1UF

VDDA

TAMPER DETECTION

C9

TAMPER1

Place close
to VDD pin

GND

C3
0.1UF

VDD

22
Place close to SDADx0 MCU pins

GND

0.1UF

C18

VDD

TAMPER1
TAMPER2

GND

SDADP2
SDADM2

SDADP0
SDADM0

30
29
28

42
43

39
40

35
36

33
34

32.768KHz

Y1

PTI0
KWH_LED
LPUART_RX
LPUART_TX

91
92
93
94
2

LCD15
LCD16
LCD17
LCD18
LCD19
LCD20
FLASH_SS
KVARH_LED

83
84
85
86
87
88
89
90

26
25

PTG0/TMR1
VAUX1
SPI0_SS
SPI0_SCK
SPI0_MOSI
SPI0_MISO
LCD13
LCD14

75
76
77
78
79
80
81
82

PUSH-BUTTON

PTI0/LLWU_P21/CMP0_IN5/UART1_RX/XBAR0_IN8/SPI1_MISO/SPI1_MOSI
PTC0/LCD_P39/UART3_RTS/XBAR0_IN1/PDB0_EXTRG
PTI1/UART1_TX/XBAR0_OUT8/SPI1_MOSI/SPI1_MISO
PTC1/LCD_P40/CMP1_IN1/UART3_CTS
PTI2/LLWU_P22/LCD_P21/LPUART0_RX
PTC2/LCD_P41/UART3_TX/XBAR0_OUT1
PTI3/LCD_P22/LPUART0_TX/CMP2_OUT
PTC3/LLWU_P13/LCD_P42/CMP0_IN3/UART3_RX
PTC4/LCD_P43
PTC5/LLWU_P12/ADC0_SE0/CMP2_IN0/UART0_RTS
PTC6/ADC0_SE1/CMP2_IN1/UART0_CTS/TMR1/PDB0_EXTRG
EXTAL32K
PTC7/ADC0_SE2/CMP2_IN2/UART0_TX/XBAR0_OUT2
XTAL32K
PTD0/LLWU_P11/CMP0_IN0/UART0_RX/XBAR0_IN2
SDADP0
PTD1/UART1_TX/SPI0_PCS0/XBAR0_OUT3/TMR3
SDADM0
PTD2/LLWU_P10/CMP0_IN1/UART1_RX/SPI0_SCK/XBAR0_IN3
PTD3/UART1_CTS/SPI0_MOSI
SDADP1
PTD4/LLWU_P9/ADC0_SE3/UART1_RTS/SPI0_MISO
SDADM1
PTD5/ADC0_SE4A/LPTMR0_ALT2/TMR0/UART3_CTS
PTD6/LLWU_P8/ADC0_SE5A/LPTMR0_ALT1/CMP1_OUT/UART3_RTS
SDADP2/CMP1_IN2
PTD7/LLWU_P7/CMP0_IN4/I2C0_SCL/XBAR0_IN4/UART3_RX
SDADM2/CMP1_IN3
PTE0/I2C0_SDA/XBAR0_OUT4/UART3_TX/CLKOUT
SDADP3/CMP1_IN4
PTE1/RESET
SDADM3/CMP1_IN5
PTE2/EXTAL1/EWM_IN/XBAR0_IN6/I2C1_SDA
PTE3/XTAL1/EWM_OUT/AFE_CLK/I2C1_SCL
TAMPER0
PTE4/LPTMR0_ALT0/UART2_CTS/EWM_IN
TAMPER1
PTE5/LLWU_P6/TMR3/UART2_RTS/EWM_OUT
TAMPER2
PTE6/LLWU_P5/CMP0_IN2/XBAR0_IN5/UART2_RX/I2C0_SCL/SWD_IO
PTE7/ADC0_SE6A/XBAR0_OUT5/UART2_TX/I2C0_SDA/SWD_CLK
VREFH
VREFL
PTF0/LLWU_P4/ADC0_SE7A/CMP2_IN3/RTC_CLKOUT/TMR2/CMP0_OUT
PTF1/LCD_P0/ADC0_SE8/CMP2_IN4/TMR0/XBAR0_OUT6
PTF2/LCD_P1/ADC0_SE9/CMP2_IN5/CMP1_OUT/RTC_CLKOUT
PTF3/LLWU_P20/LCD_P2/SPI1_PCS0/LPTMR0_ALT1/UART0_RX
PTF4/LCD_P3/SPI1_SCK/LPTMR0_ALT0/UART0_TX
PTF5/LCD_P4/SPI1_MISO/I2C1_SCL
PTF6/LLWU_P3/LCD_P5/SPI1_MOSI/I2C1_SDA
PTF7/LCD_P6/TMR2/CLKOUT/CMP2_OUT

PTB0/LCD_P31
PTB1/LLWU_P17/LCD_P32
PTB2/LCD_P33
PTB3/LCD_P34
PTB4/LCD_P35
PTB5/LCD_P36
PTB6/LCD_P37/CMP1_IN0
PTB7/LCD_P38/AFE_CLK

PTA0/LLWU_P16/LCD_P23
PTA1/LCD_P24
PTA2/LCD_P25
PTA3/LCD_P26
PTA4/LLWU_P15/NMI/LCD_P27
PTA5/CMP0_OUT/LCD_P28
PTA6/LLWU_P14/XBAR0_IN0/LCD_P29
PTA7/XBAR0_OUT0/LCD_P30

U2

61
VDDA

U1

31
AFE_VDDA

VDD

24
VBAT

VCAP1
VCAP2
100
99
VCAP1/LCD_P63/PTM3
VCAP2/LCD_P62/PTM2

VDDA

11
27
59
95

SPI0_SS

41
VREF

VLL1
VLL2
VLL3
98
97
96
VLL1/LCD_P61/PTM1
VLL2/LCD_P60/PTM0
VLL3
VSS1
VSS2
VSS3
VSS4

VDD

60

VSSA

SAR_VDDA

AFE_VSSA

32

TP1

TL3301AF160QG

L_OUT

SPI0_MOSI 5

FLASH_SS

VLL1

3
1

VLL2

VAUX1

4
2

VLL3

L_IN

VREFL
VCAP1

34
VCAP2

4kB SPI EEPROM

Metering Board Electronics

Appendix A. Metering Board Electronics

Figure 26. Schematic diagram of the metering board (sheet 1 of 3 MCU & AFE section)

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015

Freescale Semiconductor, Inc.

Metering Board Electronics

ARDUINO SHIELD / FRDM CONNECTORS


ISOLATED PULSE OUTPUT

J5
HDR_1X2

390.0
DNP

VPWR
1
2

PTC1 [3]
PTF7/CLKOUT [3]
UART1_RTS [3]
UART1_CTS [3]
PTG0/TMR1 [3]
PTI0 [3]
UART1_TX [3]
UART1_RX [3]

GND
SPI1_SCK [3]
SPI1_MISO [3]
SPI1_MOSI [3]
FRDM_SS[3]
PTE5/TMR3 [3]
PTD0 [3]

[3] I2C1_SDA
[3] I2C1_SCL

HDR 1X2
DNP

20
18
16
14
12
10
8
6
4
2

VDD

AREF

J6

16
14
12
10
8
6
4
2

1
2

U4
R23
[3] EOC

J8

J7
CON_2X10

SFH6106-4

DNP

CON 2X8

15
13
11
9
7
5
3
1

19
17
15
13
11
9
7
5
3
1

OPTIONAL ONLY

TP10

IR INTERFACE

R24
TP4

VAUX2

Arduino/FRDM digital LSB

Arduino/FRDM digital MSB

10K

PTI0 [3]
PTG0/TMR1 [3]

R25
1.0K

Arduino/FRDM power

Arduino/FRDM analog

IR diode and phototransistor must


be placed to have 6.5mm in between

~2.65mA @ 3.3V

J10

J11

CON 2X8

TSAL4400

GND

CON 2X6 SKT

GND
J12
HDR_1X2

2
4
6
8
10
12

[3] LPUART_TX

SPI1_MOSI

1
3
5
7
9
11

D4
R26 680

HDR 2X3
Arduino ICSP

1
3
5
7
9
11
13
15

GND

GND

2
4
6
8
10
12
14
16

TP5

2
4
6

SPI1_MISO 1
SPI1_SCK 3
5
RF_RST

Q1
OP506B

C25
2200PF

VOUT

J9

[3] LPUART_RX

J13
HDR_1X2

VPWR

ADC0_SE5
ADC0_SE7
ADC0_SE8
ADC0_SE9

1
2

1
2

VOUT
GND

[3] RF_RST

VCC_5V

VCC_3V6

[3]
[3]
[3]
[3]

Keep spacing between J7...J11 connectors according to the Arduino/FRDM specification.

ISOLATED RS232 INTERFACE

U5
R27

[3] UART3_TX
390.0
DNP
VDD

R28 4.7K
DNP

R29
1.0K
DNP
U6
2

R30 470

C26
2.2uF
DNP

[3] UART3_RX

SFH6106-4
DNP

D5

MMSD4148T1G
DNP
D6
MMSD4148T1G
DNP

Freescale Semiconductor RCSC


J14
1
3
5
7
9

2
4
6
8
10

DNP
HDR_2X5
DNP
Max. 19200 Bd
1

4
GND
OPTIONAL ONLY

SFH6106-4
DNP

D7

MMSD4148T1G
DNP

1. maje 1009
765 61 Roznov p. R. Czech republic, Europe
This document contains inf ormation proprietary to Freescale Semiconductor and shall not be used f or
engineering design, procurement or manuf acture in whole or in part without the express written permission
of Freescale Semiconductor.
PUBI: ____
FIUO: X
FCP: ____
ICAP Classif ication:
Drawing Title:
Designer:
Ludek Slosarcik

KM34Z256 1-Ph Power Meter

Drawn by :
Ludek Slosarcik

Page Title:

Approv ed:
Martin Mienkina

Size
B

Document Number

Date:

Friday , December 12, 2014

Digital Interfaces
Rev
A

SCH-28639 PDF: SPF-28639


Sheet

of

Figure 27. Schematic diagram of the metering board (sheet 2 of 3 digital interfaces section)

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

35

Metering Board Electronics

85-265V AC-DC SMPS MODULE


C27
4.7uF
[1] VIN

+ C30
4.7uF

+ C31
4.7uF

VOUT

470uH
Open J15 to
power board
from +5V
laboratory
JP5
JP6
HDR 1X1 HDR 1X1 power supply.

C33

C32
D10
ES1JL

0.1UF

R34
1.6K

1000uF

GND

GND

Connect phase and neutral to the JP1 and JP2:


JP1: Neutral (Terminal case 3, 4)
JP2: Line input (Terminal case 1,Shunt red wire)

GND

GND

GND

GND GND

Don't populate AC-DC SMPS if capacitive power supply module is used instead.
Connect input of the external capacitive power supply module to JP4 (Neutral)
and JP3 (Line input). Output voltage of the external capacitive power supply
module must be connected to JP5 (Vout) and JP6 (GND).

VIN

GND

JP4
HDR 1X1

L2

1
2

2
1

LNK306DN

JP3
HDR 1X1

J15
HDR_1X2

D9
MRA4007T3G

C29
22uF

1%

5
6
7
8

R33
20S0271

GND
HDR 1X1

R32
2.0K
C28
0.1uF

VOUT = 1.65V x [ (R31+R32)/R32] = 5.19 V

1%

S1
S2
S3
S4

Keep spacing between


nets and GND in this
region 40mils or more.

JP2

D8
MRA4007T3G

Route
HDR 1X1

R31 4.3K

U7

L1

1500uH

FB
BP

VIN

JP1

VOUT

GND

LDO AND BATTERY MANAGEMENT


Open J16 to
measure BT1
current.
J16
HDR_1X2

BT1
ER142503PT
-v e2

+v e

D11
MMSD4148T1G
A
C

1
2

3
GND

VBAT

-v e1
R35 23.7K

R36 45.3K

2
3
C42
10UF

C43
10UF

1%

U8
VIN

VOUT

EN

ADJ

C40
10UF

C44
10UF

L4

GND

1uH

C35
1uF

C36
1uF

GND
SAR_VDDA
2
C38
1uF

C39
1uF

GND
Place close to SAR_VDDA MCU pin
GND

GND GND

C37
1uF

C41
100UF

C45
10UF

SPX3819M5-L
GND

GND

Place close to VDDA MCU pin


VDDA

C34
1uF

VDD

VPWR

1%
5

1uH

J17
HDR_1X2

D12
BAT54CLT1

GND
1

Open J17
to measure
MCU + RTC
currents.

1
2

3.6 V Battery

L3

GND

GND

VPWR = 1.235V x [ 1 + R36/R35] = 3.5956 V

Freescale Semiconductor RCSC


1. maje 1009
765 61 Roznov p. R. Czech republic, Europe

POWER SUPPLY TEST POINTS


VDDA
TP3

VDDA

VPWR
TP6

VPWR

SAR_VDDA
TP7

GND
TP8

SAR_VDDA

GND

VDD
TP9

VDD

This document contains inf ormation proprietary to Freescale Semiconductor and shall not be used f or
engineering design, procurement or manuf acture in whole or in part without the express written permission
of Freescale Semiconductor.
ICAP Classif ication:
FCP: ____
FIUO: X
PUBI: ____
Designer:
Drawing Title:
Ludek Slosarcik

KM34Z256 1-Ph Power Meter

Drawn by :
Ludek Slosarcik

Page Title:

Approv ed:
Martin Mienkina

Size
B

Document Number

Date:

Friday , December 12, 2014

Power Supply Section


Rev
A

SCH-28639 PDF: SPF-28639


Sheet

of

Figure 28. Schematic diagram of the metering board (sheet 3 of 3 power supply section)

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


36

Freescale Semiconductor, Inc.

Metering board layout

Appendix B. Metering board layout

Figure 29. Top-side view of the metering board (not scaled)

Figure 30. Bottom-side view of the metering board (not scaled)

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

37

Bill of materials of the metering board

Appendix C. Bill of materials of the metering board


Table 6. BOM report
Part Reference

Qty

Description

Manufacturer

Part Number

BT1

BATTERY 1/2AA LI-SOCI2 3.6 V


1200 MAH

EVE ENERGY CO.,


LTD

ER142503PT

21

CAP CER 0.10 F 25 V 10 % X7R


0603

KEMET

C0603C104K3RAC

MURATA
KEMET

GRM188R61C225KE15
D
C0603C222J5RACTU

C1, C2, C3, C4,


C5, C6, C7, C8,
C11, C12, C14,
C15, C16, C18,
C19, C20, C21,
C22, C23, C24,
C32
C26

CAP CER 2.2 F 16 V 10 % X5R

C9, C10, C25


C34, C35, C36,
C37, C38, C39
C28

0603
CAP CER 2200
pF 50 V 5 % X7R
0603
CAP CER 1 F 25 V 10 % X7R 0603

C29

C30, C31

C41

C33

C40, C42, C43,


C44, C45

C27

C13, C17

DS1

D5, D6, D7, D11

DIODE SW 100 V SOD-123

D4

LED IR SGL 100 mA TH

D2, D3

D8, D9

LED RED SGL 30 mA TH


DIODE PWR RECT 1 A 1000 V SMT
403D-02

D10

D12

D1
J5, J12, J13, J15,
J16, J17
JP1, JP2, JP3,
JP4, JP5, JP6
J7

6
1

CAP CER 0.1 F 50 V 5 % X7R 0603


CAP CER 22 F 16 V 10 % X5R
0805
CAP ALEL 4.7 F 400 V 20 %, SMT
CAP CER 100 F 6.3 V 20 % X5R
1206
CAP ALEL 1000 F 6.3 V 20 %, Low
ESR, SMT
CAP CER 10 F 16 V 10 % X5R
0805
CAP CER 4.7 F 16 V 10 % X5R
0603
CAP CER 0.015 F 50 V 5 % X7R
0603
LCD DISPLAY 1/8 DUTY CYCLE 3.3
V TH NON-ROHS

CAPAX
TECHNOLOGIES Inc.
AVX

06035C104JAT2A

TDK

C2012X5R1C226K

NIC COMPONENTS
CORP
MURATA

NACV4R7M400V10x10.8
TR13F
GRM31CR60J107ME39L

PANASONIC

EEEFP0J102AP

AVX

0805YD106KAT2A

TDK

C1608X5R1C475K

KEMET

C0603C153J5RACTU

MAK-SAY

M550

DIODE SCH DUAL CC 200 mA 30 V


SOT23
LED HER SGL 2.1 V 20MA 0805

ON
SEMICONDUCTOR
VISHAY
INTERTECHNOLOGY
KINGBRIGHT
ON
SEMICONDUCTOR
TAIWAN
SEMICONDUCTOR
ON
SEMICONDUCTOR
AVAGO Technologies

HDR 1X2 SMT 100MIL SP 380H AU

SAMTEC

HDR 1X1 TH -- 330H SN 115L

CON 2X10 SKT SMT 100MIL CTR


390 H AU

DIODE RECT 1 A 600 V SMT

0603X105K250SNT

MMSD4148T1G
TSAL4400
WP7104LSRD
MRA4007T3G
ES1JL
BAT54CLT1G
HSMS-C170
TSM-102-01-SM-SV-PTR

SAMTEC

SSW-110-22-F-D-VS-N

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


38

Freescale Semiconductor, Inc.

Bill of materials of the metering board

Table 6. BOM report


Part Reference

Qty

J6

J14

J4

J8, J10

J9

J11

J3

HDR 1X3 SMT 100MIL SP 380H AU

J1, J2

CON 1X2 TB TH 5 MM SP 394H

IND PWR 1500 H @ 100 kHz


130 mA 20 % SMT

COILCRAFT

LPS6235-155ML

L2

IND PWR 0.47 mH @ 100 kHz


400 MA 10 % RADIAL

COILCRAFT

RFB0807-471L

L3, L4

IND CHIP 1 H @ 10 MHz 220 MA


25 %

TDK

MLZ2012A1R0PT

Q1

TRAN PHOTO NPN 250 mA 30 V TH

R13, R14, R15,


R16

RES MF 150 K 1/4 W 1 % MELF0204

R14, R20

RES MF 390 1/4 W 1 % MELF0204

R17, R28

RES MF 4.7 K 1 / 10 W 5 % 0603

R7, R8, R23, R27

RES MF 390.0 1/10 W 1 % 0603

OPTEK
TECHNOLOGY
WELWYN
COMPONENTS
LIMITED
WELWYN
COMPONENTS
LIMITED
VISHAY
INTERTECHNOLOGY
KOA SPEER

R25, R29

RES MF 1.00 K 1/10 W 1 % 0603

KOA SPEER

RK73H1JTTD1001F

R30

RES MF 470 1/10 W 1 % 0603

KOA SPEER

RK73H1JTTD4700F

R26

RES MF 680 1/10 W 5 % 0603

BOURNS

CR0603-JW-681ELF

R4

RES MF 47 K 1/10 W 5 % 0603

VENKEL COMPANY

CR0603-10W-473JT

R1, R22, R24

RES MF 10K 1/10 W 5 % 0603

KOA SPEER

RK73B1JTTD103J

R9

RES MF 1.6 M 1/10 W 1 % 0603

KOA SPEER

RK73H1JTTD1604F

R2, R6, R10

RES MF 4.7 M 1/10 W 1 % 0603

KOA SPEER

RK73H1JTTD4704F

R18

BOURNS

CR0603-JW-821ELF

R33

EPCOS

B72220S0271K101

R34

RES MF 820 1/10 W 5 % 0603


RES VARISTOR 275 VRMS 10 % 4.5
kA 151J TH
RES MF 1.6 K 1/10 W 1 % 0603

KOA SPEER

RK73H1JTTD1601F

R35

RES MF 23.7 K 1/10 W 1 % 0603

KOA SPEER

RK73H1JTTD2372F

R36

RES MF 45.3 K 1/10 W 1 % 0603

KOA SPEER

RK73H1JTTD4532F

R3

RES MF 3.9 K 1/10 W 5 % 0603

BOURNS

CR0603-JW-392ELF

R5, R21

RES MF 330 K 1/10 W 1 % 0603

KOA SPEER

RK73H1JTTD3303F

L1

Description
HDR 1X2 TH 100MIL SP 338H AU
150L
HDR 2X5 SMT 100MIL CTR 380H AU
HDR 2X5 SMT 1.27 MM CTR 175H
AU
CON 2X8 SKT TH 100MIL SP 335H
AU 104L
HDR 2X3 TH 100MIL CTR 335H AU
95L
CON 2X6 SKT TH 100MIL CTR 340H
AU 104L

Manufacturer

Part Number

SAMTEC

HMTSW-102-24-G-S-230

SAMTEC

TSM-105-01-S-DV-P-TR

SAMTEC

FTS-105-01-F-DV-P-TR

SAMTEC

SSW-108-01-S-D
TSW-103-07-S-D

SAMTEC

SSW-106-01-G-D

SAMTEC

TSM-103-01-S-SV

SAMTEC

OP506B
WRM0204C-150KFI

WRM0204C-390RFI
CRCW06034K70JNEA
RK73H1JTTD3900F

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


Freescale Semiconductor, Inc.

39

Table 6. BOM report


Part Reference

Qty

Description

Manufacturer

Part Number

R11, R19

KOA SPEER

R31

RK73H1JTTD22R0F
RK73H1JTTD4301F

R32

SW1

SW2

TP1-TP11

11

U4, U5, U6

U1

U2

U3

U7

U8

Y1

RES MF 22.0 1/10 W 1 % 0603


RES MF 4.3 K 1/10 W 1 % AECQ200 0603
RES MF 2.00 K 1/10 W 1 % 0603
SW SPDT SNAP ACTION 0.1 A 30 V
TH
SW SPST MOM NO PB SMT 50 V
50 MA GULL_WING
ROUND TEST PAD SMT; NO PART
TO ORDER
IC OPTOCOUPLER 100 MA 70 V
SMD
IC MEM EEPROM SPI 4 Kb 1.8 5.5
V SOIC8
IC MCU FLASH 256 KB SRAM 32 KB
75 MHZ 2.8 3.6 V LQFP100
IC MEM FLASH SPI 2 MBIT 2.3 3.6
V SOIC8
IC VREG LINKSWITCH 225 MA /
360 MA 85 265 VAC / 700 V S0-8C
IC VREG LDO ADJ 500 MA 2.5 16
V SOT23-5
XTAL 32.768 kHz PAR 20PPM -SMT

KOA SPEER
ROHM

MCR03EZPFX2001

OMRON

D2F-01L

E SWITCH

TL3301AF160QG

VISHAY
INTERTECHNOLOGY
ON
SEMICONDUCTOR
FREESCALE
SEMICONDUCTOR
WINBOND
ELECTRONICS CORP
POWER
INTEGRATIONS

MKM34Z256VLL7

EXAR

SPX3819M5-L

PRECISION DEVICES,
INC.

T600032XFSD12XA

SFH6106-4
CAT25040VE-G

W25X20CLSNIG
LNK306DN

MKM34Z256 One-Phase Power Meter Reference Design, Rev. 0, 06/2015


40

Freescale Semiconductor, Inc.

How to Reach Us:


Home Page:
freescale.com
Web Support:
freescale.com/support

Information in this document is provided solely to enable system and software


implementers to use Freescale products. There are no express or implied copyright
licenses granted hereunder to design or fabricate any integrated circuits based on the
information in this document.
Freescale reserves the right to make changes without further notice to any products
herein. Freescale makes no warranty, representation, or guarantee regarding the
suitability of its products for any particular purpose, nor does Freescale assume any
liability arising out of the application or use of any product or circuit, and specifically
disclaims any and all liability, including without limitation consequential or incidental
damages. Typical parameters that may be provided in Freescale data sheets and/or
specifications can and do vary in different applications, and actual performance may
vary over time. All operating parameters, including typicals, must be validated for each
customer application by customer's technical experts. Freescale does not convey any
license under its patent rights nor the rights of others. Freescale sells products pursuant
to standard terms and conditions of sale, which can be found at the following address:
freescale.com/SalesTermsandConditions.
Freescale and the Freescale logo are trademarks of Freescale Semiconductor, Inc.,
Reg. U.S. Pat. & Tm. Off.
ARM and Cortex are registered trademarks of ARM Limited (or its subsidiaries) in the
EU and/or elsewhere. All rights reserved.
2015 Freescale Semiconductor, Inc.

Document Number: DRM163


Rev. 0
06/2015

Вам также может понравиться