We are using the ade9113.c/.h example code in our design and we attempting to use the ade9113_convert_to_millivolts() to read data from the x_WAV Registers but there seems to be no accounting for any kind of scaling in the code.
Specifically, we are using the ADE9103 device to measure DC voltage and DC Current.
Each x_WAV Register is 24 bits and stores information in a two's complement format so it can represent a positive and negative voltage range. A 24 bit signed integer can represent a range can be -8,388,608 to 8,388,607.
Page 6 of the datasheet indicates:
- the Analog input Differential Voltage Range for IP and IM pins (current) is +/- 31.25 mV
- the Analog input Single-ended Voltage Range for IP and IM pins (current) is +/- 500 mV

Current Calculation: +/- 31.25mV
When I read the contents of the I_WAV (current) register, the value it holds, or each unit should represent the entire range divided by how many units of measurement or (31.25 mV) / (8,388,607) or 0.0000037252907425511768521281304512179 mV...
So I would think when I read this register I should be multiplying the contents by 0.00000372529 to properly scale it to mV.
Voltage Calculation: +/- 31.25mV
Using the same reasoning, when I read the contents of the Vx_WAV (voltage) register the value it holds, or each unit should represent the entire range divided by how many units of measurement or (500 mV) / (8,388,607) or .000059604651880818829634050087219487 mV...
Again, I would think when I read this register I should be multiplying the contents by .0000596046518 to properly scale it to mV.
The ade9113_convert_to_millivolts() function:
Meanwhile the ade9113_convert_to_millivolts() function does not appear to do any scaling when reading the x_WAV Registers. It only sign extends the value. see code below:
/**
* @brief Convert a 24-bit raw sample to millivolts.
* @param dev - The device structure.
* @param dev_no - Device number (0 if in not in daisy-chain setup).
* @param ch - Device channel.
* @param mv_val - Value in millivolts.
* @return 0 in case of success, negative error code otherwise.
*/
int ade9113_convert_to_millivolts(struct ade9113_dev *dev,
uint8_t dev_no, enum ade9113_wav_e ch, int32_t *mv_val)
{
int64_t value = 0;
if (!dev)
return -ENODEV;
if (ch > ADE9113_V2_WAV)
return -EINVAL;
switch (ch) {
case ADE9113_I_WAV:
/* times 2, two's complement data */
value = (int64_t)dev->i_wav[dev_no];
break;
case ADE9113_V1_WAV:
value = (int64_t)dev->v1_wav[dev_no];
break;
default:
value = (int64_t)dev->v2_wav[dev_no];
break;
}
*mv_val = (int32_t)value;
return 0;
}I
Questions:
- I want to know if my math (above) for scaling the x_WAV registers for current and voltage is correct or not. If not what am I doing wrong.
- Any idea why there is no scaling done in the ade9113_convert_to_millivolts() function? Are they expecting the calling function has to handle this scaling?
- After scaling is there anything else that needs to be done to convert it to amperage?
Thanks - mike
