Arduino ethernet shield and accessing SD cards

Hey fellow Arduino'ers..
I've just got an arduino and ethernet shield (the original Wiznet SD card version) and ethernet wise its working great.

I'd like to use the the SD card slot but supposedly it is still unsupported by the ethernet library. However I know that SD cards can be interfaced directly with the Arduino, so after a lot of inconclusive research, my questions:

Is there any way to harness the SD slot onboard the Ethernet shield using the standard sdcard libraries?

Are the card slot pins connected directly to the spi pins on the ethernet shield, or is the slot somehow interfaced with the Wiznet chip?

Is there a schematic for the ethernet shield?

So far I only know to bring pin 4 high when using the SD card, and pin 10 for when using ethernet, but nothing else! The Arduino site is vague and they may only be talking about the latest ethernet shield with a supported MicroSD slot.

any help much appreciated

Hi,
I was looking for the same thing and found this:
file:///D:/DESK/A/EthernetShield/EthernetShieldSDHardwareSPIMod.htm
This way it should be possible to use any lib (I plan to try Google Code Archive - Long-term storage for Google Code Project Hosting.).

@ArJack
For some reason, that link to a file on your hard drive is not working...

Ops... Sorry!!!

Here's it:
Arduino Playground - EthernetShieldSDHardwareSPIMod

The problem that I see with that playground kludge for SD on the old Ethernet Shield is that Arduino boards like the Duemilanove have 5 Volt logic levels, but SD memory is rated for 3.3 Volts (!)

I'm not saying that it can't work. I'm saying that I don't believe that it's good for the SD card, and I wouldn't be surprised to find that the SD card is damaged by those direct connections. Maybe not instantaneously, but sooner or later.

I have seen surgical approaches that cut traces on the Shield and put resistive voltage dividers between the three Arduino SPI port output pins and the corresponding SD input pins, but those reportedly result in timing problems with newer SDHD cards. Maybe it could work with older SD (non-HD, non-Ultra) cards???

The old Shield schematic is here: http://arduino.cc/en/uploads/Main/arduino-ethernet-shield-schematic.pdf

The new one is here: http://arduino.cc/en/uploads/Main/arduino-ethernet-shield-05-schematic.pdf

(Until a couple of days ago, they had the new description but they only had the old schematic.)

I note that the new Shield uses resistor voltage dividers on the Arduino outputs for level shifting to the SD pins. I think that is a highly questionable design decision.

I mean, maybe the new Shield works OK, but, really! I always raise my eyebrows when I see circuits with resistors and diodes and stuff like that performing logic functions.

Oh, well...

I used three sections of a 74HC4050 on my homebrew (hand-wired on perfboard) SD card interface. That chip is expressly designed for level-shifting (can use 3.3 Volt output supply and inputs are designed to tolerate higher voltages), and my circuit talks to every flavor of SD card that I have tried. I use the SdFat library from Google Code Archive - Long-term storage for Google Code Project Hosting.. Lots of good (and working) examples. Reads FAT12, FAT16, and FAT32; no need to reformat the cards as they come from the factory. Etc., etc., etc.

Some SD interfaces that I have seen use diodes in series with the Arduino output lines---cathode toward the Arduino---and 3.3 Volt pullup resistors on the SD card side. Uggh and double-uggh!

I had a few of the level shifter chips left over from previous projects, but if I had to buy them new, the '4050s would cost something like 15 cents (0.15 US Dollars) each from Jameco. Why the heck would I use resistors and/or diodes???

If you do try to use the old Shield with an SD SPI interface (or any other SPI port device), you will have to do something about the Wiznet SPI bug. I used a single section of a CD4049 instead of the 74LVC14 shown on the new Shield schematic to invert the Ethernet SS signal and apply it to the SEN pin on the Wiznet device.

I just hot-glued the '4049 (with its little feet in the air) to the top of the Shield and sky-wired the connections. See Footnote.

Note that unused inputs of CMOS devices should always be tied high or low...not left floating.

Regards,

Dave

Footnote:
This technique of attaching DIP ICs (upside down) to existing boards and wiring their pins to points in the existing circuit has been used by experimenters for years, and is affectionately known as the "dead bug" method. The tiniest dab of hot-melt glue keeps them in place and you can remove the chip with no damage to the board if you ever feel the need to restore it to factory-fresh condition.

Please, can you explain the difference between your Wiznet SPI bug solution and the one in the playground (that involves also some library mods)...
Thanks!!!

On the Wiznet site http://www.wiznet.co.kr/en/, there is an errata sheet and an application note that shows a way to work around the bug on the '5100. You can refer to the schematic of the latest Ethernet shield to see how it is done on the new version.

For the old version of the Ethernet Shield. you don't have to change the library if you do the following:

Connect the input of a logic inverter to the SPI "SS" signal coming into the Ethernet Shield. Connect the output of the inverter to the "SEN" pin on the '5100. (That's pad number 2 of the "Prog" pads).

Now, when the Ethernet SPI interface is not selected ("SS" is high), the SEN signal on the '5100 is pulled low. This keeps the '5100 from corrupting data on the MISO pin back to the Arduino.

A single section of a CD4049 or a 74HC4049 hex inverter will do the trick. At least, it does for me. With a little hot-melt glue, a $0.15 chip and some 30-gauge insulated wire, the SPI now works as it should.

Note that I connected the power and ground of the hex inverter chip to Arduino +3.3 Volts (not +5 volts) and GND signals, respectively, and I connected the five unused inverter inputs to GND.

Regards,

Dave

Footnote:
Above and beyond the fact that the inverter mod doesn't require any library (software) modifications, it's more important to me that you don't have to use another Arduino pin for an Ethernet Shield SPI_EN_BIT as shown on the playground page. I'm always running out of pins with the ATmega328p.

Also note that I really (really) don't recommend running an SD memory card with 5 Volt logic signals as seems to be suggested on that playground page. After fixing the '5100 SPI bug on the Ethernet Shield, I used a separate SD interface card on the Arduino SPI port. (Same MISO, MOSI and SPI clock pins; different SS pin.)

Thanks a lot for sharing!

I'll take your suggestions and:

  • fix my 1st version ethernet shield
  • use a separate shield for SD

I only have to practice with SMD :-/

...waiting for the parts to to the job...

meanwhile: I can't figure out how the reset controller works on the new Ethernet Shield board. From the schematics it seems there's a 4-pin chip added between the reset button and the WIZNET chip, but no indication on it...

Thanks for helping

4-pin chip added between the reset button and the WIZNET

It appears to be something like an STMicroelectronics STM812. http://www.st.com/stonline/products/literature/ds/9873/stm812.pdf (The Eagle board layout view shows the value "STM812" for that chip. The schematic doesn't show the name, U2, or its value.)

I did not have success with the Wiznet power-on reset when its reset pin was pulled up to +5 volts. I assume that the Arduino folks have tested the circuit that they concocted for the new shield.

However...

If I had bought one of the old shields before reading about the various bugs (Wiznet power-on reset doesn't work, Wiznet reset doesn't work when Arduino is auto-reset from the serial interface, Arduino SD card connections not supported by Arduino library, Possible SD card damage with 5V logic signals), I would have assumed that they had tested that one too.

Oh, well...

Anyhow, I don't have one of the new ones to work with, and have no needs for more shields just now (even if I had the money). My two old (modified) ones suit my purposes, although I do wish I didn't have to use separate circuitry on another board for the SD card.

Maybe reports on the new shield will trickle in to this forum as the new shields become available. Maybe suppliers will have a "clearance sale" on the old ones. Then maybe I will pick up another one or two.

Regards,

Dave

when its reset pin was pulled up to +5 volts

...maybe grounded?
... I found this interesting topic (suggesting a cap and protection diode 'cause perhaps normal reset time is to short for the Wiznet chip)
http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1225354009/15

@davekw7x:

I did not have success with the Wiznet power-on reset when its reset pin was pulled up to +5 volts.

@ArJack:

maybe grounded?

No. I said that it didn't work (for me) when it is pulled up to +5 Volts, and that's what I meant to say.

Here's the deal:

When you plug the Shield into an Arduino board, the Wiznet's reset pin is connected to the Arduino's reset pin. This is pulled up to +5V through a resistor on the Arduino board.

@ArJack:

I found this interesting...

I have seen dozens of fixes posted on this forum that work for some people but not for others. That is, the value of capacitance required seemed to be fairly critical. Too little doesn't work; too much doesn't work. A value that gives satisfactory results for some people does not work for others.

I think (just a guess) that the differences may be explained by the differences in the way that power ramps up. That is, different setups will ramp up differently. My observation was that the normal auto-reset pulse on the Arduino was long enough to meet Wiznet specification.

However...

The reset must be asserted after the 3.3V power to the Wiznet reaches working value. Just adding more and more capacitance on the reset pin may eventually work on the Wiznet, but it will also eventually inhibit the auto-reset of the Arduino.

Here are some tests that I ran on the two "genuine" Arduino shields that I own. See Footnote.

The tests were performed with the Shield plugged into a "genuine" Duemilanove. I uploaded one of the Ethernet library sample sketches (the ChatServer) to the Duemilanove.

Then...

Test number 1:


1.  Connect a 10K resistor from the Wiznet reset pin to [b]+5V[/b]

2.  Connect a 10 nF capacitor from the Wiznet reset pin to GND.

3.  Isolate the Wiznet chip's reset signal from the Arduino reset by bending the reset pin on the Shield away from the Arduino connector before plugging them together.  (I didn't want to cut traces on the Shield.)

4. Power down and power up.

5. Repeat step 4 until I get really tired.

Results of test number 1:
It never powered up correctly (did not link up with my Ethernet LAN). It always required that I hit the manual reset button on the shield before I got anything. Then the operation was normal (after restarting the sketch that I was running).

Note that the way that I isolated the Shield from the Arduino means that the manual reset button on the Shield will not reset the Arduino. So if your setup doesn't work with Arduino auto-reset, this probably won't be the way to go.

Test number 2:


1.  Connect a 10K resistor from the Wiznet reset pin to [b]+3.3V[/b]

2.  Connect a 10 nF capacitor from the Wiznet reset pin to GND.

3.  Isolate the Wiznet chip's reset from the Arduino reset by bending the reset pin on the shield away from the Arduino connector before plugging them together.

4. Power down and power up.

5. Repeat step 4 until I get really tired.

Results of test number 2: It has never failed to power up correctly.

Now, I can only say that IWFMYMMV (It Works for Me, Your Mileage May Vary).

Additional notes:

I tried both tests with 100 nF capacitors; same results.

I tried both tests with the Arduino+Shield powered from USB and with power from a 9V regulated wall wart. Same results.

I tried both tests with no network connected at power up (then plugging in the Ethernet cable) and with the network connection present at power up. Same results.

Bottom line: Maybe it won't work for everybody, but this seems to be a relatively benign approach to testing:

Doesn't require cutting traces.
Doesn't require any additional ATmega output pins to perform the reset.
Doesn't require any software changes.

Regards,

Dave

Footnote:

The engineer's "rule" of finite Mathematical Induction:

If it works for n equal to 1 and it works for n equal to 2, then it works for all n.

Hi Dave,
many thanks for your clarifications.

Another approach I've seen is Arduino sketch giving a reset on the etherne shield using a dedicated digital out pin.
Don't know if it can work only at first startup...

I'll try the capacitor ASAP...

Reset can be asserted just about any time after power-up.

It can be asserted manually by pushing the "reset" button. Lots of people do this, but I simply won't live with it like that. No way.

If you make sure that the Wiznet chip's reset pin is no longer connected to the Arduino reset (by bending the Shield's reset pin away from the connector before plugging the Shield and the Arduino board together), you can use a logic output from the ATmega, as reported in numerous threads on this forum. I think that is probably the most robust and controllable way, but I didn't want to give up one of my precious I/O pins if I could find another method.

As far as I know both of these methods work reliably.

I haven't seen anyone else saying that they "discovered" what I think is true about the 5V pullup versus 3.3V pullup on the Wiznet chip in this application. All I can say is that it works for me.

Regards,

Dave

I successfully implemented davekw7x's suggestions (THANK YOU!), with arduino 2009 boards and wiznet 5100 shields.

Here Only_Dead_Fish_Go_With_The_Flow: Arduino Wiznet ethernet shield proper reset are some details and pictures.

After the mod, everything works fine.

Marco ( @mgua )

Excellant info! I just recently discovered the issue with the ethernet shield not self recovering from a power interruption. This should allow the arduino to be a remote stand alone server that can recover after a power failure.