SparkFun Qwiic Current Sensor - ADE7953  v1.0.0-3-g9a02684
Arduino Library for the SparkFun Qwiic Current Sensor (ADE7953)
Loading...
Searching...
No Matches
sfDevADE7953 Class Reference

Platform-independent driver for the ADE7953 energy metering IC. More...

#include <sfDevADE7953.h>

Inheritance diagram for sfDevADE7953:
SfeADE7953ArdI2C

Public Member Functions

 sfDevADE7953 ()
 
sfTkError_t begin (sfTkIBus *theBus=nullptr)
 Initialize the device driver with the given bus. More...
 
bool isConnected (void)
 Check whether the ADE7953 is connected and responding. More...
 
sfTkError_t getVersion (uint8_t &version)
 Read the silicon version number from the Version register (0x702). More...
 
sfTkError_t reset (void)
 Perform a software reset and re-apply the datasheet performance configuration. More...
 
sfTkError_t setWriteProtect (uint8_t protect)
 Set write protection bits. More...
 
sfTkError_t getWriteProtect (uint8_t &protect)
 Get the current write protection setting. More...
 
sfTkError_t setGainIA (sfe_ade7953_pga_gain_t gain)
 Set the PGA gain for Current Channel A. More...
 
sfTkError_t getGainIA (sfe_ade7953_pga_gain_t &gain)
 Get the PGA gain for Current Channel A. More...
 
sfTkError_t setGainIB (sfe_ade7953_pga_gain_t gain)
 Set the PGA gain for Current Channel B. More...
 
sfTkError_t getGainIB (sfe_ade7953_pga_gain_t &gain)
 Get the PGA gain for Current Channel B. More...
 
sfTkError_t setGainV (sfe_ade7953_pga_gain_t gain)
 Set the PGA gain for the voltage channel. More...
 
sfTkError_t getGainV (sfe_ade7953_pga_gain_t &gain)
 Get the PGA gain for the voltage channel. More...
 
sfTkError_t setDigitalGainIA (uint32_t gain)
 Set the digital (fine) gain for Current Channel A using a raw register value. More...
 
sfTkError_t setDigitalGainIA (float multiplier)
 Set the digital (fine) gain for Current Channel A using a floating-point multiplier. More...
 
sfTkError_t getDigitalGainIA (uint32_t &gain)
 Get the digital gain for Current Channel A as a raw register value. More...
 
sfTkError_t getDigitalGainIA (float &multiplier)
 Get the digital gain for Current Channel A as a floating-point multiplier. More...
 
sfTkError_t setDigitalGainIB (uint32_t gain)
 Set the digital (fine) gain for Current Channel B using a raw register value. More...
 
sfTkError_t setDigitalGainIB (float multiplier)
 Set the digital (fine) gain for Current Channel B using a floating-point multiplier. More...
 
sfTkError_t getDigitalGainIB (uint32_t &gain)
 Get the digital gain for Current Channel B as a raw register value. More...
 
sfTkError_t getDigitalGainIB (float &multiplier)
 Get the digital gain for Current Channel B as a floating-point multiplier. More...
 
sfTkError_t getIRMSA (uint32_t &value)
 Read the raw IRMS value for Current Channel A. More...
 
sfTkError_t getIRMSB (uint32_t &value)
 Read the raw IRMS value for Current Channel B. More...
 
sfTkError_t getCurrentA (float &amps)
 Read the RMS current on Channel A converted to amps. More...
 
sfTkError_t getCurrentB (float &amps)
 Read the RMS current on Channel B converted to amps. More...
 
sfTkError_t getInstantaneousIA (int32_t &value)
 Read the instantaneous current sample for Channel A. More...
 
sfTkError_t getInstantaneousIB (int32_t &value)
 Read the instantaneous current sample for Channel B. More...
 
sfTkError_t setCurrentClamp (sfe_ade7953_clamp_t clamp)
 Select a known current clamp and apply its turns ratio and PGA gain to both channels. More...
 
sfTkError_t setCurrentClampA (sfe_ade7953_clamp_t clamp)
 Select a known current clamp for Channel A and apply its turns ratio and PGA gain. More...
 
sfTkError_t setCurrentClampB (sfe_ade7953_clamp_t clamp)
 Select a known current clamp for Channel B and apply its turns ratio and PGA gain. More...
 
void setCurrentClamp (float turnsRatio)
 Configure a custom current clamp on both channels by its turns ratio. More...
 
void setCurrentClampA (float turnsRatio)
 Configure a custom current clamp on Channel A by its turns ratio. More...
 
void setCurrentClampB (float turnsRatio)
 Configure a custom current clamp on Channel B by its turns ratio. More...
 
void setCurrentTransformerRatio (float ratio)
 Set the CT (current transformer) turns ratio used by getCurrentA() and getCurrentB(). More...
 
void setCurrentTransformerRatioA (float ratio)
 Set the CT turns ratio used by getCurrentA() for Channel A. More...
 
void setCurrentTransformerRatioB (float ratio)
 Set the CT turns ratio used by getCurrentB() for Channel B. More...
 
float getCurrentTransformerRatio (void)
 Get the configured CT turns ratio for Channel A. More...
 
float getCurrentTransformerRatioA (void)
 Get the configured CT turns ratio for Channel A. More...
 
float getCurrentTransformerRatioB (void)
 Get the configured CT turns ratio for Channel B. More...
 
void setBurdenResistor (float ohms)
 Set the burden resistor value (in ohms) used by getCurrentA() / getCurrentB(). More...
 
float getBurdenResistor (void)
 Get the configured burden resistor value. More...
 
sfTkError_t autoCalibrateA (uint16_t numSamples=50)
 Auto-calibrate the Channel A no-load baseline by averaging samples. More...
 
sfTkError_t autoCalibrateB (uint16_t numSamples=50)
 Auto-calibrate the Channel B no-load baseline by averaging samples. More...
 
void clearCalibration (void)
 Clear the software no-load baseline for both channels (set by autoCalibrate). More...
 
sfTkError_t getPeakIA (uint32_t &value)
 Read the peak current value for Channel A. More...
 
sfTkError_t getPeakIB (uint32_t &value)
 Read the peak current value for Channel B. More...
 
sfTkError_t readAndResetPeakIA (uint32_t &value)
 Read the peak current value for Channel A and clear it. More...
 
sfTkError_t readAndResetPeakIB (uint32_t &value)
 Read the peak current value for Channel B and clear it. More...
 
sfTkError_t setOvercurrentLevel (uint32_t level)
 Set the overcurrent detection threshold. More...
 
sfTkError_t getOvercurrentLevel (uint32_t &level)
 Get the overcurrent detection threshold. More...
 
sfTkError_t setIRMSOffsetA (int32_t offset)
 Set the IRMS offset for Current Channel A. More...
 
sfTkError_t getIRMSOffsetA (int32_t &offset)
 Get the IRMS offset for Current Channel A. More...
 
sfTkError_t setIRMSOffsetB (int32_t offset)
 Set the IRMS offset for Current Channel B. More...
 
sfTkError_t getIRMSOffsetB (int32_t &offset)
 Get the IRMS offset for Current Channel B. More...
 
sfTkError_t setZXISourceChannel (bool useChannelB)
 Select which current channel drives the ZX_I output. More...
 
sfTkError_t getZXISourceChannel (bool &useChannelB)
 Get which current channel drives the ZX_I output. More...
 
sfTkError_t setZXEdge (sfe_ade7953_zx_edge_t edge)
 Set the zero-crossing edge selection for interrupt generation. More...
 
sfTkError_t getZXEdge (sfe_ade7953_zx_edge_t &edge)
 Get the current zero-crossing edge selection. More...
 
sfTkError_t enableZXLPF (bool enable)
 Enable or disable the zero-crossing low-pass filter. More...
 
