0% found this document useful (0 votes)
43 views48 pages

Picref-3: Watt-Hour Meter Reference Design

Uploaded by

iskandarn_el5735
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)
43 views48 pages

Picref-3: Watt-Hour Meter Reference Design

Uploaded by

iskandarn_el5735
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
You are on page 1/ 48

Whm.

bk Page 1 Wednesday, July 29, 1998 2:18 PM

M PICREF-3
Watt-Hour Meter Reference Design

INTRODUCTION PICREF-3 OVERVIEW


The PICREF-3 Watt-Hour Meter (WHM) Reference The WHM Reference Design provides a cost effective
Design shows the use of a mixed signal microcontroller circuit capable of monitoring and displaying power and
in an AC power measurement application. energy consumption on worldwide power mains in the
The traditional sensor signal processing chain consist- 90V to 264V range.
ing of sensor, signal conditioning electronics, A/D con- The PIC16C924 microcontroller shows that the
verter and microcontroller is abbreviated by the use of real-time events of sampling voltage and current wave-
the mixed signal microcontroller with its on-board A/D forms can be interleaved with power and energy calcu-
converter. lations. All measurements and calculations are
The mixed signal microcontroller used is the Microchip performed once per second.
PIC16C924. This microcontroller has five A/D chan- The current waveforms measured are linear for resis-
nels, two of which are used to digitize voltage and cur- tive and inductive loads and non-linear for switching
rent signals. The microcontroller features of pulse width power supplies. The current waveform is sampled dur-
modulation (PWM) and direct liquid crystal display ing the positive current cycle with waveform symmetry
(LCD) drive are utilized to further reduce cost and parts assumed between positive and negative cycles (valid
count. for the measured waveforms). A hardware method for
The PWM output feature is used with a single pole RC full cycle current measurements and firmware methods
filter to provide a comparator reference with 10 bits of for complex current waveform shapes are provided in
resolution. the Design Modifications section.

The direct LCD drive is used to drive an 8-digit, PICREF-3 KEY FEATURES
7-segment LCD. • Accepts polarized and unpolarized worldwide
MICROCONTOLLER BENEFITS power mains.
• Measures and displays AC Voltage (90V to 264V),
The use of a PIC16C924 microcontroller in a power
Load Current and Power Factor.
meter offers the following advantages:
• Measures power line frequency (47 Hz to 63 Hz).
• Real-Time Electrical Measurement and
• Calculates Watts, Watt-Hrs and cumulative
Power/Energy Calculations
Watt-Hrs and displays these values, as well as
• Direct LCD Drive frequency and time.
- Present Time • True RMS measurements.
- Total Watt-Hours (Whr) • Firmware control of triac load switch on/off state.
- Maximum or Cumulative Demand • Real time clock during power-saving sleep mode.
• Customization • Hibernate mode to save on battery life during stor-
• Quick Time-to-Market age.
• Battery back-up for microcontroller.

INFORMATION CONTAINED IN THIS PUBLICATION IS INTENDED THROUGH SUGGESTION ONLY AND MAY BE SUPERSEDED BY UPDATES.
NO REPRESENTATION OR WARRANTY IS GIVEN AND NO LIABILITY IS ASSUMED BY MICROCHIP TECHNOLOGY INC. WITH RESPECT TO
THE ACCURACY OR USE OF SUCH INFORMATION, OR INFRINGEMENT OF PATENTS ARISING FROM SUCH USE OR OTHERWISE. IT IS
THE RESPONSIBILITY OF EACH USER TO ENSURE THAT EACH WATT-HOUR METER IS ADEQUATELY DESIGNED, SAFE, AND COMPATI-
BLE WITH ALL CONDITIONS ENCOUNTERED DURING ITS USE. "TYPICAL" PARAMETERS CAN AND DO VARY IN DIFFERENT APPLICA-
TIONS. ALL OPERATING PARAMETERS, INCLUDING "TYPICALS", MUST BE VALIDATED FOR EACH CUSTOMER APPLICATION BY THE
CUSTOMER'S TECHNICAL EXPERTS. USE OF MICROCHIP'S PRODUCTS AS CRITICAL COMPONENTS IN LIFE SUPPORT SYSTEMS IS NOT
AUTHORIZED EXCEPT WITH EXPRESS WRITTEN APPROVAL BY MICROCHIP. NO LICENSES ARE CONVEYED, IMPLICITLY OR OTHERWISE,
UNDER ANY INTELLECTUAL PROPERTY RIGHTS.

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 1


Whm.bk Page 2 Wednesday, July 29, 1998 2:18 PM

PICREF-3
TABLE OF CONTENTS
System Overview..........................................................................................................................................3
Hardware Overview ......................................................................................................................................4
Firmware Overview.......................................................................................................................................8
Firmware Detail...........................................................................................................................................16
Test Results................................................................................................................................................21
Calibration...................................................................................................................................................21
Power Theory .............................................................................................................................................22
Design Modifications...................................................................................................................................23
App A: System Specifications.....................................................................................................................25
App B: Schematics .....................................................................................................................................26
App C: Firmware Listing .............................................................................................................................37
App D: PCB Layout & Fab Drawing............................................................................................................39
App E: Bill of Materials (BOM) ....................................................................................................................40
App F: Watt-Hour Meter Demo Unit............................................................................................................45

ACKNOWLEDGMENTS
Hardware Design and Firmware Development:
Dennis E. Coleman, Sr. Applications Engineer,
Microchip Technology, Inc.
[email protected]
Documentation:
Beth McLoughlin, Applications Engineer,
Microchip Technology, Inc.

DS30452A-page 2 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 3 Wednesday, July 29, 1998 2:18 PM

PICREF-3
System Overview Power line voltage (90V – 264V) is sensed by the high
voltage AC electronics (Figure 1). Balanced input volt-
The PICREF-3 Reference Design shows how to age and current signals are then provided to the Small
develop a cost-effective watt-hour meter (WHM). Using Signal Analog/Digital Sense Electronics for input into
the PIC16C924 microcontroller, the WHM performs the PIC16C924. The PIC16C924 uses the analog/digi-
power line measurements, followed by power and tal voltage sense and analog/digital current sense to
energy calculations, once per second. System Specifi- calculate the power and energy consumption of the
cations may be found in Appendix A. load. The microcontroller then displays these calcula-
The PICREF-3 can accept all worldwide power mains tions on the 8-digit LCD according to user pushbutton
and is calibrated for both. Worldwide power mains can input.
be either polarized or unpolarized. A polarized power The PIC16C924 controls the on/off state of the triac
main has a grounded neutral connection. Reversal of control circuit. The triac control circuit applies current to
line and neutral on a polarized power main will create a the power triac gate to effect on/off load current switch-
power line fault. An unpolarized power main does not ing. (Triac switch included for demo purposes only.)
have a grounded neutral connection. Therefore, line
In addition, the pulse width modulation (PWM) output of
and neutral can be connected at random without caus-
the microcontroller is filtered and used as a variable ref-
ing a power line fault.
erence to a comparator in the current sense circuitry.
Countries using polarized power mains include Austra-
A serial EEPROM is available to store the watt-hour
lia, United Kingdom, Ireland, Denmark, India, Israel,
count displayed at the time of a power outage. In addi-
Japan and Switzerland. Countries using unpolarized
tion, an RS-232 serial port is available for sending and
power mains include Germany, Austria, Norway, Swe-
receiving serial data. Firmware for these functions has
den, France, Finland, the Netherlands, Belgium and
not been implemented (See Design Modifications).
Italy.
Linear power supply electronics provide general device
The PICREF-3 is limited to measuring a maximum cur-
power, voltage reference and battery backup.
rent of 10 Amps. However, residential current loads are
200 Amps maximum. See Design Modifications for
hardware design changes to scale the meter for 200A
loads.
FIGURE 1: PICREF-3 WATT-HOUR METER (WHM) BLOCK DIAGRAM

Small Signal Analog/Digital


High Voltage AC Electronics
Sense Electronics 8-Digit LCD Display

Current Current
AC
90V - 264V 10 A Max Sense Sense
Input Trans. Circuitry

Power Phase Sense


Resist. Triac Voltage
AC Gate
Load Voltage Sense
Output
Divider Circuitry

PWM
RC Filter
Microchip Technology’s
Triac Control PIC16C924
Microcontroller
Pushbuttons

Linear Power Serial EEPROM


Supply Electronics
RS-232
Serial Port
Digital & Analog Power,
Battery Backup, Voltage References
90V - 264V
Voltage References

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 3


Whm.bk Page 4 Wednesday, July 29, 1998 2:18 PM

PICREF-3
The PIC16C924 source code is written in C. Firmware Hardware Overview
algorithms accomplish voltage and current measure-
ments, voltage and current waveform phase shift mea- This section describes the PICREF-3 hardware and
surements, real-time timekeeping, and calculation and how it functions in the system. Hardware detail (sche-
display of power and energy consumption. In addition, matics) may be found in Appendix B.
there is code to display measurements on the LCD. Microcontroller
The Watt-Hour Meter (WHM) reference design has five The PIC16C924 (Figure 2) allows for the real-time
(5) modes of operation, determined by the PIC16C924 interleaving of sampling voltage and current wave-
firmware: Reset, Entry, Measurement, Sleep, and forms, and power and energy calculations. Also, the
Hibernate. More information on each mode is pre- PIC16C924 drives the display (LCD) and controls the
sented in Firmware Overview. triac and current sense input (for true RMS current
measurements).
FIGURE 2: PIC16C924 PINOUT

RD7/SEG31/COM1
RD6/SEG30/COM2
RA3/AN3/VREF

LEGEND:

MCLR/VPP
RA2/AN2

RA1/AN1
RA0/AN0

PLCC Input Pin

COM0
Output Pin
RB2
RB3

RB4
RB5
RB7
RB6
VDD
VSS

N/C Input/Output Pin


Digital Input/LCD Output Pin
LCD Output Pin

9 8 7 6 5 4 3 2 1 68 67 66 65 64 63 62 61
RA4/T0CKI 10 60 RD5/SEG29/COM3
RA5/AN4/SS 11 59 RG6/SEG26
RB1 12 58 RG5/SEG25
RB0/INT 13 57 RG4/SEG24
RC3/SCK/SCL 14 56 RG3/SEG23
RC4/SDI/SDA 15 55 RG2/SEG22
RC5/SDO 16 54 RG1/SEG21
C1 17 53 RG0/SEG20
C2 18 PIC16C924 52 RG7/SEG28
VLCD2 19 51 RF7/SEG19
VLCD3 20 50 RF6/SEG18
AVDD 21 49 RF5/SEG17
VDD 22 48 RF4/SEG16
VSS 23 47 RF3/SEG15
OSC1/CLKIN 24 46 RF2/SEG14
OSC2/CLKOUT 25 45 RF1/SEG13
RC0/T1OSO/T1CKI 26 44 RF0/SEG12

2728 2930 3132 33 34 35 36 37 38 39 40 41 42 43


RC1/T1OSI
RC2/CCP1
VLCD1
VLCDADJ
RD0/SEG00
RD1/SEG01
RD2/SEG02
RD3/SEG03
RD4/SEG04
RE7/SEG27
RE0/SEG05
RE1/SEG06
RE2/SEG07
RE3/SEG08
RE4/SEG09
RE5/SEG10
RE6/SEG11

DS30452A-page 4 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 5 Wednesday, July 29, 1998 2:18 PM

PICREF-3
High Voltage AC Electronics
AC voltage (90V - 264V) is applied to the AC input and AC current also flows through a resistive voltage divider
a load is connected to the AC output (Figure 3). via the AC output.
AC current flow is from the AC input to the AC output The current sense transformer and resistive voltage
and through the load. AC current continues through divider provide low-voltage analog waveforms which
triac switch and current sense transformer back to the replicate the large scale voltage and current waveforms
AC input. at their respective sensor inputs.
FIGURE 3: HIGH-VOLTAGE AC ELECTRONICS DETAIL

