In this tutorial, we will see how to calibrate STPM32/33. STPM32 is an ASSP (Application Specific Standard Product) for metering applications. It is designed for measurement of power and energies in a power line with high accuracy. It provides instantaneous voltage and currents, active, reactive and apparent powers, and energies. Lets start with how to Calibrate STPM32/33 For Digital Smart Energy Meter.

Contents

- 1 Introduction To Energy Calibration
- 1.1 Why Calibration is Required
- 1.2 Standard Meter Calibration Process
- 1.3 Smart meter Tests
- 1.4 STPM32/33 Calibration
- 1.5 Step 1. Reading RMS voltage and current values for no of samples time.
- 1.6 2.Calculating average voltage and average current values for number of samples.
- 1.7 3.Calculating target values for voltage and current using nominal voltage and current values.
- 1.8 4.Calculating voltage and current calibrator values using average and target voltage and current values.
- 1.9 5.Writing voltage calibrator values to DSP control register .
- 1.10 Share this:
- 1.11 Like this:
- 1.12 Related

## Introduction To Energy Calibration

Calibration is the process of comparing reading on one piece of equipment or system, with another piece of equipment. The other piece of equipment that has been calibrated and referenced to a known set of parameters. After the design phase, any tolerance of the real components from these values or device internal parameter drift can be compensated through calibration.

### Why Calibration is Required

Electricity meters are calibrated in billing units, the most commonly used KiloWatt hour (kWh). Periodic readings of energy meters establish billing cycle. There are mainly three types of meters available in market,

**Electromechanical Meters** – most commonly used meter, also called induction watt hour meter. It counts revolutions of non-magnetic but electrically conductive metal disc. This disc rotates at a speed proportional to power passing through meter.

**Electronic Meter** – These meters make use of analog measurement IC, specially designed to measure energy usage.

**Smart Meter** – Difference between electronic meter and smart meter is, smart meter has two way communication with utility supplier ie periodically it sends meter data to central system.

So, calibration is very important because these meters are only source to measure power consumption and generate revenue. Apart from this to satisfy the consumer about correctness of reading and accuracy of meters.

### Standard Meter Calibration Process

A known amount of energy is supplied to reference meter and to the UUT – unit under test. The reading from reference meter is then compared with UUT and error is calculated.

This is standard calibration process once your smart meter is ready, there are NABL Accredited labs for doing this testing. As it requires special setup with CMRI – common meter reading instrument along with software. In India, NABL – National Accreditation Board for Testing and Calibration Laboratories makes guidelines for getting your smart meter calibration certificate. The cost of it varies based on type of meter you are testing. For smart meters, certification cost is high comparted to other types of meters.

### Smart meter Tests

There are various types of tests needs to be performed

scanner test

100% imax UPX test

5% to 100% Ibasic UPX test

100% ibasic lead and lag test

Voltage failure

current failure

magnet tampering

mobile tamper test

### STPM32/33 Calibration

In this post we will discuss about how to calibrate metering IC while building your smart meter IoT application.

Any energy measure performed by the device (active wideband and active fundamental, reactive or apparent power and energy) is calculated digitally (without error) from current and voltage signals. This means that every measure is automatically calibrated if current and voltage channels are calibrated.

Design the application as stated in Section 3: “System calibration” in stpm32 datasheet ,for our STPM32 board, designed parameters are:

Reference voltage in v V_REF = 1.2 Voltage divider resistor 1 R1 = 810000 Ohm //user manual Voltage divider resistor 2 R2 = 470Ohm //user manual Voltage calibrator CALIB_V = 0.875 //STPM datasheet Voltage gain AV = 2 //calibration process doc Current calibrator CALIB_I = 0.875 //STPM datasheet Current gain AI = 16 //calibration process doc Current sensor Sensitivity KS = 0.3mV/A //user manual Integrator gain KINT = 1 //calibration process doc Sampling freq DCLK = 7812.5 //calibration process doc

**Step 1. Reading RMS voltage and current values for no of samples time.**

After applying voltage VN and current IN to the meter, a certain number of voltage and current RMS samples must be read and averaged(averaged values for voltage and current will be stored in Vav and Iav respectively). To find V_{av} and I_{av} do following steps:

maxSampleCount is the maximum number of samples to take for calibration. We are taking 20 samples for average values of RMS voltage and RMS current i.e. reading voltage and current value for each second . In datasheet it is given that “RMS updated values are available in DSP_REG14 and DSP_REG15 registers every 128 μs.” We will read voltage and current values using method given in another blog. Please refer “Measuring voltage, current, energy and power from STPM32/33”.

Read RMS voltage and RMS current.** Here note that we have to read raw voltage and current register values, no need to multiply it by LSB value.**

Add RMS voltage to one variable till maxSampleCount is not reached. Add RMS current to one variable till maxSampleCount is not reached.

### 2.Calculating average voltage and average current values for number of samples.

Once maxSampleCount is reached, calculate average of voltage and current value.

`vAverage = getVavg(device_index, channel); iAverage = getIavg(device_index, channel);`

### 3.Calculating target values for voltage and current using nominal voltage and current values.

The target values of voltage and current RMS registers, XV and XIrespectively are calculated as follows:

XV = (V_NOMINAL/VLSB_RMS)

where, VLSB_RMS = (V_REF*(1+(R1/R2)))/(CALIB_V*AV*32768) calculate from above parameters.

XI = (I_NOMINAL/ILSB_RMS)

where, ILSB_RMS = (V_REF)/(CALIB_I*AI*131072*KS*KINT) calculate from above parameters.

### 4.Calculating voltage and current calibrator values using average and target voltage and current values.

CHV is voltage calibrator value , CHC is current calibrator value calculated using formulae as:

```
CHV = (CALIB_MULTIPLY_FACTOR*vTarget)/vAverage)-CALIB_SUBTRACT_FACTOR
CHC = (CALIB_MULTIPLY_FACTOR*iTarget)/iAverage)-CALIB_SUBTRACT_FACTOR
where,
CALIB_MULTIPLY_FACTOR = 14336
CALIB_SUBTRACT_FACTOR = 12288
```

### 5.Writing voltage calibrator values to DSP control register .

For writing voltage calibrator value of channel 1, we have to write bits[11:0] in DSP control register 5(DSP_CR5).For writing voltage calibrator value of channel 2, we have to write bits[11:0] in DSP control register 7(DSP_CR7).

```
#define PRIMARY_V_CALIB_REG 0x08
#define SECONDARY_V_CALIB_REG 0x0C
/*We have to write [11:0]12 bits Calibrator value to register. Take calibrator value as 16 bit value.*/
/*Split CHV into data1 and data2*/
uint16_t CHV_Integer = (uint16_t)CHV;
/*Split CHV value into two 8 bit values for writing using SPI communication. Data1 as LSB and data2 as MSB value.*/
uint8_t data1 ,data2 =0;
data1 =((CHV_Integer)&(0x00FF));
data2 =((CHV_Integer>>8)&(0x000F));
/*Corresponding to channel no, call measure_writeRegister function with LSB and RSB data.*/
if(channel == CHANNEL_1)
{
measure_writeRegister(PRIMARY_V_CALIB_REG,device_index,data1,data2);
delay_us(5);
}
else if(channel == CHANNEL_2)
{
measure_writeRegister(SECONDARY_V_CALIB_REG,device_index,data1,data2);
delay_us(5);
}
where, data1 is LSB and data2 is MSB.
```

**Writing current calibrator values to DSP control register .**

For writing current calibrator value of channel 1, we have to write bits[11:0] in DSP control register 6(DSP_CR6).For writing current calibrator value of channel 2, we have to write bits[11:0] in DSP control register 8(DSP_CR8).

```
V_NOMINAL#define PRIMARY_I_CALIB_REG 0x0A
#define SECONDARY_I_CALIB_REG 0x0E
We have to write 12 bits Calibrator value to register. Take calibrator value as 16 bit value.
uint16_t CHC_Integer = (uint16_t)CHC;
Split CHV value into two 8 bit values for writing using SPI communication. Data1 as LSB and data2 as MSB value.
uint8_t data1 ,data2 =0;
data1 =((CHC_Integer)&(0x00FF));
data2 =((CHC_Integer>>8)&(0x000F));
/*Corresponding to channel no, call measure_writeRegister function with LSB and MSB data*/
if(channel == CHANNEL_1)
{
measure_writeRegister(PRIMARY_I_CALIB_REG ,device_index,data1,data2);
delay_us(5);
}
else if(channel == CHANNEL_2)
{
measure_writeRegister(SECONDARY_I_CALIB_REG,device_index,data1,data2);
delay_us(5);
}
where, data1 is LSB and data2 is MSB.
```

We are writing these Voltage and current calibrator values to storage and then for each time on controller reset, Get the values from storage and writing these values to calibrator registers. Hope you have enjoyed reading on how to Calibrate STPM32/33 For Digital Smart Energy Meter.

Build your future ready smart meter application with our ready to use IoT platform, mobile application. Why to pay for DLMS if you can make use our IoT cloud along with IoT security.