Go Down

Topic: SD/MMC From the ground up (Read 31954 times) previous topic - next topic

MetroExpress

Ok so this is my first post on the board, hello all.

I've been tinkering around with the arduino mega for a few weeks and the next project i am trying to finish includes an SD card.

Now I have the Arduino Mega w/ ATMEGA1280 I know the SPI pins are different so I have tried to change the mmc.h but with no luck.

Maybe I have been going about it all wrong but when I run the example sketch I only show:

uFat / DevicePrint Demo
2009 arduinonut.blogspot.com

Nothing else, so it makes me think it might not be detecting the SD everything has been rechecked wiring wise, I am stumped.

Maybe this is not at all possible for this Arduino, please let me know, thanks in advance.

Geoff

awdark

I am interested in building a gps logger and I was wondering if the same SD wiring schematic will work with the different arduino codes.  I know there's the ladyada one which seems very complete and the other that uses ufat.  I don't know which will work the best and it will be nice to know if I could try both of them to see what works best.

FrankLang

Hello all,

i am new here. I have a Ardduino Duemilanove Board. It worked very fine till now. I built a Ultra Sonic distance measurement and a lcd display. But now I tried a SD Card Shield from seeed Studio.

I tried the code

 microfat2::walkDirectory(showDirectory_walkerfn, &count);

 Serial.println(PSTR("\n"));
 Serial.print(count, DEC);
 Serial.println(" files found.\n\n");

And the response is 0 files found.

But I formated the SD Card. I put one File with a smal Text in the file.

What can be wrong ?

Frank

FrankLang

Ok ok now it works. I put the code after initialize.

But after that I tried this

if (microfat2::locateFileStart(PSTR("HOLA.TXT"), sector, length))

and I get false every Time.

why ?

Thanks

Frank

FrankLang

Hello all,

now it works, I tried the example of SDuFAT and it whttp://www.arduino.cc/yabbfiles/Templates/Forum/yabb21/grin.giforks fine.

bye

Frank

ptool64ar

I've been working with sir morris' SD from the ground up for several months.  The system works OK for me.  I've been using it to count electronic pulses per second, then store the count/sec on an SD card.

I have used the system to count/store pulses from the speed sensor on my Harley Sportster.  I can remove the SD card from the arduino ckt. bodily transport the card to my laptop where I download the data via USB into notepad (or wordpad), from whence I can enter the data to my spreadsheat for scientific analysis (HA-HA).  

I could also use the circuitry to count pulses from the ignition system, or whatever pulsating electronics that I desire to take a look at.

Problem, though.   New data entered on the card replaces previous data, so its hard to keep track of which is old, which is new.  New data always starts at the beginning of pre-entered data, and overwrites the old.  Therefore, one needs to modify the program, adding something, that id's old from new, but data still gets jammed together.  

I use the atmega's EEPROM to store a number, which is increased each time I shut the ckt off then restart it.  That number id's each use, but older data is still overwritten and can be lost. However, one needs not shut the ckt off intentionally, as data can be entered to the card for a long, long, I don't know how long, time.  Of course, there are times when the ckt. shuts off unintentionally.

Recenty, I added an accelerometer to the system.  It does a real good job of recording every bump on the road.  So, OFF with the accelerometer. ::)

PO'T

Angelo

#141
Nov 18, 2009, 08:55 am Last Edit: Nov 19, 2009, 04:55 am by ARQuattr Reason: 1
I have been having some trouble getting the uFAT and Device Print working.  I'm using Arduino 0015 and Duemilanove with Atmega328, on Windows XP.  I have the FutureElec SD breakout board and I wired it up according to the details provided including the voltage dividers.

I am using the library archive dated 4/19/09 and DevicePrintDemo sketch from 2/11/09.  I tried to follow the code setup instructions (eg. reply #82), but for some reason it wouldn't compile.  I had to copy the 3 header files to the ..\hardware\tools\avr\avr\include folder, and I had to 'Add File' for the 3 cpp files to the DevicePrintDemo sketchbook.  I'm new to Arduino so I'm not sure if I set this up right.  But it would finally compile with no errors, and sketch size of 5280 bytes.

I have tried two cards, one is a 16MB MMC, formated in a DOS prompt in FAT with 512 block size.  The other is a 2GB SanDisk MiniSD (in an adapter).  This one wouldn't let me use 512 byte block size ("The specified cluster size is too small for FAT16/12.") or anything up to 16k for that matter, so I used the default 32k.  I put a ~160kB data.txt file on each.

The 16MB MMC card gave the following error:

uFat / DevicePrint Demo
2009 arduinonut.blogspot.com

Error  Couldn't initialise microfat
<press reset>


...and the 2GB SD gave me the following:

uFat / DevicePrint Demo
2009 arduinonut.blogspot.com

Error  Couldn't initialise card
<press reset>


I am going to try to get another card to test, but does anyone have any other ideas what I might be doing wrong?

Many thanks,
Angelo

davewking

Interesting posts.  I've used the WaveRP library to read and write to the SD card on a wave shield.  It works pretty well.

Angelo

I'm still having trouble with the uFat library, so I decided to try some of the other options.

I tried Roland's library but had trouble compiling.  It gave a lot of 'outside C99' errors, which I started to go through and fix, but obviously something else is wrong there so I stopped.  Should that library not work with the Arduino 0015 compiler?

I then tried the Fat16 library from Greiman.  This is a great package, very well documented with many example sketches and I was able to open and compile them with no problems.  When running them however I keep getting card errors.  I also tried a new SD card and am still having troubles.

I thought there may be problems with the hardware setup and reviewed it several times but it's very simple wiring (the resistor divider design) and I don't see any issues.  I put a logic analyzer on it and can observe SPI data which appears to follow what the code is doing.  Using 4.7k and 10k resistors I'm getting voltages around 3.4V - does anybody feel that might be too high for the SD cards?  Also, any issue with using the 3.3V supplied by the Arduino?  I understand that comes from the regulator inside the FTDI chip, which I think is limited to 50mA.  I measured the current going to the SD card board and it was only about 6-8mA, but I had trouble using the supply from that chip on another board.  It seems others are using that supply for this purpose, so I thought I would be OK.

I'm going to use the scope next to see if I'm having problems with attenuation or anything else that might be interfering with the communications.

Using the Fat16 library I get the following errors:

With the 2G SanDisk SD:

FreeRam: 1288
readCID failed

With the 16MB MMC and 32MB SD cards:

FreeRam: 1288
card.init failed
SD error
errorCode: 2
errorData: 3

or sometimes:

FreeRam: 1288
card.init failed
SD error
errorCode: 1
errorData: FF

According to the SDCard header, error code 1 is "Card did not go into SPI mode", and error code 2 is "Card did not go ready".

This is quite frustrating, since I've seen so many people get these libraries working 'out of the box'.  I have some pressing needs now, so I think I will go back to a Flash chip on SPI for the moment, but I would love to have this functionality working for future projects.

Anybody with advice on where to look or what to try, would be greatly appreciated.

Regards,
Angelo





BenF

Quote
I'm still having trouble with the uFat library


I've used the Roland library and is quite happy with it. There are some issues with compiling (as the library was not made for Arduino), but it is fairly straight forward to fix.

To me it seems as if you have hardware issues. One thing to consider is your 3V3 power supply. Using a voltage divider to power logic circuitry is generally no good. The issue here is that voltage will jump up and down as current through the divider changes. You will be better off using the Arduino 3V3 output as it is regulated (50mA is plenty).

Angelo

No, I wasn't clear - the SD is powered directly from the 3.3V supply pin on the Arduino.  I'm using the voltage divider for logic level shifting the 5V output pins from the ATMEGA to the SD card.  The data line from the SD to the ATMEGA goes directly.

It's good to hear that I should expect to need to make changes to Roland's library to get it to work in Arduino, since I was starting to think I was really lost.

Thanks for the feedback.

weersch

Hi.
Is there a SD card Read-Only library (with limited code size)?
I need to read data from 1 text file on the SD card that has been written on a Desktop/Laptop (FAT16).
I need to find a text string/ text line out of 1000 lines on the SD card. Then read that line of characters.
Any suggestions ?

florinc

I used SDuFAT
http://blushingboy.net/p/SDuFAT/downloads/2/
with good results in my project that does just that: reads text from SD card and parses it:
http://timewitharduino.blogspot.com/

tz

http://harleyhacking.blogspot.com/2010/01/lf25-03a.html

Read the other posts for history and other info.  Not public domain or GPL, (at least not yet) but free for educational or personal use.

SD or SDHC.  Runs near theoretical maximum speed (class 2 @ 2Mb/S, class6 @ 6Mb/sec).  Still being adjusted.  Might not work with MMC cards (without restoring the slow clock until SD detected).  Tested with 512M 1.0 through 16Mb SDHC 2.0 - most in between.  Just under 2k (could be trimmed but be slow and even less compatible).

FAT32 only, but fairly complete (Open/Create/mkdir/chdir/delete/optional extended partitions/read/write/seek/truncate - no rmdir (it could but no verification for empty directory) - see fat32.h and sdhc.h and main.c demo).  Library is about 10K with everything, less if you only need to write, uses under 100 bytes of ram for state, just over 512 bytes for sector buffer.  You can zap the filesystem with the wrong calls so beware.  FAT32 demo also runs under linux for testing (e.g. "sudo testfat /dev/sdc").

Written in C.

Runs on the OpenLog from sparkfun or any arduino or AVR with the SPI attached (ss# to cs#, mosi/miso/sck to the respective SD pins).  Set the F_CPU in the makefile if it isn't 16Mhz (will run proportionately slower at slower clocks).

Still an alpha but generally works.  At least until I do something stupid which I don't have an interlock for (like open directory, write...).

MetroExpress

Figured out the problem dont use this library at all lol.. that is if you are using a mega :)

used a different library working fine now.

Go Up