AC
90V - 264V
Input
Unbalanced Input
Current Signal
Power 10 A
Triac
Gate
Current
Sense
Triac Control Transformer

AC Resistive
Load Voltage Balanced Input
Output
Divider Voltage Signal

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 5


Whm.bk Page 6 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Small Signal Analog/Digital Sense Electronics
– Voltage
The balanced input voltage signal from the resistive An unbalanced input voltage signal is tapped off of the
divider is amplified by an instrumentation amplifier balanced input voltage signal and connected to a com-
(Figure 4). This amplifier accomplishes signal amplifi- parator input. This comparator is used to compare the
cation and rejection of common mode noise. input signal to an analog ground reference.
The signal at the amplifier output swings above and The comparator output goes high when the input signal
below a negative reference potential. The amplifier out- exceeds the ground reference. The output of the com-
put is connected to A/D converter input AN0 of the parator provides digital voltage sense information and
PIC16C924. is connected to I/O line RG7 of the PIC16C924.
FIGURE 4: SMALL SIGNAL ANALOG/DIGITAL VOLTAGE SENSE ELECTRONICS DETAIL
Unbalanced Input Voltage Signal Digital Voltage
Comparator
Sense

GND Reference

Balanced Input Instrumentation Analog Voltage


Voltage Signal Amplifier Sense

Negative Reference

Small Signal Analog/Digital Sense Electronics


– Current
The unbalanced input current signal from the sense The unbalanced input current signal is also connected
transformer is amplified by an instrumentation amplifier to a comparator input. This comparator is used to com-
(Figure 5). This amplifier accomplishes signal amplifi- pare the input signal to a variable positive reference
cation and rejection of common mode noise. (PWM reference).
The signal at the amplifier output swings above and The comparator output goes high when the input signal
below a ground reference potential. The amplifier out- exceeds the reference. The output of the comparator
put is connected to analog converter input AN1 of the provides digital current sense information and is con-
PIC16C924. nected to I/O line RE7 of the PIC16C924.
FIGURE 5: SMALL SIGNAL ANALOG / DIGITAL CURRENT SENSE ELECTRONICS DETAIL

Comparator Digital Current


Sense

PWM Reference

Unbalanced Input Instrumentation Analog Current


Current Signal Amplifier Sense

GND Reference

DS30452A-page 6 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 7 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Microcontroller I/O
The PIC16C924 is a “mixed-signal” microcontroller, or An A/C Input Balanced/Unbalanced Sense line pro-
a microcontroller capable of analog and digital vides the microcontroller with information on whether
input/output (Figure 6). This capability is used by the the input neutral line is grounded or ungrounded to sup-
PIC16C924 to control the functions of the PICREF-3. port worldwide power main functionality of WHM.
Input Output
The on-board A/D converters of the PIC16C924 allow The PIC16C924 feature of direct LCD drive makes dis-
input of analog, as well as digital, voltage and current play simple. The information displayed is determined
sense signals from the Small Signal Analog/Digital by user pushbutton input (Firmware Overview).
Sense Electronics (Figure 1). Depending on user push- Through the use of PWM and an RC filter, the
button input (Firmware Overview), these signals may PIC16C924 can vary the analog reference voltage to
be used for display (LCD) or calculation and display. the current sense comparator (Small Signal Ana-
Pushbutton input is digital. log/Digital Sense Electronics) for use in true RMS cur-
A +5V analog reference is provided for the A/D convert- rent measurements (Firmware Overview).
ers on the microcontroller. A +3V analog reference is The microcontroller controls the triac through triac con-
also available for better A/D resolution. trol circuitry. The triac (High Voltage AC Electronics)
Interrupt input is provided into microcontroller pin may be turned on/off by pressing the START/STOP
RB0/INT. The digital voltage sense line, digital current pushbutton. This will turn on/off current flowing to the
sense line, and serial communication input lines are load. (Triac switch included for demo purposes only.)
each differentiated, by identical circuits, and wire-or’d
Input/Output
together as input to RB0/INT. The differentiated digital
voltage sense signal is used to wake the microproces- A Serial EEPROM is provided to store data in the event
sor from Sleep or Hibernate modes. of a power loss. In addition, an RS-232 serial port is
provided for communication with a computer. Firmware
for these functions has not been implemented (See
Design Modifications).
FIGURE 6: MICROCONTROLLER I/O DETAIL

8-Digit LCD

SEG00 - SEG26, Analog Voltage Sense


RC Filter PWM RC2 RA0/AN0
COM0 - COM2
Digital Voltage Sense
RG7
Triac Control Circuit RA4
Analog Current Sense
RA1/AN1
Digital Current Sense
PIC16C924 RE7
Microcontroller

Pushbuttons RB4 - RB7, interrupt d/dt


RB0/INT
MCLR

Serial EEPROM RB1 - RB3


SDI, SDO RS-232 Serial Port
3V Reference
RA3
+5V Analog Reference
AVDD AC Input Balanced/Unbalanced Sense
RA5

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 7


Whm.bk Page 8 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Push Buttons Firmware Overview
PICREF-3 pushbuttons and functions are listed in
The PIC16C924 firmware controls the Watt-Hour Meter
Table 1. For more information on pushbutton functions,
operational modes and calculates power forms for dis-
see Firmware Overview.
play.
TABLE 1: PUSHBUTTONS There are five (5) modes of operation for the
PICREF-3:
Push- Name Function
button • Reset
S1 Start/Stop Turn on/off the current flow to • Entry
the load. • Measurement
S2 Cancel*; D Cancel: Quit w/o saving; • Sleep
D: Increment • Hibernation
S3 Enter; Enter: Enter info; The 8-digit LCD is used to display information in each
Hiber Hiber: Enter hibernate mode mode (Figure 7). Each digit has seven segments.
S4 CLR*; Ñ Clr: Clear; Pushbuttons are used to control display output and set
Ñ: Decrement parameters.
S5 MCLR Master Clear - Reset WHM There is a Watt-Hour Meter Demo Unit available to
* This feature not implemented. demonstrate the firmware. For a description of how to
set up the demo unit, see Appendix F.
Linear Power Supply Electronics
FIGURE 7: LCD AND PUSHBUTTONS
The linear power supply provides the signals listed
below. Digit 8 Digit 1

• +5V digital
• +8V and -8 V analog
• Battery backup (4.5V to 5.5V) - provides power to
the microcontroller during AC power outages LCD START
STOP ENTER
• +5V analog reference - provides an analog refer-
ence for the PIC16C924 on-board A/D converters
• +3V analog reference - provides an analog refer- CANCEL HYBER CLR
ence for the PIC16C924 on-board A/D converters
for higher-resolution measurements of signals
less than 3V peak amplitude.
Pushbuttons

MCLR

DS30452A-page 8 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 9 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Reset Mode • Digit 4 represents tens of minutes. Use the D
pushbutton to increase and the Ñ pushbutton to
The Reset mode occurs immediately after a power-on
decrease this value. Press the Enter pushbutton
reset of the microcontroller. Power-on reset occurs
to select a value. Once a value is selected, digit 3
when the microcontroller MCLR pin is lowered to
will display a “0.”
ground potential and then raised to VDD. Reset will
occur when: EX:
1. The first time that the battery is connected to the
circuit with no AC input power;
2. The first time AC power is connected to the cir-
• Digit 3 represents single minutes. Use the D push-
cuit when there is no battery, or;
button to increase and the Ñ pushbutton to
3. Any time that the PICREF-3 MCLR button is decrease this value. Press the Enter pushbutton
pressed and released. to select a value.
In Reset mode, the firmware version number is shown EX:
on digits 8, 6 and 5.
Firmware Version Number
EX:
• After the digit 3 value is selected, the selected
time is shown on the LCD.
EX:
Note: The Start/Stop pushbutton is not enabled
during the Reset mode.
Entry Mode
Entry Mode occurs after Reset mode. In entry mode,
the time must be set. Also, the cumulative Watt-Hours
are cleared (Not implemented for this version of the
document).
To set the time of the 24-hr clock, use the following pro-
cedure (maximum value is 24:00 before rolling over to
00.00):
• The display will show a “0” on digit 6 and colons
separating hours/minutes/seconds. Digit 6 repre-
sents tens of hours.
Use the D pushbutton to increase and the Ñ push-
button to decrease this value. Pressing and
releasing D or Ñ will increase or decrease the
value by one. Pressing and holding D or Ñ will
begin a scrolling increase or decrease in the
value. Release the pushbutton to stop the scroll.
Press the Enter pushbutton to select a value.
Once a value is selected, digit 5 will display a “0.”
EX:

• Digit 5 represents single hours. Use the D push-


button to increase and the Ñ pushbutton to
decrease this value. Press the Enter pushbutton
to select a value. Once a value is selected, digit 4
will display a “.”
EX:

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 9


Whm.bk Page 10 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Measurement Mode • Power Factor - “PF”
Measurement mode occurs immediately after Entry Range: 0.199 to 0.999
mode. EX:
When the unit is connected to line AC power, the load
may be disconnected from the AC line power through
power triac TR1. To start measuring power (from Reset
Mode), press and release the START/STOP key (When • True Power in Watts - “P”
the START/STOP key is released, the Triac receives Range: 0W to 2640W
gate trigger pulses). The triac is now enabled and the EX:
Load is now connected to the AC line voltage.
In one second, voltage, current and phase shift mea-
surements are made and power factor, true power and
watt-hour calculations are carried out. • Watt-Hrs - “Hr”
Measurement Mode Display - No AC The maximum watt-hours displayed will be
999999, and will then roll over to 000000.
If there is no AC input, the WHM goes into Sleep mode.
EX:
Measurement Mode Display - No Load
If there is no AC current flow to the load, the display
shows Frequency, Voltage (= 0), Current (“A OFF” mes-
sage) and Time. Each value is displayed for 3 seconds To stop power measurement, press and release the
before the next parameter is displayed. START/STOP button.
Measurement Mode Display - Current Flowing
If there is AC current flow to the load, the display shows
Frequency, Voltage, Current, Power Factor, True Power
and Watt-Hrs. Each value is displayed for 3 seconds
before the next parameter is displayed.
Because a 7-segment per digit display is used, not all
letters can be used for measurement parameter units.
Therefore, the following abbreviations have been
selected for each parameter:
• Frequency - No letter displayed.
Range: Frequency is resolved to either 50 or 60
Hz.
EX:

• Voltage - “V”
Range: 90V to 264V. Also 000.00 for voltages less
than 90 V, or no load/no current.
EX:

• Current - “A”. No numbers are displayed when


current waveform shape is unknown.
Range: 0A to 10 A
EX:

DS30452A-page 10 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 11 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Sleep Mode Voltage and Current Measurements
Sleep Mode is entered when the microcontroller exe- This section discusses the voltage and current mea-
cutes the SLEEP assembly instruction, located within surements that are made by the PIC16C924 firmware
the interrupt service routine of the sleep.c file. The during Measurement mode.
interrupt service routine is called when AC voltage
Voltage
dropout is detected. The battery provides power to the
microcontroller in Sleep Mode (Remove black heat A peak detect, RMS responding algorithm is used. The
shrink tubing from positive battery terminal for battery sinusoidal voltage waveform is sampled to determine
backup operation.). The processor clock is stopped at the peak value.
this time. Absolute calibration point data is stored for sinusoidal
Disconnecting the AC line voltage at P1 at anytime will load voltages (see Voltage Sensor Calibration for list of
cause the unit to go into Sleep mode. In this mode, an calibration point values). At each calibration point, the
“S” is displayed on digit 8 of the LCD. whole and fractional part of the AC load voltage corre-
sponding to a voltage A/D conversion are stored. An
The unit will maintain time for 5 minutes. If no AC line
8-bit integer representing hundreds and tens of milli-
voltage is applied at P1, then, after 5 minutes, the unit
volts (ex; 69 = 690mV) is stored. This stored value is
will automatically enter Hibernate mode to conserve
the rate of change in mV/sample between the calibra-
battery life. (Time keeping function in Sleep mode not
tion point and the next higher calibration point. The
implemented for this version of the document.)
increase in voltage resulting from the difference
The unit will automatically exit Sleep mode when AC between the A/D conversion result and the A/D conver-
line power is applied at P1 and return to Measurement sion result at the calibration point is calculated by mul-
mode. tiplying the rate in mV/sample by the number of
Hibernate Mode samples. The resulting difference voltage is added to
the voltage stored at the calibration point to form the
Hibernate mode is defined as a complete shutdown of final load voltage result.
all power consuming microcontroller peripherals prior
to entering Sleep mode. The real-time clock is not
updated during this mode.
When an AC power drop-out is detected, the display
will flash “S.” If the Hiber pushbutton is pressed while
the “S” message is showing, the microprocessor will be
put into hibernate mode and the display will first show
“H” and then go blank.
If the Hiber pushbutton is not pressed while the display
shows “S,” the processor will go into Sleep mode and
the display will go blank. After 5 minutes in Sleep mode,
Hibernate mode is entered automatically (Not imple-
mented for this version of the document).
Applying AC line voltage at P1 will cause the unit to exit
Hibernate mode and enter Entry mode.

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 11


