cancel
Showing results for 
Search instead for 
Did you mean: 

STPM34 - PH1 Active Energy register(Address 54)

APK.1
Associate II

Please advise on the below issue in STPM32 Active Energy Register.

  • Project details -Single Phase Smart Meter. Input voltage - 240VAC and Current - 60A max.Interface - Wifi.

  • Issue - PH1 Active Energy register(Address 54) of STPM34 is overflow once the Energy reach also most 230W and going to the negative side. Agin increases up to 230W. This is repairing like a sine wave.

All other parameters are reading correctly. Voltage, Current, Frequent, PF, and Active Power. 

  • Also, Tap the TX, RX connection from the Meter and connect a computer using USB to TTL converter, Use " STPM3x evaluation software" and read the values from the Meter. The software also shown the same Active Energy overflowing issue once reach 300W. 

  • Design details-

Voltage resistor divider - 470E and 270K X 4. 

CT - 1:2500 ration Class 0.5,

STPM interface to the controller through the UART interface. An additional signal is "EN".

Attached the Schematic of the STPM34 section. 

The load connected - 3200W resistive load, 

  • Code details- Take this section from the sample code.

int32_t PH1_REG1=0;

SEND_DATA_TO_STPM34(0x58,0xFF,0xFFFF);

memcpy(&PH1_REG1,U2_STPM34_RX,4);

buffer1 = PH1_REG1;

DATA.ACTIVE_ENERGY1=ENERGY_CALCULATION(PH1_REG1,ACTIVE);

------------------------------------------------

int32_t ENERGY_CALCULATION(uint32_t raw_nrj,TYPE_ENERGY type)

{

int64_t calc_nrj = 0;

/* manage the 2 U32 to have enougth place to save energy cumulated */

/* Make sure between two reads inside hardware registers if we have to add carry inside ext U32 */

if (((uint32_t)energy[type]>0xA0000000) && ((uint32_t)raw_nrj<0x60000000))

{

energy_extension[type]++;

}

if (((uint32_t)energy[type]<0x60000000) && ((uint32_t)raw_nrj>0xA0000000))

{

energy_extension[type]--;

}

/* save the new result cumulated come from register inside internal structure */

energy[type] = raw_nrj;

/* calculate the nrj value and add the 32 bits extension */

calc_nrj = (uint64_t)raw_nrj + ((int64_t)energy_extension[type] << 32);

calc_nrj *= (int64_t)35145;

/* multiply by 10 to have in milli- */

calc_nrj *= 10;

/* Put the result in 32 bits format */

calc_nrj >>= 32;

/* return the nrj value */

return((int32_t)calc_nrj);

}

3 REPLIES 3
PJani.5
Associate

Hi Aneesh, I am facing same issue. Can you please help.

Energy values overflow after 230W.

Mobile - 8888883467

APK.1
Associate II

hi, did u got the solution,

Hi... No still looking for solution... What about you ?