This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

INA219: INA219 Operational Clarification

Part Number: INA219

Hello,

When operating INA219, if we choose averaging modes for INA219_CONFIG_BADCRES and INA_219_CONFIG_SADCRES, which range from 2 to 128 averages, and if the ina219 is working on continious mode,

will it take longer time to read current from ina219? or does the ina219 does the averaging while continiously running, and when i get the current register, it reflects the latest value.

What I am trying to understand is that will it slow my main loop when I am reading the current from the ina219, when averaging modes are used.

Here is my code for initializing the ina219:

void setCalibration_32V_2A(uint32_t ui32WorkerAddress) {

ina219_calValue = 4096;

ina219_currentDivider_mA = 10.0f; // Current LSB = 100uA per bit (1000/100 = 10)
ina219_powerMultiplier_mW = 2.0f; // Power LSB = 1mW per bit (2/1)

// calculate ui8CalRegister
ui8CalRegister[0] = (ina219_calValue >> 8) & 0xFF;
ui8CalRegister[1] = ina219_calValue & 0xFF;

// initial send of calibration register
I2CSend(ui32WorkerAddress, INA219_REG_CALIBRATION, ui8CalRegister, 2);

uint16_t config = INA219_CONFIG_BVOLTAGERANGE_32V |
INA219_CONFIG_GAIN_8_320MV |
INA219_CONFIG_BADCRES_12BIT_8S_4260US |
INA219_CONFIG_SADCRES_12BIT_8S_4260US |
INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS;

/*
uint16_t config = INA219_CONFIG_BVOLTAGERANGE_32V |
INA219_CONFIG_GAIN_8_320MV |
INA219_CONFIG_BADCRES_12BIT |
INA219_CONFIG_SADCRES_12BIT_1S_532US |
INA219_CONFIG_MODE_SANDBVOLT_CONTINUOUS;
*/

ui8Register[0] = (config >> 8) & 0xFF;
ui8Register[1] = config & 0xFF;
I2CSend(ui32WorkerAddress, INA219_REG_CONFIG, ui8Register, 2);

}

And here is how I read the current register:

uint16_t getCurrent_raw(uint32_t ui32WorkerAddress) {
// resend calibration register
I2CSend(ui32WorkerAddress, INA219_REG_CALIBRATION, ui8CalRegister, 2);
// receive op
I2CReceive(ui32WorkerAddress, INA219_REG_CURRENT, ui8Register, 2);
return ((ui8Register[0] << 8) | ui8Register[1]);
}
  • Hello,

    The result register can be read at any time, and will just show the last value that was ready after averaging was done.  So, the read operation will take the same amount of time either way, and not slow the code, but if you read before the averaging is done, then you will get the previous value.