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.

BQ25883: /BQ25882 How to read ADC values

Part Number: BQ25883

Hi,

I'm using the bq2588x linux driver, but I'm havin difficulties understanding the ADC voltage and current readings coming out of the bq2588x_update_status function. If I understand correctly, these functions should report in mV and mA quantities, but I'm getting values in the KV and KA range that do not match at all with the testing conditions. I have already spotted a programming mistake where all values coming out of the chip are multiplied by 256 because the LSB multiplication factor should be 1, not 256 as defined in the header. LSB of the low byte of an ADC register is always is 1mV or 1mA as defined in datasheet. But then still I'm getting values I cannot match with what I'm seeing on the bench. The datasheet mentions I can set the precision of the ADC between 12 and 15 bits. Does that mean the mV/mA of the LSB changes accordingly? i.e with 15 bits precision LSB is 1/8mV while with 12 bits precision LSB is 1mV? This is not mentioned in the ADC register descriptions.

Datasheet does also mention that ADC values are in signed 2-s complement words, while the driver all reads them as u16 and then converts to int(32). Could that also be causing wrong readings?

 

  • Jan,

    Could you please insert print statements for the following variables, so we can trace through the code?

    • i2c_smbus_read_word_data
    • bq2588X_read_word
    • bq2588X_read_adc_data
    • bq2588X_read_bus_curr

    I want you to let me know the results of these values with 1A being drawn into VBUS (standard boost mode) and 1A drawn out of VBUS (OTG buck mode). Ideally, the code should report +1A and -1A respectively. If not, we can try and figure out what is going wrong.

    Thanks,

    Ricardo

  • Hi,

    In our application, we monitor the bq25883 with a SoC that is the load at the same time and also consumes quite a lot of power (between 500mA and 1500mA). We also have a MAX17261 fuel gauge connected.

    When I hook up a lab supply set for 5V and max 2A (equivalent of a normal USB charger), it takes 1.682A from the supply. This equals exactly 8.41W. Is IBUS supposed to be measured at VSYS (8.4V) or VBUS (5V?). If it is to be measured at VSYS, this would mean exactly the 1A you are asking for. At this settings, the bq ADC reports a values of 0x3d06 (15622) on all the functions you have listed. When I limit the lab supply current to exactly 1A, the voltage on the lab supply drops down to 4.55V and IBUS ADC values read 0xd503, (54531). We don't use OTG so I haven't got any values for that.



     

  • Jan,

    There seems to be an endian-ness (big endian vs. little endian) issue with the i2c_smbus_read_word_data.

    When you limit the bus current to 1A you say that you read 0xD503 (this would translate to -11.0040 A, this is not possible).  If you swap the upper and lower bytes you would read 0x03D5 (this would translate to 0.9800A)

    When you expect 1.682A, you read 0x3D06 (15.6210 A). Swapped, this would be 0x063D (1.5960 A)

    This function is not defined by our driver code, but rather the Linux header used. A workaround would be to swap the upper and lower bites after reading from i2c_smbus_read_word_data. 

    Thanks,

    Ricardo

  • Thanks! Now it all makes perfect sense. Please note that in the original driver code all BQ2588X_***_ADC_LB_LSB are set to 256, whcih in fact should be 1 according to the datasheet.