ADS1256 sampling rate

Hello Everyone,

I have interfaced ADS1256 high precision board with Arduino and I am also able to read the data.
The problem is I am able to get only 800 to 900 sa,ples per seconds. Even if I am changing data rate in the register till 7500 and 15000 sps its not making any change.
Not able to figure out the problem in the code.

Interfacing ADC for the first time, Please help me.

Thanks

Not able to figure out the problem in the code.

Me neither, because you didn't post any code.

You have italics in your code due to the [­i] in the array index.

Did you read this before posting a programming question ?

Hello,

No i did not read it before posting, sorry for that.
So i have attached .ino file with this reply.

Thanks.

multi_channel_read_1256_new.ino (2.57 KB)

anurag2508:
Hello,

No i did not read it before posting, sorry for that.
So i have attached .ino file with this reply.

Thanks.

And now those of us on mobile devices can't see your code at all

Here it is Auto Formatted and in code tags

#include<SPI.h>

#define ADS_SPISPEED   5000000
#define reset_pin      8 //ADS1256 reset_pin pin
#define Drdy_pin       9 //ADS1256 data ready
#define Cs_pin         10 //ADS1256 chip select
#define DIN            11 //MOSI
#define DOUT           12 //MISO
#define CLK            13

byte status_reg = 0x00 ;  // address (datasheet p. 30)
byte status_data = 0x01; //status: Most Significant Bit First, Auto-Calibration Disabled, Analog Input Buffer Disabled
byte adcon_reg = 0x02; //A/D Control Register (Address 02h)
byte adcon_data = 0x20; // 0 01 00 000 => Clock Out Frequency = fCLKIN, Sensor Detect OFF, gain 1
byte drate_reg = 0x03; // Choosing Data Rate register = third register.
byte drate_data = 0b1010001; // 11000000 = 3,750SPS

void setup()
{
  Serial.begin(115200);
  SPI.begin();
  SPI.beginTransaction(SPISettings(ADS_SPISPEED, MSBFIRST, SPI_MODE1));
  pinMode(Cs_pin, OUTPUT);
  pinMode(Drdy_pin, INPUT);
  pinMode(reset_pin, OUTPUT);
  digitalWrite(reset_pin, LOW);
  delayMicroseconds(100);
  digitalWrite(reset_pin, HIGH);
  Write_Register(0x50 | status_reg, 0x00, status_data);
  Write_Register(0x50 | adcon_reg, 0x00, adcon_data);
  Write_Register(0x50 | drate_reg, 0x00, drate_data);
}

void Write_Register(byte Register_Address, byte cmd, byte Value)
{
  digitalWrite(Cs_pin, LOW);
  SPI.transfer(0xFE);
  SPI.transfer(Register_Address);
  SPI.transfer(cmd);
  SPI.transfer(Value);
  SPI.transfer(0xF0); // perform offset and self calibration
  digitalWrite(Cs_pin, HIGH);
  delay(1);
}

void loop()
{
  unsigned long adc_val[8] = {0, 0, 0, 0, 0, 0, 0, 0};
  digitalWrite(Cs_pin, LOW);
  for (int i = 0; i <= 7; i++)
  {
    wait_DRDY();
    byte channel = i;
    byte data = (channel << 4) | (1 << 3); //AIN-channel and AINCOM
    Write_Register(0x50 | 1, 0x00, data);
    //SYNC command 1111 1100
    SPI.transfer(0xFC);
    delayMicroseconds(4);
    //WAKEUP 0000 0000
    SPI.transfer(0x00);
    SPI.transfer(0x03); // Read  Data Continuously;
    delayMicroseconds(4);
    adc_val[i] = SPI.transfer(0);
    adc_val[i] <<= 8; //shift to left
    adc_val[i] |= SPI.transfer(0);
    adc_val[i] <<= 8;
    adc_val[i] |= SPI.transfer(0);
  }
  for (int i = 0; i <= 7; i++)
  {
    if (adc_val[i] > 0x7fffff)
    {
      //if MSB == 1
      adc_val[i] = 16777216 - adc_val[i]; //do 2's complement
    }
    float  Read_Data = adc_val[i] * 0.0000002980232;
    Serial.print(Read_Data);
    Serial.print("\t");
  }
  Serial.println();
  digitalWrite(Cs_pin, HIGH);
  SPI.endTransaction();
}

void wait_DRDY(void)
{
  while (!digitalRead(Drdy_pin) == LOW)
  {
    continue;
  }
}

  delay(1);I'd think hard about what effect that is having on your sample rate, if I were you.

Hello,

Thanks for your reply.
Actually If i am removing that delay(1); from the code, then i would get only 0 value continuously in the serial monitor.

I f i put any value less than that In that case also i am receiving 0 in output,

So i donet know where actual problem is in the code.

Try 250 microseconds instead.
See how that goes.

I f i put any value less than that

In a delay(), the only sensible value less than one is zero, and that's not particularly sensible at all.

no actually, by less than that i mean to say is in microseconds only not delay(0);
I f i give in microseconds also it gives 0 value in output continuously.

Which is why I wrote "Try 250 microseconds instead", and not "get rid of the delay completely".

it works for 800 Microseconds but for 250 i just see reading 0. At 800 it reads but shows 0 many times. and if i reduce more delay serial monitor stops reading in between.

Time to hit the datasheets and check those settings and timings