Skip to content

Example 08 zero calibration does not affect displayed Amps value #5

Description

@NGL3324
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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions