Pages: [1]   Go Down
Author Topic: TinkerIt Ethernet SD won't connect  (Read 753 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello,

I am trying to get my Arduino Duemilanove to read/write to an SD card. I have a TinkerIt ethernet board, with solderpads for an SD slot. Since I assumed those pads had to be connected to something, I've soldered an SD slot to the ethernet shield. Plugged in an SD card, turned on the power.. LEDs turned on and no smoke escaped  smiley-lol

To actualy read or write to the card, I've at first used the default 1.01 SD library. My code:


Code:
#include <SD.h>

File file;

void setup()
{
  Serial.begin(9600);


  Serial.print("Initializing SD card...");
   pinMode(10, OUTPUT);
  
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  
  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");
  }
  
  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");
    
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
     Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
   // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
}

void loop()
{
// nothing happens after setup
}


Yes, this is the ReadWrite example provided with the SD library  smiley-wink  When I run this code, it say "Initialization failed!". Hence SD.begin(4) failed. I also tried ports 8 and 10, but since this is an ethernet port I believe 4 is the correct port.

Next I tried the SDFat library:

Code:
#include <SdFat.h>

SdFat sd;


void setup(){
  Serial.begin(9600);  
  digitalWrite(10,OUTPUT);
  
  if (!sd.init(SPI_FULL_SPEED, 4)) sd.initErrorHalt();
  
  ifstream file("HELLO.TXT");
  if (!file.is_open()) Serial.println("open failed");
  
  
  
}

void loop(){}

Not a lot of code, but it still fails at the initialization. Again, I tried ports 8 and 10 as wel.


Finally I tried the Quickstart example provided with SDFat. Manualy entered different port numbers, and yet again, failed.

I have tripple checked AND resoldered the SD slot. I have tested the setup with a 8GB formatted at FAT32 and a 2GB SD card formatted at FAT16 , both formatted at FAT32. I am aware FAT16 is prefered, but it should still work with FAT32.
Unfortunatly I can not find any decent information about the Tinker It ethernet shield, but it is based on a Wiznet W5100.

Using the SD slot does make the W5100 chip warm up, but it does not become hot. I can still use the ethernet module, so the chip is still alive and well.

Also, I do notice a lot of ethernet shields have Micro-SD slots, leaving a couple of solderpads unused. Since I am using a regular SD card, does this make a difference?


Does anyone know where to look for as to why the SD card can not be read?
Thanks  smiley-mr-green




edit: 2GB card was formatted at FAT16, not FAT32




« Last Edit: June 12, 2012, 01:54:59 pm by eightonegulf » Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 149
Posts: 6119
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

You should disable the w5100 SPI before setting up the SD card. Note pin 10 HIGH.
Code:
  // disable w5100 SPI
   pinMode(10, OUTPUT);
   digitalWrite(10,HIGH);
   
  Serial.print("Initializing SD card...");
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for your reply.

I have set pin 10 to high, while using the default SD library and the SdFat library. I have tried this with both my SD cards.

Code:
#include <SdFat.h>

SdFat sd;

void setup(){
  Serial.begin(9600);  
  digitalWrite(10,OUTPUT);
  digitalWrite(10,HIGH);
  
  if (!sd.init(SPI_FULL_SPEED, 4)) sd.initErrorHalt();
  ifstream file("HELLO.TXT");
  if (!file.is_open()) Serial.println("open failed");
}

void loop(){}

Code:
#include <SD.h>

void setup()
{
  Serial.begin(9600);

   // disable w5100 SPI
   pinMode(10, OUTPUT);
   digitalWrite(10,HIGH);
  
  Serial.print("Initializing SD card...");
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
  
}

void loop(){}

No luck so far. Both still fail while initializing.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Well, this explains a lot..
I have measured all SD slot pins. Normally the DataIn, DataOut and Clock pins should be connected to the SPI ports of the Arduino (11,12,13). Instead they are wired to the following Arduino pins.
   CS, pin 6
   DataIn, pin 8
   DataOut, pin 3
   Clk, pin 9

This corresponds exactly with the data here http://arduino.cc/playground/Main/EthernetShieldSDHardwareSPIMod.
So I hardwired the ethernet board like said, and I was able to connect to the SD card  smiley-lol
Logged

Pages: [1]   Go Up
Jump to: