English
Language : 

AN939 Datasheet, PDF (1/18 Pages) Microchip Technology – Designing Energy Meters with the PIC16F873A
AN939
Designing Energy Meters with the PIC16F873A
Author: Sandip Chattopadhyay
Microchip Technology Inc.
INTRODUCTION
The deployment of electronic energy meters has
gained a great deal of momentum over the past several
years. This is due to their two main advantages over
the traditional electromechanical designs: improved
accuracy and an expanded set of features. Current
microcontroller technology allows designers to build
meters that are competitive in price with traditional
devices, while maintaining the required IEC 1036
Class 1 accuracy of ±1% for domestic applications.
Microcontrollers also allow the easy incorporation of
added features, such as rms voltage and current and
peak demand metering, as local electric utility
companies desire to implement them.
In this application note, we will discuss the implementa-
tion of a basic watthour meter using PICmicro® Flash
microcontrollers. In the process, we will show how one
ADC with a single sample-and-hold circuit can effectively
measure both voltage and load current and maintain
Class 1 accuracy. The firmware discussed measures and
displays rms voltage and current, as well as kWh,
presented in a clear digital format on an LCD.
Besides basic energy measurement, this design also
includes features that many electric utilities are very
interested in rolling out on a wider basis. Dual-channel
measurement provides a simple method for monitoring
for tamper conditions. An on-board RTC provides a
time source for calculating and tracking current and his-
torical peak demand. All metered data is securely
stored as it is updated in nonvolatile memory.
The design discussed here uses the PIC16F873A and
two Current Transformers (CTs) for current sensing. It
can be implemented just as easily with the pin compati-
ble PIC18F2320. Current measurement using a shunt
may also be used in this design, with little or no change
to the current amplifier design.
PRINCIPLES OF MEASUREMENT
Basically, a watthour meter is designed to measure
energy or power consumed over time. In simple terms,
electrical power is the product of voltage and current. If
we make repeated measurements of both instanta-
neous voltage and current, or Vi and Ii, we can keep a
running total of their products over time. By dividing the
total accumulated energy over the number of samples,
we have the average power (the first expression in
Equation 1). Multiplying the average power by time
gives the total energy consumed.
EQUATION 1:
CALCULATING AVERAGE
ENERGY AND CONSUMED
POWER
Σ⎛ N
⎞
Average Power
(watts)
=
⎜
⎝
k
=
1Vi k
•
Ii
⎟
k⎠
N
Σ⎛ N
⎞
Energy Consumed
(wattseconds) =
⎜
⎝
k
=
1Vi k
•
Ii
⎟
k⎠
Fs
For alternating current, such as that from the mains,
average power also must account for power factor,
which is the phase relationship between voltage and
current. In simple terms, average AC power is V I cosθ,
where V and I are average rms voltage and current,
and θ is the phase angle between the two. Instanta-
neous sampling does not directly use power factor; the
value of the phase angle is essentially embedded in the
instantaneous current measurement. Recovering the
actual phase angle for the purpose of calculating and
displaying the power factor can be done separately and
is very calculation intensive. If we are just measuring
energy consumption, it is not necessary.
© 2005 Microchip Technology Inc.
DS00939A-page 1