ADS1234 data rate problem

Hello,

I am working with external adc ADS1234 to sample three channels each time, I am using library from GitHub - HamidSaffari/ADS123X: An Arduino library to interface with TI ADS1232 and ADS1234 MultiChannel 24-bit ADC For Bridge Sensors.. The problem is that I am not able to get higher data rate since the author of the library has added more than required large delays. I tried to write the code directly on my to retrieve the data but was not successfull. Can someone help me with that. Since I am using 80 SPS and that is divided by 3 channel hence around 26 sps should be achieved. following nyquist theorem I should able to get 10 Hz of signal at max nicely. But the problem is I am only able to get a nice and smooth 800 mHz of signal at best after wards I get pointy ones from adc. Hence can someone please write me a code for retrieving signals at atleast 5 Hz. I tried to to that while following the data sheet but failed hence resorting to get help here

Here is the code that follows the library I mentioned earlier

#include <ADS123X.h>
#include <SPI.h>



#define SCALE_DOUT   12
#define SCALE_SCLK   13
#define SCALE_PDWN   5
#define SCALE_GAIN0  9
#define SCALE_GAIN1  8
#define SCALE_SPEED  7
#define SCALE_A0     4
#define SCALE_A1     3

ADS123X scale;

byte buf[4];
long adc_data1;
long adc_data2;
long adc_data3;
int i=0;
void setup() {
  
  Serial.begin(115200);
  delayMicroseconds(100);
  for(i=1 ; i >= 0; i--) {
      digitalWrite(SCALE_SCLK, HIGH);
      digitalWrite(SCALE_SCLK, LOW);
  }
  scale.begin(SCALE_DOUT, SCALE_SCLK, SCALE_PDWN, SCALE_GAIN0, SCALE_GAIN1, SCALE_SPEED, SCALE_A0, SCALE_A1);
}

void loop() {
  scale.setSpeed(FAST);   
    scale.read(AIN1,adc_data1);
    
    buf[0] = adc_data1 & 0xFF; 
    buf[1] = (adc_data1 >> 8) & 0xFF; 
    buf[2] = (adc_data1 >> 16) & 0xFF;
    buf[3] = (adc_data1 >> 24) & 0xFF;

    for(int i=0; i<4;i++)
    {
      Serial.write(buf[i]);
    }

   delayMicroseconds(2);
   
    scale.read(AIN2,adc_data2);
    buf[0] = adc_data2 & 0xFF; 
    buf[1] = (adc_data2 >> 8) & 0xFF; 
    buf[2] = (adc_data2 >> 16) & 0xFF;
    buf[3] = (adc_data2 >> 24) & 0xFF;

    for(int i=0; i<4;i++)
    {
      Serial.write(buf[i]);
    }

    delayMicroseconds(2);
    
    scale.read(AIN3,adc_data3);
    buf[0] = adc_data3 & 0xFF; 
    buf[1] = (adc_data3 >> 8) & 0xFF; 
    buf[2] = (adc_data3 >> 16) & 0xFF;
    buf[3] = (adc_data3 >> 24) & 0xFF;

    for(int i=0; i<4;i++)
    {
      Serial.write(buf[i]);
    }
    delayMicroseconds(2);

    Serial.write(0x2F);
    delayMicroseconds(1);
    Serial.write(0x41);
    delayMicroseconds(1);
    Serial.write(0x2F);
    delayMicroseconds(1);

}```

The linked library doesn't contain delays, why do you think the author added too large delays?

On what type of Arduino are you using the ADS1234? Please post schematics of your setup.

1 Like

Arduino Uno. I saw data sheet but what author said in code is that he made delays for being safe.

Update: I saw the data sheet more carefully tthis time and that 51ms delay is justifiable. Hence I think there is no problem with the author's library. Thank you

The author doesn't mention delays in the library code and there aren't any delays in the code of the library. But there are several delays in your code. Did you mean those.

The linked library doesn't have any delay() call. Where is that number from?

Hi, sorry for the late reply, the auhor mentions delays in Cpp files and the data sheet at page 22 table 8.5 specifys the delays when channel is changed

No, the complete git repository contains the word "delay" exactly once, in the example to wait for one second before the next loop run. Do you have an old version of the code?

To wait for the filter settling you should check the DRDY signal (method is_ready()) and not waiting a predefined time.

Hi,

I am using this library for ADS1234

if you go to CPP file and read line 168-213, you can know what I meant to say. It was delay as far as I could understand(of course "delay" was not mentioned in the code)

Sorry for late reply

A delay is waiting in the code for a given amount of time without doing something.
That code waits for a spike on DOUT but has a timeout for the case there is a problem with the hardware. That's definitely not a delay.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.