SD, microSD, fat, et al

Has anyone gotten SD or uSD card access to work with the Mega? I just tried a Sparkfun SD shield on my Duemilanove and no luck. I've also tried a DFRobot Arduino SD Data log module on my Mega and not a squeek! The Sparkfun examples compile but didn't work with either configuration, uSd shield on my Duemilanove or the DFRobot module on my Mega. I've remapped the SS,MOSI, MISO and SCK pins on the Mega to 53, 51, 50,and 52 respectively. It's not an SPI issue, as I've gotten my MPL115A1 barometer and uMFPU-V3 floating point co-processor to work (cool chip by the way)

I'm building a "tricorder"/navigation device thingy. I want to log way points, temperature, humidity, altitude, speed, distance covered. So far I have my HMC6352, RTC1307, GPS, one of those HUGE 160x128 LCD screens Sparkfun sell and a groovy custom keyboard I designed and built. I am also adding an XBee module to communicate with a cut down version of the main unit that will be attached to my dogs. The "satellite" units will just have a GPS, Mega and XBee module. All of this stuff is working, except the damn SD card!

Can anyone help?

What am I doing wrong?

If all alse fails I'll go for a Processing scetch running on my eee 701 logging data. All of that

Usually there are 2 probs. 1 is mapping the pins in the sdfat library. Depending on the library you may have to change a header.

2nd is the 5v to 3.3v conversion of the data lines. SDcards are 3.3v. This can be done with a resistor divider, or a hexbuffer powered at 3.3v.

I don't know the mega, but if its running at 3.3v you may have to bypass a resistor divider if its built into the shield, which would be dividing 3.3v down to 2v or something.

Also Clk and Data lines may also need pullup resisters, but this is a foggy memory....

Good luck Mr. Spock.

I managed to get the Spargun uSD to give me error messages after I posted last night, that was as far as I got.

It was my understanding the DFRobot SD module had the logic level issues dealt with.

One important point I’m not sure of is, are the pull up resistors needed for level shifting or termination?

After I wrestled with the SD module for a while I tried my barometer, FPU and LCD shield again, this time all together on the Duemilanove, they worked no problem!
Same goes for the barometer and FPU on the Mega.
I do find it odd I can’t get the Adafruit library to compile.

Spock out…

Pull up resistors set the clk and data lines high.

Because the start of spi data is to signal LOW. You have SS/CS set?

Are these commercial parts? You have schematics or page links? What else is on the spi bus other than sdcard? What Sdcard library are you trying to use?

Old sparkfun cards SAID they had level shifters but did not. Should be a 74LSxxx hex buffer of some sort, iirc.

I'll have to look at my setup at home again.

The DFRobot Sd card I see online has resistor dividers from the pic. These are unreliable. You can try slowing down the spi bus, or a different mem card. Different cards may work.

You can try enabling the internal pullups on the spi lines, as a quick test.

I've been trying to find a schematic for the DFRobot module, with no luck. When trying to get the SD module to work, it is the only thing on the bus, going with the KISS principle! :-)

Which SD library should I be using, I've tried all the ones I can find.

Just looked at the module with a 12x magnifier, there is a voltage regulator with decoupling caps and voltage dividers acrross the signal lines.

The regulator has a weird pin-out, but it's getting 4.80V and outputting 3.30V with no card. Just measured it and having a card doesn't change the regulator o/p. Checking with the AC range on the meter I can see no ripple.

The SD cards I've tried are all 1G, Sandisk, Lexar and some re-badged DSE & MTV cards.

I was considering getting a Sparkfun level shifter module, but isn't that what the voltage dividers on the module do anyway?

How do I enable the internal pull-ups?

At this point, I'm considering using an I2C memory chip or a whole bunch of static CMOS RAM with battery back up!

If I need something like one of my eee's to read the data anyway, I'm thinking it'll be less hassle to use ALL the pins on my Mega! I mean, isn't that what they are for? :-)

Hi,

I use this library, iirc: http://code.google.com/p/sdfatlib/downloads/list

I see it was recently updated to include megas.

From the docs: (emphasis is mine)

SdFat was developed using an Adafruit Industries Wave Shield. 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 always use a 74HC4050 with my sd card circuits, it has worked the first time and every time.

See this section for using internal pullups: http://www.arduino.cc/en/Tutorial/DigitalPins

Thanks for that pull up tip on input pins, I was looking at the ATMega 1280 data sheet, then wondering how that translated to the Arduino language.

I'll still try and get the SD card to work, purely for the intellectual exercise, but...

After reading the docs that come with the various libraries and seeing how big they are and how much overhead is involved with using a DOS based storage medium, I had to ask myself...

Is this really worth it?

I've written code to read and write DOS files on x86 machines, in x86 assembler so I know how much hassle it is.

So I've ordered 8 24LC256 I2C EEPROM's.

For what I want to do a 1Gb SD card is over kill! Each 24LC256 is 32K, that is a LOT of way points and data! 8 of them will give me 256K, even more way points and data! 8 x 24LC256's is still cheaper than a 1G SD card, I have an 8M SD card here some where but most of my gadgets don't like it.

Realistically if I need more than 256K of storage I'll just use one of my eee netbooks or get a Beagle Board.

This "Tricorder"/navigation aid/dog tracker thingy has an XBee module in it anyway and the code to dump data to a Processing sketch on my eee is a lot less hassle and takes up less Flash.

Thanks to every one that has made suggestions, it really has helped and as I said I'll have a go at getting the SD card to work just for the hell of it.

Live long and prosper!

Spock out :-)

ps added a MLX90614 temperature sensor!

Problem with eeproms is they are really "read mostly", "write, very occasionally" type devices. Raw eeprom have no wear leveling schemes, and most dos/file sw is not going to target them.

It is also possible/better to just do raw read/writes from sd cards. You know, just move to some offset address and read 2kb data. This requires very little overhead.

You'll figure it out.