Jump to content
  • 0

PmodAD5 and Pmod SD


Jrlin

Question

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

Hi Jrlin,

I'm looking into this now. I keep getting a timeout error when I try to download the AD7193 library from Analog Devices so I can't look at that just yet, but I'm looking at the standard SD library and board files for the MX3 as well to see if anything jumps out at me from there.

Thanks,
JColvin

Link to comment
Share on other sites

After looking into the SD library, when you call the begin() function for it (and do some digging in the folders) there is a line that resets all of the SPI settings to default.

I personally don't know if the initialization of the PmodAD5 changes any of the SPI settings (which would then be all reset when you called SD.begin), but it may be worth a try to have the SD.begin() line be placed before all of the initialization of the A/D occurs. 

Let me know if this helps.

Thanks,
JColvin

Link to comment
Share on other sites

JColvin,

I dont have hardware right now but I'll give it a try once I have it.

Using the SPI or DSPI I would first have the microcontroller signal which device I want to talk to for exmaple

Something like this?

Thanks for all the help

 

While Loop{

begin PmodAD5

Give me Data PmodAD5

Stop PmodAD5

begin Pmod SD

Save data PmodSD

Stop Pmod SD

}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...