PM9903BPE: Evaluation Board For The SA9903B Energy Metering IC
PM9903BPE: Evaluation Board For The SA9903B Energy Metering IC
PM9903BPE: Evaluation Board For The SA9903B Energy Metering IC
FEATURES + Designed to + + + +
be used together with accompanying software as fully functional single phase trivector meter. Operation better than class 1 operation for active and class 2 for reactive energy. On board power supply. Two on-board LEDs for active and reactive pulse output. Single Phase 2 wire configuration, 230V 80A (Imax).
+ + + + + +
On-board LCD. Current sensing via on-board shunt or optional CT. Isolated connection to PC parallel port. Easy accessible test pins. Micro-controller plug-in support Micro-controller / PC operation
DESCRIPTION
This Application Note describes the PM9903BPE evaluation board and together with the SA9903B data sheet provides a complete evaluation platform. The SA9903B is an accurate bidirectional power / energy measurement IC with serial (SPI) interface measuring active as well as reactive power / energy, RMS voltage and frequency. More detailed information specific to the SA9903B can be found in its datasheet. The PM9903BPE module is designed for single-phase twowire applications. The mains voltages easily connect to the module by way of a Molex connector (SK1).Anon-board shunt resistor measures the current, while provision has been made to insert a current transformer in place of the shunt. A simple transformer power supply supplies the energy metering IC with power. The 78L05 regulator is used to generate a 5 V supply voltage for the device and on-board opto-couplers. Provision has been made to connect an external 5V power supply to drive the isolated opto-coupler. The SA9903B forms the energy/power metering front-end of the module and connects to the SPI bus. Sharing the SPI bus is the SA8807A LCD driver which is capable of driving 96 segments on a 4 back plane LCD. The PM9903BPE evaluation board is configured and calibrated via the parallel port of a PC. The data interface between the evaluation board and the PC is fully isolated. The PM9903BPE module can easily be connected to a microcontroller. The SAMES micro-controller board connects to the evaluation module by means of the SPI and JP3 connectors thereby creating a complete power meter without the PC interface. Physically the micro-controller board plugs into the evaluation module with its opto-coupler facing the mains connector (SK1). It shares the SPI bus with the SA8807A onboard LCD controller.
JP4
SK3
PCVSS
IVP Resistor Network IIN IIP JP1/SPI Load SA9903B J12 FMO JP3 PCVSS SA8807A JP2
Test Pins
VDD
VSS
PCVSS
Test Pins
1/22
08-03-05
J12
Communication jumpers
Jumpers J8 to J11 connect pull up resistors to the SPI inputs of the SA9903B. The pull up resistors are required by the open drain outputs of the HCPL2631 opto-couplers. If a PC is used with the PM9903BPE module the jumpers must be closed, and can be left closed in the case of the SAMES microcontroller board. This board is capable of driving the SPI bus in this state. Default Closed.
sames
JP4
PM9903BPE L SK1 N
J7 Micro-controller board PB J8 J9 AGND J10 J11 SPI SK2 Push button J5 VSS J4 VDD J6 J12 FMO* JP1
* On some pcb's this may be labled as PB/F150, however FMO and F150 is the same connection. Figure 2: Jumper positions
http://www.sames.co.za
2/22
Load
N L
5V
SK3
JP4 Supp Sel
SK1
J7 J6 J5 VSS J4
To PC Parallel port
J10 J11
VDD
SK2
http://www.sames.co.za
3/22
Subtract previous value and Check / fix register wrapping Add to active energy integrator Wait for next measurement cycle Do other functions on meter
No
Generate pulse
4/22
PM9903BPE
It is recommended that the flow diagram be implemented together with a timer interrupt used for the creep timing.
Creep threshold time (s): Ct = 1/(Cc / Imax) x Rf where: Cc is the specified creep current; energy below this value is discarded. Imax is the maximum mains current to be measured and correspond to 16A on the current inputs of the device. Rf is the rated current frequency. The flow diagram (figure 6) for the timer interrupt shows how the time between pulses is measured, if the time since the last pulse is more than the time measured, the integrator is reset and a new count down is started.
Integrator zero
Pulse LED
Pulse Generated Reg 0 add to Integrator Reg 0 add to Integrator Reg 0 add to Integrator
5/22
PM9903BPE
Hardware The schematic is presented in Figure 18. As can be seen the major elements are: + + + + + micro-controller, eeprom, keys, rate LEDs / opto-isolated rate pulse output andmiscellaneous connectors.
No
No
Micro-controller A PIC 16F876-20/so is used to generate the rate pulses, in this application the micro uses a 20 MHz crystal (X1). This device has 8kB Flash ROM (program memory) and 368 Byte RAM (data memory). Detail information on the device can be obtained in the appropriate MICROCHIP datasheet. EEPROM A 93C46 EEPROM provides storage for non-volatile data, such as calibration factors. This device has 1 kB space available or stated differently 128 x 8bit words. Keys Four keys are provided of which one is connected to the microcontrollers reset pin. The other three are available to implement an HMI (Human Machine Interface) in the firmware; theyre labelled Up/Down and Enter on the printed circuit board. Rate outputs Two LEDs are provided for active and re-active energy respectively. These pulse outputs can be coupled to an optocoupler via JP3/4 providing an output for external usage. This output-pulse selection is accomplished with a jumper on JP3/4 as follows: + + + Jumper on boards outside edge Jumper on boards centre pins Jumper on boards inside edge = active = re-active = not used
Creep timer = 0 No
Yes
Exit interrupt
Miscellaneous Connectors JP1 and JP2 are provided to ease debugging during code development, all relevant signals are available. J1 in conjunction with SK2 are the two plug-in points to the evaluation module, where SK2 is the SPI connector and J1 merely a stabilising holder. The micro-controller is programmed via SK1 using the controllers ICSP (in circuit serial programming) capability, as described in the relevant MICROCHIP datasheet. If the intention is to program the board
6/22
PM9903BPE
from MICROCHIPs PICSTART-programmer a buffer needs to be inserted in the VDD line to boost the programmers output capability.An example of such a buffer is shown in Figure 8.
>5V
User Interface A simple interface has been implemented using two of the three available keys. The Enter Key toggles display of consumed kWh and kVARh units. The Down Key display of RMS voltage and frequency data. The LCD is updated each second based on the last 'key-press' value. Memory Usage ROM: 3452 words RAM: Bank0 Bank1 Bank2 Bank3
R1 820K
R3 100R
2N3906
INPUT
2N3819
0V
Figure 8: Typical buffer circuit Firmware The micro-controllers code was created according to the guidelines set out in the evaluation software section. It is presented as a kick-start to experimentation with the microcontroller module and as such shouldnt be seen as the only possible implementation. The code was generated using HiTech PIC C (v8.00PL1); the demo version on their www site (www.htsoft.com) is sufficient for experimentation. The program flow is presented in Figure 9. SPI The 16F876's SPI hardware is used to read the SA9903B's registers, using normal byte wide protocol. All registers are read after receiving a zero-crossing (FMO) interrupt from the SA9903B. The CE signal enables the SPI for the display driver and the CS signal enables the SPI for the SA9903B. Rate LEDs / opto-outputs The 10ms pulse widths on these outputs are derived from a timer interrupt. Creep If the time between two successive pulses is greater than a predefined maximum, the respective energy accumulator is cleared. The simplest method of deciding what the predefined value should be is to measure the time between two pulses at the lowest permissible load current, this is then expressed i.t.o basic timer ticks. Method of deciding what the predefined value should be is to measure the time between two pulses at the lowest permissible load current, this is then expressed i.t.o basic timer ticks.
http://www.sames.co.za
Please refer to the readme. 1st file for any updated information not contained in this application note. The mentioned file is part of the source code that accompanies this module.
LOOP
No
No
Yes
7/22
Pin 1
Voltage Divider
Referring to figure 11 the connections for the voltage sense input for one phase is shown. The current into the A/D converter (IVP) is set 14ARMS at nominal mains voltage. This voltage sense input saturates at approximately 17ARMS. A nominal voltage current of 14A allows for 20% over driving. Each phase voltage is divided down by a voltage divider to 14V. The current into the voltage sense input is set at 14A via a 1M resistor. The following equation is used to calculate the 14V voltage drop: RA=R22+R23+R24 RB = R8 || R13 Combining the two equations gives: (RA + RB) / 230V = RB / 14V A 24k resistor is chosen for R13 and a 1M resistor is used for R8. Substituting these values result in: RB = 23.44k RA=RBx(230V/14V-1) RA=361.6k Resistor values of R22, R23 and R24 are chosen to be 120k. If a CT is used capacitors C500 / C501 can be used to compensate for phase shifts between the SA9903s voltage sense inputs and current sense inputs. The value of the phase shift compensation capacitors are calculated as follows, assuming a phase shift of 0.18 degrees. C = 1 / (2 x xMainsfrequency x R8 x tan (Phase shift angle)) C = 1 / (2 x x 50Hz x 1M tan (0.18 degrees)) C = 1.013F
C5 R13 1u 24k
Bias Resistor
Pin VREF (SA9903B pin 3) is connected to Vss via R9 which determines the on chip bias current. With R9=24k optimum conditions are set. VREF does not require any additional circuitry.
V1In
L1 R22 120k
R23 120k
R24 120k
R8 1M
Pin 19
GND
http://www.sames.co.za
8/22
PM9903BPE
Power Supply
The PM9903BPE module uses a transformer based power supply. The maximum current that can be drawn by the circuit is approximately 100mA. The normal operating current of the module is closer to 30mA. An 78L05 voltage regulator is used to regulate the voltage from the transformer. Two resistors (R500 and R501) generate the analog ground voltage for the SA9903B. The SA9903B operates between 0V and 5V with the GND pin connected tomid-rail. taken not to have current flowing in the node that connects the voltage reference resistor to VSS as it may introduce power supply noise on the voltage reference circuit.
Signal Routing
The signal routing is done in such a manner that any signal coupling in to the measured signal will be a common mode noise signal and is subsequently rejected. Care should be taken that the signals to the SA9903B not be influenced by other sources such as electric fields from transformers etc.
PCB DESIGN
The PM9903BPE evaluation module represents a Class 1 meter and is designed to demonstrate the functionality and performance of the SA9903B metering integrated circuits. The SA9903B is mainly the analog front end of a meter. The SA9903B measures the energy, voltage and frequency which aremadeavailable via SPI to an external controller / PC.When themeters PCB is designed, it should be remembered that the SA9903B inputs are analog and special care need to be taken with the power supply and signal routing to the SA9903B.
Protection
The SA9903B should be protected from the measuring environment. This is achieved by using resistor dividers to scale all the SA9903Bs input signals. MOV's Z1 together with resistor R83 protects the power supply transformer as well as the voltage sense inputs. The current setting resistors on the current sense inputs attenuates any common mode and asymmetrical transients.
Component placement
All the resistors on the SA9903Bs current sense inputs should be placed as close as possible to the SA9903B. This eliminates the possibility of any stray signals coupling into the input signals.
Ground Plane
The GND pin of the SA9903B is connected to the neutral phase, which is halfway between VDD and VSS. Note that supply bypass capacitors C1 and C2 are positioned as close as possible to the supply pins of the SA9903B, and is connected to a solid ground plane. Capacitor C6 is also positioned as close as possible to the supply pins of the SA9903B for proper supply bypassing.
SPI Interface
The SA8807A shares the SPI interface with the SA9903B and connects directly to the opto-couplers on the PM9903BPE evaluation board.
http://www.sames.co.za
9/22
PM9903BPE
Commands
The demonstration software uses a buffer in memory on the PC to generate the complete display. The buffer is dumped to the LCD driver device in one go. The data passed to the driver IC is formatted with a starting address followed by the data for all segments. The first 8 bits is interpreted as address byte and the rest of the data is sequentially passed as data bytes. The address counter on the driver IC is incremented every 8 clocks. The procedure is repeated until all of the LCD memory is filled up.
Address
The address of the data is set up in the followingmanner
Pin36 Pin35
Pin32
COM1
T1 T2 T3 T4
DR-01255
Cos
f
a b f
a b COM2
Total Com
e
1
g c d h e d
4
g c h
COM3
Cost
COM4
Pin1
Pin2
Pin5
COLUMNS
Figure 12: Mapping of a single character Address LCD Pin COM1, 17 COM2, 18 COM3, 19 COM4, 20 30 5f 5g 5e 5d 5 7 5a 5b 5c 5h 32 4f 4g 4e 4d 4 5 4a 4b 4c 4h 33 3f 3g 3e 3d 3 4 3a 3b 3c 3h 34 2f 2g 2e 2d 2 3 2a 2b 2c 2h 35 1f 1g 1e 1d 1 2 1a 1b 1c 1h 36 Cos Total Com Cost 0 1 T1 T2 T3 T4
Table 1: LCD display memory map Address LCD Pin COM1, 17 COM2, 18 COM3, 19 COM4, 20 Blank Blank Blank T1, T2, T3, T4 23 Blank Blank Blank Total 11 21 k1 Hz ~1 ~2 10 16 k2 W s h 22 % Error imp/KWh Wh/imp ~3 9 15 V A r h 24 8f 8g 8e 8d 8 13 8a 8b 8c 8h 26 7f 7g 7e 7d 7 11 7a 7b 7c 7h 28 6f 6g 6e 6d 6 9 6a 6b 6c 6h
10/22
35 1f 1g 1e 1d
34 2f 2g 2e 2d
33 3f 3g 3e 3d
32 4f 4g 4e 4d
31
30 5f 5g 5e
29
28 6f 6g 6e
27
26 7f 7g 7e
25
24 8f 8g 8e
23
21 k1 Hz ~1 ~2
23
23
COM3 COM4
T1
5d
T2
6d
T3
7d
T4
8d
Total ~ 3
Table 3 : Mapping of display Pin COM1 COM2 COM3 COM4 1 T1 T2 T3 T4 2 1a 1b 1c 1h 3 2a 2b 2c 2h 4 3a 3b 3c 3h 5 4a 4b 4c 4h 6 7 5a 5b 5c 5h 8 9 6a 6b 6c 6h 10 11 7a 7b 7c 7h 12 13 8a 8b 8c 8h 14 15 V A r h 16 k2 W s h 17 COM1 COM2 18
11/22
PM9903BPE SCHEMATIC
R13 24K
GND
C500
R22
LIVE IN GND
R23 120k
R1 1K6
14V1
J50 A R26 B B A
120k
1U C501 Optional IIN IIP VREF TP4 TP3 TP2 TEST VDD TP9 OSCO GND IVP CS DI TP16 FMO VSS DO SCK OSCI 20 19 18 17 16 15 14 13 12 11 VDD VSS MISO SCK DO SCK F150 FMO VDD VSS F150 SCK CS_A MISO MOSI CS_D GND R8 1MCS_A MOSI CS DI
CT1 A B
1 2 3 4 5 6
R2 1K6
24k
VSS 7 VDD 8 9 10
JP2000
1 2 3 4 5 6 7 8
SA9903B
X1
HEADER 8
C2 220n
3.5795MHz GND
C6 1u
CON1
L
U3 78L05
1 2
Mains
N
D1 1N4148 T1 D3 1N4148
Vin
NEUTRAL
R83 10R/2W Z1
R500 1k
C2 220n
p
230/9
+ C506
2200u/25V D2 1N4148 D4 1N4148
+ C507
220u/16V R501 1k
LIVE GND
VSS JP5
C1 220n
VSS
http://www.sames.co.za
12/22
PM9903BPE
13/22
PM9903BPE
http://www.sames.co.za
14/22
PM9903BPE
http://www.sames.co.za
15/22
http://www.sames.co.za
16/22
1 / 16V (C501 optional) Capacitor Electrolytic Radial, Non-Polar 2200 / 25V 220 / 16V Tz76 1N4148 LED SW-PB 1k6 1M 24k 120k 2R7 Capacitor Electrolytic Radial Capacitor Electrolytic Radial Optional Silicon Diode LED 3mm Diameter Micro switch, push to make Watt, 1%, Metal Film Resistor Watt, 1%, Metal Film Resistor Watt, 1%, Metal Film Resistor Watt, 1%, Metal Film Resistor Watt, 1%, Metal Film Resistor Watt, 5%, Carbon Resistor Watt, 5%, Carbon Resistor Watt, 5%, Carbon Resistor Watt, 5%, Carbon Resistor 2 Watt, 5%, Wire Wound Resistor Shunt Resistor 2 Pin Molex, Center square pin, Friction Lock Db25, PCB Mount, Female 2 Pin Molex, Center square pin, Friction Lock 9V, 1.5VA 20 Pin IC Socket, Tulip Type 44 Pin PLCC IC Socket TO-92 Package DIP 8 Package Crystal Metal Oxide Varistor
Note 2
Note 1, b
R34, R35, R36, R37, R38, R39 680R R40, R41, R44, R45, R46, R47 4k7 R48, R49, R50, R51 R42, R43, R500, R501 R83 SHUNT Sk1 Sk2 Sk3 T1 U1 U2 U3 U5, U6, U7 X1 Z1, (MOV) Notes: 1. Use only with CT (a) else replace with wire-line (b) else leave open 2. For CT value will change 4R7.............12R 1k 10R 80A / 50mV (625) MAINS PC PC 5V Transformer SA9903B SA8807AF 78L05 HCPL2631 3.5795MHz S10 / 275
http://www.sames.co.za
17/22
PM9903BPE
18/22
sames
RB7 RB6 RB5 RB4 RB3 RB2 C5 UP S1 R5 RESET S4 R6 Opto Out
19/22
PM9903BPE
ISP MCLR RA0 RA0 RA2 RA3 RA4 RA5 VSS OSCI OSCO CS_D CS_A CS_M SCK C2 C3 U2 C1 D2 U1 Q1
sames
RB7 RB6 RB5 RB4 RB3 RB2 RB1 F50 VDD VSS RC7 RC6 Active MOSI MISO ENTER S3 R4 Reactive DOWN S2 C5 UP S1 JP3/4 R5 RESET S4 R6 Opto Out
http://www.sames.co.za
20/22
http://www.sames.co.za
21/22
Any sales or technical questions may be posted to our e-mail address below: [email protected]
For the latest updates on datasheets, please visit our web site: http://www.sames.co.za. SOUTH AFRICAN MICRO-ELECTRONIC SYSTEMS (PTY) LTD SUBSIDIARY OF LABAT AFRICA (PTY) LTD Tel: (012) 333-6021 Tel: Int +27 12 333-6021 Fax: (012) 333-8071 Fax: Int +27 12 333-8071
http://www.sames.co.za
22/22