sparkfun / sparkfun/SparkFun_ADE7953_Arduino_Library

Example 08 zero calibration does not affect displayed Amps value

Open Beginner friendly
#5 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C++
Stars
1
Forks
0
Avg merge
1m
Merged PRs (30d)
1

Description

uint32_t corrected =
    (rawIrms > zeroOffset) ? (rawIrms - zeroOffset) : 0;

In Example 08 (`Example08_DiagnosticTool`), the `z` command calculates a local
`zeroOffset` from raw IRMS readings. That offset is applied to the displayed
`Corrected` and `Averaged` raw values as above.

However, the displayed current in amps is obtained independently using:

mySensor.getCurrentA(amps);

Consequently, zero calibration does not affect the Amps field. For example,
after zeroing, Corrected may be near zero while Amps continues to show the
original no-load value.

Also, linear subtraction of two RMS magnitudes is not generally the correct
noise-floor correction. The library already provides autoCalibrateA(), which
performs the correction in the squared/RMS domain.

Would you consider changing the z command to use the library calibration?

For example:
void doZeroCalibration()
{
    const uint16_t NUM_SAMPLES = 50;

    Serial.println(
        F("\nZero calibration - keep the CT connected with no current flowing."));

    if (mySensor.autoCalibrateA(NUM_SAMPLES) != ksfTkErrOk)
    {
        Serial.println(F("Zero calibration failed!"));
        return;
    }

    resetBuffer();
    Serial.println(F("Channel A zero calibration complete.\n"));
}

The r command could correspondingly call:

mySensor.clearCalibration();

This would make the zero operation affect getCurrentA(amps) directly and
would avoid having two independent calibration paths in the example.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Example08_DiagnosticTool at doZeroCalibration and the z/r command handlers; compare the local zeroOffset path with mySensor.getCurrentA(amps). Verify the library calibration APIs are used consistently and that after zeroing or resetting, the displayed Amps and raw fields reflect the calibration.

Written by the indexing model from the issue text.

Assessment

Tech stack
arduino, cpp
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.