Arduino Due SerialUSB.print slower than Serial.print (at 250000 baud)

Hi Arduino forum members,

I’m currently using Labview in combination with my Arduino Due to control a process and send measurement data from the Arduino to Labview trough the (virtual) serial port. This works really well as in I can send commands and setpoints to the Arduino and receive measurement data from the Arduino easily.

The thing is serial communications even over the native serial port (using SerialUSB) are incredibly slow. I get the USB protocol works with larger chuncks of data than I’m sending but even so I don’t think it should lose to regular serial. Perhaps my Arduino Due is defective.

For comparison I used the attached sketches one is for regular Serial at 250000 baud and the other is using SerialUSB. I get about 150 ms for the SerialUSB one versus just 79 ms for the Serial one.

Are these results the same for your Arduino Dues?

Kind regards,
Maarten

sketch_sep30b.ino (369 Bytes)

sketch_sep30c.ino (378 Bytes)

I solved the slowdown by first gluing everything together to form 1 larger string: Identifier string (just 2 capital letters so Labview knows what the value means) Value string (the actual measures value) and a "\n" (I'm using this in Labview as a separator)

Sending it as one big packet reduced the time from 17 ms to 1,5 ms which is acceptable to me. Since I'm doing active checking if a set interval has passed 17 ms would mean I could be of by up to 17 ms. (This is the scenario where it arrives at the checkpoint just before the interval passed and would then only execute a full iteration later). Sending it only every n iterations also wouldn't cut it because I would still have the same problem except this time the problem would only have a chance of occurring every n-th iteration.

With this 1,5 ms sending time I can actually remove any risk since I can simply execute it just after a new interval has been set (all my intervals last longer than 1,5 ms). And in the future when I need faster SerialUSB I will just get a Teensy.