Wiznet W5200 Arduino Shield by Elecrow

Oh W5100, why you so slow?

For a long time the standard Arduino Ethernet Shield has been driven by the Wiznet W5100 Internet Processor. This shield and the chip upon which it is based forms the basis of just about every IP enabled networking project in the Arduino world.

The Wiznet W5100 chip has some interesting features, such as direct and indirect memory access, but it has some severe limitations in its SPI bus capabilities . Also, the W5100 can support only 4 ports within its hardware IPv4 engine. Unlimited software ports can be added, by providing your own IP stack in MACRAW mode using Port 0, but that is not the road well travelled.

There are two major issues with interfacing with the W5100. First, the SPI interface is only specified to run at 4MHz. And second, the SPI interface supports only a byte mode transmission.

The limitation in SPI rate to 4MHz means that the standard 16MHz Arduino board SPI bus cannot be driven at any speed greater than SCK/4, if it is to remain within specification for driving the W5100. 20MHz boards, such as the Goldilocks, it must drop to SCK/8 if they are to remain within specification.

Also, the W5100 byte mode transmission requires a 4 byte SPI bus transaction for each byte of data to be transferred into and out of the network interface.

Counting the (unachievable) theoretical best case rate for the W5100, it means that 4 * 8 * 4 = 128 system clocks elapse to transfer a single byte of data. Ugh! Slow.

What to do?

I guess Wiznet must have realised this performance issue (which is more apparent with more capable 32 bit MCUs which run at higher system clocks than the slow old 8 bit AVR ATmega range) and they’ve recently released the W5200 as a replacement (specific to SPI bus interfacing) for the W5100 chip.

Wiznet 5200

Wiznet 5200

The W5200 brings a number of new performance features to the game, based on the well known and understood IPv4 network engine of the W5100. The table below contrasts the two chips.

Comparison Table showing Wiznet W5100 vs W5200

Key features comparison W5200 vs W5100

The W5200 is a much smaller and simpler chip to locate on the board, and it is easier to solder for those interested in private SMD constructions. Importantly for networking performance, the W5200 has twice as much Tx/Rx buffer memory for IP packets, and supports 8 simultaneous hardware IP sockets. These features make the W5200 a great performance increment on the W5100, and already sufficient to make a switch. An example of the size of the two chips compared can be found below, with the Elecrow W5200 on the left and an old DF Robot W5100 v1.0 on the right.

Image

Elecrow W5200 and DF Robot W5100 v1

However, the greatest improvement in the W5200 lies in the area of the SPI bus interface. Wiznet has ditched the Direct addressing mechanisms (that took all the pins) on the W5100, and made the W5200 a SPI specialist, capable of running at up to 80MHz clock. That is a 20x increment.

Additionally, the W5200 supports SPI burst mode transmission. This means that up to the full Tx/Rx buffer (32kByte) could be read or written written in one transaction.

In the Arduino situation the W5200 can be driven at SCK/2, the maximum SPI speed achievable on an AVR ATmega MCU, and each byte takes one SPI byte to transfer. This means we can achieve a rate of 2 * 8 * 1 = 16 system clocks to transfer a byte of data.

This means the W5200 is 8x faster for the Arduino, and for Goldilocks 20MHz boards it will be 16x faster than the W5100 – fast as a leopard!

A practical analysis of the speed difference between the two Wiznet chips is here.

Easy to use.

The W5200 is easy to use, and easy to get.

Wiznet have provided some ready made W5200 driver files to include into the Arduino IDE. These replacement drivers for the existing W5100 driver files provided within the IDE just have to be substituted (or overwritten) to enable the slightly different SPI interfacing requirements of the W5200. They also provide C code drivers, which I used as a basis for my AVR freeRTOS code.

The Socket API provided by the W5100, and utilised by the Arduino IDE remains unchanged in the W5200. This means that it is only the performance enhanced SPI bus interface that needs to be rewritten to take advantage of the burst mode transmission, and the slightly different register locations associated with the increased Tx/Rx buffer and number of sockets available.

W5200 functional blocks

