0% found this document useful (0 votes)
30 views7 pages

Electrical Measurement by Microcontroller

The document discusses the transition from traditional electromechanical electricity meters to modern multirate, multifunction electronic meters powered by advanced microcontrollers. These new meters offer improved accuracy, automated data collection, and the ability to account for power factor, enabling utilities to manage energy consumption more effectively. The integration of measurement, computation, communication, and display functions into microcontrollers simplifies meter design and enhances functionality.

Uploaded by

GermanilloZeta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views7 pages

Electrical Measurement by Microcontroller

The document discusses the transition from traditional electromechanical electricity meters to modern multirate, multifunction electronic meters powered by advanced microcontrollers. These new meters offer improved accuracy, automated data collection, and the ability to account for power factor, enabling utilities to manage energy consumption more effectively. The integration of measurement, computation, communication, and display functions into microcontrollers simplifies meter design and enhances functionality.

Uploaded by

GermanilloZeta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Microcontrollers Fit the

Bill for Electricity Metering


By Ben Smith,Staff Engineer,
Dallas Semiconductor/Maxim, Dallas

New MCUs integrate the measurement,


computation, communications, memory and
display driver functions needed in multirate,
multifunction electronic energy meters.

A
quiet revolution is in progress in the utility While a century of refinement has made the kilowatt-
industry. Electromechanical metering hour meter one of the most reliable mechanical products
devices, in use for the better part of a in wide production, it remains a mechanical device prone
century to record electrical energy usage to wear, shock and other events that affect anything with
in kilowatt hours, are gradually being moving parts. Another limitation is that the meter, as usually
replaced by multirate, multifunction meters capable deployed, maintains no record of the time when usage
of more accurately accounting for utility usage. A new occurred. The meter only counts revolutions of the wheel
generation of microcontrollers is speeding the progress of and does not record the times when the wheel is moving
this revolution. faster or slower.
It is useful to know when electric power is consumed,
Beginnings because the demand placed on the electric utility is not
In 1885, Galileo Ferraris discovered that a solid armature constant over time. In fact, much more power is used during
placed in an out-of-phase ac magnetic field would rotate at waking hours than overnight. Utilities must design their
a rate proportional to the flow of electrical energy in the delivery systems to meet demand in the “peak hour.” This
coils that generated the field. This discovery is the principle means that for all other times, generators will be operating at
on which the great majority of electric meters still operate less than peak capacity; and since electricity can’t be stored,
today. an expensive capital resource is being partially wasted.
In the typical meter, a solid armature is mounted on jeweled For this reason, electric utility providers have an interest
bearings and allowed to rotate freely in a sealed container. in encouraging energy conservation during peak periods
Coils apply the ac magnetic field proportional to the amount and consumption during off-peak periods. The best way
of power flowing through the meter, and a counter detects to do this is through selective pricing; that is, charging the
the number of revolutions made by the disk. customer more for energy consumed during peak periods and
providing a discount during slack periods. This is a function
400 kΩ
of which static kilowatt-hour meters are incapable.
Voltage Sense Hi
A third limitation of traditional meters is that they
Neutral measure only real power. In an ideal world, measuring real
power is all that would be necessary—current and voltage
1 kΩ
0.1 µF would flow in phase. However, devices such as induction
motors and fluorescent lamp ballasts cause current to flow
out of phase with the applied voltage. Only the in-phase
component is usable as power, the remainder is reflected back
Hot Voltage Sense Lo
into the power grid. As a result, fewer actual watts are used
1 kΩ compared to the number of volt-amperes delivered.
0.1 µF For large industrial customers, electric utilities have
long used VAR-hour meters to determine the amount of
out-of-phase or reactive power delivered to the customer.
Fig. 1. The voltage channel of the reference electric meter consists of a With a multifunction meter, utilities can extend power
simple voltage divider providing a ratio of 400-to-1. factor monitoring to smaller commercial customers and, in

Power Electronics Technology June 2005 30 www.powerelectronics.com


