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.

ADS124S08EVM: Output data analysis from strain gauge interfaced with EVM ADC and arduino uno

Part Number: ADS124S08EVM
Other Parts Discussed in Thread: ADS124S08

Hello sir,

Actually I have done SPI interfacing with skin friction sensor as a input using EVM ADC and arduino UNO. When I am loading the skin friction sometimes the data will change and sometimes it will not change and sometime the data will repeat for some time then it will change. Please suggest what is the problem? How we will ensure that particular digital value belongs to that analog value?

#include <SPI.h>
#include <TimerOne.h>
#define START 6
#define RESET 7
#define CS  4
long signed int stat;
SPISettings settings1(4000000, MSBFIRST, SPI_MODE1);

void setup() {
SPI.begin();
pinMode(CS,OUTPUT);
pinMode(RESET, OUTPUT);
pinMode(START,OUTPUT);
digitalWrite(RESET , HIGH);
delay(5); // 
Serial.begin(9600);
SPI.beginTransaction(settings1);
digitalWrite(CS, LOW);
digitalWrite(START,LOW);
}

void loop() {
for(int i=0;i<10;i++)
{
if(i==0){
SPI.transfer(0x42); // WREG register adress
SPI.transfer(0x07); // WREG byte number -1
SPI.transfer(0x24); // WREG write AIN2-AIN4
SPI.transfer(0x07); //128 gain
SPI.transfer(0x1E); // DATA RATE 4000 SPS
SPI.transfer(0x10); //REF
SPI.transfer(0x00); // IDAC MAG
SPI.transfer(0xFF); // IDAC MUX
SPI.transfer(0x00);// Vbias
SPI.transfer(0x14);// Timeout bit second =1 ,default is 10h
SPI.transfer(0x08); // start converting command
delay(1);
}
else
{
SPI.transfer(0x12); //RDATA command 
stat = SPI.transfer(0) ;
stat = (stat<<8) | SPI.transfer(0); 
stat = (stat<<8) | SPI.transfer(0); 
Serial.print(stat);
Serial.print("\n");
delayMicroseconds(250);// need an additional delay to allow the next conversion period to end.
}
//digitalWrite(CS,HIGH);
}
SPI.endTransaction();

}

Yellow is the clock pulse, green is Dout in digital oscilloscope.

  • Hi Sushmita,

    Your program loop only lasts a few milliseconds, so I'm not sure what you expect to see.  Also, the output of the ADS124S08 is binary 2's complement so you need to properly sign-extend the data from a 24-bit value to the signed 32-bit value.  You need to also make sure that your sensor connections are solidly connected to the EVM.

    Another issue is the gain register setting you are using.  This is an invalid setting as you are attempting to use a gain of 128 with the PGA disabled.  The PGA must be enabled if you wish to use a gain greater than 1.  With the PGA disabled you must set the gain to 1.  For a gain of 128 and PGA enabled the setting is 0x0F and not 0x07.

    The scope shot should show the entire transaction to include the RDATA command and all 3 bytes of the data. This would require seeing the SCLK, DOUT and DIN from the ADS124S08.  You may also want to toggle CS for the communication by setting it low before the RDATA command is transmitted, and setting the CS back high after the last SPI.transfer(0).  This will ensure that if there were any communication issues in a previous communication, the SPI bus will be reset at the next read cycle.

    Best regards,

    Bob B

  • Hi Bob,
    Sorry I have send you the wrong file, the new code is as follows:


    #include <SPI.h> #include <TimerOne.h> #define START 6 #define RESET 7 #define CS 4 //#define DRDY 8 long int stat; //volatile int DRDY_state = LOW; SPISettings settings1(4000000, MSBFIRST, SPI_MODE1); void setup() { SPI.begin(); //pinMode(DRDY, INPUT); pinMode(CS,OUTPUT); pinMode(RESET, OUTPUT); pinMode(START,OUTPUT); digitalWrite(RESET , HIGH); delay(5); Serial.begin(9600); SPI.beginTransaction(settings1); digitalWrite(CS, LOW); digitalWrite(START,LOW); } void loop() { for(int i=0;i>=0;i++) { if(i==0){ SPI.transfer(0x42); // WREG register adress SPI.transfer(0x07); // WREG byte number -1 SPI.transfer(0x24); // WREG write AIN2-AIN4 SPI.transfer(0x0F); //128 gain SPI.transfer(0x1E); // DATA RATE 4000 SPS SPI.transfer(0x10); //REF SPI.transfer(0x00); // IDAC MAG SPI.transfer(0xFF); // IDAC MUX SPI.transfer(0x00);// Vbias SPI.transfer(0x12);// Timeout bit second =1 ,default is 10h SPI.transfer(0x08); // start converting command delay(1); } else { digitalWrite(CS, LOW); SPI.transfer(0x12); //RDATA command stat = SPI.transfer(0) ; stat = (stat<<8) | SPI.transfer(0); stat = (stat<<8) | SPI.transfer(0); Serial.print(stat); Serial.print("\n"); digitalWrite(CS, HIGH); delay(1000);// need an additional delay to allow the next conversion period to end. } } SPI.endTransaction(); }

    If I set the TIMEOUT bit to 1 then is it necessary to toggle CS from LOW to HIGH during SPI Transaction?

  • Hi Sushmita,

    You fixed a few things, but you still are not sign-extending the result.  Although this code should function, you are taking 4000 samples per second but only reading one of the samples per second.  I'm still do not understand what your expectations are and what you are receiving as a result.

    Your first code showed a wait time of 250us which is at the 4ksps data rate.  But you are reading very few samples.  Now you are taking lots of samples, but only reading once a second.  There is also a significant amount of time that the print statements will take to be transmitted.  If you are going to operate the device at 4ksps, then you should be reading and transmitting the data during the conversion period of 250us, otherwise there is no need to operate the ADS124S08 device at 4ksps.

    Can you explain to me why 4ksps is needed?  Have you verified that you are able to collect the data at this rate?

    As far as the TIMEOUT, you are not required to use CS if there is enough time for the ADS124S08 to timeout.  The timeout will reset each time a complete byte of SCLKs are transmitted.  The timeout will take about 8ms before the SPI is reset.  This can function at your current delay of 1 second intervals, but will not timeout at the 250us interval you used previously.  I highly recommend using the CS if at all possible to frame your communication.

    Best regards,

    Bob B