wiznet w5200 stability

Hello,

I have a project that is working, with a w5200 module attached too it. Everything works as expected, except that the Ethernet module only works for few hours then quits working. A reset brings it back and all is good for another few hours.

I have tried many different versions of the driver, and tried modifying the code in my sketch, even using the example code that comes with it, but nothing seems to keep it running for more than a few hours. After that period of time all communication stops, pings don't work, but the nic still has power.

This can be repeated using my secondary uno and a secondary w5200 nic and a different power source. So I don't think it is a hardware problem.

I am at wits end, there is nothing else I can think of that will solve this, except an auto reset every hour or so....

Does anyone have a working stable system and a driver that they could share? The example code I was using is the: Examples-Ethernet-WebServer

Thanks, Dan.

Hi Dan. This works well with the w5100. There are two versions on this page. The new (top) sketch uses the SD and the old one (bottom) doesn't. Your choice. Both are well tested. http://playground.arduino.cc/Code/WebServerST

At the bottom of the new server sketch is a function called ShowSockStatus(). You should be able to use it with the w5200. It will show the status for all the sockets. Call it in your sketch to see if you are running out of sockets. It shows 4 sockets for the w5100 and should show 8 for the 5200. I haven't checked it on a w5200 yet.

edit: I forgot to ask if you replaced the old w5100.h and w5100.cpp files with the w5200 versions from Wiznet. If you haven't, that could cause a problem.

You should look at this page also. Read the comments. There are some changes to the library code you must make if you use the w5200 versions of those files. https://code.google.com/p/arduino/issues/detail?id=898

Hi Tim,

Those were the drivers I was using. Found them to be the most compatible and compile properly. I had replaced all of the files in the correct directories yes…

If I just want to check the socket status in the serial monitor should I not just be able to add this to my sketch?

void myStuff() {
  if(Serial.available()) {
    if(Serial.read() == 'r') ShowSockStatus();    
  }
}

byte socketStat[MAX_SOCK_NUM];

void ShowSockStatus()
{
  for (int i = 0; i < MAX_SOCK_NUM; i++) {
    Serial.print(F("Socket#"));
    Serial.print(i);
    uint8_t s = W5100.readSnSR(i);
    socketStat[i] = s;
    Serial.print(F(":0x"));
    Serial.print(s,16);
    Serial.print(F(" "));
    Serial.print(W5100.readSnPORT(i));
    Serial.print(F(" D:"));
    uint8_t dip[4];
    W5100.readSnDIPR(i, dip);
    for (int j=0; j<4; j++) {
      Serial.print(dip[j],10);
      if (j<3) Serial.print(".");
    }
    Serial.print(F("("));
    Serial.print(W5100.readSnDPORT(i));
    Serial.println(F(")"));
  }
}

and then add this in the loop:

  myStuff();

Doesn’t seem to give me any socket status.

I don’t have an sd card reader on this setup so I cannot use the new sketch on the page you recommended. I tried the old one and again, it worked for a while but quit. It does not show the socket usage though.

Dan.

The ShowSockStatus function should display the status. When you enter the ‘r’ and press the enter key in the serial monitor, does it print the socket status with the incorrect values?

edit: Insure you include the w5100.h file in your sketch or it won’t compile.
#include <utility/w5100.h>

I’ve run a variation of the below code (the 1 sec refresh) using a w5100 Ethernet shield for a couple of days in the past without a hang (500,000+ refreshes). You might want to see if it hangs with your setup.

// zoomkat's meta refresh data frame test page 5/25/13
// use http://192.168.1.102:84 in your brouser for main page
// http://192.168.1.102:84/data static data page
// http://192.168.1.102:84/datastart meta refresh data page
// for use with W5100 based ethernet shields
// set the refresh rate to 0 for fastest update
// use STOP for single data updates

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

const int analogInPin0 = A0;
const int analogInPin1 = A1;
const int analogInPin2 = A2;
const int analogInPin3 = A3;
const int analogInPin4 = A4;
const int analogInPin5 = A5;

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip[] = { 192, 168, 1, 102 }; // arduino ip in lan
byte gateway[] = { 192, 168, 1, 1 }; // internet access via router
byte subnet[] = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port
unsigned long int x=0; //set refresh counter to 0
String readString; 

//////////////////////

void setup(){
  Serial.begin(9600);
    // disable SD SPI if memory card in the uSD slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

  Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();
  Serial.println("meta refresh data frame test 5/25/13"); // so I can keep track of what is loaded
}

void loop(){
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
         if (readString.length() < 100) {
          readString += c; 
         } 
        //check if HTTP request has ended
        if (c == '\n') {

          //check get atring received
          Serial.println(readString);

          //output HTML data header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();

          //generate data page
          if(readString.indexOf("data") >0) {  //checks for "data" page
            x=x+1; //page upload counter
            client.print("<HTML><HEAD>");
            //meta-refresh page every 1 seconds if "datastart" page
            if(readString.indexOf("datastart") >0) client.print("<meta http-equiv='refresh' content='1'>"); 
            //meta-refresh 0 for fast data
            if(readString.indexOf("datafast") >0) client.print("<meta http-equiv='refresh' content='0'>"); 
            client.print("<title>Zoomkat's meta-refresh test</title></head><BODY>
");
            client.print("page refresh number: ");
            client.print(x); //current refresh count
            client.print("

");
            
              //output the value of each analog input pin
            client.print("analog input0 is: ");
            client.print(analogRead(analogInPin0));
            
            client.print("
analog input1 is: ");
            client.print(analogRead(analogInPin1));
                        
            client.print("
analog input2 is: ");
            client.print(analogRead(analogInPin2));
            
            client.print("
analog input3 is: ");
            client.print(analogRead(analogInPin3));
                                    
            client.print("
analog input4 is: ");
            client.print(analogRead(analogInPin4));
            
            client.print("
analog input5 is: ");
            client.print(analogRead(analogInPin5));
            client.println("
</BODY></HTML>");
           }
          //generate main page with iframe
          else
          {
            client.print("<HTML><HEAD><TITLE>Zoomkat's frame refresh test</TITLE></HEAD>");
            client.print("Zoomkat's Arduino frame meta refresh test 5/25/13");
            client.print("

Arduino analog input data frame:
");
            client.print("&nbsp;&nbsp;<a href='http://192.168.1.102:84/datastart' target='DataBox' title=''yy''>META-REFRESH</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='http://192.168.1.102:84/data' target='DataBox' title=''xx''>SINGLE-STOP</a>");
            client.print("&nbsp;&nbsp;&nbsp;&nbsp;<a href='http://192.168.1.102:84/datafast' target='DataBox' title=''zz''>FAST-DATA</a>
");
            client.print("<iframe src='http://192.168.1.102:84/data' width='350' height='250' name='DataBox'>");
            client.print("</iframe>
</HTML>");
          }
          delay(1);
          //stopping client
          client.stop();
          //clearing string for next read
          readString="";
        }
      }
    }
  }
}

Hi Tim,

Ok, I copied the code, changed the ip address to match my subnet, and it worked for about 5 minutes then quit.

Any ideas?

Dan.

Ok, I think I may have found my problem. I made myself a pcb board from protoboard and some various cables and connectors. If I remove this board and go directly from the uno to the w5200 it works fine.....

How could the pcb board make it unstable, but yet work some of the time?

Dan.

Could have been anything like intermittent break in a connection, too much line impedance, resistive short, etc. But the important part is it is working now. :)

No, I take that back. Still not stable. Put it in a breadboard, connected it directly and it worked for about 5 hours then quit again.

Post your code and where in the code it quit. What was the last thing displayed on the serial monitor?

edit: Did you use the ShowSockStatus function to check the sockets? Was the Arduino still running or did it freeze up?

Be aware the current consumption of the w5200 chip could be 175mA, so when powered via arduino you could overheat the voltage regulator easily… Also check you have got enough decoupling capacitors on power lines…

SurferTim: Post your code and where in the code it quit. What was the last thing displayed on the serial monitor?

edit: Did you use the ShowSockStatus function to check the sockets? Was the Arduino still running or did it freeze up?

SurferTim: Post your code and where in the code it quit. What was the last thing displayed on the serial monitor?

edit: Did you use the ShowSockStatus function to check the sockets? Was the Arduino still running or did it freeze up?

Tim,

I was just using the example code included with the IDE.

I have not used the ShowSockStatus function yet. Can I just put it in my code or is there something else I need to include. Sorry I didn't quite understand how to use it.

zoomkat:
I’ve run a variation of the below code (the 1 sec refresh) using a w5100 Ethernet shield for a couple of days in the past without a hang (500,000+ refreshes). You might want to see if it hangs with your setup.

// zoomkat's meta refresh data frame test page 5/25/13

// use http://192.168.1.102:84 in your brouser for main page
// http://192.168.1.102:84/data static data page
// http://192.168.1.102:84/datastart meta refresh data page
// for use with W5100 based ethernet shields
// set the refresh rate to 0 for fastest update
// use STOP for single data updates

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

const int analogInPin0 = A0;
const int analogInPin1 = A1;
const int analogInPin2 = A2;
const int analogInPin3 = A3;
const int analogInPin4 = A4;
const int analogInPin5 = A5;

byte mac = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; //physical mac address
byte ip = { 192, 168, 1, 102 }; // arduino ip in lan
byte gateway = { 192, 168, 1, 1 }; // internet access via router
byte subnet = { 255, 255, 255, 0 }; //subnet mask
EthernetServer server(84); //server port
unsigned long int x=0; //set refresh counter to 0
String readString;

//////////////////////

void setup(){
  Serial.begin(9600);
    // disable SD SPI if memory card in the uSD slot
  pinMode(4,OUTPUT);
  digitalWrite(4,HIGH);

Ethernet.begin(mac, ip, gateway, gateway, subnet);
  server.begin();
  Serial.println(“meta refresh data frame test 5/25/13”); // so I can keep track of what is loaded
}

void loop(){
  EthernetClient client = server.available();
  if (client) {
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
         if (readString.length() < 100) {
          readString += c;
         }
        //check if HTTP request has ended
        if (c == ‘\n’) {

//check get atring received
          Serial.println(readString);

//output HTML data header
          client.println(“HTTP/1.1 200 OK”);
          client.println(“Content-Type: text/html”);
          client.println();

//generate data page
          if(readString.indexOf(“data”) >0) {  //checks for “data” page
            x=x+1; //page upload counter
            client.print("");
            //meta-refresh page every 1 seconds if “datastart” page
            if(readString.indexOf(“datastart”) >0) client.print("");
            //meta-refresh 0 for fast data
            if(readString.indexOf(“datafast”) >0) client.print("");
            client.print("Zoomkat’s meta-refresh test
");
            client.print("page refresh number: “);
            client.print(x); //current refresh count
            client.print(”

");
           
              //output the value of each analog input pin
            client.print("analog input0 is: “);
            client.print(analogRead(analogInPin0));
           
            client.print(”
analog input1 is: “);
            client.print(analogRead(analogInPin1));
                       
            client.print(”
analog input2 is: “);
            client.print(analogRead(analogInPin2));
           
            client.print(”
analog input3 is: “);
            client.print(analogRead(analogInPin3));
                                   
            client.print(”
analog input4 is: “);
            client.print(analogRead(analogInPin4));
           
            client.print(”
analog input5 is: “);
            client.print(analogRead(analogInPin5));
            client.println(”

");            }           //generate main page with iframe           else           {             client.print("Zoomkat's frame refresh test");             client.print("Zoomkat's Arduino frame meta refresh test 5/25/13");             client.print("

Arduino analog input data frame:
“);
            client.print(”  <a href=‘http://192.168.1.102:84/datastart’ target=‘DataBox’ title=’‘yy’’>META-REFRESH");
            client.print("    <a href=‘http://192.168.1.102:84/data’ target=‘DataBox’ title=’‘xx’’>SINGLE-STOP");
            client.print("    <a href=‘http://192.168.1.102:84/datafast’ target=‘DataBox’ title=’‘zz’’>FAST-DATA
“);
            client.print(”

");           }           delay(1);           //stopping client           client.stop();           //clearing string for next read           readString="";         }       }     }   } } > ```

Ok, I ran this one on my test setup using a secondary UNO and my secondary w5200 and it seems to work longer…

pito: Be aware the current consumption of the w5200 chip could be 175mA, so when powered via arduino you could overheat the voltage regulator easily.. Also check you have got enough decoupling capacitors on power lines..

Ok, this could very well be my problem. On my production setup I have a 3.3 voltage regulator with two tantalum capacitors as show in this example:

http://www.jameco.com/Jameco/workshop/JamecoBuilds/arduinocircuit.html

I have only the nic connected to it and did a temperature test on it and it was at 149F....too hot to hold you finger on it. Yikes.

On my secondary setup I have use an UNO and a w5200 nic, and with this setup it seems to run for a lot longer periods.

Does the w5200 freeze and the Arduino keeps running? Or do both freeze? Still got LEDs lit on both devices? They should go out if the regulator shuts down due to overheat. Most regulators have thermal overload protection.

I run the w5100 and the SD card with my server code, and it gets a bit hot, but has not failed or shut down because of it. The SD adds another 100ma to my load when uploading images. I've run mine for days at a time exposed to the internet. No fails.

Ok, then I guess the regulator is fine then.

No it appears that everything is running fine, there are lights on both the arduino and the w5200. If you could clarify how the ShowSockStatus function is supposed to work? I think that would be best place to start troubleshooting.

Thanks, Dan.

There are two ways I use it. It will display the socket status every connection, and allows you to check between connections by entering the 'r' key when it freezes, to see if it is the Arduino code or the w5200 that failed. If the 'r' key does not display anything, then the Arduino code has stopped or is in an endless loop somewhere in your code.

Add the ShowSockStatus function and make these modifications to your loop code.

void loop(){
   if(Serial.available()) {
      if(Serial.read() == 'r') ShowSockStatus();
   }

  EthernetClient client = server.available();
  if (client) {
    ShowSockStatus();
    while (client.connected()) {

Ok, first test:

Using the meta refresh code that zoomkat provided, I did a datastart. After it quit working, there were no sockets in use:

Socket#0:0x0 0 D:0.0.0.0(0) Socket#1:0x0 0 D:0.0.0.0(0) Socket#2:0x0 0 D:0.0.0.0(0) Socket#3:0x0 0 D:0.0.0.0(0) Socket#4:0x0 0 D:0.0.0.0(0) Socket#5:0x0 0 D:0.0.0.0(0) Socket#6:0x0 0 D:0.0.0.0(0) Socket#7:0x0 0 D:0.0.0.0(0)

When it was working there were two sockets in use:

Socket#0:0x14 84 D:192.168.75.114(54134) Socket#1:0x0 84 D:192.168.75.114(54135) Socket#2:0x0 0 D:0.0.0.0(0) Socket#3:0x0 0 D:0.0.0.0(0) Socket#4:0x0 0 D:0.0.0.0(0) Socket#5:0x0 0 D:0.0.0.0(0) Socket#6:0x0 0 D:0.0.0.0(0) Socket#7:0x0 0 D:0.0.0.0(0)

Second test resulted in the following:

Socket#0:0x14 84 D:0.0.0.0(0) Socket#1:0x0 0 D:0.0.0.0(0) Socket#2:0x0 0 D:0.0.0.0(0) Socket#3:0x0 0 D:0.0.0.0(0) Socket#4:0x0 0 D:0.0.0.0(0) Socket#5:0x0 0 D:0.0.0.0(0) Socket#6:0x0 0 D:0.0.0.0(0) Socket#7:0x0 0 D:0.0.0.0(0)

The format for that is:
Socket# : D:(client port)

The status 0x0 is a socket that is available. If you don’t start the server, there will be no sockets reserved. All will be 0x0.
The socket retains the client data from the last connection. That is why you see data associated with some sockets with a status of 0x0.

The status 0x14 is a server socket waiting for a client.
The status 0x17 is a socket with a client connected.

If the w5200 is showing all socket status as 0x0 after a crash, then it is the w5200 that is failing, not the Arduino. That is not good. Either the w5200 is not responding, or did not start a socket listening after the last connection.

The “second test” results is after a crash? Or after zoomkat’s code quit updating? Does the server respond if you try it again? Sometimes the browser’s meta refresh fails. I use a JavaScript routine to update my Arduino page into a iFrame instead of using meta refresh. If the meta refresh fails once, it stops updating. If the JavaScript fails once, it will continue to reload the page.

edit: How do you have the w5200 connected to the Arduino? Is it on a circuit board or breadboard? Are you certain all is connected correctly? Don’t leave any pins on the w5200 floating that shouldn’t be floating, like the “Reset” and “Power Down” pins. Here is a quote from a site that deals with the w5200 and the power down pin on one model w5200 shield.

Firstly, they have used quite a high resistance on the PWDN pin (which is intended to allow the W5200 to be powered down to reduce energy consumption). There is insufficient current on this resistor to hold ground, and sometimes the W5200 slips into PWDN mode and can’t be addressed.