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.

ADS1114: output consistency

Part Number: ADS1114

Hi Sir,

I have give below my code for ads1114 writing and reading data from it with HAL i2c library for STM32L4S9AII board. But I get values not consistently. 

 So, please refer it and help me. 

Thank you. 

// Function "init_ADS1114"  initializes ads1114 and read reset value of Config Register.

void init_ADS1114(void)
{

bool stat = true;

uint8_t rdd3[2];

hal_stat = HAL_I2C_Master_Transmit(&hi2c3, (0x48 << 1), 0x00, 1, 50); // I2C transmit 1 byte SLAVE ADDRESS + Write and read ACK status

if(hal_stat != HAL_OK)
{

return stat = false ;
}

hal_stat = HAL_I2C_Master_Transmit(&hi2c3, (0x48 << 1), 0x00, 1, 50); // I2C transmit 1 byte Address pointer register and read ACK status

if(hal_stat != HAL_OK)
{

return stat = false ;
}


hal_stat = HAL_I2C_Mem_Read(&hi2c3, 0x48 << 1, 0x01, 1, rdd3, 2, 100);   // Read  default value of config register

}

int16_t ADS_Result = 0;
int16_t start_ADS_1114(void)
{
uint16_t wrt =0x8483; //  Configuration value for Configuration reg

uint8_t ADS_RAW[2] = {0};


bool status;


hal_stat = HAL_I2C_Mem_Write(&hi2c3, 0x48 << 1, 0x01, 1, &wrt, 2, 100);   writing value to config register (0x8483 = 15bit -  Start a single conversion,14:12 bits - MUX[2:0] - 000 : AINP = AIN0 and AINN = AIN1 (default),

                                                                                11:9 bits - PGA[2:0] - 010 : FSR = ±2.048 V (default),8-bit- MODE -  0 : Continuous-conversion mode,7:5 bits - DR[2:0] - 100 : 128 SPS (default),4 bit - COMP_MODE - 0 :                                                                                   Traditional comparator (default), 3 bit - COMP_POL - 0 : Active low (default), 2 bit -COMP_LAT - 0 : Nonlatching comparator . The ALERT/RDY pin does not latch when                                                                                        asserted(default) , 1:0 bit - COMP_QUE[1:0] -   11 : Disable comparator and set ALERT/RDY pin to high-impedance (default) )

HAL_Delay(50);

hal_stat = HAL_I2C_Mem_Read(&hi2c3, 0x48 << 1, 0x01, 1, ADS_RAW, 2, 50);    //reading the value in config register

status = (ADS_RAW[1] & (1 << 7))?1:0 ;                                                                 // checking for 15 bit OS for device conversion status  

while(status != 1);                                                                                                    // waiting till OS bit is set

hal_stat = HAL_I2C_Mem_Read(&hi2c3, 0x48 << 1, 0x00, 1, &ADS_Result, 2, 100); // reading  ADC data  from conversion register 

return ADS_Result;
}

  • Hello Dinesh,

    What exactly do you mean by inconsistent data? Can you elaborate on what you are seeing? Also, can you please share a schematic as well as the I2C transactions?

    Regards,

    Aaron Estrada

  • Hello Aaron,

    Thanks for replying.

    I am using ADS1114 for converting the heat flux signal into digital value. when I try to read HE heat flux value for a hot object it is giving digital data but the values fluctuate.  I am not getting Continuous correct digital values.

    I am using STM32 Cube IDE for programming and while debugging I read ADS1114 digital data in Expression Window.

    I attached a file for Schematic.

    The below function sends the 7-bit device address.

    1. hal_stat = HAL_I2C_Master_Transmit(&hi2c3, (0x48 << 1), 0x00, 1, 50); // I2C transmit 1 byte SLAVE ADDRESS + Write and read ACK status

    IN I2C function "HAL_I2C_Master_Transmit"

    1st parameter is I2C Handler,

    2nd parameter is SLAVE ADDRESS, // 1 BYTE    . If we put slave address as  (0x48 << 1) left shift by 1. HAL  I2C read and Write functions take care of setting and resetting of read/write bit. 

    3rd parameter is DATA to address pointing Register // 1BYTE

    4th parameter is Size of  data to  be sent.  // 1BYTE

    5th parameter is Time out 

    It returns the status of I2C transaction.

    The next three steps are to send the Address Pointer Register

    2 . hal_stat = HAL_I2C_Master_Transmit(&hi2c3, (0x48 << 1), 0x00, 1, 100); // I2C transmit 1 byte Address pointer register and read ACK status

    3 . hal_stat = HAL_I2C_Mem_Write(&hi2c3, (0x48 << 1), 0x01, 1, 0x8483, 2, 100);  

    In the "HAL_I2C_Mem_Write" function I am trying to write into Config Register address 0x01 with value 0x8483 of 2 Byte data.

    Before reading ADS data I try to read the status Config Register 15 bit  position.

    4 .hal_stat = HAL_I2C_Mem_Read(&hi2c3, (0x48 << 1), 0x00, 1, ADS_RAW, 2, 100);    //reading the value in config register

    In "HAL_I2C_Mem_Read"  function I'm  trying to read Converted value in Conversion register address 0x00 and store in 2 BYTE "ADS_RAW" variable.

    Hope this is clear and waiting for your reply.

    Thank you,

    Dinesh Reddy.

  • Hi Dinesh,

    Thank you for sending this over. What is the voltage range of input on AIN0? I see that AIN1 is set to 1.65V and the FSR of the device is set to +/- 2.048V and I would just like to make sure that the FSR is set properly. Some scope captures of the inputs would be helpful as well. 

    Regards,
    Aaron Estrada

  • Hi Aaron,

    Once again thank you for replying,

    The resistors are DNP(Do Not Populate). So no voltage across AIN0 and AIN1. And  I set FSR to +/- 0.256V. So  I loaded config register with 0x8F83. I am getting values like 0 , 256 , 512 , 768 and  soo on. But not getting output as 1,2,3... Is the values what I am getting is correct or should I make  any  changes in configuration register. Waiting for your replay.

    Thank You,

    V Dinesh Reddy 

  • Hi Dinesh,

    Thanks for the information! You mentioned that you are using an FSR of +/- .256V but looking at your code, it shows you are writing 0x8483 to the configuration register. This would set the the FSR to +/- 2.048V. The FSR should be set according to the input voltage and the input voltage should not exceed that range.

    That being said, what you are seeing make sense from a output code standpoint. However, it would be great to see the input level you are measuring and compare that with the ADC output code that is generated. Is the input at a constant level or varying? Based on the output data you are seeing, it seems like the input level is varying but you can confirm. 

    You are also using continuous conversion mode which is fine but the ADC will constantly be converting. You can set the device to single-shot mode and measure a known Vin and we can check to see if the output code is expected. 

    Regards,
    Aaron Estrada