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);
}```