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.
