43 Replies Latest reply on Dec 12, 2012 3:42 AM by neilk

    SD Card interface board made by LC Studio/lcsoft.net

    neilk

      I am trying to get the above SD Card interface board working with my Arduino UNO. The interface board includes a 5v to 3.3v regulator and appears to have appropriate resistors to cope with 5v signals from the UNO.


      The pinout on the board is not directly compatible with the header on the UNO, so I have made up some connectors and I am fairly sure I have made the connections to the SPI correctly:

       

      I/F Board     Arduino Pin

      CS               10

      MOSI           11

      SCK            13

      MISO           12

       

      I have tried supplying +5v, to derive 3.3v via the I/F card regulator and also supplied +3.3v directly.

       

      My test program fails to find the card and returns "Card Failure", irrespective of whether there is a card present or not.

      The card I am using is 2GB, formatted as FAT16 and contains a single file - "test.txt", the contents of which are simply:

      test1,test2

      I keep checking the card in a reader on my PC and, so far, I don't seem to have damaged it.

       

      I would be grateful for any advice, please.

       

      A fragment of the program is shown below:

       

      //Program by Jeremy Blum

      //www.jeremyblum.com

      //SD Card Demonstration

      //Based on Example by Tom Igoe

      //Further adapted simplified by NGK to try and prove my SD Card interface board actually works!!!

       

      #include <SD.h> // This is the standard SD library in version 0023

       

      //These values are used by default in the standard SD Card Library

      //MOSI = 11

      //MISO = 12

      //SCLK = 13

       

      //We need to set the CS Pin - it's 10 for the UNO

      int CS_pin = 10;

       

      void setup()

      {

        Serial.begin(9600);

        Serial.println("Initializing Card");

        //CS Pin is an output

        pinMode(CS_pin, OUTPUT);

       

        if (!SD.begin(CS_pin))

        {  

         Serial.println("Card Failure");

         return;

         }

       

        Serial.println("Card Ready");

       

        //Now read the File test.txt)

        File commandFile = SD.open("test.txt");

        if (commandFile)

        {

          Serial.println("Reading Command File");

          while(commandFile.available())

          {

            char temp = (commandFile.read());

            Serial.println(temp);

           }

        }

        else

        {

          Serial.println("Could not open command file.");

          return;

        }

      }

        • Re: SD Card interface board made by LC Studio/lcsoft.net
          Drew Fustini

          Hi -

           

          I tried looking up the module put couldn't find much detail on the board (that translated to English with Google at least).  One idea I had from working with other 3.3V modules is that logic level shifting (e.g. converter) might be necessary.  I believe the Arduino UNO runs at 5V so this could be an issue.

           

          I ran into this when working with interfacing an Arduino with a 3.3V Microchip SRAM chip.  SparkFun has a nice tutorial called "Sensor Interfacing" that describes different solutions to this issue:

           

          http://www.sparkfun.com/tutorials/65

           

          I ended up ordering SparkFun's little converter boards which worked very well:

           

          http://www.sparkfun.com/products/8745

           

           

          Cheers,

          Drew

          http://twitter.com/pdp7

          1 of 1 people found this helpful
            • Re: SD Card interface board made by LC Studio/lcsoft.net
              neilk

              Hi Drew - many thanks for your quick answer.

               

              I have already looked at the SparkFun tutorial and the lcsoft board appears to have appropriate resistors, as in the example they show. The board is double sided, with thru-hole plating and I am finding it VERY difficult to trace the cicuit to be certain.

              Thanks again

               

              Neil

                • Re: SD Card interface board made by LC Studio/lcsoft.net
                  neilk

                  I have finally located a schematic of the lcsoft SD board, if it helps anyone to help me further.

                   

                  I have arttached a .pdf

                    • Re: SD Card interface board made by LC Studio/lcsoft.net
                      Drew Fustini

                      Thanks - I think that gives me a better understanding.  However, I'm not sure why JP1 is a 8x2 header - it seems to have the same layout on both sides.  Could you post a pic of the board?

                       

                      I'm not sure if there is any there doing level shifting.  Those four 10k resistors look just like pullups to me.

                       

                      Thanks,

                      Drew

                        • Re: SD Card interface board made by LC Studio/lcsoft.net
                          neilk

                          Maybe JP1 is a 8x2 header (male) to give mechanical stability??

                           

                          Yes, the connections are the same in both rows of pins.

                           

                          You are right, of course - the resistors are purely pullups. Do you think I need series resistors as in the tutorial?

                           

                          Pics attached.

                           

                          Thanks again

                           

                          Neil

                            • Re: SD Card interface board made by LC Studio/lcsoft.net
                              Drew Fustini

                              Yeah, I think the issue is 3.3V & 5V interfacing.  I'm not sure if the resistor method is very good per this advice from Adafruit:

                               

                              http://www.ladyada.net/products/microsd/

                              One is that they are strictly 3.3V devices and the power draw when writing to the card can be fairly high, up to 100mA (or more)! That means that you must have a fairly good 3.3V power supply for the card. Secondly you must also have 3.3V logic to interface to the pins. We've found that SD cards are fairly sensitive about the interface pins - the newest cards are edge triggered and require very 'square' transitions - things like resistor dividers and long wires will have a deleterious effect on the transition speed, so keep wires short, and avoid using resistor dividers for the 3.3V logic lines. We suggest instead using level shifters, such as HEF4050, 74LVX245 or74AHC125 chips.

                               

                              Might you have one of those types of ICs available?

                               

                              Cheers,

                              Drew

                              1 of 1 people found this helpful
                                • Re: SD Card interface board made by LC Studio/lcsoft.net
                                  neilk

                                  Hi Drew......once again, many thanks.

                                  The first thing I'll do is shorten my cables. I was going to do it anyway, for tidiness!

                                  I'll also look for a level-shifter in my box-of-bits.

                                  Thanks again

                                  Neil

                                  • Re: SD Card interface board made by LC Studio/lcsoft.net
                                    neilk

                                    Thanks to Drew and nermash re use of logic devices for 5v to 3.3v logic level shifting:

                                     

                                    I was hoping to avoid getting my hands "dirty" and working at this level! However, I started to search the Aduino lib stuff to try and understand what actually happens when you issue the call: SD.begin(CS_pin)

                                    I haven't worked that out yet, but I did come across the following in:

                                     

                                      arduino\arduino-0023\libraries\SD\utility\SdFatmainpage.h

                                     

                                    "The hardware interface to the SD card should not use a resistor based level shifter.  SdFat sets the SPI bus frequency to 8 MHz which results in signal rise times that are too slow for the edge detectors in many newer SD card controllers when resistor voltage dividers are used.  The 5 to 3.3 V level shifter for 5 V Arduinos should be IC based like the 74HC4050N based circuit shown in the file SdLevel.png.  The Adafruit Wave Shield uses a 74AHC125N.  Gravitech sells SD and MicroSD Card Adapters based on the 74LCX245.  If you are using a resistor based level shifter and are having problems try setting the SPI bus frequency to 4 MHz.  This can be done by using  card.init(SPI_HALF_SPEED) to initialize the SD card."

                                     

                                    I think that concludes the discussion re the use of resistors or logic level shifters!

                                     

                                    I haven't yet sourced an appropriate chip at a sensible price here in the UK - I don't think a catalogue price of approx 0.35GBP ending up costing almost 7GBP because of delivery & handling is sensible, especially when I paid less than 3.5GBP approx $5 for the SD Interface from China

                                     

                                    If you are all interested, I'll keep you informed!

                          • Re: SD Card interface board made by LC Studio/lcsoft.net
                            harbo

                            Drew, how did you make the connection from the Arduino [SCK-MISO-MOSI-CS] to the 8745{RX, TX]  ??

                              • Re: SD Card interface board made by LC Studio/lcsoft.net
                                Drew Fustini

                                Hi Harrie,

                                 

                                I think I've since disconnected it but I'll have a look tonight.  I remember there was a bit of trial and error - wish I would have documented it better (last worked on it in February).

                                 

                                Cheers,

                                Drew

                                  • Re: SD Card interface board made by LC Studio/lcsoft.net
                                    harbo

                                    and Drew, did you find the something?

                                     

                                    Cheers

                                     

                                    Harrie

                                      • Re: SD Card interface board made by LC Studio/lcsoft.net
                                        Drew Fustini

                                        Hi Harrie,

                                         

                                        Sorry this slipped by my mind before I left for a wedding in Canada.  I'll check tonight.

                                         

                                        Thanks,

                                        Drew

                                          • Re: SD Card interface board made by LC Studio/lcsoft.net
                                            Drew Fustini

                                            Hi Harrie -

                                             

                                            Sadly, my project has been dismantled so I can't recollect.  But I hooked it up based on advice I read on arduino.cc forum.  Were you able to get it working?

                                             

                                            Thanks,

                                            Drew

                                              • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                harbo

                                                Drew,

                                                 

                                                Finale I got it working, attached the scheme I used. But.....The SD, apart,

                                                is working, and the Max31855 Temperature read-out also apart working. But

                                                together .....Noy yet.

                                                I'm not real a C-specialist, so I'm struggling with SPI now.

                                                 

                                                 

                                                2011/12/12 Drew Fustini <messages@element14.com>

                                                 

                                                **

                                                    image: element14<http://www.element-14.com?CMP=e14notificationemail_header> Re: SD Card interface board made by LC Studio/

                                                lcsoft.net  created by Drew Fustini<http://www.element14.com/community/people/fustini>in

                                                Arduino Projects | Arduino Programming - View the full discussion<http://www.element14.com/community/message/41273#41273/l/re-sd-card-interface-board-made-by-lc-studiolcsoftnet

                                                 

                                                  • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                    r3cgm

                                                    I'm in the same boat as Neil.  Same pin connections (tried CS on both pin 10 and pin 4), and the CardInfo diagnostic program still returns:

                                                     

                                                    Initializing SD card...initialization failed. Things to check:
                                                    * is a card is inserted?
                                                    * Is your wiring correct?
                                                    * did you change the chipSelect pin to match your shield or module?

                                                    Initializing SD card...initialization failed. Things to check:

                                                    * is a card is inserted?

                                                    * Is your wiring correct?

                                                    * did you change the chipSelect pin to match your shield or module?

                                                    Anyone else have success with this component from LC Studio?  Is the 3.3V conversion with a 74HC4050 really needed?  Any tips appreciated.
                                                    Christopher

                                                      • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                        neilk

                                                        Hi Christopher - I have spent hours trying to get this to work, including building a 5v to 3.3v logic conversion with a 74HC4050 (sourcing that at a sensible price is another story!)

                                                        Out of sheer frustration, I took a meter to the LC Studio board (unplugged from my arduino stuff). What I appeared to find confused me - MISO and MOSI were both shorted to ground ??

                                                        I suspected the soldering around the card socket & so went over with very carefully and eventually unsoldered it, damaging it in the process. I then scraped off the protective layers from areas of the PCB and tried to follow the copper - I found what appeared to be shorts in the copper and so tried to scrape them away.

                                                         

                                                        In short, I virtually destroyed the board, but more or less convinced myself that it was originally faulty. Christmas and New Year have intervened and I am only just picking up the Arduino project again. I haven't yet communicated with the (eBay) seller, but am wondering what can be done........It would cost me more to return the board (to the far east) than I paid for it.

                                                         

                                                        Just to buy an SD Card connector (I mean 1, not 100 or 10,000) is ridiculously expensive, so I am now contemplating cannibalising a USB/SD Card reader.

                                                         

                                                        I would be fascinated to know if your LC Studio board shows the same symptoms as mine??

                                                         

                                                        Neil

                                                          • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                            terry king

                                                            Hi, I had similar problems with a different SD Card module. I found these that use FETs for level translation and include a 3.3V regulator set up to run on both 5V Arduinos etc. and 3.3V controllers:

                                                             

                                                            http://arduino-direct.com/sunshop/index.php?l=product_detail&p=246

                                                             

                                                            I now stock these for $9.50   DISCLAIMER: Mentioned stuff from my own shop...!! Which is what I know most about :-)

                                                             

                                                            Regards, Terry King  ...On the Mediterranean in Italy  terry@yourduino.com

                                                            • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                              r3cgm

                                                              Hi Neil,

                                                               

                                                              Our stories sound really similar.  I was staring at the board and trying to figure out where all the connections were running just to satisfy myself that everything was wired correctly, but the protective layers prevented being able to follow the traces.  I'm glad you went through the effort to scrape the protection off in your investigations.   It doesn't fill me with a lot of confidence in these boards that you found apparent shorts.

                                                               

                                                              I'd bought some 74HC4050 chips as an "insurance policy" in case I had to do manual 5 > 3.3V conversion, but was really hoping this LC Studio board already had that conversion on it so I wouldn't have to.  Again, I'm glad you went through the effort to build this additional circuitry because learning from your experience it sounds like that might not solve my problem either.

                                                               

                                                              I'm starting to get the sense that these may not be the highest quality components. :|  Even though I would have preferred to fix the board or at least find out what was wrong with it, I may just cut my losses and order a different SD card reader.

                                                               

                                                              I guess one minor consolation is that I won an auction for 3 of these on eBay for only $11.94 including shipping, so I didn't lose a lot of money here.

                                                               

                                                              I like Terry's link to the model of SD reader on YourDuino.com.  And $9.50 per unit doesn't seem too expensive.  And we know there's at least one other person on this earth who made these boards work.

                                                               

                                                              Also I noticed that Lady Ada has a spiffy looking SD reader, although it's a little more expensive at $15: https://www.adafruit.com/products/254  The upshot with that one is great online documentation: http://www.ladyada.net/products/microsd/

                                                               

                                                              Anyway, if a fix can be found for these LC Studio boards than I'll be glad to use them, but meantime I'm going to consider them defective.

                                                               

                                                              Cheers,

                                                               

                                                              Christopher

                                                                • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                  terry king

                                                                  Hi, The Lc Soft stuff can be found here:  http://tmp.www.lcsoft.net:8080/Hardware/#

                                                                  (May need to click ENGLISH at upper right).

                                                                   

                                                                  I was looking at sourcing some of their other modules, but after the board quality problems detailed above, I'll want a REAL good look at samples before I sell any of them..

                                                                   

                                                                  The LadyAda Tutorial is great!  I know how much work that stuff is; I have some at http://arduino-info.wikispaces.com/

                                                                   

                                                                  Regards, Terry King

                                                                  • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                    neilk

                                                                    Hi Christopher

                                                                    You don't say whether you have checked for a short circuit between MOSI, MISO and ground on your 3 LCsoft boards.

                                                                    I would be very interested to know if any of them have the same symptoms as mine.

                                                                     

                                                                    Currently in discussion with the supplier as to what they are going to do.

                                                                     

                                                                    I have seen the LadyAda - looks good, but quite expensive to buy here in UK, or have shipped from the states.

                                                                     

                                                                    Terry's board looks very attractive - I may invest!

                                                                     

                                                                    Please let me know if you can find any short circuits on your board(s)

                                                                     

                                                                    Best wishes

                                                                     

                                                                    Neil

                                                                      • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                        r3cgm

                                                                        Hi Neil,

                                                                         

                                                                        I checked for ground shorts for the MOSI and MISO pins, on all 3 of my boards, but found none.  Doesn't necessarily mean that my boards aren't defective, but probably not due to that cause.

                                                                         

                                                                        Hope you have success working with the supplier.

                                                                         

                                                                        Cheers.

                                                                         

                                                                        Christopher

                                                                          • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                            neilk

                                                                            Hi Christopher (and anyone else reading this thread)

                                                                             

                                                                            I got nowhere with the supplier of the LCstudio card.

                                                                             

                                                                            I invested in a card from Terry's shop; unfortunately, UK customs held on to it for a very long time hence the dilence

                                                                             

                                                                            Terry's board includes FET level shifters so I jumpered it direct to the relevant pins on my arduino UNO. Using the test sketch I published at the beginning of this thread, it still failed to initialise an SD card........OH NO!

                                                                             

                                                                            I have now upgraded to Arduino-1 and discovered there is an SD test sketch called Cardinfo that wasn't in Arduino - 23 - I tried it and found that it recognised my SD card, but could not find a partition on it.

                                                                            This card is an unbranded (here is a lesson!!) 2GB card which is formatted FAT16 and works fine on myPC........

                                                                             

                                                                            I also tried a brand new Transcend 2GB microSD, with the same result

                                                                             

                                                                            I then remembered I had some 3 year old San Disk Extreme III 1GB cards for my digital camera...tried one and it worked fine, even listing out the directories and their contents (came straight out of the camera).

                                                                             

                                                                            So I tried the read.write tests and more and it all works fine with the San Disk card

                                                                             

                                                                            Searching the Internet I find plenty of warnings that not all cards will work with the arduino - to do with the rise time of the signals on the SPI bus lines. However there is little clear guidance about which cards will work and which cards won't!  I did find one article which gave several San Disk cards a good report.

                                                                             

                                                                            I now wonder if the LCStudio interface card, tested with the Cardinfo sketch, might have partially worked and given me the hint that the card was actually the problem - I will never know because my LCStudio card is now totally dead - destructive testing.

                                                                             

                                                                            SO if anyone is having trouble with any SD Card interface make sure you use the Cardinfo sketch FIRST to help you find an SD Card that actually works in your setup. The fact that it is correctly Fat16/Fat32 fromatted and works on you PC is no guarantee. I have wasted hours and hours on this problem

                                                                              • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                r3cgm

                                                                                Hi Neil (and others),

                                                                                 

                                                                                I admire your tenacity in working the issue.  What a crazy trip it's been, between distructive testing and import customs and different SD cards and partition types... glad in the end you found a setup that works!

                                                                                 

                                                                                My own epilogue has a similarly happy ending.  I'd found out about the Arduino-23 > Arduino-1 upgrade some weeks ago, so I'd been using the Cardinfo program during testing.  Handy tool.  I took the setup() function from it, copy/pasted it into my sketch, and seasoned to taste (modified the bootup debug messages a bit).

                                                                                 

                                                                                I completely gave up on those LCsoft boards and went with Lady Ada's micro SD card reader.  It worked like a charm.  I had a couple generic MicroSD cards (2 gigs, pre-formatted FAT16), and Cardinfo saw the cards and partitions without any additional tweaking on my part.  Now my project is able to use the SD the way I originally hoped it would.  But thanks for mentioning that Terry's board also worked; good to know that there are multiple known working options.

                                                                                 

                                                                                Not related to this SD card discussion, but I bumped into a new problem.  The ATMega328 only has 2k of RAM.  I'd never given RAM availability much thought until my Arduino started crashing.  I started checking for free mem, and sure enough it was running out.  So, two consequences came of that: 1. I had to retool my sketch to keep a restricted "window" of the data read from the SD card because not enough RAM to hold it, and 2. discovered a trick to recover more RAM.

                                                                                 

                                                                                That trick is:

                                                                                 

                                                                                (old way) Serial.println("Hi, this string is loaded at boot time and will consume ~70 bytes of RAM.");

                                                                                 

                                                                                (new way) Serial.println(F("This string is kept in flashmem (the 32k area where compiled sketches are stored), and will consume no additional RAM during program execution.");

                                                                                 

                                                                                This doesn't really relate to the SD card effort here, just mentioning it in case others go down the same path I did and notice their Arduinos crashing due to running out of memory.  Wrapping your print() and println() strings in F("") is an easy way to save some bytes.

                                                                                 

                                                                                The final piece of the puzzle in my project is to produce a production board, and for that I'm attempting to reverse engineer the Lady Ada reader so I can reproduce it in Eagle PCB.  I know this board works, so I'm trying to use similar components on my PCB.  But I'm still a newbie when it comes to surface mount components, so I can't tell yet what the 2 capacitor values are from this board just by looking at them.

                                                                                 

                                                                                Not sure if you're hoping to make a production board from your project or not, but if so I'd be interested in comparing schematics and notes.

                                                                                 

                                                                                Cheers.

                                                                                 

                                                                                Christopher

                                                                                  • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                    neilk

                                                                                    Hi Christopher (and others)

                                                                                     

                                                                                    Congratulations on getting your SD Card working as well. I looked again at the Lady Ada stuff - the guidance seems to have been substantially upgraded since I looked at it before christmas - it uses Arduino-1.0 for a start!

                                                                                     

                                                                                    I am intrigued by the use of flash memory - please can you tell me where is the technique described? And how do you check for free RAM?

                                                                                     

                                                                                    I am long way from even thinking about a production board yet, but when I do I will be happy to share my schematics with you

                                                                                     

                                                                                    Please let me know about the flash memory technique

                                                                                     

                                                                                    Best wishes

                                                                                     

                                                                                    Neil

                                                                                      • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                        neilk

                                                                                        Ouch - I just found the flash memory information..

                                                                                          • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                            Sanzer

                                                                                            My LC Studio is working on my Chipkit max32. I had some problems aswell but I could figure out which pins to use

                                                                                              • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                                neilk

                                                                                                That's fantastic, Pablo. Congratulations. As a matter of interest, does the Chipkit max32 deliver 3.3v signals directly to the LC Studio board, or did you have to build a level shifter?

                                                                                                  • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                                    Sanzer

                                                                                                    It does directly, but I'm using 5v pin instead of 3.3v and it works great.

                                                                                                      • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                                        knoakes

                                                                                                        For all those trying to use the lcsoft SD board. I had many problems using an Arduino Mega 2560 and have not yet made this work. So as a last attempt I tried using an Arduino Duo using the pin connections in the original post and it worked frst time.

                                                                                                         

                                                                                                        The code I used was someone else's example and works fine and I can read the text file it creates on a pc (copied below)

                                                                                                        I have only connected the +5v rail and I do not have any resistors in series or circuitry to drop the voltage. I may be wrong, but I believe the board has some current limited resistors already on the board.

                                                                                                         

                                                                                                        #include <SD.h>

                                                                                                         

                                                                                                        File myFile;

                                                                                                         

                                                                                                        void setup()

                                                                                                        {

                                                                                                          Serial.begin(9600);

                                                                                                          Serial.print("Initializing SD card...");

                                                                                                          // On the Ethernet Shield, CS is pin 4. It's set as an output by default.

                                                                                                          // 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.

                                                                                                         

                                                                                                         

                                                                                                          if (!SD.begin(10)) {

                                                                                                            Serial.println(SD.begin(10));

                                                                                                            //return;

                                                                                                          }

                                                                                                          Serial.println("initialization done.");

                                                                                                         

                                                                                                          // open the file. note that only one file can be open at a time,

                                                                                                          // so you have to close this one before opening another.

                                                                                                          myFile = SD.open("test.txt", FILE_WRITE);

                                                                                                         

                                                                                                          // if the file opened okay, write to it:

                                                                                                          if (myFile) {

                                                                                                            Serial.print("Writing to test.txt...");

                                                                                                            myFile.println("testing 1, 2, 3.");

                                                                                                                  // close the file:

                                                                                                            myFile.close();

                                                                                                            Serial.println("done.");

                                                                                                          } else {

                                                                                                            // if the file didn't open, print an error:

                                                                                                            Serial.println("error opening test.txt");

                                                                                                          }

                                                                                                        }

                                                                                                         

                                                                                                        void loop()

                                                                                                        {

                                                                                                                  // nothing happens after setup

                                                                                                        }

                                                                                                          • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                                            neilk

                                                                                                            Congratulations, Kevin! Further evidence to support the view that ALL of my problems originated from the actual SD Card. Well, you live and learn!

                                                                                                              • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                                                knoakes

                                                                                                                Just in case it helps anyone else, I now have it working with my Arduino Mega 2560.

                                                                                                                 

                                                                                                                Pins are as expected and well documented elsewhere

                                                                                                                MISO : Pin 50

                                                                                                                SCK : Pin 52

                                                                                                                MOSI: Pin 51

                                                                                                                CS : Pin 53

                                                                                                                 

                                                                                                                Here's a sketch I used to list the contents of the SD card (not my code )

                                                                                                                 

                                                                                                                /*

                                                                                                                  SD card test

                                                                                                                  

                                                                                                                This example shows how use the utility libraries on which the'

                                                                                                                SD library is based in order to get info about your SD card.

                                                                                                                Very useful for testing a card when you're not sure whether its working or not.

                                                                                                                   

                                                                                                                The circuit:

                                                                                                                  * SD card attached to SPI bus as follows:

                                                                                                                ** MOSI - pin 11 on Arduino Uno/Duemilanove/Diecimila

                                                                                                                ** MISO - pin 12 on Arduino Uno/Duemilanove/Diecimila

                                                                                                                ** CLK - pin 13 on Arduino Uno/Duemilanove/Diecimila

                                                                                                                ** CS - depends on your SD card shield or module.

                                                                                                                       Pin 4 used here for consistency with other Arduino examples

                                                                                                                 

                                                                                                                 

                                                                                                                 

                                                                                                                created  28 Mar 2011

                                                                                                                by Limor Fried

                                                                                                                modified 16 Mar 2011

                                                                                                                by Tom Igoe

                                                                                                                */

                                                                                                                // include the SD library:

                                                                                                                #include <SD.h>

                                                                                                                 

                                                                                                                // set up variables using the SD utility library functions:

                                                                                                                Sd2Card card;

                                                                                                                SdVolume volume;

                                                                                                                SdFile root;

                                                                                                                 

                                                                                                                // change this to match your SD shield or module;

                                                                                                                // Arduino Ethernet shield: pin 4

                                                                                                                // Adafruit SD shields and modules: pin 10

                                                                                                                // Sparkfun SD shield: pin 8

                                                                                                                const int chipSelect = 53;   

                                                                                                                 

                                                                                                                void setup()

                                                                                                                {

                                                                                                                  Serial.begin(9600);

                                                                                                                  Serial.print("\nInitializing SD card...");

                                                                                                                  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.

                                                                                                                  // 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.

                                                                                                                  pinMode(53, OUTPUT);     // change this to 53 on a mega

                                                                                                                 

                                                                                                                  // we'll use the initialization code from the utility libraries

                                                                                                                  // since we're just testing if the card is working!

                                                                                                                  if (!card.init(SPI_QUARTER_SPEED, chipSelect)) {

                                                                                                                    Serial.println("initialization failed. Things to check:");

                                                                                                                    Serial.println("* is a card is inserted?");

                                                                                                                    Serial.println("* Is your wiring correct?");

                                                                                                                    Serial.println("* did you change the chipSelect pin to match your shield or module?");

                                                                                                                    return;

                                                                                                                  } else {

                                                                                                                   Serial.println("Wiring is correct and a card is present.");

                                                                                                                  }

                                                                                                                 

                                                                                                                  // print the type of card

                                                                                                                  Serial.print("\nCard type: ");

                                                                                                                  switch(card.type()) {

                                                                                                                    case SD_CARD_TYPE_SD1:

                                                                                                                      Serial.println("SD1");

                                                                                                                      break;

                                                                                                                    case SD_CARD_TYPE_SD2:

                                                                                                                      Serial.println("SD2");

                                                                                                                      break;

                                                                                                                    case SD_CARD_TYPE_SDHC:

                                                                                                                      Serial.println("SDHC");

                                                                                                                      break;

                                                                                                                    default:

                                                                                                                      Serial.println("Unknown");

                                                                                                                  }

                                                                                                                 

                                                                                                                  // Now we will try to open the 'volume'/'partition' - it should be FAT16 or FAT32

                                                                                                                  if (!volume.init(card)) {

                                                                                                                    Serial.println("Could not find FAT16/FAT32 partition.\nMake sure you've formatted the card");

                                                                                                                    return;

                                                                                                                  }

                                                                                                                 

                                                                                                                 

                                                                                                                 

                                                                                                                 

                                                                                                                  // print the type and size of the first FAT-type volume

                                                                                                                  long volumesize;

                                                                                                                  Serial.print("\nVolume type is FAT");

                                                                                                                  Serial.println(volume.fatType(), DEC);

                                                                                                                  Serial.println();

                                                                                                                 

                                                                                                                  volumesize = volume.blocksPerCluster();    // clusters are collections of blocks

                                                                                                                  volumesize *= volume.clusterCount();       // we'll have a lot of clusters

                                                                                                                  volumesize *= 512;                            // SD card blocks are always 512 bytes

                                                                                                                  Serial.print("Volume size (bytes): ");

                                                                                                                  Serial.println(volumesize);

                                                                                                                  Serial.print("Volume size (Kbytes): ");

                                                                                                                  volumesize /= 1024;

                                                                                                                  Serial.println(volumesize);

                                                                                                                  Serial.print("Volume size (Mbytes): ");

                                                                                                                  volumesize /= 1024;

                                                                                                                  Serial.println(volumesize);

                                                                                                                 

                                                                                                                  Serial.println("\nFiles found on the card (name, date and size in bytes): ");

                                                                                                                  root.openRoot(volume);

                                                                                                                 

                                                                                                                  // list all files in the card with date and size

                                                                                                                  root.ls(LS_R | LS_DATE | LS_SIZE);

                                                                                                                }

                                                                                                                 

                                                                                                                 

                                                                                                                void loop(void) {

                                                                                                                 

                                                                                                                }

                                                                                                                  • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                                                    bmac2

                                                                                                                    using your pin structure you put above, I was able to successfully read 2 different SD cards on my LC Studios card using a Mega.  it read my 16 gig HDSC card Sandisk, and also read a PNY 2 gig that had a bunch of videos/pics on it from a camera.  I am glad YOU found the pins to use, I have been hunting since I got my mega in yesterday to figure this out.  Now on to temp and ph probes!!!

                                                                                                                     

                                                                                                                    Mac

                                                                                                                      • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                                                        bmac2

                                                                                                                        output from serial monitor showing it reading the card.

                                                                                                                         

                                                                                                                         

                                                                                                                        Initializing SD card...Wiring is correct and a card is present.

                                                                                                                         

                                                                                                                        Card type: SD2

                                                                                                                         

                                                                                                                        Volume type is FAT16

                                                                                                                         

                                                                                                                        Volume size (bytes): 1966800896

                                                                                                                        Volume size (Kbytes): 1920704

                                                                                                                        Volume size (Mbytes): 1875

                                                                                                                         

                                                                                                                        Files found on the card (name, date and size in bytes): 

                                                                                                                        DCIM/         2008-01-01 12:00:04

                                                                                                                          100MEDIA/     2008-01-01 12:00:04

                                                                                                                            SUNP0037.JPG  2008-11-29 20:12:46 82465

                                                                                                                            SUNP0038.JPG  2008-11-29 20:12:54 84479

                                                                                                                            SUNP0005.AVI  2008-01-05 13:24:56 3184344

                                                                                                                            SUNP0006.JPG  2008-01-05 13:25:12 134270

                                                                                                                            SUNP0008.AVI  2008-01-05 13:25:54 1215080

                                                                                                                            SUNP0009.JPG  2008-01-05 13:26:00 126620

                                                                                                                            SUNP0011.JPG  2008-01-05 14:43:40 143593

                                                                                                                            SUNP0012.JPG  2008-01-05 14:44:10 132048

                                                                                                                            SUNP0013.AVI  2008-01-05 14:45:02 7057480

                                                                                                                            SUNP0014.AVI  2008-01-05 14:46:32 29801992

                                                                                                                            SUNP0015.AVI  2008-01-05 14:48:44 55305000

                                                                                                                            SUNP0016.AVI  2008-01-05 14:49:50 24944696

                                                                                                                            SUNP0017.AVI  2008-01-05 14:51:16 34266552

                                                                                                                            SUNP0018.AVI  2008-01-05 14:52:56 41782040

                                                                                                                            SUNP0019.AVI  2008-01-05 14:54:40 36283880

                                                                                                                            SUNP0020.JPG  2008-01-05 14:54:58 132111132111

                                                                                                                            SUNP0021.AVI  2008-01-05 14:56:22 27502472

                                                                                                                            SUNP0022.AVI  2008-01-05 14:58:06 44539848

                                                                                                                            SUNP0023.AVI  2008-01-05 14:59:36 31050248

                                                                                                                            SUNP0024.AVI  2008-01-05 15:00:28 15262664

                                                                                                                            SUNP0025.AVI  2008-01-05 15:00:52 3446376

                                                                                                                            SUNP0026.AVI  2008-01-05 15:02:56 30331544

                                                                                                                            SUNP0027.AVI  2008-01-05 15:05:14 21797256

                                                                                                                            SUNP0028.JPG  2008-01-05 15:05:42 130155

                                                                                                                            SUNP0029.JPG  2008-01-05 15:05:50 128528

                                                                                                                            SUNP0030.AVI  2008-01-05 15:08:30 57274600

                                                                                                                            SUNP0031.AVI  2008-01-05 15:10:58 39682216

                                                                                                                            SUNP0032.AVI  2008-01-05 15:11:32 3577288

                                                                                                                            SUNP0033.AVI  2008-01-05 15:12:18 9025512

                                                                                                                            SUNP0034.AVI  2008-01-05 15:13:40 28947464

                                                                                                                            SUNP0035.AVI  2008-01-05 15:15:36 12636584

                                                                                                                            SUNP0036.AVI  2008-01-05 15:17:38 52090104

                                                                                                                  • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                                                    biacapelli

                                                                                                                    Hi, I know this topic is a little old, but I really need some help. I'm using the LCStudio SDCard module, and I turned it on without reading any instruction, and it didn't work, so I thought I had broken it, but I insisted on this topic and found your message (Kevin Noakes) - I connected my module to 5V straight, without any resistors, like you did, but the code still does not work for me . Using yours or the standard code (ReadWrite - arduino.cc), I keep getting the same results, the SD.begin(cspin) function returns 0... "Initialization failed".

                                                                                                                     

                                                                                                                    Is there anything you can tell me so I can make it work?

                                                                                                                     

                                                                                                                    My connections: GND on Arduino GND, 5V on Arduino 5V, MOSI on Arduino 11, MISO on Arduino 12, CLK on Arduino 13, CS on Arduino 4.

                                                                                                                     

                                                                                                                    Is there a chance I ruined my module? Is there a way I can verify this? Or I just buy another one without knowing the problem? I would be REALLY pleased if you'd answer me!

                                                                                                                     

                                                                                                                    Thank You,

                                                                                                                    biacapelli

                                                                                                        • Re: SD Card interface board made by LC Studio/lcsoft.net
                                                                                                          knuckle73

                                                                                                          Christopher,

                                                                                                            No need to revers engineer ladyada's board as the schematic for the board is available from github. https://github.com/adafruit/MicroSD-breakout-board