Accelerating Arduino Ethernet Speed

Status
Not open for further replies.

MDNPJ10

Member
Hello, I am using an Ethernet shield with arduino UNO. I am looking for ways to improve Ethernet UDP speed (I need at least 300 Kbytes/sec).. The best I can reach with an SPI clock of 8Mhz is a speed of ~ 70 Kbytes/sec.
Can the use of PJRC Ethernet Library improve this figure? Can it work with the UNO and replace the ARDUINO Ethernet library?
 
Yes, just using the Teensy version of the Ethernet library will speed things up on Arduino Uno.

https://github.com/PaulStoffregen/Ethernet

The other thing you can do to really speed things up is read or write many bytes at once, like 30 to 200. Admittedly your memory is so very limited on Uno. But the point is even a couple dozen bytes at a time is far more efficient than 1 at a time.

If you have a shield with the slow W5100 chip, unfortunately there's only so much the software can do. That chip is horribly inefficient. The W5200 and W5500 chips offer much better performance.

Of course, if you step up from Uno to a far more powerful board like Teensy 3.2, you can also get some large and easy speed gains. Teensy 3.2 has 32 times as much RAM as Uno, and it runs much faster, which can really help if you need to build a project with good performance.
 
Thank you Paul for the quick answer.
Actually, the speed of 70 Kbytes/sec I quoted in my previous post was reached for transmission of 200 bytes buffers.
So I understand that if replace the ARDUINO Ethernet Library with Teensy Ethernet Library (https://github.com/alex-Arc/Ethernet/tree/1-socket) It should be transparent for the IDE with the UNO! I would like to check what improvement in speed I get, before I consider the other options.
 
Using PaulStoffregen/Ethernet

OK, I replaced ARDUINO Ethernet library with the PaulStoffregen/Ethernet library.
I built two sketches: the first writes 200 bytes buffers to Ethernet using UDP and prints the time required for writing 10 such buffers, the second reads this data and prints the third byte in each buffer.
These sketches work correctly with ARDUINO Ethernet. With the other library (PaulStoffregen/Ethernet) they compile correctly but no data is transmitted (nothing printed).
I attached the 2 sketches. I suspect there are some adjustments required in the code or in the library installation. I saw the W5100 drivers quite different from the same drivers in ARDUINO Library.
Would it be possible to take a look?

Thank you
 

Attachments

  • Ethernet_read_Frame.ino
    1.7 KB · Views: 180
  • Ethernet_write_Frame.ino
    1.9 KB · Views: 151
My intention was to use your Ethernet library with the ARDUINO , to check if I can get a better speed. So the answer is to test with arduino. The 2ms delay were added when I started debugging the sketch. It may not be required.
The speed I got with ARDUINO ethernet library and UNO was ~ 70 Kbytes/sec.
Thank you
 
I looked at these speed tests. For the UNO the test was done with wiznet WIZ820io (using W5200) while I am using ARDUINO Ethernet Shield with W5100.
I have a question in relation to DMA contribution to speed. If we assume that the processor major activity is to transfer data, does the use of DMA bring a significant increase in the transfer speed?
Mike
 
The wizperf.txt link also has some w5100 performance numbers. The best I could do with w5100 was 1 megabits/sec. The SPI protocol on the W5100 is poorly designed and limits performance. You would do better with a w5200 (or newer w5500) and a Teensy 3* :D

For large block transfers DMA can improve SPI speed slightly by eliminating a few instructions, but its real advantage is allowing your sketch to do other work during the data transfer. The UNO doesn't have a DMA option but the Teensy 3s do.
 
For these tests (https://github.com/manitou48/DUEZoo/...er/wizperf.txt) is there any record of data integrity at the maximum speed? Especially in relation to UDP transfers, which are known as subjects to errors.
yep, UDP data payload had sequence number, so i could detect loss, out-of-order, duplicates, and data errors (though UDP checksum would detect most errors). test packets were 1000-bytes (large block transfers are more efficient, at least for W5200). Receive rates are based on 20 1000-byte packets received without loss/error wiith a rate-controlled transmitter. Bursts of packets can overrun the wiznet buffers ....

On a local wired-ethernet, errors are unlikely with the underlying Ethernet error checking. Wireless ether/router could introduce errors and bursts

Of course, SPI has no error checking, so there could be SPI errors. At high SPI clock rates you woiuld need short wires.
 
Last edited:
I am asking about data integrity with UDP because of the figures I am getting with tests I am running with the following setup:
- ARDUINO UNO connected to ARDUINO MEGA through Ethernet
- With Ethernet shield on each one (including W5100), SPI 4 Mbits or 8 Mbits
- Using Ethernet Library,
- UNO transmitting continuously UDP packets of 32 bytes
- MEGA receiving the packets and printing out a message every time the received packet length (using "parsepacket") is different from 32 or a particular byte within the packet is different from the transmitted value.
Results: An error message within an average of every 50 packets
I would appreciate any comments about these results, including any idea for decreasing those error rates.
 
Since your interest is in Arduino Mega and UNO, you should post your queries to one of the Arduino forums. The w5100.* files in my github repository refer to mods made in 2012 to support the w5200 chip and would not apply to your old w5100 shield. (you can find Ethernet.cpp in your IDE's installation library folders.) For your 32-byte send/receive tests, you should trying slowing down (delay(n)) the transmitter and see if that helps, and/or do some tests with a desktop Ethernet sender/receiver to see if the w5100 is sending out broken packets, or if the w5100 is not able to keep up with a rate-limited sender

when you buy your Teensy 3's and the w5220/w5500 wiznet device, visit the teeny forum again with any queries ...
 
Thank you for this answer.
I have now an arduino DUE(mainly because I need quite a large number of I/O connections, at least during the development phase) and a W5200 shield. Using DUE with W5200, I have now no UDP errors. I am looking for an ethernet library with DMA for the DUE. I may use the TEENSY after this phase is completed.
I would appreciate very much if you could recommend one such library.

Thank you in advance

Mike
 
Last edited:
What with the other tested microcontrollers? Did they use the same code? Besides the TEENSY, I am looking for the code used for maple and Due.
 
What with the other tested microcontrollers? Did they use the same code? Besides the TEENSY, I am looking for the code used for maple and Due.

yes, basically the same structure. there might be differences based on the vagaries of the Ethernet lib.
 
As far as I noticed from this code, it does not support DMA tests. I would appreciate very much a reference to the (Ethernet tests) sketch, if available, for DUE and Maple. The test results from
https://github.com/manitou48/DUEZoo)
include data related to network performance for Teensy, and also for DUE and Maple with and without DMA.
Thank you
Mike
 
Status
Not open for further replies.
Back
Top