I was waiting for a long time for the W5200 to be put onto an Arduino compatible shield, so that I could use it easily. Suddenly, there are two on the market. One from W5200 Shield from Elecrow in China, and the other W5200 Shield from Wiznet.

I decided to purchase some of the Elecrow W5200 Shields. They looked to have a much better design than the Wiznet version, because Elecrow have utilised proper 5V to 3.3V buffers to ensure the safety of the on board uSD card, and have designed using the Arduino R3 standard.

The key and unique (afaik) feature of the Elecrow W5200 boards is the use of the lowered RJ45 jack, that allows the Ethernet shield to between other boards with no clearance problems. I have taken some pictures to show the difference between the standard RJ45 jack and the Elecrow W5200 board version, mounted on a Goldilocks board, and a standard Arduino Uno, with a LCD Touch Shield (even with under-slung SD Card cage) mounted over the top.

Image Image

Some small improvements.

I spent some time working with the Elecrow W5200, and have been in discussion with Richard and David (Tech Support) at Elecrow about the implementation. They have been very helpful in resolving some issues I have found in using their design.

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. This can be solved by pulling jumper J2-2 to ground, or (permanently) by bridging Pin 1 and Pin 2 on U6 which is the buffer chip controlling the PWDN line. Check the schematics to see why this is so.

Secondly, the buffer chips used are driven from from 3.3V for Vcc. They are a little slow (100ns/V skew) at this supply voltage, and for the return data path on the MISO line they should properly be driven from 5V Vcc. At 5V Vcc the buffer chips are also much faster (20ns/V skew). The slower buffer chips, the LPF characteristic generated by the sensibly included output resistors, and the lower logic level compared to the AVR 5V TTL levels all combine to reduce the speed at which the SPI bus can work. Whilst the correct resolution is to drive the buffer chip at 5V Vcc for the inbound (AVR point of view) signal lines, I have found it is sufficient to remove and bridge the R24 resistor to achieve the SCK/2 SPI rate we desire.

This view of the Elecrow W5200 board shows the modifications in detail. I believe that later versions of the board will resolve these issues. And, with the Elecrow W5200 Shield’s unique recessed RF45 connector’s advantages and the speed of the W5200 MCU, all other sins are forgiven.

Elecrow W5200 showing R24 delete and U6 Pin 1-2 bridge.

Elecrow W5200 showing R24 delete and U6 Pin 1-2 bridge.

TL;DR

The Elecrow W5200 is a very speedy and easy to use alternative to the standard Arduino W5100 based solution. It is a great addition to my collection of IPv4 networking shields.

A practical analysis of the speed difference between the two Wiznet chips is here.

My code, as usual, on Sourceforge.

Goldilocks 1284p plus Elecrow W5200 Ethernet Shield

Goldilocks 1284p plus Elecrow W5200 Ethernet Shield

22 thoughts on “Wiznet W5200 Arduino Shield by Elecrow

  1. Pingback: BLOG | Wiznet W5200 Arduino Shield by Elecrow

  2. Pingback: BLOG | New Products Post-Gas Sensors

  3. Pingback: uIP on Wiznet W5200 versus W5100 on Goldilocks 1284p | feilipu

  4. Very nice Article! So i ordered the W5200 shield (v1.1) from elecrow. I downloaded their library and opened the example Webserver with sdcard. Well the sd card is working but the server is always at 0.0.0.0.
    First all LEDs were on and linked was blinking. Now for some reason all Leds are off and its still not working. Do you know why that happens and what i can do?
    I also created an entry in my router with a fix ip, but that didnt help. Maybe i should try another MAC, do you know any? In am Using Arduino Mega 2560.
    This is my code + output (sorry if i delete this pic after some time)

    • Thanks.

      One thing you can do is to set the MAC address to the Wiznet range.
      Won’t make any difference to your issue, but at least you’re complying with IETF and IEEE standards.
      The Wiznet MAC address range is: 0x00-08-DC-yy-yy-yy

      I’m not sure that I can help with Arduino code. I don’t use it and I’m not sure where to start in debugging your issue.

      I’d suggest that you start with the Wiznet forum or with the Arduino forum. They might be better placed to help there.

  5. Can you elaborate upon the reset issue ? An often met issue that affects quite a lot of W5200 boards is that the board does not start when the Arduino host board is powered on. In order for the board to start working, the Reset button (either Arduino or Wiznet board) has to be pressed.

  6. I haven’t experienced a “RESET” issue with the W5200, so I can’t really comment to your issue.

    I have noted that some other devices attached to the AVR SPI bus can be set to a random locked-up state by SPI transactions issued by an AVR-ISP when reprogramming the AVR firmware. That might be the issue that you’re noticing, if you’re using an AVR-ISP for programming, and not a bootloader.

    Another thing is that the W5200 needs quite a long time to start up. I found it needed double the datasheet recommended delay after power up to consistently respond. If the Arduino sketch fires up as soon as it boots without sufficient additional delay, then there will be issues.

    http://eleccelerator.com/fusecalc/fusecalc.php

    I don’t use the standard 16k + 65ms fuses, but rather set 16k + 0ms and use the highest Brown Out Detection Voltage setting (often 4.3V), so the AVR doesn’t leave RESET state until there is are enough volts to drive it properly. In context, this means that I typically have a faster starting AVR than Arduino, so I have to leave longer, at least 65ms longer, than the Arduino standard library time for the W5200 to be fully ready to receive commands.

  7. Pingback: And What About the W5200? | olduino

  8. Pingback: Wiznet W5500 and ioShield-A. What’s old is new again! | feilipu

  9. Pingback: WIZ珍藏 #2:来自Elecrow的 WIZnet W5200 Arduino Shield

  10. I have continued to fail in getting any sketch to work on a W5200 ethernet board that works on a W5100 (compile problems). I have convinced myself that it is a library issue, but all attempts to include a correct one fails. Also, how do I delete a previously included library from the IDE menu? I am still somewhat new to Arduino and need some hand-holding. Thanks for any help.

  11. I can confirm you that the shield works both with Arduino Uno and Arduino Mega. When using with Uno you CAN upload the program with shield connected, when using with Mega, you HAVE TO disconnect the shield, upload the program and connect the shield back to test it. Or you can upload the program via ICSP.
    My simple pan and tilt program (the program takes almost all SRAM / FlashRAM, so, for improvements you have to migrate it to Mega. Send me a message to get my Arduino code, please.

  12. Hmm, I am simply attempting a basic tutorial sketch: WebServerWithSD including EthernetV2_0.h onto a UNO with/without an Ethernet shield attached. Fails every time unless I change to Ethernet.h. Any suggestions?

    • Please contact me via Facebook. We’l see what we can do. Maybe the library is not registered in the Arduino IDE database. Depends on the error message. Does the sketch fail when working i.e. doesn’t work as expected, or doesn’t it compile ?

  13. Anyone know when the wiznet w5100/w5200 driver was added to the arduino core library?

    And when the microchip enc28j60 was added

    I thought the wiznet was first, and that the arduino supports both libraries, yet the official github arduino core only shows wiznet?!

  14. Hello. Can someone help to connect w5200 with arduino due? I have always errors…. With mega works fine.

    Errors.
    Arduino: 1.6.10 (Linux), Board: “Arduino Due (Programming Port)”

    In file included from /root/Arduino/libraries/Ethernet_Shield_W5200/DhcpV2_0.cpp:4:0:
    /root/Arduino/libraries/Ethernet_Shield_W5200/utility/w5200.h: In static member function ‘static void W5100Class::initSS()’:
    /root/Arduino/libraries/Ethernet_Shield_W5200/utility/w5200.h:361:36: error: ‘DDRB’ was not declared in this scope
    inline static void initSS() { DDRB |= _BV(2); };

    snip

    exit status 1
    Error compiling for board Arduino Due (Programming Port).

    This report would have more information with
    “Show verbose output during compilation”
    option enabled in File -> Preferences.

    • Sorry but this discussion is about using AVR hardware with the W5200.
      There is no coverage of either Arduino or the Due here.

      That not withstanding, the many error messages you see come from compiling AVR ATmega code for the Due ARM processor.
      Check these things, then please ask for help on the Arduino forums.

  15. Pingback: Hardware Ethernet en Arduino | Aprendiendo Arduino

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s