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.

ADS1115 switch

Other Parts Discussed in Thread: ADS1115, ADS1114

Hello, 

I have one question about the ADS1115. If I set a control register's for single-shoot, I get a bad value.

My procedure: I set a control register's (first step: Lo_thresh register and Hi_thresh register, second step: entire Config register) for single-shoot. I wait for signal give by alert pin an I read a value, but I get conversion value for previous settings of MUX. Can you tell me why?

P.S.: If I wait additional 2 ms before read a value from Conversion register, a value, that I read, is correct.

  • Hi,

    I need to ask you a few questions to ensure I understand the problem.   What are the thresh register values and the Config register settings?  What is the voltage at the inputs? If you can please provide the detailed sequence when you write to the Lo/Hi thresh and Config registers and conversion register read.   Please include in the detailed sequence the pointer register writes.  

    The programmable digital comparator provides an alert on the dedicated pin when one of the conversion readings exceeds one of the thresholds; therefore in general is used in continuous conversion mode.

    Thank you and Best Regards,

    Luis

  • Hello,

    sorry for my delay. This is my sequence:
    temp_CONF_REG[0] = 0x00;
    temp_CONF_REG[1] = 0x00;

    result = I2C_Write(I2C0, ADR1115, 2, &temp_CONF_REG[0], 2);

    temp_CONF_REG[0] = 0x80;
    temp_CONF_REG[1] = 0x00;

    result = I2C_Write(I2C0, ADR1115, 3, &temp_CONF_REG[0], 2);

    //max.1,3V
    temp_CONF_REG[0] = 0xF5;       
    temp_CONF_REG[1] = 0x80;
    result = I2C_Write(I2C0, ADR1115, 1, &temp_CONF_REG[0], 2);

    while (GPIO_PinInGet(ALERT_GPIO_PORT, ALERT_GPIO_PIN));
    Delay(20);
    result = I2C_Read(I2C0, ADR1115, 0, value, 2);     
                
    temp_CONF_REG[0] = 0x00;
    temp_CONF_REG[1] = 0x00;

    result = I2C_Write(I2C0, ADR1115, 2, &temp_CONF_REG[0], 2);

    temp_CONF_REG[0] = 0x80;
    temp_CONF_REG[1] = 0x00;

    result = I2C_Write(I2C0, ADR1115, 3, &temp_CONF_REG[0], 2);

    //max. 0,39V
    temp_CONF_REG[0] = 0xE9;        
    temp_CONF_REG[1] = 0xE0;
    result = I2C_Write(I2C0, ADR1115, 1, &temp_CONF_REG[0], 2);

    while (GPIO_PinInGet(ALERT_GPIO_PORT, ALERT_GPIO_PIN)); 
    Delay(20);
    result = I2C_Read(I2C0, ADR1115, 0, value, 2);  

    So, if I give delay between while function, that it waits on ALERT pin, and read function, I get correct value. If not, value is wrong. 
    Circuit has 2,5V suply voltage, on one pin is max. voltage 0,39V and on the next is max. voltage  1,3V.
    I configure device on single-shot mode but I don't know why device works bad.
  • Hi,

    The ADS1115 digital comparator works by comparing the ADC conversion data results to the high and low thresholds programmed in the Lo_thresh and Hi_thresh registers.  Therefore, this function is typically used on the continuous conversion mode, where the device is continuously converting and when the conversion data result exceeds one of the thresholds, the ALERT pin will assert. 

    In your program above you are using the single shot mode.   The digital comparator ALERT pin will not trigger until the conversion is complete; and the necessary delay for the conversion is a function of the selected data rate.  For example, if you have configured the device to 860SPS; the user will need to wait more than ~1.16 ms for the conversion data to be available and for the ALERT pin to assert.

    Best Regards,

    Luis 

  • Hi, 

    I understand you, but I wait to ALERT pin in this function: while (GPIO_PinInGet(ALERT_GPIO_PORT, ALERT_GPIO_PIN)). If The ALERT pin is set to High I start with read value, but I must wait additional time. For example 5 ms.  My question is why?

    Best Regards

    Petr

  • Hi Petr,

    Please post the code of the GPIO_PinInGet function and a schematic/diagram showing the supply and input voltage connections of the ADS1115. In the default settings, the ALERT pin asserts low when is active.  I am not sure what is meant by 'if ALERT pin is set to high I start with read value' 

    It appears that the PGA gain configurations and the data rate settings are changing in the two steps; one step measures AIN3 to GND at 128SPS with +/-2.048V scale and the second measurement AIN2 to GND at 860SPS with  +/-0.512V scale.  A value of 0 is written to the Lo_thresh register; and a value of negative full-scale to the Hi_thresh register value.  Is this correct?

    Best Regards,

    Luis

     

     

     

  • Hi Petr,

    The comparator settings appear to be set to the default traditional comparator with hysteresis where Bit[4] is set to 0. In the settings above, the Lo_thresh is set to 'x0000' and Hi_thresh is set to 'x8000' or negative full scale (values are in two's complement format).  Since the Hi_thresh value is more negative than the Lo_thresh value, the comparator will always trigger; and since the settings are with the comparator with hysteresis, the comparator will not deassert in this case...  The Hi-Thresh register must be larger than the Lo_thresh register value.

    You may want to try setting bit[4]=1 (window comparator without hysteresis) and set the Hi_thresh to a value that is more positive or larger than the Lo_thresh value. The user also needs to account for the different PGA gain or scale settings.  The threshold values are in two's complement format and need to be scaled or adjusted according to the PGA gain setting used.

    Best Regards,

    Luis

  • Hi Luis, 

    your description is correct. I did one mistake in description. I mean, if ALERT pin is set to low I start with read value. Code is correct.

    Best Regards,

    Petr

  • Hi Luis, 

    settings of Tresh Registers based from description on page 15 of Datasheet, chapter "CONVERSION READY PIN (ADS1114/5 ONLY)". Where is written: 

    The ALERT/RDY pin can also be configured as a
    conversion ready pin. This mode of operation can be
    realized if the MSB of the high threshold register is
    set to '1' and the MSB of the low threshold register is
    set to '0'.

    I need measurement, that works in Single-Shoot mode, for more inputs and settings. For example like I describe during the last posts.

    Best Regards,

    Petr

  • Petr,

    We were confused at what you are trying to do, so thanks for helping us understand.  Yes, you should be able to use the ALERT pin as conversion ready.  The best way to analyze what is going on is with an oscilloscope.  One thing that might be happening is a slight delay from the actual conversion startup relative to your command.  This is where it is good to use a scope to verify the timing.  If you are using an I2C peripheral on your micro, you may be transitioning to the next command line (wait/poll state) too early.  The peripheral may be still writing the configuration and the ALERT pin may still be low.  You could try adding a slight delay just before you start to poll to make sure the ALERT pin is in the correct state.

    Best regards,

    Bob B

  • Hi Bob and Luis,

    thanks for your help. Bob, you had a truth with: "The peripheral may be still writing the configuration and the ALERT pin may still be low."

    Excuse me for my English isn't very good.

    Best Regards,

    Petr