Pages: [1] 2   Go Down
Author Topic: Arduino ethernet shield and accessing SD cards  (Read 8862 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 1
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

Hi,
I was looking for the same thing and found this:
[glow]file:///D:/DESK/A/EthernetShield/EthernetShieldSDHardwareSPIMod.htm[/glow]
This way it should be possible to use any lib (I plan to try [glow]http://code.google.com/p/fat16lib/[/glow]).
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 548
Posts: 46026
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Ops... Sorry!!!

Here's it:
[glow]http://www.arduino.cc/playground/Main/EthernetShieldSDHardwareSPIMod[/glow]

Logged

Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 5
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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 http://code.google.com/p/sdfatlib/.  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.
« Last Edit: August 30, 2010, 03:19:34 pm by davekw7x » Logged

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

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!!!
Logged

Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 5
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.)
« Last Edit: September 02, 2010, 12:14:19 pm by davekw7x » Logged

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

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  :-/
Logged

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

...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
Logged

Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 5
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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
« Last Edit: September 10, 2010, 09:57:54 am by davekw7x » Logged

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

Quote
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
Logged

Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 5
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

@davekw7x:
Quote
I did not have success with the Wiznet power-on reset when its reset pin was pulled up to +5 volts.
@ArJack:
Quote
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:
Quote
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 +5V

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 +3.3V

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.

« Last Edit: September 15, 2010, 03:47:29 pm by davekw7x » Logged

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

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...
Logged

Left Coast, USA
Offline Offline
Sr. Member
****
Karma: 5
Posts: 499
Sometimes I just can't help myself.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
« Last Edit: September 17, 2010, 12:10:40 am by davekw7x » Logged

Italy
Offline Offline
Newbie
*
Karma: 0
Posts: 3
Let's build and invent!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Here http://marco.guardigli.it/2010/11/arduino-wiznet-ethernet-shield-proper.html are some details and pictures.

After the mod, everything works fine.


Marco     ( @mgua )
« Last Edit: November 22, 2010, 05:03:27 pm by mgua » Logged

@mgua

Pages: [1] 2   Go Up
Jump to: