Jump to content
  • 0

Analog Shield and SD Shield for data logging


avitaletti

Question

Hello

I would like to store the data collected by the analog shield on an sd card. I'm using and Arduino UNO and the Keyes Data Logging Shield http://www.tinkbox.ph/sites/tinkbox.ph/files/downloads/Keyes - Data Logging Module (rev 1.0).pdf

Both the Analog Shield and the Data Logging Shield works perfectly alone, but as soon as I stack both of them on top of the Arduino the Analog Shield stop  providing output on the serial interface.

I changed the CS pin on the Keyes Data Logging Shield from 10 to 4 but nothing happened.

Suggestions?

Bests, Andrea

Link to comment
Share on other sites

6 answers to this question

Recommended Posts

Hi Andrea,

After digging around, I think the issue you're running into is that even though the Data Logging Shield uses a Chip Select value of 4 (as you set it), the SD card library set will still use pin 10 as their chip select which conflicts with the Analog Shield library.

So, what you would need to do is find the SD card library file folder in your computer and find the Sd2Card.h file (likely in the utilities folder). Around line 76 or so, you will see the line:
"uint8_t const SD_CHIP_SELECT_PIN = 10;", which is what the SD card is using for it's SPI (and what is conflicting with the pin 10 Chip select on the Analog Shield). 

I believe (I haven't tried this myself) that you should be able to change this pin 10 to pin 4 and then have your application work successfully. Note that if you add anything else to your circuit that uses pin 4, you'll need to find a different pin to use. Hopefully this works out for you.

Let me know if you have any more questions.

Thanks,
JColvin

Link to comment
Share on other sites

Hi JColvin

and thank for your support ... I don't think this is the problem... I'll try to explain why

Mi setup is the following: 1) the ARDUINO UNO, 2) The SD shiled stacked on top of the arduino, 3) the analog shield stacked on top of the SD shield.

I can change the Chip Select of the SD shield connecting the CS pin to any digital pin (e.g. 4 or 10). Let's  assume in the following that the CS of the SD Shield is set to 4

For the sake of simplicity I use the very simple sketch in attachment. 

  • Simple_read.ino is used to read data from the Analog Shield.
  • simple_SD.ino is used to initialize the  SD card

When I use both the Shields, the simple_SD.ino works perfectly and as expected I get on the serial monitor the following message

Initializing SD card...initialization done.

When I load the Simple_read.ino instead I do not get anything on the serial monitor.

So I do not think it is a problem on the SD library that it is not loaded at all in the Simple_read.ino, but i guess there is a pin conflicting

As you see according to the comment in simple_SD.ino
  // Note that even if it's not used as the CS pin, the hardware SS pin
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output
  // or the SD library functions will not work.

Is this pin (10) used also in the analog shield?

If yes, is there any way to change it to any other pin?

BTW this doe not explain why the Simple_read.ino is not working when the sd library is not loaded at all!!!

Thanks in advance, Andrea

 

Simple_read.ino

simple_SD.ino

Link to comment
Share on other sites

Hi Andrea,

After comparing the two schematics, it actually seems to me that the SD Shield and the Analog Shield do not conflict with each other in terms of pins. So you should be able to have the CS pin for the SD Shield on either pin 10 or pin 4 without any special modifications; I apologize for any confusion I may have caused earlier.

That being said, I am uncertain as to why the Simple_read demo is not working. I would probably try two different things next.

The first thing would be to try placing the Analog Shield on the UNO, and then the SD card Shield on top of the Analog Shield. This will help determine if there is a hardware/software issue with the Analog Shield or if for some reason not enough power was reaching the Analog Shield when it was on top of the stack. If the latter is the case, I would expect the SD Shield to no longer be working.

The next thing I would try if the Analog Shield still does not work after switching positions would be to download the latest Analog Shield library available on GitHub here

Let me know how it goes and then we can keep working from there.

Thank you for your patience,
JColvin

Link to comment
Share on other sites

Hi JColvin

some good news ... I'm now using the last version of the Analog Shield library available on GitHub here

Let's name Arduino AR, Analog Shield SH and SD shield SD and I loaded the file in attacment

1) if the setup is AR+SH+SD everything works pretty well and I found the data correctly stored in the SD card

2) if the setup is AR+SD+SH the SD works, but not the SH and the programs blocks on the count = analog.read(0) instruction

Now the first configuration is a bit inconvenient because I cannot easily access the pin of the ADC having the SD on top ... however it works!!!

If you have suggestion to make also the second configuration working I'll be happy to help and test

Bests, Andrea

test.ino

Link to comment
Share on other sites

Hi Andrea,

Unfortunately because there are no pin conflicts or jumpers to change, it sounds like (I don't know for certain) there is some sort of power issue with the SD shield where it is not able to pass enough power to the Analog Shield if it is on top of it. Whether this is due to that specific SD Shield or all SD Shields I am unable to say; and because it should essentially just be copper pins passing power through the shields and nothing weird or bizarre about the circuitry, there isn't really anything you would be able to do differently that I can see that would let you do your original configuration. :(

I'm not sure how that SD data logging shield looks on the underside, but you might try attaching some right angle headers to the ADC and DAC pins so that you can still access them. I imagine that the pins on the SD shield are long enough so that you can still maintain an electrical connection between the two shields without accidentally shorting out anything on the right angle header (if you choose to use it).

I'm sorry that I can't be of much more help, but I'll let you know if I think of something else to try.

Thanks,
JColvin

Link to comment
Share on other sites

Hello

I've attempted using AnalogSheild with Adafruit SD Datalogger, similar to the Keyes Logger described above. 

I experienced similar problems.  What works (not sure if its proper, but it works) is the following:

1. JColvin is correct, ensure power to SD.  I accomplished via Vin-5V pin connect (not sure if thats ok or not)

2. analog shield on bottom.  There seems to be an issue getting the 6 pins at the back (one labeled mosi, another labeled miso and some GND) to seat correctly if its not on bottom.  Or these pins are preventing the SD logger from seating.  Not sure which

3. Do not issue analog.write commands until after the SD card write is complete.  analog.write commands hang the loop if written before the SD write

4. analog.read commands seem able to go anywhere.

 

Best Regards,

CML

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...