sfTkError_t enableHPF (bool enable)
 Enable or disable the high-pass filter on all channels. More...
 
sfTkError_t isHPFEnabled (bool &enabled)
 Check whether the high-pass filter is currently enabled. More...
 
sfTkError_t getPeriod (uint16_t &period)
 Read the line period derived from zero-crossing detection. More...
 
sfTkError_t setInterruptEnableA (sfe_ade7953_irq_reg_t mask)
 Set the interrupt enable mask for Channel A (and voltage). More...
 
sfTkError_t getInterruptEnableA (sfe_ade7953_irq_reg_t &mask)
 Get the interrupt enable mask for Channel A. More...
 
sfTkError_t getInterruptStatusA (sfe_ade7953_irq_reg_t &status)
 Read the interrupt status for Channel A (non-destructive). More...
 
sfTkError_t readAndResetInterruptStatusA (sfe_ade7953_irq_reg_t &status)
 Read the interrupt status for Channel A and clear it. More...
 
sfTkError_t setInterruptEnableB (sfe_ade7953_irq_reg_t mask)
 Set the interrupt enable mask for Channel B. More...
 
sfTkError_t getInterruptEnableB (sfe_ade7953_irq_reg_t &mask)
 Get the interrupt enable mask for Channel B. More...
 
sfTkError_t getInterruptStatusB (sfe_ade7953_irq_reg_t &status)
 Read the interrupt status for Channel B (non-destructive). More...
 
sfTkError_t readAndResetInterruptStatusB (sfe_ade7953_irq_reg_t &status)
 Read the interrupt status for Channel B and clear it. More...
 
sfTkError_t setNoLoadDisable (sfe_ade7953_disnoload_reg_t mask)
 Set the no-load detection disable register. More...
 
sfTkError_t getNoLoadDisable (sfe_ade7953_disnoload_reg_t &mask)
 Get the no-load detection disable register. More...
 
sfTkError_t setLineCycleMode (sfe_ade7953_lcycmode_reg_t mode)
 Set the line cycle accumulation mode register. More...
 
sfTkError_t getLineCycleMode (sfe_ade7953_lcycmode_reg_t &mode)
 Get the line cycle accumulation mode register. More...
 
sfTkError_t setLineCycleCount (uint16_t halfCycles)
 Set the number of half line cycles for line cycle accumulation. More...
 
sfTkError_t getLineCycleCount (uint16_t &halfCycles)
 Get the number of half line cycles for line cycle accumulation. More...
 
sfTkError_t setSagCycles (uint8_t cycles)
 Set the number of sag line cycles. More...
 
sfTkError_t getSagCycles (uint8_t &cycles)
 Get the number of sag line cycles. More...
 
sfTkError_t setSagLevel (uint32_t level)
 Set the sag voltage level threshold. More...
 
sfTkError_t getSagLevel (uint32_t &level)
 Get the sag voltage level threshold. More...
 
sfTkError_t getLastOperation (uint8_t &op)
 Get the type of the last successful communication. More...
 
sfTkError_t getLastAddress (uint16_t &address)
 Get the address of the last successful communication. More...
 
sfTkError_t getLastData8 (uint8_t &data)
 Get the data from the last successful 8-bit register communication. More...
 
sfTkError_t getLastData16 (uint16_t &data)
 Get the data from the last successful 16-bit register communication. More...
 
sfTkError_t getLastData32 (uint32_t &data)
 Get the data from the last successful 24/32-bit register communication. More...
 

Protected Member Functions

sfTkError_t applyDefaultConfig (void)
 Apply the datasheet unlock + optimize sequence and default configuration. More...
 

Static Protected Member Functions

static float pgaGainToMultiplier (sfe_ade7953_pga_gain_t gain)
 Convert a PGA gain enum value to its numeric multiplier (1, 2, 4, 8, 16, 22). More...
 
static void clampPreset (sfe_ade7953_clamp_t clamp, float &ratio, sfe_ade7953_pga_gain_t &gain)
 Look up the turns ratio and PGA gain for a known current clamp preset. More...
 
static float removeBaseline (uint32_t reading, uint32_t baseline)
 Remove a no-load baseline from a raw RMS reading in the squared domain. More...
 

Protected Attributes

sfTkIBus * _theBus
 Pointer to the communication bus device. More...
 
float _ctRatioA = 2000.0f
 Channel A CT turns ratio (30A:15mA = 2000:1). More...
 
float _ctRatioB = 2000.0f
 Channel B CT turns ratio (30A:15mA = 2000:1). More...
 
float _burdenResistor = 5.6f
 Burden resistor in ohms. More...
 
float _fullScaleCode = 5928256.0f
 ADE7953 full-scale IRMS code. More...
 
float _fullScaleVRMS = 0.35355f
 Full-scale input RMS voltage (0.5 V peak / sqrt(2)). More...
 
uint32_t _baselineA = 0
 Channel A no-load IRMS baseline (raw counts). More...
 
uint32_t _baselineB = 0
 Channel B no-load IRMS baseline (raw counts). More...
 

Static Protected Attributes

static const uint8_t kI2CAddress = 0x38
 7-bit I2C address for the ADE7953 (only address). More...
 
static const uint16_t kRegSagCyc = 0x000
 Sag line cycles. More...
 
static const uint16_t kRegDisNoLoad = 0x001
 No-load detection disable. More...
 
static const uint16_t kRegLCycMode = 0x004
 Line cycle accumulation mode config. More...
 
static const uint16_t kRegPgaV = 0x007
 Voltage channel PGA gain (Bits[2:0]) More...
 
static const uint16_t kRegPgaIA = 0x008
 Current Channel A PGA gain (Bits[2:0]) More...
 
static const uint16_t kRegPgaIB = 0x009
 Current Channel B PGA gain (Bits[2:0]) More...
 
static const uint16_t kRegWriteProtect = 0x040
 Write protection bits (Bits[2:0]) More...
 
static const uint16_t kRegLastOp = 0x0FD
 Last operation type (0x35=read, 0xCA=write) More...
 
static const uint16_t kRegLastRwData8 = 0x0FF
 Last successful 8-bit register data. More...
 
static const uint16_t kRegVersion = 0x702
 Silicon version number. More...
 
static const uint16_t kRegExRef = 0x800
 Reference input config (0=internal, 1=external) More...
 
static const uint16_t kRegUnlock = 0x0FE
 Register unlock (write key to unlock 0x120) More...
 
static const uint16_t kRegZXTout = 0x100
 Zero-crossing timeout. More...
 
static const uint16_t kRegLineCyc = 0x101
 Half line cycles for line cycle accumulation. More...
 
static const uint16_t kRegConfig = 0x102
 Configuration register. More...
 
static const uint16_t kRegCF1Den = 0x103
 CF1 frequency divider denominator. More...
 
static const uint16_t kRegCF2Den = 0x104
 CF2 frequency divider denominator. More...
 
static const uint16_t kRegCFMode = 0x107
 CF output selection. More...
 
static const uint16_t kRegPhCalA = 0x108
 Phase calibration (Channel A) More...
 
static const uint16_t kRegPhCalB = 0x109
 Phase calibration (Channel B) More...
 
static const uint16_t kRegPFA = 0x10A
 Power factor (Channel A) More...
 
static const uint16_t kRegPFB = 0x10B
 Power factor (Channel B) More...
 
static const uint16_t kRegAngleA = 0x10C
 Angle between voltage and Current Channel A. More...
 
static const uint16_t kRegAngleB = 0x10D
 Angle between voltage and Current Channel B. More...
 
static const uint16_t kRegPeriod = 0x10E
 Period register (line period from ZX) More...
 
static const uint16_t kRegAltOutput = 0x110
 Alternative output functions. More...
 
static const uint16_t kRegOptimize = 0x120
 Performance optimization (set to 0x0030) More...
 
static const uint16_t kRegLastAdd = 0x1FE
 Last successful communication address. More...
 
static const uint16_t kRegLastRwData16 = 0x1FF
 Last successful 16-bit register data. More...
 
static const uint16_t kRegSagLvl = 0x300
 Sag voltage level. More...
 
static const uint16_t kRegAccMode = 0x301
 Accumulation mode. More...
 
static const uint16_t kRegApNoLoad = 0x303
 Active power no-load level. More...
 
static const uint16_t kRegVarNoLoad = 0x304
 Reactive power no-load level. More...
 
static const uint16_t kRegVaNoLoad = 0x305
 Apparent power no-load level. More...
 
static const uint16_t kRegAVA = 0x310
 Instantaneous apparent power (Channel A) More...
 
static const uint16_t kRegBVA = 0x311
 Instantaneous apparent power (Channel B) More...
 
static const uint16_t kRegAWatt = 0x312
 Instantaneous active power (Channel A) More...
 
static const uint16_t kRegBWatt = 0x313
 Instantaneous active power (Channel B) More...
 
static const uint16_t kRegAVar = 0x314
 Instantaneous reactive power (Channel A) More...
 
static const uint16_t kRegBVar = 0x315
 Instantaneous reactive power (Channel B) More...
 
static const uint16_t kRegIA = 0x316
 Instantaneous current (Channel A) More...
 
static const uint16_t kRegIB = 0x317
 Instantaneous current (Channel B) More...
 
static const uint16_t kRegV = 0x318
 Instantaneous voltage. More...
 
static const uint16_t kRegIRMSA = 0x31A
 IRMS (Channel A) More...
 
static const uint16_t kRegIRMSB = 0x31B
 IRMS (Channel B) More...
 
static const uint16_t kRegVRMS = 0x31C
 VRMS. More...
 
static const uint16_t kRegAEnergyA = 0x31E
 Active energy (Channel A) More...
 
static const uint16_t kRegAEnergyB = 0x31F
 Active energy (Channel B) More...
 
static const uint16_t kRegREnergyA = 0x320
 Reactive energy (Channel A) More...
 
static const uint16_t kRegREnergyB = 0x321
 Reactive energy (Channel B) More...
 
static const uint16_t kRegApEnergyA = 0x322
 Apparent energy (Channel A) More...
 
static const uint16_t kRegApEnergyB = 0x323
 Apparent energy (Channel B) More...
 
static const uint16_t kRegOvLvl = 0x324
 Overvoltage level. More...
 
static const uint16_t kRegOiLvl = 0x325
 Overcurrent level. More...
 
static const uint16_t kRegVPeak = 0x326
 Voltage channel peak. More...
 
static const uint16_t kRegRstVPeak = 0x327
 Voltage peak read with reset. More...
 
static const uint16_t kRegIAPeak = 0x328
 Current Channel A peak. More...
 
static const uint16_t kRegRstIAPeak = 0x329
 Current Channel A peak read with reset. More...
 
static const uint16_t kRegIBPeak = 0x32A
 Current Channel B peak. More...
 
static const uint16_t kRegRstIBPeak = 0x32B
 Current Channel B peak read with reset. More...
 
static const uint16_t kRegIrqEnA = 0x32C
 Interrupt enable (Channel A + voltage) More...
 
static const uint16_t kRegIrqStatA = 0x32D
 Interrupt status (Channel A + voltage) More...
 
static const uint16_t kRegRstIrqStatA = 0x32E
 Reset interrupt status (Channel A + voltage) More...
 
static const uint16_t kRegIrqEnB = 0x32F
 Interrupt enable (Channel B) More...
 
static const uint16_t kRegIrqStatB = 0x330
 Interrupt status (Channel B) More...
 
static const uint16_t kRegRstIrqStatB = 0x331
 Reset interrupt status (Channel B) More...
 
static const uint16_t kRegCRC = 0x37F
 Checksum (32-bit only) More...
 
static const uint16_t kRegAIGain = 0x380
 Current channel gain (Channel A) More...
 
static const uint16_t kRegAVGain = 0x381
 Voltage channel gain. More...
 
static const uint16_t kRegAWGain = 0x382
 Active power gain (Channel A) More...
 
static const uint16_t kRegAVarGain = 0x383
 Reactive power gain (Channel A) More...
 
static const uint16_t kRegAVaGain = 0x384
 Apparent power gain (Channel A) More...
 
static const uint16_t kRegAIRMSOS = 0x386
 IRMS offset (Channel A) More...
 
static const uint16_t kRegVRMSOS = 0x388
 VRMS offset. More...
 
static const uint16_t kRegAWattOS = 0x389
 Active power offset (Channel A) More...
 
static const uint16_t kRegAVarOS = 0x38A
 Reactive power offset (Channel A) More...
 
static const uint16_t kRegAVaOS = 0x38B
 Apparent power offset (Channel A) More...
 
static const uint16_t kRegBIGain = 0x38C
 Current channel gain (Channel B) More...
 
static const uint16_t kRegBWGain = 0x38E
 Active power gain (Channel B) More...
 
static const uint16_t kRegBVarGain = 0x38F
 Reactive power gain (Channel B) More...
 
static const uint16_t kRegBVaGain = 0x390
 Apparent power gain (Channel B) More...
 
static const uint16_t kRegBIRMSOS = 0x392
 IRMS offset (Channel B) More...
 
static const uint16_t kRegBWattOS = 0x395
 Active power offset (Channel B) More...
 
static const uint16_t kRegBVarOS = 0x396
 Reactive power offset (Channel B) More...
 
static const uint16_t kRegBVaOS = 0x397
 Apparent power offset (Channel B) More...
 
static const uint16_t kRegLastRwData32 = 0x3FF
 Last successful 24/32-bit register data. More...
 
static const uint8_t kUnlockKey = 0xAD
 Key written to kRegUnlock to unlock 0x120. More...
 
static const uint16_t kOptimizeValue = 0x0030
 Value written to 0x120 for rated performance. More...
 
static const uint32_t kDigitalGainUnity = 0x400000
 Digital gain register value for 1.0x. More...
 
static const uint32_t kDigitalGainMax = 0x7FFFFF
 Maximum valid digital gain register value. More...
 
static const uint8_t kLastOpRead = 0x35
 Last operation was a read. More...
 
static const uint8_t kLastOpWrite = 0xCA
 Last operation was a write. More...
 

Detailed Description

Platform-independent driver for the ADE7953 energy metering IC.

This class implements register-level access to the ADE7953 via the SparkFun Toolkit bus interface. Most methods return a SparkFun Toolkit error code (::ksfTkErrOk on success, a negative value on error); values read from the device are returned through reference (output) parameters. Callers that do not care about error handling can simply ignore the returned code.

Constructor & Destructor Documentation

◆ sfDevADE7953()

sfDevADE7953::sfDevADE7953 ( )
inline

Member Function Documentation

◆ applyDefaultConfig()

sfTkError_t sfDevADE7953::applyDefaultConfig ( void  )
protected

Apply the datasheet unlock + optimize sequence and default configuration.

Shared by begin() and reset(). Assumes _theBus is valid and byte order is set.

Returns
::ksfTkErrOk on success, or an error code on failure.

◆ autoCalibrateA()

sfTkError_t sfDevADE7953::autoCalibrateA ( uint16_t  numSamples = 50)

Auto-calibrate the Channel A no-load baseline by averaging samples.

Reads numSamples raw IRMS samples (which must be taken with NO current flowing) and stores their average as a software noise floor. getCurrentA() then removes it in the squared domain — corrected = sqrt(reading^2 - baseline^2) — which is the physically correct way to subtract an RMS noise floor and needs no datasheet-specific scaling. This leaves the hardware AIRMSOS register untouched.

