SAMES PM9603APA

sames
SA9603B APPLICATION NOTE
PM9603AP
SINGLE PHASE POWER/ENERGY METERING MODULE
SPI INTERFACE
FEATURES
n
Performs both power and energy
measurement
n
Meets the accuracy requirements for
Class 1 AC Watt hour meters
n
Protected against ESD
n
Total power consumption rating below
500mW (excluding current sensing)
n
Uses a shunt resistor for current sensing
n
Operates over a wide temperature
range
n
Isolated SPI interface.
DESCRIPTION
The SAMES single phase power/energy metering module, the PM9603AP, provides
energy data via a isolated SPI interface.
Energy consumption is determined by the power measurement being integrated over
time.
The method of calculation takes the power factor into account.
The output of this innovative universal power/energy meter is ideally suited for energy
calculations in applications using a micro-controller.
The application utilises the SAMES SA9603B power metering integrated circuit for power
measurement.
As a safety measure, this application shows the current sensor connected to the neutral
line. In practice, the live line may be used for current sensing, provided that the supply
connections (MAINS) are reversed on the module.
1/16
7131
PDS038-SA9603B-001
REV.A
5-09-97
PM9603AP
BLOCK DIAGRAM
IN
NE UT RAL
OUT
NE UT RAL
IN
SHUNT
S A 96 03 B
POWER
S UP P LY
O PTOC O U PLE R
D -s u b C O N N E C T O R
NE UT RAL
POWER
M ETER
W IT H
SPI BUS
L IV E
O PTOC O U PLE R
VOL T AGE SENSE
D R -0 1 3 4 9
ABSOLUTE MAXIMUM RATINGS*
Parameter
Symbol
Supply Voltage (Note 1)
VAC
Current Sense Input (Note 1)
VIV
Storage Temperature
TSTG
Operating Temperature
TO
Max Current
IMAX
through Sensor
IMAX
Min
-2.5
-25
-10
Max
300
+2.5
+125
+70 (Note 2)
800 (Note 3)
2000 (Note 4)
Unit
V
V
°C
°C
A
A
Note 1: Voltages are specified with reference to Live.
Note 2: The SA9603B integrated circuit is specified to operate over the temperature
range -10°C to +70°C. The module functionality will however depend upon the
external components used.
Note 3: t = 500ms
Note 4: t = 1ms
*Stresses above those listed under “Absolute Maximum Ratings” may cause permanent
damage to the device. This is a stress rating only. Functional operation of the device
at these or any other conditions above those indicated in the operational sections of this
specification, is not implied. Exposure to Absolute Maximum Ratings for extended
periods may affect device reliability.
2/18
sames
PM9603AP
ELECTRICAL CHARACTERISTICS
(Over the temperature range -10°C to +70°C, unless otherwise specified. Power
consumption figures are applicable to the PM9603APE only.)
Parameter
Symbol
Supply Voltage
(Continuous)
Power Measurement
range
Power Consumption1
V AC
PRNG
Isolation Voltage2
Opto-coupler Output
Current
Opto-coupler Input
Current
Min
Typ
180
230
90
115
-18400
Max
Unit
265
135
18400
V
V
W
800
mW
VIS
2500
V
IO
10
mA
II
10
mA
Condition
PM9603APE
PM9603APA
Specified
accuracy
VAC = 230V
Supply direct
from mains
Continuous
VOL = 1V
Note 1: Power consumption specifications exclude power consumed by the current
sensor.
Note 2: Isolation voltage may be specified, depending on customer requirements.
CONNECTION DESCRIPTION
Designation
MAINS
NEUTRAL IN
NEUTRAL OUT
SK1
25-Way female
(D-type)
Description
Voltage supply connection to Neutral line
Voltage supply connection to Live line
Connection to positive side of current sensor
Connection to negative side of current sensor
P1 Supply (+ve) to opto-couplers
P2 Input SA9603B - SCK
P8 Input SA9603B - DI
P9 Input SA9603B - CS
P12 Output SA9603B - DO
P18, 20-25 Common emitters and cathodes opto-couplers
sames
3/18
PM9603AP
FUNCTIONAL DESCRIPTION
1. Power Calculation
In the Application Circuit (see Figure 2), the output current from the current sensor
will be between 0 and 16µARMS (0 to 80A through a shunt resistor of 625µΩ). The
current input stage of the module, saturates at input currents greater than 18µA RMS.
The mains voltage (Voltage + 15% - 20%) is used to supply the circuitry with power.
A SA9603B utilize current information from the current sensor (shunt resistor),
together with the mains voltage to perform the power calculation.
The SA9603B integrated circuits may be adjusted to accommodate any voltage or
current values. The method for calculating external component values is described
in paragraph 6 (Circuit Description).
SAMES offers two evaluation module options, namely 230V/80A and 115V/80A.
The on chip registers are accessed via the isolated SPI bus.
2. Electrostatic Discharge (ESD) Protection
The device's inputs/outputs are protected against ESD according to the Mil-Std
883C, method 3015. The modules resistance to transients will be dependant upon
the protection components used.
3. Power Consumption
The overall power consumption rating for this power metering application (Figure 2),
is under 500mW, excluding the current sensor, when the supply is taken directly from
the mains.
4. Isolation
The reference of the module is connected to neutral.
5. Isolated Input/Output Interface
The isolated interface is provided to allow the user to access the registers of the
SA9603B.
A 25-Way D type connector (female) is provided on the PM9603AP module. The
connector SK1 connects via a one to one connected cable to a Personal Computer
parallel port.
6. Circuit Description
In the Application Circuits, (Figures 1), the components required for power metering
applications are shown.
In Figure 1, a shunt resistor is used for current sensing. In this application, the
circuitry requires a +2.5V, 0V, -2.5V DC supply.
4/18
sames
PM9603AP
The current sense input requires a differential approach to cater for precision across
the dynamic range. It is therefore important that the PC board layout of the branches
to the sensing element, are as symmetrical as possible and the loop area is kept to
a minimum.
The most important external components for the SA9603B integrated circuit are:
R2, R1 and RSH are the resistors defining the current level into the current sense input.
The values should be selected for an input current of 16µARMS into the SA9603B at
rated line current.
Values for RSH of less than 200µΩ should be avoided.
R1 = R2 = (IL/16µARMS) * RSH/2
Where IL
=
Line current
RSH =
Shunt resistor/termination resistor
R3, R6 and R4 set the current for the voltage sense input. The values should be
selected so that the input current into the voltage sense input (virtual ground) is set
to 14µARMS.
R7 defines all on-chip bias and reference currents. With R7 = 24kΩ, optimum
conditions are set.
XTAL is a colour burst TV crystal (f = 3.5795MHz) for the oscillator. The oscillator
frequency is divided down to 1.7897MHz on-chip and supplies the A/D converters
and the digital circuitry.
7. Demonstration Software
Software which runs under Windows 3.1 and Windows 95 is provided with each
evaluation module. See README.TXT on the diskette supplied for the installation
instructions.
8. Sample C source code
The following software demonstrates how to synchronize the reading of the registers
to the SA9603B's internal offset cancellation scheme. The software is also available
on the SAMES Internet web pages.
sames
5/18
6/18
sames
L
IN
DR -0 1350
R5
C1 1B
C1 1A
D1
D2
R3A
C1 3
C1 4
S H U NT
R9
ZD1
ZD2
R1 0
R1
C9
C1 0
R3B
R6
R2
OP TIO NA L
X TA L
C1 5
R7
R1A
C1 2
R4
LK2
R1 1
R1 3
R1 2
LK1
P M 960 3A P
SAMES
R1 8
R1 5
R1 6
R1 4
R1 7
1
14
13
25
N
IN
L
OU T
N
OU T
PM9603AP
Figure 1: Connection Diagram
PARALLEL PORT
S upply
Load
RSH
80A /50mV
sames
1N4148
D2
1N4148
D1
R5
470R/2W
+ C13
100u
+ C14
100u
680R
R10
680R
R9
180k
200k
C11
470n/250V
R3B
R3A
ZD2
2.4V
ZD1
2.4V
R2
C10
100n
C9
100n
1.6k
R7
24k
R1
1.6k
dr-01351
X TA L
OSCI
DI
DO
V SS
FMO
TP 16
DI
CS
IVP
GND
Ground Plane
820n
C15
3.579545MHz
S A9603B
TP 9
OSCO
10
V DD
9
8
TP 2
TE S T
6
TP 3
7
5
TP 4
V RE F
3
4
IIP
IIN
IC4
2
1
11
12
13
14
15
16
17
18
19
20
R4
1M
R6
24k
+ C12
1000uF
2.4k
R13
2.4k
R12
2.4k
R11
680R
R14
16
15
12
11
13
14
7
8
IC2A
IC2C
IC2B
IC2D
ILQ74
ILQ74
ILQ74
ILQ74
2
1
6
5
3
4
9
10
R20
680R
R17
680R
R16
680R
R18
680R
1
14
2
15
3
16
4
17
5
18
6
19
7
20
8
21
9
22
10
23
11
24
12
25
13
DB25
S K1
PM9603AP
APPLICATION CIRCUIT
Figure 2: Application using a Shunt Resistor for Current Sensing, having a
PC (Personal Computer) Interface.
7/18
PM9603AP
Parts List For Application Circuit: Figure 2
Item
Symbol
Description
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
IC-1
IC-2
D1
D2
ZD1
ZD2
XTAL
R1
R2
R3A
R3B
R4
R5
R6
R7
R9
R10
R11
R12
R13
R14
R15
R16
R17
R18
C9
C10
C11
C12
C13
C14
C15
RSH
SA9603B
Opto Coupler, ILQ74
Diode, Silicon, 1N4148
Diode, Silicon, 1N4148
Diode, Zener, 2.4V, 200mW
Diode, Zener, 2.4V, 200mW
Crystal, 3.5795MHz
Resistor, 1.6kΩ, 1%, metal
Resistor, 1.6kΩ, 1%, metal
Resistor, 1%, metal
Resistor, 1%, metal
Resistor, 1M, ¼W
Resistor, 470Ω, 2W, 5%, carbon
Resistor, 24k, ¼W, metal
Resistor, 24k, ¼W, metal
Resistor, 680Ω, ¼W, 5%
Resistor, 680Ω, ¼W, 5%
Resistor, 2.4k, ¼W, 5%
Resistor, 2.4k, ¼W, 5%
Resistor, 2.4k, ¼W, 5%
Resistor, 680R, ¼W, 5%
Resistor, 680R, ¼W, 5%
Resistor, 2.4k, ¼W, 5%
Resistor, 680R, ¼W, 5%
Resistor, 680R, ¼W, 5%
Capacitor, 100nF
Capacitor, 100nF
Capacitor, polyester
Capacitor, 1000µF, 16V
Capacitor, 100µF, 16V
Capacitor, 100µF, 16V
Capacitor, 820nF, 16V
Shunt Resistor, 80A, 50mV (625µΩ)
Detail
DIP-20
DIP-16
Colour burst TV
Note 1
Note 1
Note 2
Note 2
Note 2
Note 1
Note 1: Resistor (R1 and R2) values are dependant upon the selected value of RSH. See
paragraph 6 (Circuit Description) when selecting the value for RSH.
Note 2: See the table below, detailing the component values for the selected voltage standard.
8/18
sames
PM9603AP
Item
Symbol
12
13
31
R3A
R3B
C11
Description
PM9603APA
PM9603APE
115V
230V
120kΩ
200kΩ
82kΩ
180kΩ
1µF
0.47µF
Detail
ORDERING INFORMATION
Part Number
PM9603APA
PM9603APE
Description
115V, 80A Module
230V, 80A Module
sames
9/18
PM9603AP
// This program will read the registers from a SA9603B device
and
// display the content on the screen.
// The program work on a PM9603AP demonstration module.
#include <stdio.h>
#include <math.h>
#define
#define
PI
3.141593
win_size 20
// Definitions for the parallel port
#define CLK_b
0x20 //D5 on port pin 7
#define DO_b
0x40 //D6 on port pin 8
#define DI_b
0x20 //Paper out
pin 12
#define CS_b
0x80 //D7 on port pin 9
#define PCTrig
0x02 //D1 on port pin 3
//#define freq_bits
0x00FFFF
//#define inv_bits
0x0C0000
#define freq_bits
#define inv_bits
#define bits_50hz
// Mask
#define
#define
#define
#define
#define
0x01FFFF
0x0E0000
0x080000
// D16..D0
definitions for the parallele port
CLK_m
~CLK_b //D5 on port pin 7
DO_m
~DO_b //D6 on port pin 8
DI_m
~DI_b //Paper out
pin 12
CS_m
~CS_b //D7 on port pin 9
byte_mask
0x80 //1000 0000
#define CLOCKFREQ
#define LPT1
#define LPT2
3579545
0x378
0x278
// Glogal variables
unsigned char
portval;
double
arr_energy[win_size],arr_volt[win_size],arr_reactive[win_size];
long
delay_time;
10/18
sames
PM9603AP
int prt, buffindex = 0;
double convert_24bits(double value)
// This function will sort out the 24 bits of the register
values
{
if (fabs(value) > 0x7FFFFF)
{
if (value > 0)
value = (16777216-value) * (-1);
else
value = (16777216+value)* (1);
}
return(value);
}
void spi_wait(void)
// This function will wait for the specified period, very
short time
{
int ti;
for (ti = 1; ti < 1 ; ti++);
}
void spi_out(unsigned char value)
// Put value on the parallel port
{
int n;
portval = value;
outport(prt,(~portval));
// Remove the ~ if you dont use opto couplers
for(n=0 ; n< delay_time ; n++); // Specify the pulse
width
}
void spi_clock(void)
// This function will pulse CLK pin of spi port
{
spi_wait();
spi_out(portval | CLK_b); // or
spi_wait();
sames
11/18
PM9603AP
spi_out(portval ^ CLK_b);
}
// xor
void spi_PCTrig(void)
// This function will set the PC trigger pin
{
spi_out(portval & (~PCTrig)); // and
spi_wait();
}
void spi_ClearPCTrig(void)
// This function will clear the PC trigger pin
{
spi_out(portval | PCTrig); // or
}
void spi_cs(void)
// This function will set CSs pin of spi port
{
spi_out(portval | CS_b); // or
}
void spi_reset(void)
// all bits of the port are made 0
{
spi_out(portval & CLK_m);
spi_out(portval & DO_m);
spi_out(portval & CS_m);
}
void spi_start_read(unsigned char value)
// All bits of the port are made 0
{
int counter;
unsigned char and_mask,mask;
mask = 0x80;
value = (value | 0xC0 );
adress 110—
12/18
sames
// Put the header for the
PM9603AP
for ( counter = 0; counter <8; counter++)
{
and_mask = (mask & value);
if (and_mask == mask)
{
spi_out(portval | DO_b); // 1
spi_clock();
}
else
{
spi_out(portval & DO_m);
// 0
spi_clock();
}
value = value << 1;
}
spi_clock(); // sort out the extra clock cycle
between command & response
}
unsigned long spi_read_register(void)
// This function will read 24 bits of a register
// the register to be red would be indicated by the
// preceding spi_start_read function
{
int counter;
unsigned char and_mask,mask;
unsigned long fromport;
fromport = 0 ;
for ( counter = 0; counter < 24; counter++)
{
spi_clock();
if (((inportb(prt+1)) & DI_b) == DI_b)
fromport = fromport+ pow(2,(23-counter));
}
return(fromport);
}
sames
13/18
PM9603AP
/
***************************************************************************/
/*
*/
/*
Main Function.
*/
/*
*/
/
***************************************************************************/
void main (int argc,char *argv[])
{ FILE *out;
char
int
long
key;
double
port,del_time ;
act , react , volt , freq, old_freq,
act1, react1,volt1,prev_inv_bits;
k, active, reactive, voltage,fm,vm;
int first = 1;
fm = 0;
act=
0;
react= 0;
volt= 0;
freq = 0;
del_time = 0;
if (argc == 3 ) {
delay_time = atol(argv[2]);
prt = atol(argv[1]);
if(prt == 1) prt = LPT1;
else prt = LPT2;
} else {
printf(“\nusage : CHIP9603 <portnum> <SPI clock delay
lime>\n”);
printf(“
<portnum>
=
1 or 2 (lpt port
14/18
sames
PM9603AP
number)\n”);
printf(“
printf(“
exit(0);
}
<SPI clock delay lime> = For loop delay\n”);
use 1000 for a 486dx266
\n”);
clrscr();
while(key !=’q’)
{
if(bioskey(1)) {
key = bioskey(0);
}
old_freq = freq;
spi_reset();
spi_cs();
spi_start_read(3);
freq = spi_read_register();
// Get the rising edge if the inversion bits
if (((freq & bits_50hz) == bits_50hz )
//D19
is now set
&& ((old_freq & bits_50hz) != bits_50hz)) //D19
was not set previously
{
// The following is used to indicate that
//registers is read every 8th mains cycle
spi_PCTrig();
delay(1);
spi_ClearPCTrig();
//del_time is the amount of inversion cycles to
wait before
//reading the rest of the register values.
del_time ++;
}
if(del_time == 10)
integrate registers
{
// spi_PCTrig();
sames
// 5 x 8 mains cycles time to
15/18
PM9603AP
spi_reset();
spi_cs();
spi_start_read(0);
act
= spi_read_register();
react = spi_read_register();
volt = spi_read_register();
// Now calculate the incremental difference and take care of
register
// overflow as well as the sign of register values
active = convert_24bits(act - act1);
reactive = convert_24bits(react - react1);
voltage = convert_24bits(volt1 - volt);
k = (1/((double)(freq&freq_bits)*del_time)) * 80
* 230/(1.44*2);
fm = (double)((CLOCKFREQ/2)/((double)(freq &
freq_bits)));
vm = (double)voltage * ((14/17.5)*0.63)/
((double)(freq&freq_bits)*del_time) *230;
if (first == 0){
printf(“%08.2f
printf(“%08.2f
printf(“%08.2f
printf(“%08.4f
printf(“%5.2f
}
first = 0;
act1 = act;
react1= react;
volt1 = volt;
del_time = 0;
}
}//while
}
16/18
sames
\t”,active*k);
\t”,(reactive*k*PI/2));
\t”,vm);
\t”,fm);
\n”,(del_time*(8/fm)));
PM9603AP
Notes:
sames
17/18
PM9603AP
Disclaimer:
The information contained in this document is confidential and proprietary to South African MicroElectronic Systems (Pty) Ltd ("SAMES") and may not be copied or disclosed to a third party, in whole or in part,
without the express written consent of SAMES. The information contained herein is current as of the date of
publication; however, delivery of this document shall not under any circumstances create any implication that the
information contained herein is correct as of any time subsequent to such date. SAMES does not undertake to inform
any recipient of this document of any changes in the information contained herein, and SAMES expressly reserves
the right to make changes in such information, without notification,even if such changes would render information
contained herein inaccurate or incomplete. SAMES makes no representation or warranty that any circuit designed
by reference to the information contained herein, will function without errors and as intended by the designer.
Any Sales or technical questions may be posted to our e-mail address below:
[email protected]
For the latest updates on datasheets, please visit out web site:
http://www.sames.co.za
South African Micro-Electronic Systems (Pty) Ltd
P O Box 15888,
33 Eland Street,
Lynn East,
Koedoespoort Industrial Area,
0039
Pretoria,
Republic of South Africa,
Republic of South Africa
Tel:
Fax:
18/18
012 333-6021
012 333-8071
sames
Tel:
Fax:
Int +27 12 333-6021
Int +27 12 333-8071