MICROCONTROLLERS
fact, electric meter manufacturers since the early 1990s have
1 kΩ Current Sense Hi
Load been producing meters that measure usage electronically and
use digital circuits to accumulate and display energy. Now a
350 µΩ
Shunt new generation of microcontrollers are making the design
1 kΩ Current Sense Lo
task easier and faster.
Line
0.1 µF
Design Fundamentals
The hardware components of a multirate, multifunction
Fig. 2. The current channel of the reference electric meter uses a current meter are simple: a means of taking samples of the input
shunt to convert the load current to a millivolt-level voltage. voltage and current through the meter, a display mechanism,
some cases, to residences. By making multifunction meters a communications subsystem, a nonvolatile memory, a
standard, a utility can more easily determine where contract power supply, and a stored-program microcontroller to keep
terms may need to be adjusted to include power factor everything in step. The good news for meter designers is that
penalty language. many of these components can be found integrated on the
Finally, there is the question of reading the meter microcontroller itself.
and transferring the collected usage data to the billing For example, the MAXQ3120 from Dallas Semiconductor/
department. Sending personnel into the field to record usage Maxim, headquartered in Dallas, integrates two 16-bit A/D
is expensive and prone to human error. Add the complexity converters for the voltage and current channels, two UARTS
of having to record usage during several tariff periods, and (one configured for IR communication), an LCD controller
the burden becomes unacceptable. Some form of automated and a 16  16 multiply-accumulate unit on a single die, with
reading is needed. sufficient data RAM and program flash to provide all the
The requirements for increased flexibility in measuring functions mentioned above for a multirate, multifunction
usage by time and power factor, improved reading speed electric meter.
and accuracy, combined with the expectation of reliability Designing the operating software for such a meter is more
long provided by mechanical
96817.4p1c.Switcher meters,
Mag_C&K suggests
1/12/05 9:12the
AM need
Pagefor
1 challenging. First, since the software defines the fundamental
an all-electronic meter built around a microcontroller. In behavior of the product, it will of necessity be different for
each locale. Second, even if designed in a high-level language
(like C), the software will have to be customized for the
particular hardware environment in which it will run.
The relative simplicity of the hardware for an electric
meter as compared to its operating software actually provides
an opportunity for the electric meter manufacturer: since
loading the operating software can be a late-stage operation,
it is possible to build and stock many base circuit boards
From 1 Watt to for an electric meter, customizing them with individual
200 Watts software loads as they are ordered by the various electric
utilities. This is important since overall product cost may
Transformers
well be the make-or-break factor in selling the product to
Inductors
an end customer. Dallas Semiconductor/Maxim provides
Filters a reference design in C that can be customized and
EMI/RFI CMCs modified to provide any level of functionality needed by the
For UL/CSA recognized magnetic end user.
components...for SMPS Since most modern A/D converters are voltage-input
applications...designed for use devices, measuring the input voltage is easy, in that it is
with leading semiconductors...for only necessary to scale the voltage on the input to the range
application notes and reference (usually from a few tens of millivolts to about 1 V) required
circuits...call Premier, the by the differential input of the A/D converter. In the reference
"Innovators in Magnetics Technology". design, a resistor network divides the input voltage by a factor
of 400. The resistor divider converts the line voltage to the
–1-V to 1-V range required by the A/D converter (Fig. 1).
On the current side, a current shunt converts the current
through the meter to a small, millivolt-level voltage. The
voltage across the shunt must be kept small to minimize the
20381 Barents Sea Circle power dissipated by the shunt: a 0.5-m shunt will provide
Lake Forest, CA 92630 Tel. (949) 452-0511
only a 20-mV full-scale signal, but will dissipate almost
www.premiermag.com 1 W at 40 A (Fig. 2).
CIRCLE 221 on Reader Service Card or freeproductinfo.net/pet
Power Electronics Technology June 2005 32 www.powerelectronics.com
MICROCONTROLLERS
Now it’s time
to focus on the Segments
Voltage Channel
data conver ters Load Common Display
CPU
themselves. At first,
Current Channel
the requirements Signal MAXQ
Conditioning 3120
to measure a 50- JTAG
Current

EEPROM
Hz or 60-Hz signal Shunt
seem trivial. But on Tx Infrared
Line
Rx Communications
closer inspection, Interface
the job is a little

Time of
Day
tougher. Look at
accuracy first: most Meter
Pulse
specifications call
for the meter to Vdd
have 1% accuracy Tx
over its entire Power Rx
range—not just Supply Tx Enable

Isolated
EIA485
full-scale accuracy.
The reference Isolated Vdd
design described
Net
here has guaranteed Address
accuracy from 1 A Button
to 40 A. To meet
this requirement, Fig 3. Hardware components of the reference design meter. Because of the highly integrated microcontroller, all that
the meter must is needed is a display, a power supply, a nonvolatile memory, physical devices for communication, and passive signal
successfully resolve conditioning for measuring voltage and current.
current as low as
10 mA, but not saturate until it is measuring more than 40 ensure that the last reading displayed is maintained internally
A—a 4000-to-1 ratio. This means that the data converter by the meter.
can be no less than 12 bits, with a 14-bit or better converter There are simply too many communications schemes
preferable. in the market today to ever hope to cover every one in an
What about sample rate? If the fundamental frequency integrated peripheral. It is a reasonable bet, however, that
was all that was of concern, then sampling at some rate above for an inexpensive metering apparatus, it is likely going to
the Nyquist frequency (120 Hz for a 60-Hz system) consistent be some variant on simple asynchronous serial.
with conservative anti-aliasing filter design would be In the reference design for the MAXQ3120, we settled on
sufficient. However, most specifications require that the meter two serial peripheral channels. The first is based on the EIA-485
accurately measure power containing frequencies as high as standard. In this arrangement, the meters reside on a network
the 21st harmonic. In a 60-Hz system, that corresponds to that is managed by a PC acting as a central controller. As the
a frequency response of 1260 Hz and a sampling frequency PC polls the meters, they respond with data packets that
of no less than 2520 Hz. While these specifications are no represent usage. The PC can then aggregate and transmit
challenge for modern data converters, they may stretch the the information to a billing facility.
capabilities of some of the A/D converters built into many The second communication channel is an IR transmitter
microcontroller devices. and receiver system based on simple asynchronous protocols.
The communications protocol is based on a Chinese electric
Hardware Design Analysis meter specification, DL/T 645, which specifies an IR physical
The hardware for the reference design is shown in Fig. 3. layer that differs significantly from those found in commonly
The entire meter consists of the MAXQ3120 microcontroller, used standards. For details on physical layer encoding, see
a power supply, a display, an I2C EEPROM, the input sensors Fig. 4. In the transmitter channel, a circuit modulates the
and communication peripherals. output of the UART so that a “0” is transmitted as a 38-kHz
The reference design described here uses an LCD as signal and a “1” is represented by the absence of the signal.
a display element. The advantage is obvious. By using The receiver is implemented in an inexpensive IC that
annunciators, the display can indicate anything from energy integrates an IR photodiode and a 38-kHz detector. In this
to voltage to time of day. way, only the optical components themselves are required to
The disadvantage of an electronic display is that it shows implement a fully functional IR transceiver system.
nothing when the power is off. And while a mechanical Power is the simplest block. Since modern micro-
counter is inherently nonvolatile, measures must be taken to controllers are low-power devices, a simple transformer-

www.powerelectronics.com 33 Power Electronics Technology June 2005


MICROCONTROLLERS

to endure between
Asynchronous Start Bit Bit Bit Bit Bit Bit Bit 10,000 and 1 million
Bit Odd Stop
Data Bit 0 1 2 3 4 5 6 7
write cycles. While Parity Bit

38 kHz Carrier 833 µs this might sound


Bit Time
like a large number,
Transmitted
Carrier consider that the
software subsystem
would like to update
Fig. 4. The IR communications channel uses a simple on-off modulation scheme. The presence of a 38-kHz carrier the nonvolatile
represents a “0” bit, while the absence of a carrier represents a “1” bit. The character format is 8 bits, one stop bit and memory every line
odd parity.
cycle. At 50 Hz, that
based linear supply is all that is needed. means even the best EEPROM might wear out in as little as
In the reference design, the microcontroller is not isolated 5-½ hours. In practice, a caching subsystem prevents this
from the power line; in fact, the system ground is at line from happening, but the problem is not trivial.
voltage. This makes it impossible to directly connect the FRAM solves these problems at a price. A FRAM has
network to the microcontroller, because equipment on the a write cycle that takes no longer than a read cycle—a
network would be exposed to line-level voltages. In this few microseconds, with the bulk of the time being
design, a separate winding on the transformer provides communications overhead—and it has an unlimited
power to the network transceiver, and the transceiver is endurance. The downside is that it can cost several times an
optically coupled to the microcontroller, thus preserving equivalently sized EEPROM.
isolation.
There are two major contenders for a nonvolatile data Choosing a Microcontroller
store for the reference design: semiconductor EEPROM There are several factors to consider when choosing
and ferroelectric RAM (FRAM.) The former is much less a microcontroller for an electric meter. Consider the
expensive, but has relatively long write times—on the order of following:
milliseconds—and, depending on model, is only guaranteed ● Feature set. Does the microcontroller have the

Cost-Effective Discrete IGBT Copacks for 480VAC to 575VAC Applications


1700V NPT IGBTs with SONIC-FRDTM Fast Recovery Diodes

IGBT COPACK Advantages Applications


C

• Optimized for fast-switiching • Induction Heating


