English
Language : 

AN939 Datasheet, PDF (10/18 Pages) Microchip Technology – Designing Energy Meters with the PIC16F873A
AN939
HARDWARE DESIGN
The conceptual design for the energy meter is shown
in Figure 7; a more detailed schematic is presented in
Appendix A: “Schematics”. As previously noted, this
design was prototyped using the PIC16F873A. Users
may also implement this design without modification
using the pin-compatible PIC18F2320, if desired.
Line voltage and current are sampled sequentially at
regular intervals, with voltage and current being pre-
sented to different analog input channels. To measure
voltage, the AC line is sampled across a potential
divider, R19 and R20, which divides the input voltage
by about 300. For current measurement, two current
transformers create voltage signals across burden
resistors (R8 and R9) that are proportional to the load
current. As the core design of the energy meter will
accommodate different types of transducers, the CTs
themselves are not shown on the schematic.
Regardless of the sensor used, current is measured
sequentially on both line and neutral, alternating with
voltage measurements. Measuring both currents is
necessary for detecting ground Faults and error
conditions. An analog switch selects between the
appropriate channels and ground.
A fixed offset of approximately 2V is added to both the
current and voltage signals. This maintains the signal
well above VSS, which is an operating requirement of
the microcontroller’s ADC.
By itself, the ADC does not have the dynamic range or
resolution to perform the necessary measurements. For
the current signal, an amplifier with two selectable gain
stages follows the analog switches; it is used to compen-
sate for the wider dynamic range of the current sample.
The application firmware senses if the amplified current
signal is above or below the ADC’s capabilities and
automatically adjusts the gain accordingly. Single stage
gain is set by the values of R5, R6 and R7; together with
the turn ratio of the CT and the value of the burden
resistors, these determine the value of the current
proportionality constant, Ki. (For reference, the formula is
Ki = ((CT Ratio)((R5 + R6)/R7)/(R8 or R9).) The micro-
controller controls the amplifier gain through an analog
switch.
Energy consumption is calculated as previously
described in the “Firmware” section. Whenever the
energy is incremented by ten counts (i.e., 0.1 kWh), the
value is also stored in EEPROM as well. In the event of
a power failure and subsequent recovery, the
previously accumulated energy is retrieved and
accumulation resumes from that value.
An external Real-Time Clock (RTC) is used to generate
an interrupt signal every 30 minutes. This is the exter-
nal timing source for peak demand period calculations
discussed previously. The RTC can also be used to
implement other time/date functions.
Information on energy consumption is sent over a 4-wire
interface to an external LCD with integrated controller.
The current version of the application firmware displays
cumulative energy use to date, as well as several other
parameters, in a continuous rollover fashion.
Four indicator LEDs are provided to indicate Fault and
calibration states. The kWh LED flashes each time that
1/3200 kWh (0.3125 Wh) is consumed, producing an
optical signal that test equipment can use for meter cal-
ibration. The other LEDs indicate normal operation,
reverse-current operation and ground Fault (tamper)
conditions.
The core hardware design also includes a serial
(RS-232) interface for calibration. The data lines are
electrically isolated from the rest of the meter circuitry
to reduce the risk of damage to external equipment.
FIGURE 7:
CONCEPTUAL BLOCK DIAGRAM OF THE ENERGY METER
Measurement
Voltage
Line Current
Neutral Current
Attenuation
AC Fail
Transistor Selectable Gain
Switch
Amplifier
Control from Firmware
PIC16F873A
PIC18F2320
ADC
Communication/Control
4
Numeric LCD
with Controller
3
LEDs
2
RTC
Calibration
2
Serial Port
Calibration
Jumper
DS00939A-page 10
© 2005 Microchip Technology Inc.