Parameters
numSamplesNumber of samples to average (must be > 0).
Returns
::ksfTkErrOk on success, ::ksfTkErrFail if numSamples is 0, or an error code on communication failure.

◆ autoCalibrateB()

sfTkError_t sfDevADE7953::autoCalibrateB ( uint16_t  numSamples = 50)

Auto-calibrate the Channel B no-load baseline by averaging samples.

Parameters
numSamplesNumber of samples to average (must be > 0).
Returns
::ksfTkErrOk on success, ::ksfTkErrFail if numSamples is 0, or an error code on failure.

◆ begin()

sfTkError_t sfDevADE7953::begin ( sfTkIBus *  theBus = nullptr)

Initialize the device driver with the given bus.

Verifies the device is responding, configures big-endian byte order, applies the optimized performance register sequence required by the datasheet, and sets sensible default gain / HPF configuration so a basic sketch works without any further setup.

Parameters
theBusPointer to the initialized bus object. If null, a bus set by a prior call is used.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ clampPreset()

void sfDevADE7953::clampPreset ( sfe_ade7953_clamp_t  clamp,
float &  ratio,
sfe_ade7953_pga_gain_t gain 
)
staticprotected

Look up the turns ratio and PGA gain for a known current clamp preset.

Parameters
clampOne of the supported clamps (see sfe_ade7953_clamp_t).
ratioOutput reference that receives the clamp's turns ratio.
gainOutput reference that receives the clamp's recommended PGA gain.

◆ clearCalibration()

void sfDevADE7953::clearCalibration ( void  )

Clear the software no-load baseline for both channels (set by autoCalibrate).

◆ enableHPF()

sfTkError_t sfDevADE7953::enableHPF ( bool  enable)

Enable or disable the high-pass filter on all channels.

The HPF removes DC offset before RMS computation. It should be enabled for accurate IRMS readings, and is enabled by default after power-on reset and by begin().

Parameters
enableTrue to enable the HPF, false to disable.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ enableZXLPF()

sfTkError_t sfDevADE7953::enableZXLPF ( bool  enable)

Enable or disable the zero-crossing low-pass filter.

Parameters
enableTrue to enable the LPF, false to disable.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getBurdenResistor()

float sfDevADE7953::getBurdenResistor ( void  )

Get the configured burden resistor value.

Returns
The burden resistor value in ohms.

◆ getCurrentA()

sfTkError_t sfDevADE7953::getCurrentA ( float &  amps)

Read the RMS current on Channel A converted to amps.

Combines the raw IRMS reading with the configured PGA gain, CT ratio, burden resistor, and full-scale constants. The PGA gain is read from the device on each call, so the conversion always matches the active gain.

Parameters
ampsOutput reference that receives the current in amps.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getCurrentB()

sfTkError_t sfDevADE7953::getCurrentB ( float &  amps)

Read the RMS current on Channel B converted to amps.

Parameters
ampsOutput reference that receives the current in amps.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getCurrentTransformerRatio()

float sfDevADE7953::getCurrentTransformerRatio ( void  )

Get the configured CT turns ratio for Channel A.

Returns
The Channel A current transformer turns ratio.

◆ getCurrentTransformerRatioA()

float sfDevADE7953::getCurrentTransformerRatioA ( void  )

Get the configured CT turns ratio for Channel A.

Returns
The Channel A current transformer turns ratio.

◆ getCurrentTransformerRatioB()

float sfDevADE7953::getCurrentTransformerRatioB ( void  )

Get the configured CT turns ratio for Channel B.

Returns
The Channel B current transformer turns ratio.

◆ getDigitalGainIA() [1/2]

sfTkError_t sfDevADE7953::getDigitalGainIA ( float &  multiplier)

Get the digital gain for Current Channel A as a floating-point multiplier.

Parameters
multiplierOutput reference that receives the gain multiplier (1.0 = unity).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getDigitalGainIA() [2/2]

sfTkError_t sfDevADE7953::getDigitalGainIA ( uint32_t &  gain)

Get the digital gain for Current Channel A as a raw register value.

Parameters
gainOutput reference that receives the digital gain register value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getDigitalGainIB() [1/2]

sfTkError_t sfDevADE7953::getDigitalGainIB ( float &  multiplier)

Get the digital gain for Current Channel B as a floating-point multiplier.

Parameters
multiplierOutput reference that receives the gain multiplier (1.0 = unity).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getDigitalGainIB() [2/2]

sfTkError_t sfDevADE7953::getDigitalGainIB ( uint32_t &  gain)

Get the digital gain for Current Channel B as a raw register value.

Parameters
gainOutput reference that receives the digital gain register value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getGainIA()

sfTkError_t sfDevADE7953::getGainIA ( sfe_ade7953_pga_gain_t gain)

Get the PGA gain for Current Channel A.

Parameters
gainOutput reference that receives the PGA gain setting.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getGainIB()

sfTkError_t sfDevADE7953::getGainIB ( sfe_ade7953_pga_gain_t gain)

Get the PGA gain for Current Channel B.

Parameters
gainOutput reference that receives the PGA gain setting.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getGainV()

sfTkError_t sfDevADE7953::getGainV ( sfe_ade7953_pga_gain_t gain)

Get the PGA gain for the voltage channel.

Parameters
gainOutput reference that receives the PGA gain setting.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getInstantaneousIA()

sfTkError_t sfDevADE7953::getInstantaneousIA ( int32_t &  value)

Read the instantaneous current sample for Channel A.

Parameters
valueOutput reference that receives the signed instantaneous current value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getInstantaneousIB()

sfTkError_t sfDevADE7953::getInstantaneousIB ( int32_t &  value)

Read the instantaneous current sample for Channel B.

Parameters
valueOutput reference that receives the signed instantaneous current value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getInterruptEnableA()

sfTkError_t sfDevADE7953::getInterruptEnableA ( sfe_ade7953_irq_reg_t mask)

Get the interrupt enable mask for Channel A.

Parameters
maskOutput reference that receives the interrupt enable bitfield.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getInterruptEnableB()

sfTkError_t sfDevADE7953::getInterruptEnableB ( sfe_ade7953_irq_reg_t mask)

Get the interrupt enable mask for Channel B.

Parameters
maskOutput reference that receives the interrupt enable bitfield.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getInterruptStatusA()

sfTkError_t sfDevADE7953::getInterruptStatusA ( sfe_ade7953_irq_reg_t status)

Read the interrupt status for Channel A (non-destructive).

Parameters
statusOutput reference that receives the interrupt status bitfield.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getInterruptStatusB()

sfTkError_t sfDevADE7953::getInterruptStatusB ( sfe_ade7953_irq_reg_t status)

Read the interrupt status for Channel B (non-destructive).

Parameters
statusOutput reference that receives the interrupt status bitfield.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getIRMSA()

sfTkError_t sfDevADE7953::getIRMSA ( uint32_t &  value)

Read the raw IRMS value for Current Channel A.

Parameters
valueOutput reference that receives the raw unsigned IRMS value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getIRMSB()

sfTkError_t sfDevADE7953::getIRMSB ( uint32_t &  value)

Read the raw IRMS value for Current Channel B.

Parameters
valueOutput reference that receives the raw unsigned IRMS value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getIRMSOffsetA()

sfTkError_t sfDevADE7953::getIRMSOffsetA ( int32_t &  offset)

Get the IRMS offset for Current Channel A.

Parameters
offsetOutput reference that receives the signed offset value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getIRMSOffsetB()

sfTkError_t sfDevADE7953::getIRMSOffsetB ( int32_t &  offset)

Get the IRMS offset for Current Channel B.

Parameters
offsetOutput reference that receives the signed offset value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getLastAddress()

sfTkError_t sfDevADE7953::getLastAddress ( uint16_t &  address)

Get the address of the last successful communication.

