Other Parts Discussed in Thread: ADS124S08
Hello sir,
I have tried logging the data of ADS124S08 EVM to SD card using arduino, but data is not logging to a file which is present in SD card. I have attached my code here. I am using voltage source (6V) as a input to EVM. But I am able to get the data from EVM using arduino but logging is not happening.
Thanks
Regards
Sushmita Chaudhary
#include <SPI.h> #include <SD.h> #include <TimerOne.h> #define START 6 #define RESET 7 #define CS 8 #define SD_CS_PIN 53 int32_t stat; SPISettings settings1(4000000, MSBFIRST, SPI_MODE1); void setup() { Serial.begin(9600); Serial.print("Initializing SD card..."); if (!SD.begin(SD_CS_PIN)) { Serial.println("Card failed, or not present"); return; } Serial.println("card initialized."); SPI.begin(); pinMode(CS,OUTPUT); pinMode(RESET, OUTPUT); pinMode(START,OUTPUT); digitalWrite(RESET , HIGH); delay(5); 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(0xAC); // WREG write AIN10-AINCOM,(1010 1100) binary,MUXP and MUXN selection SPI.transfer(0x08); // gain =1 SPI.transfer(0x14); // DATA RATE 20 SPS SPI.transfer(0x19); //REF on (0001 10-ref 01) 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); digitalWrite(CS, HIGH); if (stat & 0x800000) { stat = (stat | 0xFF000000); } File dataFile = SD.open("datalog.txt", FILE_WRITE); if (dataFile) { dataFile.println(stat); dataFile.close(); } else { Serial.println("error opening datalog.txt"); } } } SPI.endTransaction(); }