- Apply a known AC reference signal and compare the library output to the known
value.
- Adjust ADC_VOLTAGE_GAIN and ADC_CURRENT_GAIN in the adc_config.h
file using:
- gain_new = gain_old × (measured_reading / known_reference)
- For example, if the library reports 118.2V RMS against a known 120.0V reference:
gain_new = 2056.8 × (120.0 / 118.2) = 2087.1
- Repeat for current using ADC_CURRENT_GAIN. The ADC_readNormalized()
function applies these gains as:
- normalized = (raw_count - dc_offset) / gain
- The resulting normalized value is a per-unit float in the same range as the debug
signal generator output, which the metrology engine then scales by VscaleFactor /
IscaleFactor (from template.h) to produce physical units.
Phase Correction (for current
transformer phase shift):
Current transformers and analog filter
stages introduce a small but measurable phase shift between the voltage and current channels
that directly affect power factor and power accuracy. This is corrected by the
phaseOffset field in currentSensorCalibrationData
(metrology_nv_structs.h).
The default phase correction values
are defined in metrology_calibration_defaults.h:
- DEFAULT_BASE_PHASE_A_CORRECTION – Phase correction for phase A in units of:
Microseconds × SAMPLE_RATE × 256. Default: 0.0 (appropriate for DEBUG mode and
appropriate sensors). For a real CT with a 2.4 microsecond lag, this is: –2.4e-6 × 8000 ×
256.
Acceptable range is approximately –125
microseconds to +125 microseconds. Measure the actual phase error using a precision power
analyzer at unity power factor and set the correction accordingly.