Show Posts
Pages: [1] 2 3 ... 5
1  Using Arduino / Programming Questions / Re: Using SD card with another SPI device on: February 23, 2014, 02:03:01 pm
Thanks. So I think the best approach is to buy another arduino to handle the ADC and send the data to my old Mega to store in SD card? I also want to setup a ethernet server at some point which also use SPI. Do I need a third arduino?
2  Using Arduino / Programming Questions / Re: Using SD card with another SPI device on: February 23, 2014, 10:17:14 am
Thanks. So basically, SD.h and SPI.h cannot exist together, am I right? Is there a solution to the problem? SPI uses MISO, MOSI, SCK and CS, where SD card is default to be 4 and my ADC is 11. I don't quite understand what kind of "parameters" changes may have cause the conflict. Can you be a little bit more specific?

Does anyone had experience using SD card with another SPI device? Thanks.
3  Using Arduino / Programming Questions / Re: Using SD card with another SPI device on: February 22, 2014, 08:45:34 pm
Thanks for your reply. I am using a MUX to take samples from 16 sensors and I just thought it would be nicer to pack all the data into one string and print only that string to both the serial monitor and SD card.

But I don't believe it has to do with the SPI problem I am encountering. Thank you though.
4  Using Arduino / Programming Questions / Re: Using SD card with another SPI device on: February 22, 2014, 06:44:03 pm
I don't understand what can cause the Arduino to froze. I am assuming the SPI.transfer conflicts with something in SD.h library? Am I not suppose to use both SD card and SPI device together?
5  Using Arduino / Programming Questions / Re: Using SD card with another SPI device on: February 22, 2014, 05:42:59 pm
Thanks for your response. In your code, I see that you pull chipSelect_ACD to HIGH when trying to access the SD card. I tried your code, but it doesn't seem to work. Is the SPI chip select bus for the Arduino active low? Thanks.
6  Using Arduino / Programming Questions / Using SD card with another SPI device on: February 22, 2014, 05:14:09 pm
Hello! I got an external ADC device that communicates to my ArduinoMega over SPI, and I would like to log the data from the ADC into a SD card.

The SD card reader is a standard xBee shield with SD card, where ChipSelect=4. The ADC is a LTC1864, very easy to use. See the attachment for its timing diagram, where CONV=chipSelect_ACD=11 and SD0=MISO.
ADC datasheet: http://cds.linear.com/docs/en/datasheet/18645fb.pdf

Without the SD cad, I am able to get reading from the ADC as follows:
Code:
#include <SPI.h>

const int  chipSelect_ACD=11;
void setup() {
  SPI.begin();
  Serial.begin(9600);
}
void loop() {
  String dataString = "";
  dataString+=String(adc());
  Serial.println(dataString);
  delay(5000);
}

unsigned int adc(){
  byte inByte=0;
  unsigned int result=0;
  digitalWrite(chipSelect_ACD, HIGH);
  delay(1);
  digitalWrite(chipSelect_ACD, LOW);
  result = SPI.transfer(0x00);
  result = result << 8;
  inByte = SPI.transfer(0x00);
  result = result | inByte;
  return result;
}

However, when I try to store the dataString into SD card, my Arduino freezes whenever it reaches adc().
Code:
#include <SPI.h>
#include <SD.h>

const int chipSelect_SD=4, chipSelect_ACD=11;
File myFile;

void setup() {
  SPI.begin();
  Serial.begin(9600);
  if (!SD.begin(chipSelect_SD)){
    Serial.println("sd card initialization failed.");
  }
}
void loop() {
  String dataString = "";
  dataString+=String(adc());
  Serial.println(dataString);
  File dataFile=SD.open("DATA.txt", FILE_WRITE);
  if(dataFile){
    Serial.println(dataString);
    dataFile.println(dataString);
    dataFile.close();
  }
  else{
    Serial.println("error opening DATA.txt");
  }
  delay(5000);
}

unsigned int adc(){
  byte inByte=0;
  unsigned int result=0;
  digitalWrite(chipSelect_ACD, HIGH);
  delay(1);
  digitalWrite(chipSelect_ACD, LOW);
  result = SPI.transfer(0x00);
  result = result << 8;
  inByte = SPI.transfer(0x00);
  result = result | inByte;
  return result;
}