Parameters
addressOutput reference that receives the register address.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getLastData16()

sfTkError_t sfDevADE7953::getLastData16 ( uint16_t &  data)

Get the data from the last successful 16-bit register communication.

Parameters
dataOutput reference that receives the data value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getLastData32()

sfTkError_t sfDevADE7953::getLastData32 ( uint32_t &  data)

Get the data from the last successful 24/32-bit register communication.

Parameters
dataOutput reference that receives the data value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getLastData8()

sfTkError_t sfDevADE7953::getLastData8 ( uint8_t &  data)

Get the data from the last successful 8-bit register communication.

Parameters
dataOutput reference that receives the data value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getLastOperation()

sfTkError_t sfDevADE7953::getLastOperation ( uint8_t &  op)

Get the type of the last successful communication.

Parameters
opOutput reference that receives 0x35 for a read or 0xCA for a write.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getLineCycleCount()

sfTkError_t sfDevADE7953::getLineCycleCount ( uint16_t &  halfCycles)

Get the number of half line cycles for line cycle accumulation.

Parameters
halfCyclesOutput reference that receives the number of half cycles.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getLineCycleMode()

sfTkError_t sfDevADE7953::getLineCycleMode ( sfe_ade7953_lcycmode_reg_t mode)

Get the line cycle accumulation mode register.

Parameters
modeOutput reference that receives the line cycle mode bitfield.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getNoLoadDisable()

sfTkError_t sfDevADE7953::getNoLoadDisable ( sfe_ade7953_disnoload_reg_t mask)

Get the no-load detection disable register.

Parameters
maskOutput reference that receives the no-load disable bitfield.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getOvercurrentLevel()

sfTkError_t sfDevADE7953::getOvercurrentLevel ( uint32_t &  level)

Get the overcurrent detection threshold.

Parameters
levelOutput reference that receives the threshold level.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getPeakIA()

sfTkError_t sfDevADE7953::getPeakIA ( uint32_t &  value)

Read the peak current value for Channel A.

Parameters
valueOutput reference that receives the peak value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getPeakIB()

sfTkError_t sfDevADE7953::getPeakIB ( uint32_t &  value)

Read the peak current value for Channel B.

Parameters
valueOutput reference that receives the peak value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getPeriod()

sfTkError_t sfDevADE7953::getPeriod ( uint16_t &  period)

Read the line period derived from zero-crossing detection.

Parameters
periodOutput reference that receives the period register value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getSagCycles()

sfTkError_t sfDevADE7953::getSagCycles ( uint8_t &  cycles)

Get the number of sag line cycles.

Parameters
cyclesOutput reference that receives the number of half line cycles.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getSagLevel()

sfTkError_t sfDevADE7953::getSagLevel ( uint32_t &  level)

Get the sag voltage level threshold.

Parameters
levelOutput reference that receives the sag level.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getVersion()

sfTkError_t sfDevADE7953::getVersion ( uint8_t &  version)

Read the silicon version number from the Version register (0x702).

Parameters
versionOutput reference that receives the silicon version.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getWriteProtect()

sfTkError_t sfDevADE7953::getWriteProtect ( uint8_t &  protect)

Get the current write protection setting.

Parameters
protectOutput reference that receives the write protection value (Bits[2:0]).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getZXEdge()

sfTkError_t sfDevADE7953::getZXEdge ( sfe_ade7953_zx_edge_t edge)

Get the current zero-crossing edge selection.

Parameters
edgeOutput reference that receives the edge selection value.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ getZXISourceChannel()

sfTkError_t sfDevADE7953::getZXISourceChannel ( bool &  useChannelB)

Get which current channel drives the ZX_I output.

Parameters
useChannelBOutput reference set true if Channel B drives ZX_I, false for Channel A.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ isConnected()

bool sfDevADE7953::isConnected ( void  )

Check whether the ADE7953 is connected and responding.

Returns
true if the device responds, false otherwise.

◆ isHPFEnabled()

sfTkError_t sfDevADE7953::isHPFEnabled ( bool &  enabled)

Check whether the high-pass filter is currently enabled.

Parameters
enabledOutput reference set true if the HPF is enabled.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ pgaGainToMultiplier()

float sfDevADE7953::pgaGainToMultiplier ( sfe_ade7953_pga_gain_t  gain)
staticprotected

Convert a PGA gain enum value to its numeric multiplier (1, 2, 4, 8, 16, 22).

◆ readAndResetInterruptStatusA()

sfTkError_t sfDevADE7953::readAndResetInterruptStatusA ( sfe_ade7953_irq_reg_t status)

Read the interrupt status for Channel A and clear it.

Reads the read-with-reset register, returning the status and clearing the flags in a single operation.

Parameters
statusOutput reference that receives the interrupt status bitfield before reset.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ readAndResetInterruptStatusB()

sfTkError_t sfDevADE7953::readAndResetInterruptStatusB ( sfe_ade7953_irq_reg_t status)

Read the interrupt status for Channel B and clear it.

Parameters
statusOutput reference that receives the interrupt status bitfield before reset.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ readAndResetPeakIA()

sfTkError_t sfDevADE7953::readAndResetPeakIA ( uint32_t &  value)

Read the peak current value for Channel A and clear it.

Reads the read-with-reset register, which returns the peak value and clears it in a single operation.

Parameters
valueOutput reference that receives the peak value before reset.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ readAndResetPeakIB()

sfTkError_t sfDevADE7953::readAndResetPeakIB ( uint32_t &  value)

Read the peak current value for Channel B and clear it.

Parameters
valueOutput reference that receives the peak value before reset.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ removeBaseline()

float sfDevADE7953::removeBaseline ( uint32_t  reading,
uint32_t  baseline 
)
staticprotected

Remove a no-load baseline from a raw RMS reading in the squared domain.

Returns
sqrt(reading^2 - baseline^2), clamped at 0; or reading unchanged if baseline is 0.

◆ reset()

sfTkError_t sfDevADE7953::reset ( void  )

Perform a software reset and re-apply the datasheet performance configuration.

Asserts the CONFIG SWRST bit. Because a reset returns all registers to their power-on defaults, this method re-runs the unlock + optimize sequence (and default gain / HPF configuration) afterward so the device is left in the same state as a fresh begin().

Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setBurdenResistor()

void sfDevADE7953::setBurdenResistor ( float  ohms)

Set the burden resistor value (in ohms) used by getCurrentA() / getCurrentB().

Parameters
ohmsBurden resistor value in ohms.

◆ setCurrentClamp() [1/2]

void sfDevADE7953::setCurrentClamp ( float  turnsRatio)

Configure a custom current clamp on both channels by its turns ratio.

Use this for a clamp that is not one of the presets. Only the CT ratio is changed; the PGA gain is left as-is (set it with setGainIA()/setGainIB() if needed).

Parameters
turnsRatioTurns ratio of the current transformer (e.g. 2000.0 for 30A:15mA).

◆ setCurrentClamp() [2/2]

sfTkError_t sfDevADE7953::setCurrentClamp ( sfe_ade7953_clamp_t  clamp)

Select a known current clamp and apply its turns ratio and PGA gain to both channels.

Sets the CT ratio used by getCurrentA()/getCurrentB() and writes a suitable PGA gain to both current channels for the board's 5.6 ohm burden resistor. To use a different clamp on each channel, call setCurrentClampA()/setCurrentClampB() instead.

Parameters
clampOne of the supported clamps (see sfe_ade7953_clamp_t).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setCurrentClampA() [1/2]

void sfDevADE7953::setCurrentClampA ( float  turnsRatio)

Configure a custom current clamp on Channel A by its turns ratio.

Only the Channel A CT ratio is changed; the PGA gain is left as-is. Pass 1.0 to measure Channel A directly (no current transformer).