Whm.bk Page 12 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Current – True RMS Measurements Current – Linear Loads
True RMS measurements are highly dependent on Linear loads are inductive and resistive. These loads
waveform shape. The watt-hour meter first determines create a variable 0° to 90° phase shift between the
waveform shape and then calculates true RMS values. applied sinusoidal voltage waveform and the
True RMS current calculations based on recognition of phase-shifted sinusoidal current waveform. Figure 8
waveform shape and the use of constant RMS factors shows the voltage and current waveforms for a linear
for these waveform shapes is a technically sound, low inductive load, a drill press. Figure 9 shows these
cost approach to true RMS current measurements. waveforms and linear pulses.

The PICREF-3 provides algorithms for the fundamental A peak detect, waveform shape, RMS responding algo-
shapes of linear resistive, linear inductive and narrow rithm is used. The current waveform is sampled to
sinewave pulses. determine the peak value.

More complex shapes will likely be combinations of Absolute calibration point data is stored for sinusoidal
these fundamental shapes and can be recognized load currents (see Current Sensor Calibration for list of
through more complex algorithms based on the funda- calibration point values). At each calibration point, the
mental shape algorithm. (Complex combinations of whole and fractional part of the current corresponding
waveform shapes are not implemented.) to a current A/D conversion are stored. An 8-bit integer
representing hundreds and tens of milliamps (ex; 10 =
The peak current waveform amplitude sample is first 100mA) is stored. The rate of change in mA/sample
determined in order to ensure that comparator refer- between the calibration point and the next higher cali-
ence values do not exceed the waveform’s peak ampli- bration point is also stored. Two integer numbers are
tude. Current waveforms are then digitally scanned to used to store the current rate of change in mA/bit. One
determine waveform type. integer number represents tens and single milliamps
The digital scan is accomplished by varying the refer- (ex; 40 = 40mA) and the other integer number repre-
ence voltage of the digital current sense comparator. sents tenths and hundredths of milliamps (ex: 80 = 0.80
The reference voltage is varied by filtering the modu- mA).
lated pulse width from the microcontroller’s PWM out- The increase in current resulting from the difference
put. As the comparator reference voltage is increased between the A/D conversion result and the A/D conver-
from ground to the maximum signal level (in varying sion result at the calibration point is calculated by mul-
step sizes), digital pulses synchronized with the analog tiplying the rate in mA/sample by the number of
waveform zero crossings are created. A count of when samples. The resulting difference current is added to
the pulses are low and high is kept to create the digital the current value stored at the calibration point to form
current scan. the final current result.
The count numbers are applied to firmware algorithms
which determine current waveform shape. Once the
wave shape is determined, the appropriate true RMS
algorithms are applied.

DS30452A-page 12 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 13 Wednesday, July 29, 1998 2:18 PM

PICREF-3
FIGURE 8: LINEAR LOAD WAVEFORMS

voltage

current

FIGURE 9: LINEAR LOAD WAVEFORMS WITH LOGIC PULSES

digital voltage voltage


sense pulse digital current
sense pulse
current

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 13


Whm.bk Page 14 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Current – Non-linear Loads
Non-linear loads are created by active circuitry, such as developed by the watt-hour meter, as well as the wave-
switching power supplies. Figure 10 shows peak forms of Figure 10. These pulses are synchronized to
non-linear current pulses at peak voltage for a com- the current and voltage zero crossings.
puter monitor load. Figure 11 shows logic pulses,
FIGURE 10: SINUSOIDAL VOLTAGE AND NON-LINEAR PULSED CURRENT WAVEFORMS

voltage

current

FIGURE 11: SINUSOIDAL VOLTAGE AND NON-LINEAR CURRENT WAVEFORMS WITH LOGIC
PULSES

digital voltage voltage


sense pulse current

digital current
sense pulse

DS30452A-page 14 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 15 Wednesday, July 29, 1998 2:18 PM

PICREF-3
The RMS value of the sine pulse current waveform var- The average phase shift count is then applied to an
ies as the square root of the inverse of the waveform’s algorithm which counts the number of 0.5 degree
period. The RMS value of the current sine pulse, inte- phase shift increments. The total number of increments
grated over the half cycle of the exciting voltage wave- is used to index into a cosine function offset look-up
form, is predicted by Equation 1. table. This table contains an integer offset which, when
added to a long integer base number, yields a long inte-
EQUATION 1: RMS CURRENT VALUE ger cosine result of phase angles between 2° and
78.5°, which corresponds to power factors ranging from
0.999 to 0.199.

1¤tÐ 1¤T Note: If power factor of load is less than 0.199,


RMS = ----------------------------------- Ð 1 ´ 0.707 the meter will display 0.199.
1¤t
A rolling two-sample average is used to obtain an aver-
Where: age power factor reading. Two power factor calcula-
tions from consecutive one second measurement
t= Current sine pulse width
intervals are averaged to determine the power factor
T= Voltage waveform half cycle displayed.
0.707 = Peak-to-RMS ratio of a sine wave where the The firmware counter is a 16-bit integer variable which
sine wave half cycle equals the integration has a phase shift per count resolution of better than
period. 0.1° degrees at all frequencies between 47 Hz and
The firmware measures the current sine pulse width 63 Hz for the microcontroller oscillator operating at 8
and the voltage waveform half cycle time. These num- MHz.
bers are then applied to Equation 1 to determine the True Power
RMS value of the sine pulse.
True power in Watts (W) is found by multiplying the
RMS factors resulting from Equation 1 for pulse widths apparent power by the power factor.
ranging from 1 ms to 4.1 ms are stored in two arrays for
50 Hz and 60 Hz respectively. The number of tenths of Energy Calculations
ms is counted and used as an index number to access This section discusses the energy calculations that are
array elements. The arrays hold integer offset numbers made by the PIC16C924 firmware from power calcula-
which are added to an integer base number to form the tions and time measurements.
calculation result of Equation 1.
Watt-Hours
The RMS factor is used to calculate true RMS current
A true power calculation is made once per second.
as follows. A constant representing the amount of cur-
Energy in joules is obtained by converting true power in
rent per A/D sample at an RMS value of 0.001 is multi-
joules/sec to joules. One watt-hour is obtained for each
plied by the number of samples found for the peak
accumulation of 3600 joules.
current. The result is then multiplied by the RMS factor
found for the given pulse width which results in the true
RMS current for the narrow pulse waveform.
Power Calculations
This section discusses the power calculations that are
made by the PIC16C924 firmware from voltage and
current measurements. For definitions of these power
forms, see Design Background.
Apparent Power
RMS voltage and RMS current, whole and fractional
numbers are multiplied to obtain apparent power.
Power Factor
Power factor is determined using a phase shift count
and a look-up table.
Phase shift can be measured for current waveforms
that are phase shifted from voltage waveforms by up to
78.5°. A firmware counter counts between rising edges
of the voltage and current comparator outputs. The
total phase shift count from two consecutive cycles in a
one second measurement interval is divided by two to
obtain an average phase shift count.

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 15


Whm.bk Page 16 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Firmware Detail FIGURE 12: RESET MODE

PIC16C924 firmware is written in C and consists of the START


following modules: {main.c}
main.c Main program. Contains INCLUDE
statements for all files listed below,
plus a modified header file,
16C924.h. Set up microcontroller I/O
pins and turn on TMR1
16C924.h Modified header file. Redefined
some letters in standard header to
make code more readable for LCD
display instructions. Initialize LCD
pf_table.c Cosine table used for calculating {lcd_808.c}
power factor.
sleep.c Put microprocessor to sleep.
lcd_808.c LCD control. Display firmware
lcd_code.c LCD display codes for numbers version
0 through 9.
message.c Contains LCD messages.
time.c Real-time clock. Entry Mode
int_serv.c Interrupt service routines.
pwrstate.c Determine power state (on/off). FIGURE 13: ENTRY MODE
triac.c Triac control (triac on/off).
pwm.c Determine pwm for current digital Reset Mode
scan.
sample.c Sample current, voltage and neutral
line. Set time
i_meas.c Current measurements.
{time.c}
phase.c Determine phase difference
between current and voltage wave-
forms. Measurement Mode
shape.c Determine current waveform
shape.
freq.c Determine AC line voltage
frequency.
power.c Power and energy calculations.
v_meas.c RMS voltage and current calcula-
tion.
v_table.c Look-up tables for absolute voltage
calibration points and rates
between calibration points.
i_table.c Look-up tables for absolute current
calibration points and rates
between calibration points.
ac_sense.c Determine neutral line state
(grounded/ungrounded).
inl_meas.c finds pulsed current RMS values
rms_nlp.c arrays holding integer offsets of
narrow pulse RMS factors at
50 and 60 Hz.
Program flow diagrams can be found on the following
pages. Firmware listing information can be found in
Appendix C.

DS30452A-page 16 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 17 Wednesday, July 29, 1998 2:18 PM

PICREF-3
FIGURE 14: MEASUREMENT MODE – MEASUREMENT LOOP

Entry Mode

Clear Timer1
(1 second counter)

Sense neutral line state


(grounded/ungrounded)
{ac_sense.c}

Clear variables Determine current


waveform shape
{shape.c}
Set current sense
comparator ref = 0mv
{pwm.c} linear linear non-
resistive inductive linear

A B C
no Sleep
AC ON?
Mode

yes

Measure line frequency Calculate VA


{freq.c} {power.c}

Measure voltage Calculate true power


{v_meas.c} {power.c}

Calculate watt-hours
Current flow yes {power.c}
to load?

no

Increment seconds
counter and
Wait till TMR1 = 1 sec. update realtime clock
{time.c}

Loop time = 1 second

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 17


Whm.bk Page 18 Wednesday, July 29, 1998 2:18 PM

PICREF-3
FIGURE 15: MEASUREMENT MODE – MEASUREMENT LOOP, CON’T

A B C

linear linear non-


resistive inductive linear

Measure Measure phase shift Measure peak current


peak current sample (voltage/current) sample (pulse width)
{i_meas.c} {phase.c, power.c} {i_meas.c}

Calculate Calculate power factor Calculate


True RMS Current {pf_table.c} True RMS Current
{v_meas.c} {i_meas.c, inl_meas.c,
rms_nlp.c}
Measure
Measure phase shift peak current sample
(voltage/current) {i_meas.c} Measure phase shift
{phase.c, power.c} (voltage/current)
{phase.c, power.c}
Calculate
Calculate power factor True RMS Current
{pf_table.c} {v_meas.c} Calculate power factor
{pf_table.c}

DS30452A-page 18 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 19 Wednesday, July 29, 1998 2:18 PM

PICREF-3
FIGURE 16: MEASUREMENT MODE – DISPLAY LOOP

Entry Mode

Display line frequency

Display voltage

no
Determine current
current
waveform shape

current

Display current

Display power factor


Display “A OFF”

Display true power

Display watt-hours