I am wondering if you guys are able to spot what is wrong with my code? CS for SD is 4 and CS for ADC is 11. Thank you!
7  Using Arduino / General Electronics / Coaxial cable confusion on: November 27, 2013, 10:39:20 pm
Hello! Can someone please confirm that this connector:
http://www.digikey.com/product-detail/en/901-143-6RFX/ARFX1232-ND/272190
does indeed fit this cable?
http://www.digikey.com/product-detail/en/135101-02-12.00/ACX1572-ND/2003905

Thanks!
8  Using Arduino / General Electronics / Re: Ribbon cable & connector help! on: November 27, 2013, 10:17:38 pm
smiley-sad Okay thanks!
9  Using Arduino / General Electronics / Ribbon cable & connector help! on: November 27, 2013, 05:31:04 pm
Hi. I used a 2*5 holes 0.2inches spacing ribbon cable connector from the default eagle library and ordered a board, only to find out such part doesn't exist on digikey. I am wondering if any of you guys know where I can find that specific connector. The part is called "SH5-5" under "con-rib" in eagle default library. Thanks!
10  Using Arduino / Sensors / Quick question about the INA139/169 current sensor on: November 27, 2013, 01:45:06 pm
Hello. I am not completely understanding the datasheet for the INA139/169 current sensor. So if I am to provide a 3.3V power supply to the chip, what is the maximum voltage that the chip can output?

Datasheet: http://www.ti.com/lit/ds/symlink/ina169.pdf

Just a guess: On page 3 it says typical (V+)-0.9 and maximum (V+)-1.2. Does it implies that I should set my gain such that the output voltage never go above 3.3V-1.2V? Thanks!
11  Using Arduino / General Electronics / Re: Analog signal transmission on: November 16, 2013, 05:22:33 pm
Thanks for your response.
Please correct me if I am wrong. Shielded/unshielded twisted pair requires differential signal with current flows in opposite direction in order for the cancelling effect to take place, which leads us back to my original question. How would ones generate differential signal out of a single ended signal? Thanks.
12  Using Arduino / General Electronics / Re: Analog signal transmission on: November 16, 2013, 03:52:51 pm
Thanks for your response. The senors operates at 5v with a cuurent consuption of 0.0165 amps. Combines with other electroics surrounding the sensor, I would say around 0.02-ish amps, which falls within the range you provided.  Signal can ranges from 0 to 4.5V. So do you guys recommend me to connect my ciruict exactly like the one in my drawing? I guess is it just that using the shield as one of the current returning path to the battery doesn't seem quite right to me.
edit: actually the opamp alone needs 80mA. So I should probably only ground one end of the cable, right?

Hi DVDdoug. This setup is intended to used in a research environment, so I would like to make the reading as precise as posssible. In addition, I would love to learn how to properly use a twisted pair wire for analog singal tranmission, and so does many other curious people on the arduino forum I assume.
13  Using Arduino / General Electronics / Analog signal transmission on: November 16, 2013, 03:05:27 pm
Hello!

I have an analog signal that needs to be transmitted for a meter and read by an Arduino. I understand there are generally two ways to transmit the signal - coaxial cable or twisted pair.

Single ended signal can be transmitted via coaxial cable. One of the members on this forum suggests that both end of the outer shield must be connected to the ground (But wouldn't it creates a ground loop? But okay I'll take his words for it).


Shield twisted pair is a bit more complex, because I need to generate differential signal with current flowing in reverse direction (sensor hot/sensor return) in order to take advantage to the cancelling effect. Only one end of the shield goes to the ground in order to avoid ground loop. The problem is, I have no idea how to generate differential signal out of my analog signal. Can anyone give me some insight please?

Thank you very much!
14  Using Arduino / General Electronics / Re: Analog multiplexer on: November 15, 2013, 11:52:17 pm
Would you mind to explain a little bit more regarding which end to connect to the ground for the coaxial cable? What different does it make? I googled a bit and saw some info about ground loop but wasn't able to find anything regarding which end to ground. Thanks.
15  Using Arduino / General Electronics / Re: Analog multiplexer on: November 15, 2013, 11:19:01 pm
Thank you for your input! For the 1 meter cable, would a coaxial cable work? Am I suppose to connect the outer circular copper layer of the coaxial cable to the ground? Thanks!
Pages: [1] 2 3 ... 5