18 how register data is stored, How register data is stored – Maxim Integrated 71M6534 Energy Meter IC Family Software User Manual

Page 82

Advertising
background image

71M653X Software User’s Guide

Get Wh (w0sum) and VARh (var0sum) from CE:

va0sum = sqrt(w0sum

2

+ var0sum

2

)

endif

Repeat for elements B and C

va0sum,.. va2sum, w0sum,.. w2sum, var0sum,.. var2sum are now available.

Figure current, the best available way:

If Irms_A < noise-floor of current measurement && Vrms_A > 0

Irms_A = va0sum/Vrms_A

Repeat for elements B and C

Do the creep calculation:

If (Vrms_A < Vthreshold)

creep mode, set element A’s voltage, current and watts to zero

else

if (Irms_A < Ithreshold)

creep mode: set element A’s current and watts to zero

Repeat for element B and C

Set the pulse outputs.

Sum positive values to normal registers, negative values to export registers.

5.14.1.18 How Register Data is Stored

The registers cannot just be kept as a floating point number. When floating point numbers are added, the mantissa of
the smaller number has to be shifted to the right, losing precision, so that it can be added to the mantissa of the larger.
In less than an hour, a meter implemented with 32-bit floating point arithmetic begins losing billing revenue because of
underflow.

In the Teridian implementation, a variable wh_cnt contains the number of CE counts per Wh.

The registers are stored as a 32-bit count of Wh, and a 32-bit remainder in CE counts. The math adds the new CE
value to the fractional part, and then transfers even Whs to the Wh count. To do that, it divides the fraction by wh_cnt
to get the new Wh to add to the count of Wh. Then, it multiples the number of Wh by wh_cnt to get the number of CE
counts to subtract from the fractional CE count. This logic is in normalize8() inUtil\math.c.

This scheme has no underflow. It has a tiny, controlled round-off of ½ of a CE LSB per Wh, which the CE calibration
arranges to average to zero. Otherwise, all the fractional data is preserved. The overflow is perfectly controlled, and
is made to wrap around to zero at a decimal limit.

The register logic is applied so that the registers only increase. Negative values of watt hours are subtracted from an
“export” register.

wh_cnt

does not usually change; in a real meter, this would be a constant, not a variable. However, in TSC’s demo

meter, the Imax and Vmax (see glossary) are variables, and therefore so must the CE counts per Wh. So, wh_cnt is
recalculated on each accumulation interval by the routine wh_cnt_set(), defined in Util\math.c.

Unlike earlier demo code versions, this register math is easy to modify to use realistic units. The WH_RESOLUTION (in
Util\mmath.h) is already realistic number, 1.0 (Wh), with a UNITS_RANGE limit of a billion (1x10

9

) Wh.

The display routines (in Meter\wh.c) can divide the registers by 1000 in order to display KWh. This is controlled by a
compilation flag, DISPLAY_KWH, which also changes the decimal points and labels for the LCD.

The registers cannot be kept only in RAM. If there is a power failure, they would be lost. The logical scheme is to write
them to the EEPROM once each accumulation interval. The problem is that the EEPROM has only 1 million writes,
and these would be used up in a few years. So, the revenue registers are kept in a special block of memory, the C
structure Totals.Acc. This data is saved only when there is a power failure.

v1.1v1.1

TERIDIAN Proprietary

82 of 116

© Copyright 2005-2008 TERIDIAN Semiconductor Corporation

Advertising
This manual is related to the following products: