embeddedusbdrivermicrocontrollerarduino-due

Arduino Due to PC High Speed USB communication


I am working on a project that uses the Arduino Due (microcontroller ATSAM3X8E). My goal is to be able to track the values of some of the key variables I am using in my firmware in real time. The fact is that I need to plot the change in the values of the variables over time.

In order to do this, I have decided to send the data to my PC through the native USB port. The real time constraint I am having is that I need to send the values of 20 variables (each of them 8 bytes long) within 0.1 ms. There is a native USB port available on the Arduino Due, which is connected to the USB peripheral of the chip. I have tried using UART over USB by setting up the Due in USB device mode. I can only get up to speeds of 115200 baud using Serial (UART) communication (any higher speeds don't allow the Due or my host PC to send the data correctly).

So, I did some home work and found that USB based devices have different classifications based on what they do. I want to know if there is a high speed protocol with a speed of at least 2 M bits/sec I can use on top of USB to data across to my PC from the Due, and, if there is an equivalent driver I can use on my Windows PC to successfully capture that high speed data - any recommendations would be greatly helpful.

Thanks in advance!

Subramanian


Solution

  • The Arduino Due's native USB port is capable of high-speed USB (480 Mbps), and by default it will appear to the computer a USB virtual COM port. This is a virtual serial port, so you can send data as fast as the USB drivers will allow, and you are not limited by the virtual "baud rate" of the COM port, which is an irrelevant setting. I think the virtual COM port will be fast enough for you and you should try it before doing something more complicated.

    To use this port, use the SerialUSB in your Arduino program. The object has the same interface as Serial. You should already have a drivers for it if you installed the Arduino IDE or you are running Windows 10.

    Please note that USB virtual COM ports usually use USB bulk endpoints, which don't guarantee any paritcular latency or throughput. If your computer is busy talking to other devices on the bus, you might get less throughput then you were hoping for, but you have a lot of margin of error here so I don't think it will be a problem in practice. If you want to be safe, just make sure that you can buffer up a few milliseconds of data on the device side so you aren't losing any data. You might have to look at the internals of the Arduino core code to see how big its buffers are.