W5200 ETHERNET SHIELD compatibily problems

I purchased a w5200 Ethernet shield by ekitszone - i am using an UNO ver R3 and ide.10

They indicated it is 100 percent compatible with current W5100 shield Ethernet library

When i compile with the current original ethernet library using the w5100 shield - all works fine - compiles and Ethernet allows a connection.
When i install the W5200,it compiles but Ethernet does not work.

I was told to replace the 2 files in the arduino Ethernet library utility dir with 2 new files w5100.h and w5100.cpp - when i do this my pgm no longer compiles.

Anyone have any ideas to a solution??

Thanks
Joe

Anyone have any ideas to a solution??

Strangely enough,, yes..

Post the new code,, and the error messages.. Then,, we'll have some idea what you are talking about..

Does the double punctuation help,, in any way??

PaulS,

Yes the ?? makes it stick out more..... thanks for asking
Joe


These are the Compile errors i get when i put in the new 5100.cpp and 5100.h files in the dir utility

C:\ARDUINO\arduino-1.0\libraries\Ethernet\utility\socket.cpp: In function 'uint16_t bufferData(SOCKET, uint16_t, const uint8_t*, uint16_t)':
C:\ARDUINO\arduino-1.0\libraries\Ethernet\utility\socket.cpp:357: error: 'class W5100Class' has no member named 'send_data_processing_offset'


The errors occur on my code or any other of several example sketches.
As soon as I put back the original 5100.cpp and 5100.h files - it compiles but w5200 will not communicate

Below is one of the example codes which produces the compile errors indicated above.

/*
  Web Server
 
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield. 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)
 
 created 18 Dec 2009
 by David A. Mellis
 modified 4 Sep 2010
 by Tom Igoe
 
 */

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

// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 139);

// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(90);

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

void loop()
{
  // listen for incoming clients
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          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;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
  }
}

Can you post a link to the w5200.cpp and w5200.h files? I'll take a look if I have time.

SurferTim,

See attachment - the 2 files were supplied with the w5200.

Thanks
Joe

Arduino_library.zip (18.8 KB)

That is not the w5200 files. That is a LiquidCrystal_I2C something-or-other. Try it again.

SurferTim,

Sorry about that...

New files attached

Joe

w5100.cpp (5.06 KB)

w5100.h (13.6 KB)

I modified your code to compile, but I have no w5200 to check it with. Let me know if it works. The modified code is attached.

edit: The new code has an old bug. There is a bug in the 16 bit read function. Here is the bug and patch.
http://code.google.com/p/arduino/issues/detail?id=605

I might apply that patch to this code to solve that problem.

w5100.h (14.3 KB)

w5100.cpp (5.36 KB)

SurferTim,

W5200 ETHERNET SHIELD: GOOD!

Compiles - my code perfectly
W5200 - is communicating - good responses


W5100 ETHERNET SHIELD: NOT GOOD

When i now put my W5100 Ethernet shield on, it compiles but does not communicate
If i put the original 5100 libs back then it complies and communicates.

It is almost there.....

Thanks
Joe

That is good, but is the nature of the beast. By changing your C++ code to the w5200, it will not work with the w5100.

Also, for those that were affected by the "605 bug", this new code has it. I attached the new w5100.h (for the w5200) with the "605 bug" removed.

w5100.h.new (14.7 KB)

SurferTim,

Ah, ok - So seems that i could make a copy of the current original complete ethernet lib and rename the directory to ethernet5200

that way my libraries would both show --- ethernet (original) and ethernet5200 which i would select when working with a 5200)

Thanks very much for your inputs /effort!!

Joe

I like your thinking! :slight_smile:

I dug a little into the new w5200 files, and I was partly incorrect. The new w5100.cpp and w5100.h files will work with either the w5100 or w5200 depending on the define in w5100.h. If you comment out this line, it will compile for a w5100.

#define W5200

I tried to compile for a w5200 by adding that define to the sketch code, but it had no effect on the library code.

edit: Attached is the w5100.cpp and w5100.h files I am using. It has the 605 bug removed. and the w5200 define commented out.

w5100.h (14.5 KB)

w5100.cpp (5.36 KB)

SurferTim,

Will give it a try and get back to you

Thanks for the update

Joe

SurferTim,

All working well - your files for the 5100 work fine and your files for the 5200 also work.

I found i had to copy over the files, depending if i am using a w5100 or w5200.

The idea of creating a new full complete copy of the Ethernet library dir ,adding your new 5200 files to it and then renaming it to ethernet5200 did not work.

Ethernet - original
Ethernet5200 - a copy of the original but with your modified files for the w5200
Odd, as I was sure it was an easy work around.

A bit of a pain to copy the 5200 and 5100 files back and forth, and trying to remember which one is installed........ but at least i can use either ethernetshield

After searching around the net, yours still are the only ones that worked for me!
Not even the ones sent by the company worked..

Thanks
Joe

I submitted the change to the Arduino crew, and another user pointed out some changes required to other files. I attached Ethernet.h and Ethernet.cpp to this with the changes required to use the w5200. These are from the IDE v1.0.1-rc1 ethernet library.

edit: Here is the report. If you have anything else to add, now would be the time. :slight_smile:
http://code.google.com/p/arduino/issues/detail?id=898

This code works with both the w5100 and w5200. To use the w5200, you must open w5100.h, and uncomment the "#define W5200" statement.

// change this
// #define W5200
// to this
#define W5200

Ethernet.h (1.23 KB)

Ethernet.cpp (3.49 KB)

SurferTim,

When i try to compile with the new files, i get this:

C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp: In member function 'int EthernetClass::maintain()':
C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp:88: error: 'DHCP_CHECK_NONE' was not declared in this scope
C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp:91: error: 'class DhcpClass' has no member named 'checkLease'
C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp:93: error: 'DHCP_CHECK_NONE' cannot appear in a constant-expression
C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp:96: error: 'DHCP_CHECK_RENEW_OK' was not declared in this scope
C:\ARDUINO\arduino-1.0\libraries\Ethernet\Ethernet.cpp:97:

Had to put back my original back ethernet to compile.

joe

Sorry, Joe. You will need to stay with the older version. IDE v1.0 does not support checkLease(). That is new for IDE v1.0.1, according to my source code.

But that should not be a problem. If/When this change is implemented, that version will support it.

SurferTim,

Thanks for the followup!..

Joe

I just grab'd a copy of your updated files, thanks. I am trying to get UDP multicast working with the W5200. The W5100 works great. I get no packets using the W5200. If I send Unicast to the IP address, it works fine. Same code, except for the two w5100.cpp and w5100.h. Using the WIZ820io module from Wiznet.

Goal is to get E1.31 multicast working with the newer W5200 chip.