Display time

Time for each block = 3 seconds

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 19


Whm.bk Page 20 Wednesday, July 29, 1998 2:18 PM

PICREF-3
FIGURE 17: SLEEP & HIBERNATE MODES

AC line voltage disconnected at P1

Write sum of last calcu-


lated watt-hr value and last
cumulative watt-hr value to
Serial EEPROM
{mem_rw.c}

Display “S”

Hiber
yes
pushbutton
pressed?

no

Measurement yes Power


Mode reconnected?

no

5 minutes no
Display “H” passed?

yes

Hibernate Mode

Blank display

yes Power
Reset Mode
reconnected?

no

Dashed blocks = Not implemented for this version of the document.

DS30452A-page 20 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 21 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Test Results • 115V/230V, 1/6 HP, motor at 50Hz, 220V
- Start-up current: 4.9A
Results of PICREF-3 tests are listed below.
- Steady state current: 1.7A
Comparison Test
Non-Linear Load Tests
PICREF-3 Watt-Hour Meter measurements were com-
A Mitsubishi Color Display Monitor (Model #
pared to the measurements of a commercial watt-hour
FW6405ATK) was tested with the PICREF-3 at 50 Hz
meter, the Yokogawa WT2010 Digital Power Meter,
and 60 Hz.
which has a basic measurement accuracy of 0.03%.
The results of this comparison for several PICREF-3 Calibration
demo units is TBD.
This section describes the calibration procedure and
For individual WHM demo unit test results, see equipment used.
attached page(s).
The signal source used was a Hewlett Packard 6814B
Linear Resistive Load Tests AC Power Source/Analyzer. The measurement refer-
Halogen lamps of different wattage were tested with ence used was a Yokogawa WT2010 Digital Power
the PICREF-3 at 50 and 60 Hz. Meter.
• 120V: Wattages from 60W to 1100W Voltage Sensor Calibration
• 240V: 1000W, 2000W 90 VAC is applied to P1. A 200W load is connected and
Linear Inductive Load Tests the triac is turned on. Resistors R4, R25 and R37 are
adjusted to provide an A/D conversion result of “1” of an
Fractional horsepower motors used with PICREF-3 are ungrounded neutral line and “4” for a grounded neutral
listed below. Start-up and steady state currents are line.
also shown.
For an ungrounded neutral line, there is one voltage
• 115V, 1/2 HP, 2-speed motor at 60Hz, 120V sensor curve, and for a grounded neutral line, there is
- High speed start-up current: 11.5A another. These voltage sensor curves, developed at
- High speed steady state current: 8.8A R26, are viewed as piecewise linear curves with abso-
- Low speed start-up current: 10.9A lute calibration points at 90V, 100V, 110V, 120V, 130V,
- Low speed steady state current: 4.2A 150V, 200V, 210V, 220V, 230V, 240V and 260V AC.
Calibration of the voltage sensor is frequency indepen-
• 115V, 1/3 HP, 2-speed motor at 60Hz, 120V
dent.
- High speed start-up current: 17.3A
A volt/sample rate is used to calculate voltage in
- High speed steady state current: 7.0A
between absolute voltage calibration points.
- Low speed start-up current: 12.5A
Current Sensor Calibration
- Low speed steady state current: 4.25A
• 230V, 1/2 HP, 2-speed motor at 60Hz, 220V A resistive load is connected to P2 and voltage is
applied to P1. Resistors R5 and R38 are adjusted to
- High speed start-up current: 8.8A
provide an A/D conversion result of 0xFB at the load
- High speed steady state current: 2.1A current of 10A.
- Low speed start-up current: 2.7A
Separate current sensor curves are stored for 50Hz
- Low speed steady state current: 1.4A and 60Hz. The current sensor curves, developed at R9,
• 230V, 1/2 HP, 2-speed motor at 50Hz, 220V are viewed as piecewise linear curves with absolute
- High speed start-up current: 7.5A calibration points at 0.5A, 0.7A, 1.0A, 2.5A, 3.5A, 5.00A
- High speed steady state current: 3A and 10.00A. The calibration of the current sensor is
- Low speed start-up current: 5.6A independent of the state of the neutral line. The current
sensor calibration is frequency dependent.
- Low speed steady state current: 1.75A
• 115V/230V, 1/6 HP, motor at 60Hz, 120V A mA/bit rate is used to calculate currents in between
absolute current calibration points.
- Start-up current: 5A
- Steady state current: 2.9A
• 115V/230V, 1/6 HP, motor at 50Hz, 120V
- Start-up current: 7.5A
- Steady state current: 4A
• 115V/230V, 1/6 HP, motor at 60Hz, 220V
- Start-up current: 3.7A
- Steady state current: 1.2A

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 21


Whm.bk Page 22 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Phase Sensor Calibration FIGURE 19: COMPONENTS OF POWER
The phase shift between the digital voltage sense
waveform at R27 and the digital current sense wave-
Apparent Power
form at R44 is adjusted with the phase shift capacitor at VA = 1152
U5-5. Inductive loads with power factors between 1 and
Reactive Power
0.2 are connected to P2. The phase shift capacitor is
VARs = 921.6
adjusted to cause the WT2010 power meter phase and
the circuit phase difference to match at a frequency of 53.13˚
50Hz. The circuit phase difference is monitored with a
digital storage oscilloscope. Inductive loads with power True Power
factors spanning the specified measurement range are P = 691.2 W
connected to P2.
Absolute phase calibration points are obtained at or The three components are apparent power, true power
close to 2.5°, 25°, 50°, 70°, 75° and 78°. A phase and reactive power.
degree/sample rate is used to calculate phase shifts in Apparent Power This is the value that would be found
between absolute phase calibration points. The phase if a voltmeter and ammeter were used to measure cir-
sensor calibration is frequency dependent. Four piece- cuit voltage and current and then these measured val-
wise linear phase curves are stored for the following ues were multiplied together.
conditions:
VA = 240 x 4.8 = 1152
• 60 Hz neutral line grounded
• 60 Hz neutral line not grounded VA = P 2 + VAR s 2
• 50 Hz neutral line grounded True Power This is the pure resistive component mea-
• 50 Hz neutral line not grounded sured in watts.
A calibration point at a power factor of 0.999 is obtained
P = V A 2 + VAR s 2
for each condition.
Reactive Power This is the pure reactive component
Power Theory measured in VARs.

An example of how to implement a watt-hour meter VARs = V A2 + P 2


using microcontrollers has been described in the previ-
The true power, in watts, can be obtained by multiplying
ous sections. However, if a customer wishes to change
the apparent power by the cosine of the angle between
part or all of this design, then an understanding of why
the apparent power and true power.
the design was developed as it was, i.e., an under-
standing of power theory, is essential. The cosine of the angle between apparent power and
true power is known as the power factor.
Components of Power
The angle between apparent power and true power is
Residential loads are primarily inductive and resistive.
equal to the angular displacement between the voltage
These loads can be represented by a series RL circuit.
and current waveforms.
FIGURE 18: SERIES RL CIRCUIT
FIGURE 20: TRUE POWER DEFINITION
4.8 A
53.13˚

240 V

Cos (53.13) = 0.6


True Power =Apparent Power x Power Factor
Series RL Circuit = 1152 x 0.6 = 691.2 W

The components of power delivered by the AC genera-


tor to the R, L series load can be represented on a vec- Solid state watt-hour meters now in use measure and
tor diagram. display energy based on the time accumulation of true
power by default but also provide for the selection of the
alternate energy measurements of VARh and VAh.

DS30452A-page 22 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 23 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Design Modifications
This reference design is for guidance only, and it is
anticipated that customers will modify parts of it. With
this in mind, this section suggests modifications that
the customer may wish to make to the design.
• Full Cycle Current Measurements:
A hardware method for full cycle current measure-
ments involves an additional current sensor channel.
This channel would consist of instrumentation ampli-
fier U14 with current sensor input connections
reversed with respect to instrumentation amplifier
U2. The output of amplifier U14 is then 180 degrees
out-of-phase with U2. A switching circuit/device
would be needed to switch the RA1 input between
U2 and U14.
• 200A Max Current:
This design may be modified to accommodate 200A
Max residential loads by doing the following: (1)
remove the triac from the circuit, and (2) use a
higher-rated (200A) current sense transformer.
• Serial EEPROM for Power Outage Data Storage
A Serial EEPROM is provided to store data in the
event of a power loss. Additional firmware must be
written to accomplish this function.
Disconnecting the AC line voltage at P1 at any time
will cause the unit to go into Sleep mode. At this time,
the microcontroller should write the sum of the last
calculated watt-hour value and the last cumulative
watt-hour value to Serial EEPROM memory. When
power is restored, this data should be read back into
the microcontroller.
For more information on interfacing a serial
EEPROM and a PICmicro, see AN567 - Interfacing
the 24LCXXB Serial EEPROMs to the PIC16C54.
• RS-232 Communications Port
An RS-232 serial port is provided for communication
with a computer. Additional firmware must be written
to accomplish this function.
For more information on a software serial port, see
AN593–Serial Port Routines Without Using Timer0.
• Five Meters in One
The PICREF-3 may be thought of as 5 meters in one.
This design may be used as a guideline for the
designs of other meters, namely:
- Volt Meter
- Current Meter
- Power Factor Meter
- True Power Watt Meter
- Time Integrating Watt-Hour Meter

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 23


Whm.bk Page 24 Wednesday, July 29, 1998 2:18 PM

PICREF-3
NOTES:

DS30452A-page 24 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 25 Wednesday, July 29, 1998 2:18 PM

PICREF-3
APPENDIX A: SYSTEM SPECIFICATIONS
Parameter Condition Value
AC Input Frequency 47 Hz to 63 Hz
Maximum Load Current 10 Amp AC
Current Range Current below 0.5A is displayed as 0A 0.5A - 10 A AC
AC Input Voltage Voltage below 90V is displayed as 0V 90V to 264V
Voltage 1% of reading
Current 1% of reading
Laging Power Factor Inductive Loads 0.199 – 1.000
Leading Power Factor Capacitve Loads 1.000
Power Measurement Accuracy Linear resistive loads; power factor = 1.000; 1.0% of average reading
crest factor of voltage and current waveforms = plus 0.2% of full scale
1.414. Option 1: 1.0% of reading
with current automatic
gain control.
Linear inductive loads; 1.0% of average reading
crest factor of voltage and current waveforms = plus 0.2% of full scale
1.414.
Maximum Power Consumption 3.5 W @ 240V
0.54W @ 120V
0.43W @ 100V
Maximum Battery Current Sleep Mode 16 mA
Nominal Battery Current Hibernate Mode 60 nA
Minimum Battery Life Based on current in Hibernate mode 10 yrs

Visio is a registered trademark of Visio Corporation.

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 25


Whm.bk Page 26 Wednesday, July 29, 1998 2:18 PM

PICREF-3
APPENDIX B: SCHEMATICS Analog/Digital Sense Electronics. Also included is the
RC filter used, with the PIC16C924 PWM, to produce a
Watt-hour meter schematics are shown on the follow- variable reference to the current sense comparator for
ing pages. These schematics may be obtained elec- true RMS current measurements (Microcontroller I/O).
tronically on the Microchip BBS and WWW site (VisioÒ
format). Phase Sense: Includes the Voltage Sense and Current
Sense circuitry.
B.1 PCB Functional Overview Power Triac: From High Voltage AC Electronics. (Triac
switch included for demo purposes only.)
A functional layout of the PICREF-3 PCB is shown in
Figure B-1. The board functions relate to the overall Triac Control: Triac control circuitry from Microcontroller
functions as follows. I/O.
AC Input/Output: AC Input/Output from High Voltage LCD Control: Includes the 8-digit LCD, PIC16C924
AC Electronics. microcontroller and pushbuttons from Microcontroller
I/O.
DC Power Supply: From Linear Power Supply Electron-
ics. Remote Communication: Includes the serial (RS-232)
communications interface and port from Microcontrol-
Voltage Sense: Includes the Resistive Voltage Divider
ler I/O.
from High Voltage AC Electronics and the voltage
sense amplifier and comparator from Small Signal Battery Backup: Includes the Serial EEPROM from
Analog/Digital Sense Electronics. Microcontroller I/O and the Battery Backup from Linear
Power Supply Electronics.
Current Sense: Includes the Current Sense Trans-
former from High Voltage AC Electronics and the cur- Interrupt: From Microcontroller I/O.
rent sense amplifier and comparator from Small Signal

FIGURE B-1: PCB FUNCTIONAL BLOCK DIAGRAM

AC 8-Digit LCD
Output

LCD Control
(Clock Input)
DC Power
Supply
Pushbuttons

Phase Sense Timing


PIC16C924 (8MHz clock,
AC Input/ TIMER1 32KHz)
Output Voltage Microcontroller
Sense

Remote
Communications
Current
Sense

Interrupt

AC
Input

Power
Triac Optically Isolated Battery
(TR1) Triac Control Backup

DS30452A-page 26 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 27 Wednesday, July 29, 1998 2:18 PM

PICREF-3
B.2 AC Input/Output B.4.1 ANALOG CURRENT SENSE

AC voltage is applied to AC power line connector P1 The current signal from the current sense transformer
and a load is connected to AC outlet P2. Alternating is amplified by U2. The U2 amplifier accepts a balanced
current flows from P1 to P2. input and has a minimum common mode rejection ratio
(CMRR) of 93 dB. The signal at the amplifier output of
B.3 Voltage Sense U2-6 swings above and below a 0V (ground) reference
potential.
A resistive ladder (R2A, R2B, R3, R35, R36A and
R36B) is used as a voltage sensor. A differential volt- The output at U2-6 is connected to the anode of Schot-
age develops on R3,R35 that has a 1000:1 divide-down tky diode D2. The cathode of D2 is connected to analog
ratio. converter input AN1 of the PIC16C924. The analog
current sense signal is developed across R9 and C26
B.3.1 ANALOG VOLTAGE SENSE at the cathode of D2.

The voltage signal from resistive divider R3/R35 is B.4.2 DIGITAL CURRENT SENSE
amplified by U1. The U1 amplifier accepts a balanced
input and has a minimum common mode rejection ratio Comparator U5 is a dual comparator integrated circuit.
(CMRR) of 93 dB. The signal at the amplifier output Half of U5 is used to compare the sensed analog cur-
U1-6 swings above and below a negative volt reference rent signal (U5-5) to a variable positive reference
potential. (U5-6). The digital current sense output (U5-7) goes
high when the sensed current signal exceeds the refer-
The output of U1-6 is connected to the anode of Schot- ence.
tky diode D10. The cathode of D10 is connected to ana-
log converter input AN0 of the PIC16C924. The analog The comparator output at U5-7 is connected to the
voltage sense signal is developed across R26 and C22 anode of Schottky diode D12. The cathode of D12 is
at the cathode of diode D10. connected to digital input RE7 of the PIC16C924. The
digital current sense signal is developed across R44 at
B.3.2 DIGITAL VOLTAGE SENSE the cathode D12.

Comparator U5 is a dual comparator integrated circuit. B.4.3 PWM REFERENCE RC FILTER


Half of U5 compares an analog ground reference at
U5-2 to the single-ended voltage sensor signal devel- The PWM output of the microcontroller at RC2 has a
oped across R3 at U5-3. The output of U5 at U5-1 frequency of 7.81 kHz. The waveform duty cycle has a
switches to a logic high level of 5V when the voltage 10-bit resolution resulting in a single step pulse width of
sensor signal exceeds the analog ground reference. 125 ns. The pulses are filtered by R29, 470W, and C28,
2.2mF. These components form a low pass filter with a
The comparator output at U5-1 is applied to the anode break frequency of 967 Hz. The low pass filtered PWM
of Schottky diode D11. The cathode of D11 is con- signal is applied to the current sense comparator refer-
nected to the digital input line RG7 of the PIC16C924. ence at U5-6.
The digital voltage sense signal is developed across
R27 at the cathode of D11. B.5 Phase Sense
B.3.3 AC INPUT BALANCED/UNBALANCED Phase Sense is the combination of Voltage Sense and
SENSE LINE Current Sense circuitry, plus phase shift circuitry at
U5-5. The phase shift between the digital voltage sense
The AC Input Balanced/Unbalanced Sense Line is
waveform at R27 and the digital current sense wave-
used to determine whether the AC input neutral line is
form at R44 is adjusted with the phase shift low-pass fil-
grounded or ungrounded.
ter at U5-5. The phase shift circuitry is adjusted for
The RA5 microcontroller input is set in firmware as an calibration purposes.
analog input and the voltage across resistors R36A and
R35 is sampled. If the voltage is positive, the neutral B.6 LCD Control
line from the P1 AC input is not grounded. If the voltage
is zero, the neutral line is grounded. The heart of the LCD Control electronics is the
PIC16C924 microcontroller, U4.
After the microcontroller determines the neutral line
state, the RA5 input is set in firmware to be digital. The microcontroller receives analog and digital current
and voltage sense signals. Depending on user push-
B.4 Current Sense button input (S1 to S4), these signals may be used for
LCD display or calculation and LCD display.
Current flows through triac TR1 and current sense
transformer T2. A voltage is developed across burden
resistor R1B that is proportional to the current flow.

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 27


Whm.bk Page 28 Wednesday, July 29, 1998 2:18 PM

PICREF-3
The LCD is an eight-digit, seven segment per digit, dis- tors, C16 and C17. The purpose of these resistors is to
play. Additional segments make up the periods and rapidly discharge C16 and C17 when Timer 1 is turned
colons necessary for decimal and time display. The off prior to entering Hiber mode.
LCD has a total of 71 segments. Three commons are
used in a multiplexing drive scheme. B.7 Remote Communications
The LCD part, VIM-808-DP, is manufactured by V.L. The serial interface circuit (Q1 and Q2) is provided for
Electronics Inc. RS-232 communication between a computer and the
PICREF-3. Serial port connection is provided by P3.
B.6.1 LCD CONTRAST ADJUSTMENT
Firmware for this function has not been implimented
A charge pump for the LCD is formed by resistors R24, (See Design Modifications).
R47 and capacitors C7, C8, C9, and C10. The charge
B.8 Triac and Triac Control Circuit
pump consists of a 10mA constant current source, inter-
nal to U4, which sources current into R24. The voltage Triac switch included for demo purposes only.
developed across R24 is applied to C10 at VLCD1. the
charge pump boosts VLCD1 into VLCD2 = 2 * VLCD1 The triac control circuit is comprised of U13
at C8, and VLCD3 = 3 * VLCD1 at C9. By varing R24, (MOC3042), a triac output opto-coupler with zero
the LCD contrast can be adjusted. crossing detect circuitry. Resistor R10 limits forward
current to 10mA to U13’s infrared LED when the RA4
B.6.2 PUSHBUTTONS - MCLR control line is pulled low. Resistor R6 limits current to
the gate of the power triac TR1 (High Voltage AC Elec-
A processor reset signal can be manually applied to U4 tronics) when U13 fires.
at U4-2, the master clear (MCLR) input.
Microcontroller I/O pin RA4 is toggled in response to
The reset signal originates at the node of resistor R17 pressing the START/STOP button. Action is taken to
(10kW) and capacitor C14 (0.1mF). R17 is connected change the ON/OFF state of the triac after the first zero
to the 5V digital line causing C14 to charge to 5V. The crossing of the released START/STOP button.
R17/C14 node is tied to pushbutton S5. S5 is a
momentary pushbutton which is in a normally open B.9 Battery Backup
position. Depressing S5 and then releasing causes the
voltage level at U4-2 to drop to ground and then return The battery backup section consists of two 3V batter-
to 5V. The low-going logic pulse at U4-2 resets the pro- ies, B1 and B2, in series with diodes D9A and D9B, and
cessor’s program counter to the beginning of the firm- U3, a Serial EEPROM.
ware program.
B.9.1 BATTERIES
B.6.3 CLOCK INPUT
In the event of an AC line voltage dropout, the micro-
The clock input is an 8MHz frequency set by an exter- controller is powered by the 6V series battery combina-
nal three-terminal resonator designated as XTAL1. The tion, which provides voltages in the range of 4.5V to
8MHz resonator, manufactured by Panasonic 5.5V at the cathode of D9B.
(EF0-EC8004A4), has a nominal center frequency of The 3V batteries are lithium ion cell batteries, CR2032,
8.00MHz and has built-in phase shift capacitors. manufactured by Panasonic. The batteries have a
The resonator element connects to the OSC1 and 180 mAh rating.
OSC2 pins at U4-24 and U4-25. The PIC16C924 Diodes D9A and D9B, 1N4150, are in series with B1
microcontroller has an internal inverter connected and B2. The cathode of D9B is connected to the cath-
between the OSC1 and OSC2 pins. This internal odes of D8, D15 and D13 in a wire-or’d configuration.
inverter combined with the 8MHz resonator establish
the clock input frequency. B.9.2 SERIAL EEPROM

B.6.4 TIMER1 The Serial EEPROM is available to provide non-volatile


storage for key parameters during AC line voltage drop-
A 32kHz crystal, a Panasonic EF0-EC8004A4 desig- outs. Firmware for this function has not been impli-
nated as XTAL2, is connected between U4’s pin 26 and mented (See Design Modifications). Firmware should
pin 27. Capacitors C16 and C17, both 33pF, are con- function as described below.
nected to U4-26 and U4-27. These components com-
The microcontroller should provide power to the Serial
bine with an inverter internal to microcontroller U4,
EEPROM by setting the RB3 line as an output and writ-
between pins 26 and 27, to form a 32kHz oscillator.
ing a logic “1” to the RB3 line. The last calculated
This oscillator clocks Timer 1, a 16-bit counter. Timer 1
watt-hour value should be added to the last cumulative
is used to measure one second time intervals. A 22MW
watt-hour value previously written to the Serial
resistor is connected across each of the 33pF capaci-
EEPROM. The resulting sum should be written to the

DS30452A-page 28 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 29 Wednesday, July 29, 1998 2:18 PM