Parameters
turnsRatioTurns ratio of the current transformer (e.g. 2000.0 for 30A:15mA).

◆ setCurrentClampA() [2/2]

sfTkError_t sfDevADE7953::setCurrentClampA ( sfe_ade7953_clamp_t  clamp)

Select a known current clamp for Channel A and apply its turns ratio and PGA gain.

Sets the Channel A CT ratio used by getCurrentA() and writes a suitable PGA gain to Channel A only. Channel B is left unchanged.

Parameters
clampOne of the supported clamps (see sfe_ade7953_clamp_t).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setCurrentClampB() [1/2]

void sfDevADE7953::setCurrentClampB ( float  turnsRatio)

Configure a custom current clamp on Channel B by its turns ratio.

Only the Channel B CT ratio is changed; the PGA gain is left as-is. Pass 1.0 to measure Channel B directly (no current transformer).

Parameters
turnsRatioTurns ratio of the current transformer (e.g. 2000.0 for 30A:15mA).

◆ setCurrentClampB() [2/2]

sfTkError_t sfDevADE7953::setCurrentClampB ( sfe_ade7953_clamp_t  clamp)

Select a known current clamp for Channel B and apply its turns ratio and PGA gain.

Sets the Channel B CT ratio used by getCurrentB() and writes a suitable PGA gain to Channel B only. Channel A is left unchanged.

Parameters
clampOne of the supported clamps (see sfe_ade7953_clamp_t).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setCurrentTransformerRatio()

void sfDevADE7953::setCurrentTransformerRatio ( float  ratio)

Set the CT (current transformer) turns ratio used by getCurrentA() and getCurrentB().

Sets both channels to the same ratio. Use setCurrentTransformerRatioA() / setCurrentTransformerRatioB() to give each channel its own ratio.

Parameters
ratioTurns ratio of the current transformer (e.g. 2000.0 for a 30A:15mA clamp).

◆ setCurrentTransformerRatioA()

void sfDevADE7953::setCurrentTransformerRatioA ( float  ratio)

Set the CT turns ratio used by getCurrentA() for Channel A.

Parameters
ratioTurns ratio of the current transformer (e.g. 2000.0 for a 30A:15mA clamp).

◆ setCurrentTransformerRatioB()

void sfDevADE7953::setCurrentTransformerRatioB ( float  ratio)

Set the CT turns ratio used by getCurrentB() for Channel B.

Parameters
ratioTurns ratio of the current transformer (e.g. 2000.0 for a 30A:15mA clamp).

◆ setDigitalGainIA() [1/2]

sfTkError_t sfDevADE7953::setDigitalGainIA ( float  multiplier)

Set the digital (fine) gain for Current Channel A using a floating-point multiplier.

Converts the multiplier to the nearest valid register value (0x400000 = 1.0x).

Parameters
multiplierDesired gain multiplier (must be > 0 and within the representable range).
Returns
::ksfTkErrOk on success, ::ksfTkErrFail if out of range, or an error code on failure.

◆ setDigitalGainIA() [2/2]

sfTkError_t sfDevADE7953::setDigitalGainIA ( uint32_t  gain)

Set the digital (fine) gain for Current Channel A using a raw register value.

Parameters
gainDigital gain register value (0x400000 = unity).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setDigitalGainIB() [1/2]

sfTkError_t sfDevADE7953::setDigitalGainIB ( float  multiplier)

Set the digital (fine) gain for Current Channel B using a floating-point multiplier.

Parameters
multiplierDesired gain multiplier (must be > 0 and within the representable range).
Returns
::ksfTkErrOk on success, ::ksfTkErrFail if out of range, or an error code on failure.

◆ setDigitalGainIB() [2/2]

sfTkError_t sfDevADE7953::setDigitalGainIB ( uint32_t  gain)

Set the digital (fine) gain for Current Channel B using a raw register value.

Parameters
gainDigital gain register value (0x400000 = unity).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setGainIA()

sfTkError_t sfDevADE7953::setGainIA ( sfe_ade7953_pga_gain_t  gain)

Set the PGA gain for Current Channel A.

Parameters
gainPGA gain setting (see sfe_ade7953_pga_gain_t).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setGainIB()

sfTkError_t sfDevADE7953::setGainIB ( sfe_ade7953_pga_gain_t  gain)

Set the PGA gain for Current Channel B.

Parameters
gainPGA gain setting.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setGainV()

sfTkError_t sfDevADE7953::setGainV ( sfe_ade7953_pga_gain_t  gain)

Set the PGA gain for the voltage channel.

Note
ADE7953_PGA_GAIN_22 is not valid for the voltage channel and is rejected.
Parameters
gainPGA gain setting.
Returns
::ksfTkErrOk on success, ::ksfTkErrFail for an invalid gain, or an error code on communication failure.

◆ setInterruptEnableA()

sfTkError_t sfDevADE7953::setInterruptEnableA ( sfe_ade7953_irq_reg_t  mask)

Set the interrupt enable mask for Channel A (and voltage).

Parameters
maskInterrupt enable bitfield struct.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setInterruptEnableB()

sfTkError_t sfDevADE7953::setInterruptEnableB ( sfe_ade7953_irq_reg_t  mask)

Set the interrupt enable mask for Channel B.

Only bits [13:0] are valid for Channel B.

Parameters
maskInterrupt enable bitfield struct.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setIRMSOffsetA()

sfTkError_t sfDevADE7953::setIRMSOffsetA ( int32_t  offset)

Set the IRMS offset for Current Channel A.

Note
The ADE7953 applies this offset in the squared domain (the value is added to the square of the RMS result before the square root). To null a no-load noise floor of N raw counts the offset is approximately -(N*N) scaled per the datasheet, not -N.
Parameters
offsetSigned offset value for IRMS correction.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setIRMSOffsetB()

sfTkError_t sfDevADE7953::setIRMSOffsetB ( int32_t  offset)

Set the IRMS offset for Current Channel B.

See setIRMSOffsetA() for the squared-domain note.

Parameters
offsetSigned offset value for IRMS correction.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setLineCycleCount()

sfTkError_t sfDevADE7953::setLineCycleCount ( uint16_t  halfCycles)

Set the number of half line cycles for line cycle accumulation.

Parameters
halfCyclesNumber of half cycles.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setLineCycleMode()

sfTkError_t sfDevADE7953::setLineCycleMode ( sfe_ade7953_lcycmode_reg_t  mode)

Set the line cycle accumulation mode register.

Parameters
modeLine cycle mode bitfield struct.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setNoLoadDisable()

sfTkError_t sfDevADE7953::setNoLoadDisable ( sfe_ade7953_disnoload_reg_t  mask)

Set the no-load detection disable register.

Parameters
maskNo-load disable bitfield struct.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setOvercurrentLevel()

sfTkError_t sfDevADE7953::setOvercurrentLevel ( uint32_t  level)

Set the overcurrent detection threshold.

Parameters
levelThreshold level (24-bit value).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setSagCycles()

sfTkError_t sfDevADE7953::setSagCycles ( uint8_t  cycles)

Set the number of sag line cycles.

Parameters
cyclesNumber of half line cycles for sag detection.
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setSagLevel()

sfTkError_t sfDevADE7953::setSagLevel ( uint32_t  level)

Set the sag voltage level threshold.

Parameters
levelSag level threshold (24-bit value).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setWriteProtect()

sfTkError_t sfDevADE7953::setWriteProtect ( uint8_t  protect)

Set write protection bits.

Parameters
protectWrite protection value (Bits[2:0]).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setZXEdge()

sfTkError_t sfDevADE7953::setZXEdge ( sfe_ade7953_zx_edge_t  edge)

Set the zero-crossing edge selection for interrupt generation.

Parameters
edgeEdge selection (see sfe_ade7953_zx_edge_t).
Returns
::ksfTkErrOk on success, or an error code on failure.

◆ setZXISourceChannel()

sfTkError_t sfDevADE7953::setZXISourceChannel ( bool  useChannelB)

Select which current channel drives the ZX_I output.

Parameters
useChannelBIf true, ZX_I is based on Channel B; if false, Channel A.
Returns
::ksfTkErrOk on success, or an error code on failure.

Member Data Documentation

◆ _baselineA

uint32_t sfDevADE7953::_baselineA = 0
protected

Channel A no-load IRMS baseline (raw counts).

◆ _baselineB

uint32_t sfDevADE7953::_baselineB = 0
protected

Channel B no-load IRMS baseline (raw counts).

◆ _burdenResistor

float sfDevADE7953::_burdenResistor = 5.6f
protected

Burden resistor in ohms.

◆ _ctRatioA

float sfDevADE7953::_ctRatioA = 2000.0f
protected

Channel A CT turns ratio (30A:15mA = 2000:1).

◆ _ctRatioB

float sfDevADE7953::_ctRatioB = 2000.0f
protected

Channel B CT turns ratio (30A:15mA = 2000:1).

◆ _fullScaleCode

float sfDevADE7953::_fullScaleCode = 5928256.0f
protected

ADE7953 full-scale IRMS code.

◆ _fullScaleVRMS

float sfDevADE7953::_fullScaleVRMS = 0.35355f
protected

Full-scale input RMS voltage (0.5 V peak / sqrt(2)).

◆ _theBus

sfTkIBus* sfDevADE7953::_theBus
protected

Pointer to the communication bus device.

◆ kDigitalGainMax

const uint32_t sfDevADE7953::kDigitalGainMax = 0x7FFFFF
staticprotected

Maximum valid digital gain register value.

◆ kDigitalGainUnity

const uint32_t sfDevADE7953::kDigitalGainUnity = 0x400000
staticprotected

Digital gain register value for 1.0x.

◆ kI2CAddress

const uint8_t sfDevADE7953::kI2CAddress = 0x38
staticprotected

7-bit I2C address for the ADE7953 (only address).

◆ kLastOpRead

const uint8_t sfDevADE7953::kLastOpRead = 0x35
staticprotected

Last operation was a read.

◆ kLastOpWrite

const uint8_t sfDevADE7953::kLastOpWrite = 0xCA
staticprotected

Last operation was a write.

◆ kOptimizeValue

const uint16_t sfDevADE7953::kOptimizeValue = 0x0030
staticprotected

Value written to 0x120 for rated performance.

◆ kRegAccMode

const uint16_t sfDevADE7953::kRegAccMode = 0x301
staticprotected

Accumulation mode.

◆ kRegAEnergyA

const uint16_t sfDevADE7953::kRegAEnergyA = 0x31E
staticprotected

Active energy (Channel A)

◆ kRegAEnergyB

const uint16_t sfDevADE7953::kRegAEnergyB = 0x31F
staticprotected

Active energy (Channel B)

◆ kRegAIGain

const uint16_t sfDevADE7953::kRegAIGain = 0x380
staticprotected

Current channel gain (Channel A)

◆ kRegAIRMSOS

const uint16_t sfDevADE7953::kRegAIRMSOS = 0x386
staticprotected

IRMS offset (Channel A)

◆ kRegAltOutput

const uint16_t sfDevADE7953::kRegAltOutput = 0x110
staticprotected

Alternative output functions.

◆ kRegAngleA

const uint16_t sfDevADE7953::kRegAngleA = 0x10C
staticprotected

Angle between voltage and Current Channel A.

◆ kRegAngleB

const uint16_t sfDevADE7953::kRegAngleB = 0x10D
staticprotected

Angle between voltage and Current Channel B.

◆ kRegApEnergyA

const uint16_t sfDevADE7953::kRegApEnergyA = 0x322
staticprotected

Apparent energy (Channel A)

◆ kRegApEnergyB

const uint16_t sfDevADE7953::kRegApEnergyB = 0x323
staticprotected

Apparent energy (Channel B)

◆ kRegApNoLoad

const uint16_t sfDevADE7953::kRegApNoLoad = 0x303
staticprotected

Active power no-load level.

◆ kRegAVA

const uint16_t sfDevADE7953::kRegAVA = 0x310
staticprotected

Instantaneous apparent power (Channel A)

◆ kRegAVaGain

const uint16_t sfDevADE7953::kRegAVaGain = 0x384
staticprotected

Apparent power gain (Channel A)

◆ kRegAVaOS

const uint16_t sfDevADE7953::kRegAVaOS = 0x38B
staticprotected

Apparent power offset (Channel A)

◆ kRegAVar

const uint16_t sfDevADE7953::kRegAVar = 0x314
staticprotected

Instantaneous reactive power (Channel A)

◆ kRegAVarGain

const uint16_t sfDevADE7953::kRegAVarGain = 0x383
staticprotected

Reactive power gain (Channel A)

◆ kRegAVarOS

const uint16_t sfDevADE7953::kRegAVarOS = 0x38A
staticprotected

Reactive power offset (Channel A)

◆ kRegAVGain

const uint16_t sfDevADE7953::kRegAVGain = 0x381
staticprotected

Voltage channel gain.

◆ kRegAWatt

const uint16_t sfDevADE7953::kRegAWatt = 0x312
staticprotected

Instantaneous active power (Channel A)

◆ kRegAWattOS

const uint16_t sfDevADE7953::kRegAWattOS = 0x389
staticprotected

Active power offset (Channel A)

◆ kRegAWGain

const uint16_t sfDevADE7953::kRegAWGain = 0x382
staticprotected

Active power gain (Channel A)

◆ kRegBIGain

const uint16_t sfDevADE7953::kRegBIGain = 0x38C
staticprotected

Current channel gain (Channel B)

◆ kRegBIRMSOS

const uint16_t sfDevADE7953::kRegBIRMSOS = 0x392
staticprotected

IRMS offset (Channel B)

◆ kRegBVA

const uint16_t sfDevADE7953::kRegBVA = 0x311
staticprotected

Instantaneous apparent power (Channel B)

◆ kRegBVaGain

const uint16_t sfDevADE7953::kRegBVaGain = 0x390
staticprotected

Apparent power gain (Channel B)

◆ kRegBVaOS

const uint16_t sfDevADE7953::kRegBVaOS = 0x397
staticprotected

Apparent power offset (Channel B)

◆ kRegBVar

const uint16_t sfDevADE7953::kRegBVar = 0x315
staticprotected

Instantaneous reactive power (Channel B)

◆ kRegBVarGain

const uint16_t sfDevADE7953::kRegBVarGain = 0x38F
staticprotected

Reactive power gain (Channel B)

◆ kRegBVarOS

const uint16_t sfDevADE7953::kRegBVarOS = 0x396
staticprotected

Reactive power offset (Channel B)

◆ kRegBWatt

const uint16_t sfDevADE7953::kRegBWatt = 0x313
staticprotected

Instantaneous active power (Channel B)

◆ kRegBWattOS

const uint16_t sfDevADE7953::kRegBWattOS = 0x395
staticprotected

Active power offset (Channel B)

◆ kRegBWGain

const uint16_t sfDevADE7953::kRegBWGain = 0x38E
staticprotected

Active power gain (Channel B)

◆ kRegCF1Den

const uint16_t sfDevADE7953::kRegCF1Den = 0x103
staticprotected

CF1 frequency divider denominator.

◆ kRegCF2Den

const uint16_t sfDevADE7953::kRegCF2Den = 0x104
staticprotected

CF2 frequency divider denominator.

◆ kRegCFMode

const uint16_t sfDevADE7953::kRegCFMode = 0x107
staticprotected

CF output selection.

◆ kRegConfig

const uint16_t sfDevADE7953::kRegConfig = 0x102
staticprotected

