November 13, 2010

Arduino Ethernet Shield modification to solve Wiznet chip SPI bug



Using my "old version" - Wiznet chip based - Arduino Ethernet shield, I run across the well documented Buggy Wiznet SPI, but I did want a solution that was hardware, and not software as the solution proposed in the Playground. This solution is sacrificing one precious pin on my Arduino board and requires library code changes; moreover, as you will see in a moment, I'll need a pin on the Arduino board to have control on the Ethernet shield reset.

So I've decided to follow the suggentions very well described in this post on the Arduino Forum.

I've used an MC14069 Hex Inverter, following this connection schema:



This is the schema I've used to realize the modification on a stripboard to be plugged on top of the Ethernet shield:


And here's the steps, starting desoldering the SD card holder (unusable on this shield) to be used in future projects:


Here's the SD card holder (will fit nice on the copper side of a stripboard):


I've then added two female pin headers on the PROG pad on the shield:


This is the back of the stripboard, with the pin bended to fit the pin on the PROG pad:


The MC14069 chip socket:


The small patch-board sitting on top of the shield:


The reset pin of the Ethernet shield bended, because it will not be used anymore. Why? I've taken another suggestion from the forum and will implement the shield reset via software ('cause I believe I'll have more control and flexibility):


Here's the wired and completed harware patch. You can see the white cable that can be put in any free pin of the Arduino board to control the reset of the Ethernet shield (in this case it is digital pin 2):


The reset is done with some code like this:


void init_ethernet()
{
 
pinMode(2, OUTPUT);    // sets the digital pin as output
 
digitalWrite(2, LOW);
 delay(1000);           // wait for ethernet chip to reset
 
digitalWrite(2, HIGH);
 delay(1000);           // wait for ethernet chip to reset
 
pinMode(2, INPUT);     // sets the digital pin input
 delay(1000);           // wait for ethernet chip to settle down

 Ethernet.begin(mac,ip,gateway,subnet);
 //etc...