PICREF-3
Serial EEPROM. The microcontroller should then write Battery operation requires D8 and D13 to have a low
a logic “0” to the RB3 line to reduce battery current reverse current specification. These diodes are switch-
drain. ing diodes which have a reverse leakage current of
The Serial EEPROM, 24AA16/P, is manufactured by 200 nA at maximum reverse peak voltage.
Microchip Technology. The Serial EEPROM is a 16-Kbit U11, LM4040AIZ-5.0, is a precision 5V reference diode
electrically erasable PROM that operates down to 1.8V. with a +/- 0.1% accuracy. U11 receives bias current
Resistor R22 is a pull-up resistor to Vcc for the open from R40. The 5V reference voltage is buffered by U12,
drain SDA terminal of the Serial EEPROM. LM358A. The output of U12 (U12-7) is applied to the
Resistor R23 provides isolation between Vcc and the anode of D14, 1N4150. The cathode of D14 is tied back
SCL line of the Serial EEPROM. Vcc is provided by the to the input terminal of U12 and to U4-21, the analog
RB3 line to the microcontroller. input reference line of the PIC16C924 microcontroller.
Diode D14 blocks current flow from U4-21 during bat-
B.10 DC Power Supply tery backup operation.
Resistors R41, R33 and R34 provide an optional 3V
The DC power supply provides the following power
reference to buffer amplifier U12. The 5V analog refer-
forms:
ence can be divided down to 3 V at the R41/R33 node.
• + 5V digital The 3V ladder reference is applied to U12-3. The out-
• + 5V analog reference put of U12-1 is applied to U4-9. The PIC16C924 micro-
• + 8V analog controller can select U4-9 as an analog reference input.
In this design, R41 is a zero ohm wire and R23 is a 22
• - 8V analog
MW resistor. The values of R41 and R33 affect battery
• +3V analog reference current in Sleep and Hibernate modes. Battery cur-
The AC Input at P1 is applied to step-down transformer rents in this document are based on a value of 22MW
T1, MagneTek P30-200. The output of T1 is full wave for R33.
rectified by bridge rectifier BR1, General Instruments
W005G-ND. The full wave rectified waveform from BR1 B.11 Interrupt
is applied to capacitors C1 and C2, which charge to
Interrupt input is provided into microcontroller pin
positive and negative DC supply rails. Zener diodes Z2,
RB0/INT. The digital voltage sense line, digital current
Z3 and Z4, 18V 1N4746, and 68W R30 provide a shunt
sense line and serial communication input lines are
path for current from capacitor C1. The current flow
each differentiated, by identical circuits, and wire-or’d
through Z2, Z3, Z4 and R30 reduce the positive supply
together as input to RB0/INT, U4-13 (Figure B-2). The
rail to a voltage less than 26V, which is the maximum
differentiated digital voltage sense signal is used to
input voltage for 5V regulator IC U10. IC U8, New
wake the microprocessor from Sleep or Hibernate
Japan Radio Co. NJM78LO8A-ND, and U9, New Japan
modes.
Radio Co. NJM79LO8A-ND, provide +8 and -8 volt reg-
ulated output voltages. The digital voltage sense signal is differentiated by the
circuit consisting of C11, R45 and D3.
U10, LM2932AZ-5.0, is a low drop-out 5.0V regulator
manufactured by National Semiconductor. The digital current sense signal is differentiated by the
circuit consisting of C12, R46 and D4.
Diode D6, in series with diode D1, increases the virtual
ground point for regulator U10 by one schottky diode The serial communication input signal is differentiated
drop. by the circuit consisting of C15, R8 and D5.
Diode D1 provides a virtual ground point for regulator The cathodes of D3, D4 and D5 are wire-or’d together
U10 which is one diode drop above ground potential. and connected to U4-13, the RB0/INT interrupt.
The regulated output of U10 adds to the diode drop at
the U10 GND terminal.
Diode D8, 1N4150, D15, 1N4150, and diode D9,
1N5817, provide a wired-or scheme for the switching of
either 5V digital from the output of U8 or 4.5V - 5.5V
from batteries B1 and B2.
Diode D13, 1N4150, limits voltage undershoot at the
output of 5V regulator U10 when the AC input voltage
drops out. Clamping the U10 output at ground potential
prevents the regulator from sensing a negative output
voltage and entering an output shutdown mode when
AC input voltage returns.

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 29


Whm.bk Page 30 Wednesday, July 29, 1998 2:18 PM

PICREF-3
FIGURE B-2: INTERRUPT DIFFERENTIATOR BLOCK DIAGRAM

analog voltage sense signal


Voltage
Sense digital voltage sense signal

PWM
RC Filter
Current
Sense analog current sense signal
digital current sense signal

Remote
PIC16C924
Communications
Microcontroller
Interrupt Circuitry

d
-----
dt

d RB0/INT
-----
dt

d
-----
dt

DS30452A-page 30 Preliminary ã 1997 Microchip Technology Inc.


WATTHOUR - METER REFERENCE DESIGN, 50/60 Hz, 90 - 264 V, 10 A

360 470 5V
6 MOC3042 1
R6 U13 R10
FIGURE B-3:

TR1
Q4010L5 N/C 5 2 TO: U4 - 10 RA4
P2 MT2 Teccor
G Zero
N L AC output Crossing
Whm.bk Page 31 Wednesday, July 29, 1998 2:18 PM

To Load MT1 Detect TP1


4 3 N/C
8V
8V
C9A + 4.7 k D11
R2

ã 1997 Microchip Technology Inc.


3 8 R13 Digital Voltage Sense
1/2 LM393 TO: U4 - 52, RG7
0.001 uf Philips U5 1
500 VAC 1 M, 1%, 1/4 w 2 C23
- R27
5043ED 1.0 k 8V C5 4 0.01 uf 10 k
250 VAC 0.1 uf -8V

P1 AC input 3
+ D10
1 7 Analog Voltage Sense
R4 6 TO: U4 - 5, RA0/AN0
N L R37 AD620
R3 178.7 k
3.83 k U1 C22
V420LA10
420 VAC 1.0 k 8 4 5 R26 0.01 uf
Z1 J1 - 2.2 k
2 -8V R25
BUSS
VOLTAGE/CURRENT SENSE

AGC-12 66.5 k

C10A F1 T2
0.001 uf MagneTek 1.0 k
500 VAC C19 0.1 uf
CSE187-L R35
1A 2A

5 8

Preliminary
20.0, 1/8 W 1.0 k R36A
AC Input Balanced / Unbalanced Sense Line
TO: U4 - 11, RA5
R1

Philips TO: R29


1 M, 1%, !/4 w Phase Shift Capacitors
R36B
5043ED 8V
2.2 uf C28
250 VAC
0.22 uf 0.1 uf 0.056 uf 4.7 k
- D12
6 R16
Digital Current Sense
1/2 LM393 TO: U4 - 36, RE7
U5 7
R14 C24
5 + R44
0.01 uf 10 k
0.1 uf C20 1k
AC INPUT/OUTPUT, TRIAC AND TRIAC CONTROL CIRCUITRY, AND

8V
3 + 7 TP2 D2
1 5 Analog Current Sense
R38 R5 AD620 6 TO: U4 - 6, RA1/AN1
105 k 6.2 k U2
J2 8 G = 14 0.01 uf
2.2 k C26
- 4 R9
2
-8V
kwhr_v1.vsd 0.1 uf C21
11/14/97
Page 1

DS30452A-page 31
PICREF-3
WATTHOUR - METER REFERENCE DESIGN, 50/60 Hz, 90 - 264 V, 10 A

Triac Control, TO: U13-2 + 5 v Digital


FIGURE B-4:

TO U12-1, 3.0 V Reference


TO: R31 R17

DS30452A-page 32
10 K MCLR
TO: J2 - B Digital Voltage Sense
TO: J3 - B Digital Current Sense S5
TO: J1 - B Analog Voltage Sense 0.1 uf
PICREF-3

TO: J4 - B Analog Current Sense C14


+ 5 V Digital
Whm.bk Page 32 Wednesday, July 29, 1998 2:18 PM

0.1 UF
C13
470 RN1 START/STOP
S1
1 2
R45 C11
D3 100 K 0.01 uf
1N4150 470 RN1
S2
3 4
1N4150 D4 0.01 uf R39
R46 C12 10 k
470 RN1 ENTER
100 K S3

Vdd

RA1/AN1
RA0/AN0
RG7
N/C

RE7
MCLR
RD5
5 6

6
2

5
HYBER

64

60

52
36
8 RA2 R7
RB0/INT 13 RA3 470 RN1
9
Vss 10 RA4 100 K S4
7 7 8
11 RA5
0.47 uf C7 C1
17 68 RB4
C2 RB5
18 67
65 RB6 TO: R42

Preliminary
0.47 uf C8 Vlcd2 RB7 Circuit Trace TO: R43 Via
19 66
PIC16C924 R32 10 k
0.47 uf C9 Vlcd3 RC3
20 U4 14

+ 5 v Ref Avdd RC2 470 R29 TO: U5-6


TO: U12 - 6 28
21
+ 5 V Digital Vdd 22 SDI TO:U4-13 RB0
15
Vss C15 D5
23 16 SDO 0.01 uf
OSC1 +5v 100 K R8
24
OSC2 RB1
0.1 UF XTAL 1 25 12
RB2 4.7 K R18
C18 4
8 MHz RB3
3

30

29

26
27
A0 1 8 Vcc Q1 910 K
XTAL 2 1 U3
A1 2 2N3904

Vlcd1

T1OS1
32 kHz

T1OSO
200 k +5v R19 TX

VLCADJ
R24 A2 3 24AA16/P 6 SCL
2 Vss 4 5 SDA
33 pf 33 pf 0.47 uf
22 M WP
22 M 180 K
C16 C17 C10 3 7 Q2 DTR DSR RTS
2N4403
R20
10 K 10 K
R22 RX CTS
R23
100 k 9
R47 P3 1 3 5 7
R21 12 K 2 4 6 8
RS-232
MICROCONTROLLER, SERIAL INTERFACE CIRCUIT, AND SERIAL EEPROM

100
kwhr_v1.vsd -8V R48
11/14/97
Page 2

ã 1997 Microchip Technology Inc.


DS30452A-page 33 Preliminary ã 1997 Microchip Technology Inc.
Page 3
11/14/97
kwhr_v1.vsd

SEG00
31
SEG01
SEG0232
SEG0333
SEG0434 N/C
35 1
U4

SEG05
SEG0637
SEG0738
PIC16C924

SEG0839
SEG0940 COM0
63
SEG1041 COM1
62
SEG1142 COM2
43 61
44
45
46
47
48
49
50
51
53
54
55
56
57
58
59

SEG12
SEG24

SEG13
SEG14
SEG15
SEG16
SEG17
SEG18
SEG19
SEG20
SEG21
SEG22
SEG23
SEG25
SEG26

COM3
21
COM2
42
8B, 8C, 7DP COM1
1 22
N/C 41 8F, 8E
2
7B, 7C, 6DP 40 8A, 8G, 8D
3
N/C 39 7F, 7E
4
N/C 5 38 7A, 7G, 7D
6B, 6C, 5DP 37 6L
6
N/C 6F, 6E
36
N/C 7
8 35 6A, 6G, 6D
5B, 5C, 4DP 34 5F, 5E,
9
5A, 5G, 5D
N/C10 33
N/C 4L
11 32
4B, 4C, 3DP U7

LCD
12 31 4F, 4E,
N/C13 30 4A, 4G, 4D
N/C 3F, 3E,

VIM-808-DP
14 29
3B, 3C, 2DP 3A, 3G, 3D
15 28
2L
N/C16 27
N/C 2F, 2E, NC
17 26
2B, 2C, 1DP 2A, 2G, 2D
18 25
N/C 1F, 1E
19 24
1B, 1C 1A, 1G, 1D
20 23
MICROCONTROLLER AND LCD FIGURE B-5: WATTHOUR - METER REFERENCE DESIGN, 50/60 Hz, 90 - 264 V, 10 A
PICREF-3
Whm.bk Page 33 Wednesday, July 29, 1998 2:18 PM
WATTHOUR - METER REFERENCE DESIGN, 50/60 Hz, 90 - 264 V, 10 A
FIGURE B-6:

DS30452A-page 34
PICREF-3
Whm.bk Page 34 Wednesday, July 29, 1998 2:18 PM

unregulated positive rail


DC POWER SUPPLY

Z2 Z3 Z4

1N4746 1N4746 1N4746


18 V 18 V 18 V
TO:U4 - 8
RA2
68 ohm
R30
1W

TO:U10 - Vin

Preliminary
T1
MagneTek FP30-200
To : P2 - L 4 5 BR1
GI W005G-ND

U8
3 6
+8V
NJM78L08A 8.0 v
3 1
2 7
2
470 u f
+
C1 C3 0.01 uf
To : P1 - N Neutral 1 8 50 WVDC

Analog Gnd
To : P1 - GND
470 u f
+ C2 0.01 uf
C6
50 WVDC
1
- 8.0 v - 8V
NJM79LO8A-ND
unregulated negative rail 2 3
U9

Digital Gnd

kwhr_v1.vsd
11/14/97
Page 4

ã 1997 Microchip Technology Inc.


WATTHOUR - METER REFERENCE DESIGN, 50/60 Hz, 90 - 264 V, 10 A FIGURE B-7:
Whm.bk Page 35 Wednesday, July 29, 1998 2:18 PM

ã 1997 Microchip Technology Inc.


TO: U4 - 21, + 5 V Analog

- R41
6
1/2 LM358A 7
R40 5.1 k
U12 D14
8V
5 +
R33 - 8
R34 2
1% 22 M 1/2 LM358A TO: RA3, U4-9
2 U12 1 3 v Reference
N/C 3 U11 3 + 4
LM4040AIZ-5.0
-8V
1 + 5 V Reference
D13
D15
1N4150
U10 1N4150
TO: C1 +, unregulated positive rail Vin Vin Vout 5.0 v D8 + 5 V Digital
LM2931AZ-5.0
C4 1N4150
GND 10 V +

Preliminary
100 uf
3v 3v 1N4150 1N4150
D1 1N4150
DC POWER SUPPLY AND BATTERY BACKUP

D9A D9B
B1 B2
D6
+
C27
2..2 uf

kwhr_v1.vsd
11/14/97
Page 5

DS30452A-page 35
PICREF-3
WATTHOUR - METER REFERENCE DESIGN, 50/60 Hz, 90 - 264 V, 10 A

OPTION 1: CURRENT MEASUREMENT AUTOMATIC GAIN CONTROL


FIGURE B-8:

DS30452A-page 36
PICREF-3
Whm.bk Page 36 Wednesday, July 29, 1998 2:18 PM

TO: TR1-MT1

8
X 1 Range TO: U2-3

2A
T2 +5 V
MagneTek R1A
CSE187-L

100 K

1A

Preliminary
+5 V TO: U4-66 RB7
X 2 Range
R1B
TO: P1-N

100 K

+5 V X 5 Range TO: U4-8 RA2


R1C

100 K

R1D X 10 Range TO: U4-14 RC3


OPTION 1: CURRENT MEASUREMENT AUTOMATIC GAIN CONTROL

kwhr_v1.vsd
11/14/97
Page 6

ã 1997 Microchip Technology Inc.


Whm.bk Page 37 Wednesday, July 29, 1998 2:18 PM

PICREF-3
APPENDIX C: FIRMWARE LISTING
PIC16C924 firmware source code was written in C and
was compiled using MPLAB-C.
Source code, and future updates, may be obtained
electronically on the Microchip BBS and WWW site.

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 37


Whm.bk Page 38 Wednesday, July 29, 1998 2:18 PM

PICREF-3
NOTES:

DS30452A-page 38 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 39 Wednesday, July 29, 1998 2:18 PM

PICREF-3
APPENDIX D: PCB LAYOUT & FAB Figure D-1 is the WHM unit generic silk screen and
as-built schematics should be consulted for accurate
DRAWING information concerning the components of each unit.
The top silk screen drawing for the WHM unit is shown As-built schematics are provided with each unit
in Figure D-1. The dimensions listed are, with respect shipped, as calibration may alter the components used.
to the orientation of this page; (horizontal dimension x
This drawing may be obtained electronically on the
vertical dimension).
Microchip BBS or WWW site

FIGURE D-1: WATT-HOUR METER TOP SILK SCREEN

(7” x 6”)
Watt-Hour Meter Reference Design Based on PIC16C924
PICREF-3 Made in USA
P2 D7 DM003003
U14 Q4
C 1997
US1
2297
U6

R43
120/240 V AUTO Q3
D6
SWITCH
R42
C9A T1 R50

R2 C19
VOLTAGE SENSE
R36

START U7

R37
U1
R4
Z1 AN1 STOP ENTER
LCD

R27
S1 S2 S3 S4 CONTROL
F1
R26 J1
R11 R25

LOAD CANCEL HYBER CLR


C14
D10

ON LED1 R39
R13

AC
R12

R17
AC INPUT/OUTPUT

OUTPUT C11 R45


C22D11

D3
Z2
R35

D4
R3

C12 R46
D5 R8
C13

C15
U5 C23

120/240V C1 Q1
R18
TP1 U4 C10
C25
R9

BR1 C2 TP2 R47


AC R24
D2
C24

INPUT C3
D12C26

U8 U9 C6 S5
R32

C17 R29
R7

R30
R14

R44

MCLR
C28

C18
R15

R31
R16

XTAL2
C16

DC P3
R20 C7
C8
C9
Current

POWER
XTAL1
Sense

C10A TR1 Q2
SUPPLY
C21
R22
R23
U2 R5

T2 R6 R21 1
R1A U13 6
D14

BATTERY
CONTROL

R49 R38

U3
BACKUP R19 R48
C20 9
U10

D13

5
D8

D9

R10 R33
COMMUNICATION

U11 R34 J2
TRIAC
R1B

R40 R41
REMOTE

U12
LED2 C27
Current C4
Sense
R28

P1 DC B1
D1

POWER AC ON
SUPPLY

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 39


Whm.bk Page 40 Wednesday, July 29, 1998 2:18 PM

PICREF-3
APPENDIX E: BILL OF MATERIALS (BOM)
This appendix lists the Bill of Materials (BOM) for the
WHM PCB. WHM schematics may be found in
Appendix B.
TABLE E-1: WATT-HOUR METER (PICREF-3) BOM

Part #, Manufacturer,
Item Description Component Distrib #, Distributor
Contact #
1 Instrumentation Amplifier U1, 2 AD620AN, Analog Devices, Newark
(617) 329-4700
2 Serial EEPROM U3 24AA16/P, N/A
Microchip Technology,
(602) 786-7200
3 Microcontroller (8MHz) U4 PIC16C924 - 08I/L, N/A
Microchip Technology,
(602) 786-7200
4 PLCC Socket U4-Socket PLCC 68P-T-2, McKenzie, 978-2220, Allied
(510) 651-2700
5 Dual Comparator U5 LM393N, LM393N-ND, DigiKey
National Semiconductor,
(408) 712-5800
(800) 272-9959 (USA Only)
6 LCD, Multiplexed Display U7 VIM-808-DP-RC-S-HV, 10995-ND, DigiKey
VL Electronics, Inc.,
(213) 738-8700
7 3-Terminal Regulator, 8.0V, U8 NJM78L08A, JRC, NJM78L08A-ND,
TO-92 Pkg DigiKey
8 3 Terminal Regulator, Neg 8.0V, U9 NJM79L08A, JRC, NJM79L08A-ND,
TO-92 Pkg DigiKey
9 Positive 5.0V Regulator, TO-92 U10 LM2931AZ-5.0, LM2931AZ-5.0-ND,
Pkg National Semiconductor, DigiKey
(408) 712-5800
(800) 272-9959 (USA Only)
10 Reference Diode, 0.1%, 5V U11 LM4040AIZ-5.0, LM4040AIZ-5.0-ND,
National Semiconductor, DigiKey
(408) 712-5800
(800) 272-9959 (USA Only)
11 Dual Operational Amplifier U12 LM358A, LM358AN-ND,
National Semiconductor, DigiKey
(408) 712-5800
(800) 272-9959 (USA Only)
12 Triac Output Optoisolator U13 MOC3042, Isocom, MOC3042IS-ND,
(214) 423-5521 DigiKey
13 Metal Film Resistor, R1B 20E0MF1/4W-B 1%, Yageo, 20.0XBK, Digikey
20 W, 1%, 1/8 W 886-2-917-7555
14 Metal Film Resistor, 1 MW, 1% R2, 36 5043ED1M000F, Philips, 50F8317, Newark
(914) 246-2811
(800) 234-7381 (USA only)
15 Metal Film Resistor, 1 kW, 1% R3, 35 5043ED1K000F, Philips, 50F8302, Newark
(914) 246-2811
(800) 234-7381 (USA only)
16 Select Resistor, Alignment R4 RN60C 68.1K 1%, Dale, 58F006R 68.1K,
(402) 563-6506 Newark
17 Metal Film Resistor, 6.2 kW, 1% R5 Generic

DS30452A-page 40 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 41 Wednesday, July 29, 1998 2:18 PM

PICREF-3
TABLE E-1: WATT-HOUR METER (PICREF-3) BOM (CON’T)

Part #, Manufacturer,
Item Description Component Distrib #, Distributor
Contact #
18 Carbon Film Resistor, 360W, 1%, R6 Yageo, 360QBK-ND, DigiKey
1/4W 886-2-917-7555
19 Carbon Resistor, 100 kW, 5% R7, 29 Yageo, 100KQBK-ND,
886-2-917-7555 DigiKey
20 Carbon Resistor, 2.2 kW, 5%, R9, 26 Yageo, 2.2KQBK-ND, DigiKey
1/4W 886-2-917-7555
21 Carbon Resistor, 470W, 5%, 1/4W R10, 29 Yageo, 470QBK-ND, DigiKey
886-2-917-7555
22 Carbon Resistor, R13, 16, 18 Yageo, 4.7KQBK-ND, DigiKey
4.7 kW, 10%, 1/4W 886-2-917-7555
23 Metal Film Resistor, 1 kW, 1% R14 5063JD1K000F, Philips, 50F8359, Newark
(914) 246-2811
(800) 234-7381 (USA only)
24 Carbon Resistor, 10 kW, 5% R17, 22, 23, Yageo, 10KQBK-ND, DigiKey
27, 28, 32, 886-2-917-7555
39, 44
25 Carbon Resistor, R19 Yageo, 910QBK-ND, DigiKey
910 kW, 10%, 1/4W 886-2-917-7555
26 Carbon Resistor, R20 Yageo, 180QBK-ND, DigiKey
180 kW, 10%, 1/4W 886-2-917-7555
27 Carbon Resistor, R21 Yageo, 12KQBK-ND, DigiKey
12 kW, 10%, 1/4W 886-2-917-7555
28 Trimmer Potentiometer, 250 kW R24 3352E-1-254, Bourns, 3352E-1-254, DigiKey
(909) 781-5500
29 Metal Film Resistor, 63.4 kW, 1% R25 RN60C 63.4k 1%, Dale, 58F006R 63.4k, New-
(402) 563-6506 ark
30 Carbon Resistor, 68W, 5%, 1W R30 Generic
31 Metal Film Resistor, 1%, 1/4W R33 Generic
32 Metal Film Resistor, 1%, 1/4W R34 Generic
33 Metal Film Resistor, 3.83 kW, 1% R37 3K83MF-1/4W-B 1%, Yageo, 3.83KXBK, Digikey
886-2-917-7555
34 Select Resistor, Alignment R38 Generic
35 Carbon Resistor, 5.1 kW, 5%, R40 Yageo, 5.1QBK-ND, DigiKey
1/4W 886-2-917-7555
36 Metal Film Resistor, 1%, 1/4W R41 Generic
37 Carbon Resistor, 100 W, 5%, R48 Yageo, 100QBK-ND, DigiKey
1/4W 886-2-917-7555
38 8-pin SIP resistor network, 470W RN1 CTS, 770-83-R 470-ND,
(219) 293-7511 DigiKey
39 Fast Acting Fuse, F1 AGC-12, Cooper, 94F2182, Newark
AGC 0.25 x 1.25, 12 A (414) 549-5000
40 PCB 3AG Fuse Clips F1-Clips 102074, Little Fuse, 27F1086, Newark
(847) 824-0400
41 NPN Transistor, TO-92 pkg Q1 2N3904, Motorola, 2N3904-ND, DigiKey
(602) 244-6900
42 PNP Transistor, TO-92 pkg Q2 2N4403, Motorola, 2N4403-ND, DigiKey
(602) 244-6900

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 41


Whm.bk Page 42 Wednesday, July 29, 1998 2:18 PM

PICREF-3
TABLE E-1: WATT-HOUR METER (PICREF-3) BOM (CON’T)