Configuration register.

◆ kRegCRC

const uint16_t sfDevADE7953::kRegCRC = 0x37F
staticprotected

Checksum (32-bit only)

◆ kRegDisNoLoad

const uint16_t sfDevADE7953::kRegDisNoLoad = 0x001
staticprotected

No-load detection disable.

◆ kRegExRef

const uint16_t sfDevADE7953::kRegExRef = 0x800
staticprotected

Reference input config (0=internal, 1=external)

◆ kRegIA

const uint16_t sfDevADE7953::kRegIA = 0x316
staticprotected

Instantaneous current (Channel A)

◆ kRegIAPeak

const uint16_t sfDevADE7953::kRegIAPeak = 0x328
staticprotected

Current Channel A peak.

◆ kRegIB

const uint16_t sfDevADE7953::kRegIB = 0x317
staticprotected

Instantaneous current (Channel B)

◆ kRegIBPeak

const uint16_t sfDevADE7953::kRegIBPeak = 0x32A
staticprotected

Current Channel B peak.

◆ kRegIRMSA

const uint16_t sfDevADE7953::kRegIRMSA = 0x31A
staticprotected

IRMS (Channel A)

◆ kRegIRMSB

const uint16_t sfDevADE7953::kRegIRMSB = 0x31B
staticprotected

IRMS (Channel B)

◆ kRegIrqEnA

const uint16_t sfDevADE7953::kRegIrqEnA = 0x32C
staticprotected

Interrupt enable (Channel A + voltage)

◆ kRegIrqEnB

const uint16_t sfDevADE7953::kRegIrqEnB = 0x32F
staticprotected

Interrupt enable (Channel B)

◆ kRegIrqStatA

const uint16_t sfDevADE7953::kRegIrqStatA = 0x32D
staticprotected

Interrupt status (Channel A + voltage)

◆ kRegIrqStatB

const uint16_t sfDevADE7953::kRegIrqStatB = 0x330
staticprotected

Interrupt status (Channel B)

◆ kRegLastAdd

const uint16_t sfDevADE7953::kRegLastAdd = 0x1FE
staticprotected

Last successful communication address.

◆ kRegLastOp

const uint16_t sfDevADE7953::kRegLastOp = 0x0FD
staticprotected

Last operation type (0x35=read, 0xCA=write)

◆ kRegLastRwData16

const uint16_t sfDevADE7953::kRegLastRwData16 = 0x1FF
staticprotected

Last successful 16-bit register data.

◆ kRegLastRwData32

const uint16_t sfDevADE7953::kRegLastRwData32 = 0x3FF
staticprotected

Last successful 24/32-bit register data.

◆ kRegLastRwData8

const uint16_t sfDevADE7953::kRegLastRwData8 = 0x0FF
staticprotected

Last successful 8-bit register data.

◆ kRegLCycMode

const uint16_t sfDevADE7953::kRegLCycMode = 0x004
staticprotected

Line cycle accumulation mode config.

◆ kRegLineCyc

const uint16_t sfDevADE7953::kRegLineCyc = 0x101
staticprotected

Half line cycles for line cycle accumulation.

◆ kRegOiLvl

const uint16_t sfDevADE7953::kRegOiLvl = 0x325
staticprotected

Overcurrent level.

◆ kRegOptimize

const uint16_t sfDevADE7953::kRegOptimize = 0x120
staticprotected

Performance optimization (set to 0x0030)

◆ kRegOvLvl

const uint16_t sfDevADE7953::kRegOvLvl = 0x324
staticprotected

Overvoltage level.

◆ kRegPeriod

const uint16_t sfDevADE7953::kRegPeriod = 0x10E
staticprotected

Period register (line period from ZX)

◆ kRegPFA

const uint16_t sfDevADE7953::kRegPFA = 0x10A
staticprotected

Power factor (Channel A)

◆ kRegPFB

const uint16_t sfDevADE7953::kRegPFB = 0x10B
staticprotected

Power factor (Channel B)

◆ kRegPgaIA

const uint16_t sfDevADE7953::kRegPgaIA = 0x008
staticprotected

Current Channel A PGA gain (Bits[2:0])

◆ kRegPgaIB

const uint16_t sfDevADE7953::kRegPgaIB = 0x009
staticprotected

Current Channel B PGA gain (Bits[2:0])

◆ kRegPgaV

const uint16_t sfDevADE7953::kRegPgaV = 0x007
staticprotected

Voltage channel PGA gain (Bits[2:0])

◆ kRegPhCalA

const uint16_t sfDevADE7953::kRegPhCalA = 0x108
staticprotected

Phase calibration (Channel A)

◆ kRegPhCalB

const uint16_t sfDevADE7953::kRegPhCalB = 0x109
staticprotected

Phase calibration (Channel B)

◆ kRegREnergyA

const uint16_t sfDevADE7953::kRegREnergyA = 0x320
staticprotected

Reactive energy (Channel A)

◆ kRegREnergyB

const uint16_t sfDevADE7953::kRegREnergyB = 0x321
staticprotected

Reactive energy (Channel B)

◆ kRegRstIAPeak

const uint16_t sfDevADE7953::kRegRstIAPeak = 0x329
staticprotected

Current Channel A peak read with reset.

◆ kRegRstIBPeak

const uint16_t sfDevADE7953::kRegRstIBPeak = 0x32B
staticprotected

Current Channel B peak read with reset.

◆ kRegRstIrqStatA

const uint16_t sfDevADE7953::kRegRstIrqStatA = 0x32E
staticprotected

Reset interrupt status (Channel A + voltage)

◆ kRegRstIrqStatB

const uint16_t sfDevADE7953::kRegRstIrqStatB = 0x331
staticprotected

Reset interrupt status (Channel B)

◆ kRegRstVPeak

const uint16_t sfDevADE7953::kRegRstVPeak = 0x327
staticprotected

Voltage peak read with reset.

◆ kRegSagCyc

const uint16_t sfDevADE7953::kRegSagCyc = 0x000
staticprotected

Sag line cycles.

◆ kRegSagLvl

const uint16_t sfDevADE7953::kRegSagLvl = 0x300
staticprotected

Sag voltage level.

◆ kRegUnlock

const uint16_t sfDevADE7953::kRegUnlock = 0x0FE
staticprotected

Register unlock (write key to unlock 0x120)

◆ kRegV

const uint16_t sfDevADE7953::kRegV = 0x318
staticprotected

Instantaneous voltage.

◆ kRegVaNoLoad

const uint16_t sfDevADE7953::kRegVaNoLoad = 0x305
staticprotected

Apparent power no-load level.

◆ kRegVarNoLoad

const uint16_t sfDevADE7953::kRegVarNoLoad = 0x304
staticprotected

Reactive power no-load level.

◆ kRegVersion

const uint16_t sfDevADE7953::kRegVersion = 0x702
staticprotected

Silicon version number.

◆ kRegVPeak

const uint16_t sfDevADE7953::kRegVPeak = 0x326
staticprotected

Voltage channel peak.

◆ kRegVRMS

const uint16_t sfDevADE7953::kRegVRMS = 0x31C
staticprotected

VRMS.

◆ kRegVRMSOS

const uint16_t sfDevADE7953::kRegVRMSOS = 0x388
staticprotected

VRMS offset.

◆ kRegWriteProtect

const uint16_t sfDevADE7953::kRegWriteProtect = 0x040
staticprotected

Write protection bits (Bits[2:0])

◆ kRegZXTout

const uint16_t sfDevADE7953::kRegZXTout = 0x100
staticprotected

Zero-crossing timeout.

◆ kUnlockKey

const uint8_t sfDevADE7953::kUnlockKey = 0xAD
staticprotected

Key written to kRegUnlock to unlock 0x120.


The documentation for this class was generated from the following files: