ARDUINO SERIAL VS SERIALUSB

Summary of ARDUINO SERIAL VS SERIALUSB


This article explores why the SerialUSB() function on the Arduino Due (Cortex M3-based) is faster than Serial() on ATmega-based boards like the Uno or Nano. Through experiments and Wireshark captures, it reveals that ATmega boards transmit data in USB packets grouped by four characters due to their USB-to-serial converter chips (FT232RL or ATMEGA8U2), while the Arduino Due sends entire strings directly via USB to the SAM3X8E processor. The baud rate is less meaningful in virtual USB serial links, and packet size seems fixed by hardware or protocol rather than software control.

Parts used in the Arduino Serial USB Speed Comparison Project:

  • Arduino Due (Cortex M3-based board with SAM3X8E processor)
  • Arduino Uno (ATmega-based board with ATMEGA8U2 USB interface)
  • Arduino Nano (ATmega-based board with FT232RL USB-to-serial chip)
  • USB connection cable
  • Computer with Wireshark software installed
[Andrew] wonders why the SerialUSB() function on the Cortex M3-based Arduino Due is so much faster than Serial() on the Uno or Nano, and shares his observations in this short video. He sets up an experiment with a simple sketch on both boards and uses Wireshark to evaluate the results.

Data is sent in the USB packets in groups of four characters on the ATmega-based boards, but the entire string is put in a packet on the Due board. If you look under the hood, the answer is hiding in plain sight. While the Arduino family of boards connect to your computer using a USB virtual serial port, the ATmega ones have an actual serial connection on-board. For instance, on the Nano there is an FT232RL between the USB connector and the microprocessor (on an Arduino Uno board, a small ATMEGA8U2 is used instead of an FTDI chip, but the concept is the same). On the Arduino Due, the USB connects directly to the SAM3X8E processor.

https://youtu.be/64qXT2zZmZM

This concept doesn’t apply only to Arduino boards, of course. On any serial connection between two computers, when a virtual USB device is used on both sides of the link (no actual serial signals involved), the serial baud rate is a fictional thing — data transfer speeds depends on USB alone. We are curious why the packets contain four characters in [Andrew]’s ATmega Wireshark captures — why not 1, 2, or 10? Is this something that can be controlled by the programmer, or is it fixed by the protocol and/or the FTDI chip? If you have the answer, let us know in the comments below.

Source: ARDUINO SERIAL VS SERIALUSB


About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top