G
• tFI(TYP) < 50ns (25°C) for switching • Induction Cooking
E frequency up to 100kHz • Microwave Ovens
TO-247-(H) TO-268-(T) • Lower EON/EOFF than series • Offline High Voltage PWM Power Converters
connected devices • 480 to 575VAC Offline Inverter and UPS Applications

Part Number VCES IC(90°C) VCE(ON, 25°C)@ IC(90˚C) (TYP) EOFF@TJ=125˚Typ RTH(J-C) Package

IGBT Copacks
PLUS247TM-(X) ISOPLUS247TM-(R) IXGH16N170AH1 1700 V 11 A 4.00 V 1.1 mJ 0.65°C/W TO-247
CU IXGT16N170AH1 1700 V 11 A 4.00 V 1.1 mJ 0.65°C/W TO-268
PHASE LEG GU QU
IXGR16N170AH1 1700 V 8A 4.20 V 1.1 mJ 1.10°C/W †ISOPLUS247™
IXGH24N170AH1 1700 V 16 A 4.50 V 2.2 mJ 0.5°C/W TO-247
EU, CL IXGT24N170AH1 1700 V 16 A 4.50 V 2.2 mJ 0.5°C/W TO-268
IXGX32N170AH1 1700 V 24 A 4.20 V 3.0 mJ 0.35°C/W PLUS247™
GL
QL
IXGR32N170AH1 1700 V 17 A 4.20 V 3.0 mJ 0.65°C/W †ISOPLUS247™
ISOPLUS-i4PAKTM-(F) ISOPLUS-i4PAK-STM-(F..S) Phase Leg Packages
EL

FII24N17AH1 1700 V 11.5 A 4.20 V 1.7 mJ 0.95°C/W †ISOPLUS i4-PAK™


w ww.ixys.com FII24N17AH1S 1700 V 11.5 A 4.20 V 1.7 mJ 0.95°C/W †ISOPLUS i4-PAK-S™
(1) Samples and datasheets available 6/05. (2) Samples and datasheets available early 7/05.
† 2500V isolated packages; consult datasheets for more details.

Efficiency Through Technology


CIRCLE 222 on Reader Service Card or freeproductinfo.net/pet
Power Electronics Technology June 2005 34 www.powerelectronics.com
MICROCONTROLLERS
peripherals you will
need? Look for an
IR EIA485
integrated time- Driver Driver
of-day clock, serial Task
Wheel Message
co m m u n i c a t i o n Board
peripherals, timers
and counters, IR
Message Processing
communication,
and a display Display
Time of
controller. You will Day Formatter
also require some Manager Register
form of signal Manager
processing, either on Priority
the microcontroller Highest
or in an external Scheduling Asynchronous Normal
device. DSP Engine Events
Lowest
● Code space.

If the application
Fig 5. Software components of the reference design meter. Each of the tasks is called by a central task wheel without
will be written in
pre-emption. Higher priority tasks occur earlier in the task list and thus get an earlier chance at processor cycles. The
C, plan on between message board facilitates inter-task notifications, as depicted by bold arrows in the diagram.
16 kbytes and 64
kbytes of code space. The reference design presented here needs to be updated. For these events, the system maintains
fits comfortably in 32 kbytes. a set of bits, each of which is set by one task to alert another
● Data space. Make sure your microcontroller has enough task that there is a condition that requires its attention. This
data RAM to accommodate your data structures. set of bits is called the “message board.”
● Data converters. While many microcontrollers have In a practical meter design, the data elements to be
“data acquisition systems” built onto the die, often they
are low speed, low resolution or both. An ideal converter
for a Class-1 meter as defined in IEC61036 would have
14-bits or better resolution, and 10-ksps sample rate or
better.
● Real-time clock. Make sure the clock is trimmable to

a half-second-per-month accuracy. If it is not, consider an


external oscillator or clock module.

Getting the Software Right


In the reference design, a full, pre-emptive OS was
considered and rejected on the grounds that it would be
unnecessarily wasteful of resources. While the design does
need some degree of multitasking, full pre-emption is not
required. Instead, a simple main process was built that calls
tasks one after another, and each task is designed to do its
work and then relinquish control of the processor after
a short time. This main process is called the “task wheel”
and performs the work of a simple task scheduler. In this
way, every task executes when it must and no task is starved
for cycles. See Fig. 5 for an overview of the major software
blocks.
In the electric meter design, every task monitors its input
conditions to see if there is anything to be done; if not, it
simply returns to the task wheel. For some tasks, the input
conditions are based on external events. For example, a
sample becomes ready at the A/D converter or a character
becomes available at one of the serial ports.
For other tasks, the condition is strictly internal: an update
to the cumulative energy needs to be made or the display
CIRCLE 223 on Reader Service Card or freeproductinfo.net/pet
www.powerelectronics.com 35 Power Electronics Technology June 2005
MICROCONTROLLERS

