Go Down

Topic: Measuring Arduino UNO Atmega8U2 throughput rate ? (Read 1 time) previous topic - next topic

smd

Oct 11, 2010, 12:41 am Last Edit: Oct 11, 2010, 12:53 am by smd Reason: 1
Hi all,

This post is, in some sense, a continuation of Measuring Arduino's FT232 throughput rate ?. I'm on Ubuntu Linux as described on that thread.

Well, I just tried the Uno, and had to post back...

I must say - I love that they replaced the FT232 with something more open - as now, in principle, one should be able to program the Atmega8U2 for different USB behaviors. Although, I do not particularly like that the part is so small, it doesn't look solderable by hand (maybe only with hot air gun - but even then, it will be a challenge to hold those ultrasmall pins in place).  

Unfortunately, it seems that the default edition - for now - can not support speeds up to 2 Mbps, not even close.

First of all, I'm using the exact same procedure/code as in Measuring Arduino's FT232 throughput rate ? Reply #28. Some of the differences between UNO and Duemillanove are:

  • Device is no longer /dev/ttyUSB0 - now it is /dev/ttyACM0
  • The driver in Linux is no longer ftdi-sio - now it is usbcore
  • Using Arduino 0021 to program the Uno
  • The Uno will not need an extra capacitor between RESET and GND just for the sake of it being programmed by the IDE; however any other sort of serial access by other programs (stty, writeread_bonus) again resets the Uno - so I again had to add the capacitor to run the loopback test.


Here is a code snippet which shows some data about the Uno, and then shows the result of running writeread_bonus:
Code: [Select]

$ lsusb # not much shown
Bus 005 Device 005: ID 2341:0001  

$ find /sys/devices/pci0000\:00/ -name '*tty*'
/sys/devices/pci0000:00/0000:00:1d.3/usb5/5-2/5-2:1.0/tty
/sys/devices/pci0000:00/0000:00:1d.3/usb5/5-2/5-2:1.0/tty/ttyACM0

$ for ix in $(find /sys/devices/pci0000:00/0000:00:1d.3/usb5/5-2 -type f); do echo "$(basename $ix):" ; cat $ix ; done
...
idVendor:
2341
idProduct:
0001
...
manufacturer:
Arduino (www.arduino.cc)
product:
Arduino Uno
serial:
649383233313513181C0
...
uevent:
MAJOR=166
MINOR=0
DEVNAME=ttyACM0

$ stty 2000000 inpck -ixon -icanon -hupcl -isig -iexten -echok -echoctl -echoke min 0 -crtscts </dev/ttyACM0

$ ./writeread_bonus /dev/ttyACM0 2000000 ./ttester 3>myout.txt
stdalt opened; Alternative file descriptor: 3
Opening port /dev/ttyACM0;
Got speed 2000000 (4107/0x100b);
Got file/string './ttester'; opened as file (102400).
write_thread_function spawned

  EAG: 0, WR: 1, WF: 0, read: 102400, FRD:    59, TOU: 14080, OBS: 18944, RB/s:   14622.06, WB/s:  13019.38    
+++DONE+++
Wrote: 102400 bytes; Read: 102400 bytes; Total: 204800 bytes.
Start: 1286748859 s -251915 us; End: 1286748861 s 708822 us; Delta: 2 s 960737 us.
2000000 baud for 8N1 is 200000 Bps (bytes/sec).
Measured: write 34585.98 Bps (17.29%), read 34585.98 Bps (17.29%), total 69171.97 Bps.


Notice that - in spite of write gauging (done in respect to 2 Mbps, though) - the writeread_bonus program still detected an output buffer size of 18944 bytes (this number can, however, change between runs); and the effective speed settled at some 34 KBytes/s (some 17% of requested 2 Mbps).

I'm not sure if this is due to:

  • hardware (whether Atmega8U2 can at all support USB->serial at 2Mbps purely electrically), or
  • a limitation of the current firmware on the Atmega8U2, or
  • a limitation of the usbcore driver


If this is a limitation due to firmware or driver, I believe that it opens a very interesting topic for discussion - as then it is in principle possible to achieve 2 Mbps also with the Atmega8U2, as with the FT232 :) Which is why, I thought the case of the UNO/Atmega8U2 throughput merits its own thread :)

Well, I'd love to hear any responses on this,

Thanks,
Cheers!


westfw

Well, to start with the 8U2 is a 16MHz AVR, so its UART probably completely tops out at 2Mbps (and perhaps at the 1Mbps max of a non-U2X configuration.)  And then all of the arguments that people have made about how few cycles a 16Mhz AVR will have to run 2Mbps async will apply twice.  Or maybe 4 times.

There are lots of hits on "LUFA AVR Throughput."  Have fun :-)

smd

Hi westfw,

Quote
Well, to start with the 8U2 is a 16MHz AVR, so its UART probably completely tops out at 2Mbps (and perhaps at the 1Mbps max of a non-U2X configuration.)  And then all of the arguments that people have made about how few cycles a 16Mhz AVR will have to run 2Mbps async will apply twice.  Or maybe 4 times.
Thanks for that - will be good to have it in mind.. Heck, I think even if 1 Mbps can be demonstrated, its all good :)

Quote
There are lots of hits on "LUFA AVR Throughput."  Have fun :)


Thanks for the query - lots of new terms to keep track of, such as LUFA (Lightweight USB Framework for AVRs)...

In any case, I browsed through the ATmega8U2 datasheet and it claims: "USB 2.0 Full-speed Device Module with Interrupt on Transfer Completion ... 48 MHz PLL for Full-speed Bus Operation : data transfer rates at 12 Mbit/s" - so maybe it will be possible to transfer some of that to the ATmega as well :)

In any case, now I have a good starting point in looking into this further, should the need arise...

Thanks,
Cheers!

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy