Pulses to KWh conversion in Energy meter
Hi,
I am working with STM32G491RE.I communicating ATM90E26 single phase energy meter with STM32 through SPI communication.
I can able to read voltage ,current values correctly from the meter.
For KWH calculation, I am reading Absolute active energy register for kwh values. In the datasheet they mentioned the values I receive from the energy register are pulses.
how can I convert pulses to kwh. can anyone suggest?
my pulse constant value is 1000 imp/kwh.

From the datasheet they mentioned register will be cleared after read.
For that I am following below process
uint16_t Em_kwh=0;
uint16_t Em_kwhcharging=0;
uint8_t kwh_power[2]={0x00,0x00,0x00};
Em_kwh=GetAbsoluteActiveEnergy(); //to read the register its working properly
Em_kwhcharging=Em_kwhcharging+Em_kwh;
// I am converting above decimal value in to hex values
void ConvertDecimalToHex(int decimalValue, uint8_t* res) {
res[0] = (uint8_t)((decimalValue >> & 0xFF); // High byte
res[1] = (uint8_t)(decimalValue & 0xFF); // Low byte
}
ConvertDecimalToHex(Em_kwhcharging,kwh_power);
I am sending the hex value to other mcu using uart.
Is above way of handling the reset of register is correct. Can anyone suggest.
Is there any possibility Em_kwhcharging overflows. Is it better to take Em_kwhcharging as uint32_t.
Please suggest
Thanks

