Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem in reading Total Kwh(ApenergyT) in ATM90E32 #5

Open
RamyaDidde opened this issue Feb 28, 2024 · 3 comments
Open

Problem in reading Total Kwh(ApenergyT) in ATM90E32 #5

RamyaDidde opened this issue Feb 28, 2024 · 3 comments

Comments

@RamyaDidde
Copy link

RamyaDidde commented Feb 28, 2024

Each phase Kwh is matching with my Reference energy meter. Total Kwh is not matching. I am reading ApenergyT for Kwh.

@CircuitSetup Please respond. With Out responding please don't close the issues as completed

ATM90E32_SPI.zip

@AbrahamAV97
Copy link

Hey there!

I've been banging my head against this issue for months—tons of manual measurements, endless testing with different codes and devices, and I finally nailed down the problem.

It comes down to two key factors:

  1. Bug in the ATM90E32.cpp library
    There's a mistake in the GetImportEnergy() function that's messing up the imported energy readings:
double ATM90E32::GetImportEnergy() {
  unsigned short ienergyT = CommEnergyIC(READ, APenergyT, 0xFFFF);
  return (double)ienergyT / 100 / 3200; //returns kWh
}

That 100? Yeah, it’s actually supposed to be 10.

  1. Import Energy register overflow
    The import energy register overflows at 0.2 kWh, so if you’re reading it less frequently than you should, you're straight-up losing data due to overflow.

Hope this helps anyone else struggling with the same headache!

@CircuitSetup
Copy link
Owner

@AbrahamAV97, thanks for bringing this up. I'm sorry you've spent so much time on it.

  1. I looked at this again and I'm not seeing how it could be ienergyT / 10 / 3200. The resolution is 0.01CF, which means APenergyT increments 100 times for every 1CF or Meter Constant (3200).
    This can also be written as:
    APenergyT / (100 * 3200) = kWh

  2. This is correct since APenergyT is a 16 bit register, and the max is 65535 / 100 / 3200 = 0.2 kWh

@AbrahamAV97
Copy link

Hi again!

I've always trusted math, but I trust my own eyes even more.

Let me share an experiment I did: with a constant consumption of 2200 watts, my calculations showed that the imported power per 5-second reading should be 0.003 kWh. However, after much observation, I discovered that the value I was getting wasn't 0.003, but 0.0003—and it wasn't just a coincidence.

By taking more frequent readings to avoid the overflow issue I explained earlier, I noticed that the register was reading values ten times lower than it should.

So, when I changed the division factor from 100 to 10, I got the correct values that matched what my SDM630 and my current clamp were measuring. (Although you're probably right that it doesn’t make sense mathematically.)

That said, my intention is not to criticize or cast doubt on the library—please don't misunderstand me! In fact, I'm very grateful for it. It's been incredibly helpful, and I just wanted to share my solution to save anyone else from the headache if they run into the same issue in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants