Is there any example on hoe to use the MX3kck with Pmod Ad5 and saving data to Pmod SD?
I got them both working individually but having trouble getting them to work together. I pretty sure its something to do with the SPI or DSPI setups or calls.
After I run this command which makes the SD selected " SD.begin(chipSelect_SD) " I can no longer get PmodAD5 data.
How would I turn the Pmodad5 back on make it the active one?
Whats an good way to get data from PmodAd5 and save it to Pmod SD at fast rates.
AD7193 myAD7193; //char tempString [10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; unsigned long data = 0; double voltage = 0;
File myFile; const int chipSelect_SD=16; //CS is at logical port 16 const int LD4=42; //LD4 is at logical port 42 const int LD5=43; //LD4 is at logical port 43
pinMode(LD4,OUTPUT); //set LD4 as output pinMode(LD5,OUTPUT); //set LD5 as output digitalWrite(LD4,LOW); //turn OFF LD4 to start with digitalWrite(LD5,LOW); // turn OFF LD5 to start with
if(!SD.begin(chipSelect_SD)) //************************************** <<<<After I run this command I can no longer get A/D data*************************************************** { digitalWrite(LD4,HIGH); //was digitalWrite(LD4,HIGH); return; }
Question
Jrlin
Hello
Is there any example on hoe to use the MX3kck with Pmod Ad5 and saving data to Pmod SD?
I got them both working individually but having trouble getting them to work together. I pretty sure its something to do with the SPI or DSPI setups or calls.
After I run this command which makes the SD selected " SD.begin(chipSelect_SD) " I can no longer get PmodAD5 data.
How would I turn the Pmodad5 back on make it the active one?
Whats an good way to get data from PmodAd5 and save it to Pmod SD at fast rates.
Thanks for all the help
Code below if you want to look at it
PmodAD5 on JE connector
Pmod SD on JC connector
Using Mx3ck board.
#include <AD7193.h>
#include <DSPI.h>
#include <SD.h>
/******************************************************************************/
/************************ Variables Definitions *******************************/
/******************************************************************************/
AD7193 myAD7193;
//char tempString [10] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
unsigned long data = 0;
double voltage = 0;
File myFile;
const int chipSelect_SD=16; //CS is at logical port 16
const int LD4=42; //LD4 is at logical port 42
const int LD5=43; //LD4 is at logical port 43
void setup()
{
Serial.begin(115200);
if(myAD7193.Init())
{
Serial.println("AD7193 OK");
}
else
{
Serial.println("AD7193 Error");
}
/*! Resets the device. */
myAD7193.Reset();
/*! Select Channel 0 */
myAD7193.ChannelSelect(AD7193_CH_0);
/*! Calibrates channel 0. */
myAD7193.Calibrate(AD7193_MODE_CAL_INT_ZERO, AD7193_CH_0);
/*! Selects unipolar operation and ADC's input range to +-2.5V. */
myAD7193.RangeSetup(0, AD7193_CONF_GAIN_1);
//myAD7193.SetRegisterValue(1,0x010008,3,1);
pinMode(LD4,OUTPUT); //set LD4 as output
pinMode(LD5,OUTPUT); //set LD5 as output
digitalWrite(LD4,LOW); //turn OFF LD4 to start with
digitalWrite(LD5,LOW); // turn OFF LD5 to start with
pinMode(chipSelect_SD,OUTPUT);
digitalWrite(chipSelect_SD,HIGH);
if(!SD.begin(chipSelect_SD)) //************************************** <<<<After I run this command I can no longer get A/D data***************************************************
{
digitalWrite(LD4,HIGH); //was digitalWrite(LD4,HIGH);
return;
}
}
void loop()
{
data = myAD7193.SingleConversion();
voltage = myAD7193.BinaryToVoltage(data);
myFile.println(voltage);
Serial.println(voltage);
}
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.