data, configuration
7. The Message Builder appends a preamble and information, and
1. Character by character, the calculates the checksum and passes the message,
Serial Port Driver alerts the byte by byte, to the Serial Port Driver. many commands
Message Checker that data Serial
is incoming. Port are transferred to
Driver and from the meter
2. Message Checker 8. The Serial Port Driver
acknowledges each acknowledges each byte as using a series of
character as received. it is transmitted.
registers. Each reg-
9. After the last
3. When Message Checker byte, the Message Builder Message
ister is designated
Message
receives a complete, valid clears the flag toward the Builder by a four-digit hexa-
Checker
message, it alerts Message Formatter.
the Message decimal number
Decoder. 6. After creating the response, the and contains one
Message Formatter alerts the
Message Builder. piece of informa-
10. As each flag is tion: register 9010
4. Messages that require a Message cleared, completion notification Message
register read are routed to Decoder flows up the chain until finally the
contains information
Formatter
the Register Manager. Message Checker is notified. The about current usage
system is now ready to
process the next message.
while register C032
5. The Register Manager contains the serial
Register retrieves data from the number of the
Manager register and passes it to the
Register Formatter. meter.
Figure 6 illu-
Fig. 6. Message processing in the electric meter reference design. Inbound messages are assembled, decoded and strates how a mes-
processed; outbound messages are formatted and built by separate tasks that communicate with one another using s a g e r e q u e s t i n g
a message board. data from a register
maintained in storage and the data formats will depend would be handled. In the illustration, the request begins
strongly on the communication protocols that are used. The as it is received at the serial port manager and flows
reference design was based on DL/T 645, a Chinese electric counterclockwise, activating each task along the way until the
meter communication standard. In this standard, usage requested data is finally transmitted at the serial port manger.

CIRCLE 224 on Reader Service Card or freeproductinfo.net/pet


Power Electronics Technology June 2005 36 www.powerelectronics.com
MICROCONTROLLERS
Then, acknowledgments flow clockwise, clearing the busy
indication at each task until the entire system is ready for
the next inbound message.
The following narrative provides more detail on the
message passing and processing system:
● The message comes in, byte by byte, from the IR receiver

module. As each byte comes in, the serial port driver sets a
bit in the message board to notify the message checker task
of the event.
● When notified, the message checker consumes the

character from the serial port driver and, if contextually


correct, adds the byte to the message queue. The message
checker understands message syntax, but does not
understand anything about the message payload. When the
message has been completely received, the message decoder
task is alerted by setting a message board bit.
● The message decoder inspects the incoming message

and determines that: (1) it is a read command; (2) it is for


a valid register; and (3) there is no other condition that
would prevent the execution of the command. If all this is
true, the register manager is notified via the message board
that a register read is required. Note that the message
decoder does not at this time clear the notification given
by the message checker. Only one message is handled at
a time.
● The register manager interacts with the EEPROM

to retrieve the requested information. When finished, it


notifies the message formatter that a register is ready to be
transmitted. As in the previous step, it does not clear the
message flag set by the message decoder.
● The message formatter moves the data just read from

the register manager data buffer to the communication


buffer. It also sets the message length in the communication
buffer before notifying the message builder that a buffer is
ready to be transmitted.
● The message builder then sends each byte of the

message one at a time to the serial port driver. It is also


responsible for calculating the message checksum. When the
last byte has been sent, it clears the notification bit from the
message formatter. On its next turn, the message formatter
clears its notification bit from the register manager, and so For superior solutions:
forth until the message chain is clear.
Every process in the meter works in this way, setting Power capacitors
bits in the message board and notifying other tasks of
conditions. The primary advantage of using this method
is that it requires very little RAM to implement: the entire � Power electronics
reference design fits in less than 1/2 kbyte of data RAM. � Motor run and lighting
Fully documented source code is available from Dallas
Semiconductor/Maxim.
� Power factor correction
As utilities are increasingly squeezed by generation
prices on the one hand and regulatory pressure on the other,
More information at www.epcos.com
they are increasingly seeking ways of enhancing market
efficiency. With the new generation of microcontrollers
now available, meter manufacturers can deliver the CIRCLE 225 on Reader Service Card or freeproductinfo.net/pet
means of more efficient electric power delivery, metering
and billing. PETech

www.powerelectronics.com 37 just everywhere …


Power Electronics Technology

You might also like