Ethernet Shield (5100) problem, random garbage

Greetings all! This is my first question/post, and my question is about the Ethernet Shields using the Wiznet chip.

Long story short, I used the example code from the Ethernet Library, and after that didn’t work I changed the IP address accordingly after connecting to my Router to resolve this, and modified the code to simplify the information spit out, rather than using the FOR loop to read all 6 analog input pins.

Things work sort of, but I started experiencing problems, that of occasional random garbage after connecting to the device. Not entirely random garbage, just aperiodic random garbage comingled with normal output data. The data would be read flawlessly for several iterations, then suddenly garbage, or the device would stop responding.

I changed the source example to just spit out millis() readings and an iterator showing how many times the Browser had queried the device, and changed the line of code that tells the browser to query every 5 seconds, to querying every 30 seconds. That was all fine and good, as by the Browser the page contents now showed when exactly, as well as which iteration. It ran fine for more than an hour, but being adventurous I changed the latency back to 5 seconds from “my client.println(”<meta http-equiv=“refresh” content=“30”>");"

This information (chronological information and iterative information that I modified the source code to spit out) later became important when I was to cut & paste aperiodic random spew (that appeared in the browser) from the shield. That which was spewed occasionally, was the comingled results of the information to be currently broadcast, as well as what appeared to be the partial (reverse-chronological) contents of the buffer of the Wiznet chip. Not linear, just randomly sized chunks of previous buffer contents, including content which was no longer relevant having uploaded new code after resetting the Arduino (but not resetting the Wiznet). I figured out that I should hard-reset the Wiznet device (my rev of the board doesn’t do that).

Still I had the problem; unpredictable outputs from the device, regardless of latency. Occasionally, the sensible outputs from the device would be interrupted by burps and farts of information that was present since the last hardware reset. Not things that the Arduino was sending. To me the result appears like interrupt recursion, where two devices are trying to stream stuff at the same time.

The initial workaround that I used, was to change the “refresh” latency to 30 seconds, rather than 5. But I’m not going to let it run for DAYS to figure out if that (ultimately) solved my problem. The example code causes the Browser to refresh every 5 seconds, and should work without issue notwithstanding.

This problem to me is mysterious. I’ve ruled out the infrastructure, and the power supply and such. I get regular message broadcasts, occasionally mixed with (what appears to be) random (5100) buffer garbage after making the changes to the source code.

Given that this problem is aperiodic, and is it consistent (the information spewed varies in quantity if not content), and having looked at the physical hardware, I can only suspect that this problem is firmware related should that be the case, or there is something lacking in the Software examples (the libraries) which does not address this problem; but the problem is likely related to the Wiznet chip.

Maybe this is as simple as purging the buffer of the Wiznet chip somehow visa vis the Ethernet library? Again if that was important, it should have been part of the (library) example, so I apologize for lack of due-diligence in finding a solution before posting the question in the first place. My questions (3) being, what is causing this aperiodic garbage output despite periodic non-random output? Should there be a Library upgrade to address this problem if it is not entirely unique? And given the spurious nature of this problem which I think is (5100) buffer related, is there a simple workaround to alleviate this?

Perhaps a single line of CODE would remedy the situation, but I think that if this WAS a known issue, the library examples dating back more than 5 years would have had just this.

Has anyone else experienced this exact problem in particular? That not of it not working, but just not working predictably.

I’d appreciate any ideas as to how to solve this problem; replacing the physical hardware doesn’t to me seem like the obvious solution given that it does in fact work most of the time. I’m not convinced that this is a Hardware problem, I’m more inclined to think its a software or firmware problem.

Thanks for reading, and if anyone has any ideas about this, I’d like to hear them.

http://arduino.cc/forum/index.php/topic,97455.0.html

Try disabling the SD SPI interface. That has been known to trash up the SPI interface if not disabled.

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

   // sprinkle a little magic pixie dust
   pinMode(4,OUTPUT);
   digitalWrite(4,HIGH);

   // rest of your setup code
}

Posting your code would help.

Nick and Tim, thank-you for your responses. Obviously (Nick) I have some in-depth reading top do, and Tim thx for mentioning the Slave Select line for the SD Card. Since I posted the question I've been doing some troubleshooting, and I think that the problem is related to the (particular) shield itself.

I bought a second Ethernet shield and another power supply. Both were programmed identically (other than IP/MAC differences) using the library examples. I plugged both into a router, opened two terminal windows and two browser windows, and watched and waited. One of the two (the same one) did in fact crash again. I sequentially swapped power supplies, network cables, cleaned header pins, reseated cables, let the boards run and heat up, threw them in the fridge to chill them, and even swapped the shields with each other. Six hours of this so far but one particular shield had in fact malfunctioned a half dozen times whereas the other has not (despite any changes), so all things IMHO now point to a faulty board.

I thank you Gentleman for your help, and believe that my problem has been solved ;)

I tested the below code using IE over a number of days and it appreared to refresh 150K+ times without issues. I have an old arduino with an old w5100 shield.

// zoomkat meta refresh server test code
// arduino IDE 1.0
// for W5100 ethernet shield
// the IP address will be dependent on your local network/router
// port 80 is default for HTTP, but can be changed as needed
// use IP address like http://192.168.1.102:84 in your brouser
// or http://zoomkat.no-ip.com:84 with dynamic IP service
// use the \ slash to escape the " in the html
// meta refresh set for 2 seconds

#include <SPI.h>
#include <Ethernet.h>

int x=0; //set refresh counter to 0
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,102); // ip in lan
EthernetServer server(84); //server is using port 84

void setup()
{
  // start the server
  Ethernet.begin(mac, ip);
  server.begin();
}

void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
     while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // see if HTTP request has ended with blank line
        if (c == '\n') {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
          
          //meta-refresh page every 2 seconds
          x=x+1; //page upload counter
          client.println("<HTML>");
          client.print("<HEAD>");
          client.print("<meta http-equiv=\"refresh\" content=\"2\">");
          client.print("<TITLE />Zoomkat's meta-refresh test</title>");
          client.print("</head>");
          client.println("<BODY>");
          client.print("Zoomkat's meta-refresh test IDE 1.0");
          client.println("
");
                    
          client.print("page refresh number ");
          client.println(x); //current refresh count
          client.println("
");
          client.println("
");
          
          client.print("Zoomkat's arduino analog input values:");
          client.println("
");
          client.println("
");
          
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("
");
            }
           break;
          client.println("</BODY>");
          client.println("</HTML>");
         }
        }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}