Part #, Manufacturer,
Item Description Component Distrib #, Distributor
Contact #
43 MOV, 420V AC Z1 V420LA10, Harris, V420LA10, Newark
(407)724-7000
(800) 4 HARRIS (USA Only)
44 Zener diodes, 18V, 1W Z2, 3, 4 1N4746A, Motorola, 1N4746A-ND, DigiKey
(602) 244-6900
45 High Speed Switching Diode, D1, 3, 4, 5, 1N4150, Diodes Inc., Sterling
0.5W, D0-35 8, 9A, 9B, (805) 446-4800
13, 15
46 Schottky Barrier Rectifier, D2, 6, 10, 1N5817, Diodes Inc., Newark
DO-41 Pkg 11, 12 (805) 446-4800
47 8 MHz Ceramic Resonator/w built XTAL1 EF0-EC8004A4, Panasonic, PX800-ND, DigiKey
in caps (714) 373-7366
48 32 kHz Crystal Resonator XTAL2 C-001R 32.768K-A, Epson, SE3201-ND, DigiKey
(310) 787-6300
49 PC Mount Transformer T1 PF30-200, MagneTek, DigiKey
(219) 297-3111
50 Current Sense Transformer T2 CSE187-L, MagneTek, 10515-ND, DigiKey
(219) 297-3111
51 Bridge Rectifier BR1 W005G-ND, W005G-ND, DigiKey
General Instrument,
(516) 847-3000
52 Aluminum Electrolytic Capacitor, C1, 2 515D477M035CG6A, Sprague, 50F072, Newark
470 uF, 35W VDC (603) 224-1961
53 Ceramic Capacitor, 0.01 mF C3, 6, 15, 1C10Z5U103M050B, Sprague, 81F2060, Newark
22, 23, 24, (603) 224-1961
26,11,12
54 Tantalum Capacitor, C4 199D107X0010EE2, Sprague, 17F2029, Newark
100 uF, 10W VDC (603) 224-1961
55 Ceramic Capacitor, 0.1 mF C5, 13, 14, 1C10Z5U104M050B, Sprague, 81F2061, Newark
18, 19, 20, (603) 224-1961
21
56 Monolithic Ceramic Capacitor, C7, 8, 9, 10 ECU-S1J474MEB, Panasonic, P4919-ND, DigiKey
0.47 uF (714) 373-7366
57 Ceramic Capacitor, C9A, C10A 125LD10, Sprague, 46F5228, Newark
0.001 uF, 500 VAC (603) 224-1961
58 Ceramic Capacitor, 33 pF C16, 17 1C10C0G330J050B, Sprague, 95F7168, Newark
(603) 224-1961
59 Tantalum Capacitor, 2.2 mF, 25W C27, 28 199D225X0025AA1, Sprague, 17F2041, Newark
VDC (603) 224-1961
60 3V Lithium Battery, PCB Termi- B1, 2 CR2032, Panasonic, P189-ND, DigiKey
nal Coin Type (714) 373-7366
61 20mm Coin Cell Lithium PC Bat- B1, 2-Holder 1026, Keystone, 1026K-ND, DigiKey
tery Holder (718) 956-8900
(800) 379-3943 (USA only)
62 AC Power Line Connector - P1 GSP1.3101.1, Schurter, 509-1269, Allied
Input (707) 778-6311
(800) 848-2600 (USA only)
63 AC Power Line Connector - P2 4300.0251, Schurter, 509-1271, Allied
Output (707) 778-6311
(800) 848-2600 (USA only)

DS30452A-page 42 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 43 Wednesday, July 29, 1998 2:18 PM

PICREF-3
TABLE E-1: WATT-HOUR METER (PICREF-3) BOM (CON’T)

Part #, Manufacturer,
Item Description Component Distrib #, Distributor
Contact #
64 Right Angle, DB9, P3 DEKL-09SAT-F2, Cinch, 95F4128, Newark
PCB Connector (708) 981-6000
65 Triac, 10 amps TR1 Q4010L5, Teccor, Q4010L5-ND, DigiKey
(214) 580-1515
66 TO-220 Heat Sink, Extruded Pins TR1-Heat 531002B02500, AAVID, HS190-ND, DigiKey
Sink (603) 528-3400
67 Momentary Switch S1, 2, 3, 4, 5 EVQ-PAD04M, Panasonic, P8007S, DigiKey
(714) 373-7366
68 Circuit Board Test Points TP1, 2 131-5031-00, Tektronix, N/A
(503) 627-5000
(800) 426-2200 (USA only)

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 43


Whm.bk Page 44 Wednesday, July 29, 1998 2:18 PM

PICREF-3
NOTES:

DS30452A-page 44 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 45 Wednesday, July 29, 1998 2:18 PM

PICREF-3
APPENDIX F: WATT-HOUR METER F.2 Demo Unit Assembly
DEMO UNIT
This Demo Unit was designed to showcase the
PIC16C924 microcontroller in a watt-hour meter appli-
DANGER
cation. Electrocution Hazard
Do Not Disassemble Unit
F.1 Demo Unit Specifications
The specifications for this demo are stated in A Watt-Hour Meter demo unit top view is shown in the
Appendix A. figure below.

FIGURE F-1: DEMO ASSEMBLY - TOP

AC Output 8-Digit LCD Push Buttons

Protective Covering Power


Of AC Electronics Electronics

PIC16C924

Serial EEPROM

AC Input Serial Port

Battery Backup
Current Sense
Transformer

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 45


Whm.bk Page 46 Wednesday, July 29, 1998 2:18 PM

PICREF-3
F.3 How to Set Up the Demo Unit damage.
3. Display the desired power and energy informa-

DANGER tion on the LCD display by pressing the push


buttons (See Firmware Overview).
Electrocution Hazard F.4 Recommended Loads
Do Not Disassemble Unit
The following loads are recommended:
Linear Resistive Loads
(Halogen lights):

Caution •

90W
180W
Load current is 10A MAXIMUM. • 250W
• 500W
• 1000W
Follow these steps to set up the PICREF-3 Demo Unit: • 2000W
1. Plug the receptacle end of a power cord into the Linear Inductive Loads
Demo Unit “AC Input”. Plug the pronged end of (Fractional horsepower motors):
the power cord into an AC wall socket. The AC
• 230 V; 1/2 HP
Input will accept voltages in the 90 - 264V range.
• 115V; 1/2, 1/3, 1/6 HP

Note: A grounded AC power cord MUST be Non-linear Loads:


used for proper operation of the meter. • Computer monitor
2. Plug the load into the Demo Unit “AC Output”
socket. Steady state load currents in the 0.5 -
10A range can be measured. Surge currents of
up to 17A have been applied to the unit without

FIGURE F-2: DEMO ASSEMBLY - SIDE

LCD PIC16C924

Power
Electronics

AC Output AC Input

DS30452A-page 46 Preliminary ã 1997 Microchip Technology Inc.


Whm.bk Page 47 Wednesday, July 29, 1998 2:18 PM

PICREF-3
NOTES:

ã 1997 Microchip Technology Inc. Preliminary DS30452A-page 47


Whm.bk Page 48 Wednesday, July 29, 1998 2:18 PM

M
WORLDWIDE SALES AND SERVICE
AMERICAS AMERICAS (continued) ASIA/PACIFIC (continued)
Corporate Office Toronto Singapore
Microchip Technology Inc. Microchip Technology Inc. Microchip Technology Singapore Pte Ltd.
2355 West Chandler Blvd. 5925 Airport Road, Suite 200 200 Middle Road
Chandler, AZ 85224-6199 Mississauga, Ontario L4V 1W1, Canada #07-02 Prime Centre
Tel: 602-786-7200 Fax: 602-786-7277 Tel: 905-405-6279 Fax: 905-405-6253 Singapore 188980
Technical Support: 602 786-7627 Tel: 65-334-8870 Fax: 65-334-8850
Web: http://www.microchip.com ASIA/PACIFIC Taiwan, R.O.C
Atlanta Hong Kong Microchip Technology Taiwan
Microchip Technology Inc. Microchip Asia Pacific 10F-1C 207
500 Sugar Mill Road, Suite 200B RM 3801B, Tower Two Tung Hua North Road
Atlanta, GA 30350 Metroplaza Taipei, Taiwan, ROC
Tel: 770-640-0034 Fax: 770-640-0307 223 Hing Fong Road Tel: 886-2-2717-7175 Fax: 886-2-2545-0139
Boston Kwai Fong, N.T., Hong Kong
Microchip Technology Inc. Tel: 852-2-401-1200 Fax: 852-2-401-3431 EUROPE
5 Mount Royal Avenue India United Kingdom
Marlborough, MA 01752 Microchip Technology Inc. Arizona Microchip Technology Ltd.
Tel: 508-480-9990 Fax: 508-480-8575 India Liaison Office 505 Eskdale Road
Chicago No. 6, Legacy, Convent Road Winnersh Triangle
Microchip Technology Inc. Bangalore 560 025, India Wokingham
333 Pierce Road, Suite 180 Tel: 91-80-229-0061 Fax: 91-80-229-0062 Berkshire, England RG41 5TU
Itasca, IL 60143 Japan Tel: 44-1189-21-5858 Fax: 44-1189-21-5835
Tel: 630-285-0071 Fax: 630-285-0075 Microchip Technology Intl. Inc. France
Dallas Benex S-1 6F Arizona Microchip Technology SARL
Microchip Technology Inc. 3-18-20, Shinyokohama Zone Industrielle de la Bonde
14651 Dallas Parkway, Suite 816 Kohoku-Ku, Yokohama-shi 2 Rue du Buisson aux Fraises
Dallas, TX 75240-8809 Kanagawa 222-0033 Japan 91300 Massy, France
Tel: 972-991-7177 Fax: 972-991-8588 Tel: 81-45-471- 6166 Fax: 81-45-471-6122 Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79

Dayton Korea Germany


Microchip Technology Korea Arizona Microchip Technology GmbH
Microchip Technology Inc.
168-1, Youngbo Bldg. 3 Floor Gustav-Heinemann-Ring 125
Two Prestige Place, Suite 150
Samsung-Dong, Kangnam-Ku D-81739 Müchen, Germany
Miamisburg, OH 45342
Seoul, Korea Tel: 49-89-627-144 0 Fax: 49-89-627-144-44
Tel: 937-291-1654 Fax: 937-291-9175
Tel: 82-2-554-7200 Fax: 82-2-558-5934 Italy
Detroit
Shanghai Arizona Microchip Technology SRL
Microchip Technology Inc.
Microchip Technology Centro Direzionale Colleoni
42705 Grand River, Suite 201
RM 406 Shanghai Golden Bridge Bldg. Palazzo Taurus 1 V. Le Colleoni 1
Novi, MI 48375-1727
2077 Yan’an Road West, Hong Qiao District 20041 Agrate Brianza
Tel: 248-374-1888 Fax: 248-374-2874
Shanghai, PRC 200335 Milan, Italy
Los Angeles Tel: 86-21-6275-5700 Fax: 86 21-6275-5060 Tel: 39-39-6899939 Fax: 39-39-6899883
Microchip Technology Inc.
18201 Von Karman, Suite 1090 7/7/98
Irvine, CA 92612
Tel: 714-263-1888 Fax: 714-263-1338
Microchip received ISO 9001 Quality
New York
System certification for its worldwide
Microchip Technology Inc.
headquarters, design, and wafer
150 Motor Parkway, Suite 202
Hauppauge, NY 11788 fabrication facilities in January, 1997.
Tel: 516-273-5305 Fax: 516-273-5335 Our field-programmable PICmicro™
8-bit MCUs, Serial EEPROMs,
San Jose
related specialty memory products
Microchip Technology Inc.
2107 North First Street, Suite 590
and development systems conform
San Jose, CA 95131 to the stringent quality standards of
Tel: 408-436-7950 Fax: 408-436-7955 the International Standard
Organization (ISO).

All rights reserved. © 1998, Microchip Technology Incorporated, USA. 7/98 Printed on recycled paper.

Information contained in this publication regarding device applications and the like is intended for suggestion only and may be superseded by updates. No representation or warranty is given and no
liability is assumed by Microchip Technology Incorporated with respect to the accuracy or use of such information, or infringement of patents or other intellectual property rights arising from such use
or otherwise. Use of Microchip’s products as critical components in life support systems is not authorized except with express written approval by Microchip. No licenses are conveyed, implicitly or
otherwise, under any intellectual property rights. The Microchip logo and name are registered trademarks of Microchip Technology Inc. in the U.S.A. and other countries. All rights reserved. All other
trademarks mentioned herein are the property of their respective companies.

DS30452A-page 48 ã 1998 Microchip Technology Inc.

You might also like