Pages: [1]   Go Down
Author Topic: I wired up an SD Slot  (Read 1613 times)
0 Members and 1 Guest are viewing this topic.
Tacoma, WA
Offline Offline
Full Member
***
Karma: 4
Posts: 192
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I had an old digital camera laying around with and SD Slot in it.. smiley I managed to desolder it successfully, and then wired it up to work with the new Arduino SD Library. I used these instructions:
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1206874649/8
Which I think are completely wrong, he's got the CS pin going through the resistors, but not one of the data pins.. His library also used slightly different pins than the new built in library does. I took my pictures before I got it wired up right, so don't try to follow my jumpers..





I loaded up the example Datalog sketch, and after fixing the wiring, it works like a champ.
Since I just posted pictures of it wired wrong, here's the correct way to wire and SD slot:
SDCard pin 1 to Arduino pin 4
SDCard pin 2 to Arduino pin 11 (with the resistors)
SDCard pin 5 to Arduino pin 13 (resistors)
SDCard pin 7 to Arduino pin 12 (resistors)
If you're not sure what I mean about the resistors, see the link above.. I couldn't find any example schematics for the new SD Library, but I assume it should be wired with the resistors still? Unless that guy was wrong about that too. smiley
SDCard pins 3 & 6 go to Ground
SDCard pin 4 goes to 3.3v

Worked great for me, I've got some great plans for future projects datalogging to an SD Card. Just wanted to show off my repurposing part of an old worthless digital camera (was one of those that took absolutely rancid looking VGA resolution pictures).
And if anyone knows off the top of their head, or can point me to the answer.. What speed is this thing writing to the SD Card at? SPI is Serial, right? So is it 9600, faster, slower?
Logged

Brian from Tacoma, WA
Arduino evangelist - since Dec, 2010.

CT, USA
Offline Offline
Sr. Member
****
Karma: 3
Posts: 446
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I like the cutout in the PCB:)

Looks like you are using resister level shifters to make the 3.3V required by the SD... I read somewhere that newer SD cards sometimes have problems with this approach, not sure if you have encountered any.
Logged

Tacoma, WA
Offline Offline
Full Member
***
Karma: 4
Posts: 192
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I've only tried the one card so far. I assume the resistors are better for the card than sending 5v to it? Is there a better way to do this? smiley
Logged

Brian from Tacoma, WA
Arduino evangelist - since Dec, 2010.

CT, USA
Offline Offline
Sr. Member
****
Karma: 3
Posts: 446
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You could use a voltage level shifter as described here (http://www.ladyada.net/make/logshield/design.html) to make the 5V-3.3V matching.
Logged

Tacoma, WA
Offline Offline
Full Member
***
Karma: 4
Posts: 192
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Eh.. I really didn't want to buy any parts for this. It works the way it's wired, for now. Eventually I'll be picking up a Wave shield, and a CAN-BUS shield, both of which have a properly wired SD Slot. I figure if I'm going to spend some money to do this, I'll just buy a predesigned shield.
Also, I was daydreaming about this earlier, I think it dawned on me why one of the two IO pins didn't go through the resistor network, it'd be the output from the card, there's no need to drop the voltage on that pin, since the SD card is creating the voltage, not the Arduino.. I'll change my wiring around before I finalize my circuit. smiley I still haven't heard back about the speed of this SD interface.. I looked at the cpp files in the library, I see it calibrates per card, so I imagine there is some flux in the speed.. I just hope it writes faster than 9600 bps.. smiley
Logged

Brian from Tacoma, WA
Arduino evangelist - since Dec, 2010.

Tacoma, WA
Offline Offline
Full Member
***
Karma: 4
Posts: 192
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, I answered my question about how fast it writes to the SDCard.. This might be usable for something like a weather station, that makes one write every hour, or everytime the conditions change, but definitely not for the speed I need. Here's two log files:

The file on the right was captured from the serial port, at 38,400bps. The looptime is in Micros, each loop was 10,000 or so from the previous. Pretty much the only thing I changed in my code was to change the Serial.println's to logFile.println's, it's now about 400,000 each time around, so 40x slower, roughly.. So that's 10ms for the serial output, and 400ms to write to the SDCard.. Ouch..
either way is too slow for my needs anyways, I need 1ms resolution for the project I had in mind.
Logged

Brian from Tacoma, WA
Arduino evangelist - since Dec, 2010.

0
Offline Offline
Newbie
*
Karma: 0
Posts: 32
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

if it's an older SD card, then the read/write speed will be much slower than a newer card, so you could try to change to a newer card =)
Logged

Tacoma, WA
Offline Offline
Full Member
***
Karma: 4
Posts: 192
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I doubt even a Class 1 is THAT slow.. But this was a Class 4.. I use a Class 4 as a hard drive on my SheevaPlug server. And I can VNC into that thing and nearly use it as a normal computer.
Maybe it's my resistor network that's slowing me down? I'll be ordering a WaveShield soon for another project, so I'll get a chance to see if that properly designed SD interface is any faster.
Logged

Brian from Tacoma, WA
Arduino evangelist - since Dec, 2010.

North Yorkshire, UK
Offline Offline
Faraday Member
**
Karma: 104
Posts: 5531
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

There's been a recent thread on speeding up write times. Perhaps take a look at that.
Sounds like it can go much faster.

Mowcius
Logged

Pages: [1]   Go Up
Jump to: