Go Down

Topic: Max usb speed in Arduino Uno? (Read 15270 times) previous topic - next topic


Dec 29, 2010, 01:14 pm Last Edit: Dec 29, 2010, 01:56 pm by optimistx Reason: 1
Is there a way to send from Arduino Uno to the host pc via usb-cable faster than baudrate 115200? The serial monitor baudrate list ends at 115200 (version 0021),
but when experimenting with own programs up to 921600 bd seems to "almost" succeed.
(win XP, reading COM13 with hyperterminal of XP).
I am producing megabytes or even gigabytes of sensor data in Arduino and would like to send them continuously to pc for analysis. One way would be to use an microSD-card in Arduino and gather data there, but it would be better, if serial transfer to host via usb would succeed .
I did experiment with this program:

long starttime, endtime, elapsedtime;
int lines = 500;
long baudrate = 921600; // 115200;

String s = "0123...   1         2         3         4    ...49";
int linelength = s.length() + 2; // incl carriage return + line feed

void setup(){

void loop(){
  starttime = micros();
  for (int ind = 0;ind < lines;ind ++){
    delay(10); // remove or vary this, or use delayMicroseconds(100)
  endtime = micros();
  elapsedtime = endtime - starttime;
  Serial.println(baudrate, DEC);
  Serial.print(lines, DEC);
  Serial.print(" lines with ");
  Serial.print(linelength, DEC);
  Serial.print(" characters each, elapsed time in microseconds = ");
  Serial.println(elapsedtime, DEC);
  Serial.print("actual throughput chars/sec = ");
  float charspersec = lines * linelength / (float(elapsedtime) * 0.000001);
  Serial.println(charspersec, 3);

When using delay(10), the data arrives well at baudrate 921600 , but  with shorter delays there seems to be something like buffering problems. Or might be the receiving program is too slow (?).
Any ideas to get data to host fast?


You should probably begin by looking at the source code for the Serial.begin() function to see what happens when a baud rate is specified.

Specific timing is set up, based on the specified baud rate. Look at what happens when the specified baud rate is not in the list.

You'll notice, if you try to modify the list, that at some point, the resolution of the timer becomes greater than the minimum time required. This limits the speed of serial data transmission.
The art of getting good answers lies in asking good questions.


Dec 30, 2010, 09:14 am Last Edit: Dec 30, 2010, 09:18 am by optimistx Reason: 1
Thanks PaulS. If Arduino cannot send bits(?) bytes(?) serially at right moments in time at high baudrates, then this feature limits any serial communication, including serial microSD cards, other Arduinos etc ? If so, I have a bigger problem than expected. USB 2.0 (http://en.wikipedia.org/wiki/Universal_Serial_Bus) can transfer
480 megabits per second (57 megabytes/s) , but  Arduino cannot utilize that (?), only  about 10 kilobytes/s. Sigh.

Other cheap, quick and dirty  methods to consider for high speed data transfer to host?

Coding Badly

Other cheap, quick and dirty  methods to consider for high speed data transfer to host?




Dec 30, 2010, 09:39 am Last Edit: Dec 30, 2010, 09:41 am by retrolefty Reason: 1
Other cheap, quick and dirty  methods to consider for high speed data transfer to host?

1 Cheap, 2 high-speed, 3 easy to use. You get to pick only any two attributes but Arduino doesn't do #2, if 57Mbytes is your criteria. Arduino is clocked with a 16Mhz crystal, what does that tell you?


James C4S

, then this feature limits any serial communication,

eh, not really.  Anyone who is using an emulated serial port for significant amount of data transfer is probably not going about their solution correctly.

Very rarely does anyone make a complaint about how fast they can transfer data from the Arduino to the PC.  For most cases the Arduino's implementation is fine.  

So in YOUR corner case, it limits "any" serial communication.  However, in the majority of projects using the Arduino the serial connection is, by far, the lowest thing on the list of bottlenecks.

Maybe you need to consider an alternative implementation.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com


Jan 05, 2011, 08:51 pm Last Edit: Jan 05, 2011, 08:53 pm by optimistx Reason: 1
Thanks to everyone for the opinions and ideas.
My problem seems to have been the following:
The host can receive at baud rates 115 200, 230 400, 460 800, 921 600,
but my 16 Mhz Arduino can send at baudrates 1 000 000, or 500 000. (or less)
When trying to send at 1 000 000 bd the transmission "almost succeeded", which was astonishing and missleading my thoughts. The difference 921 600 vs 1000 000 was so high that I could not believe that the host really was using 921 600 baud rate.
When the difference in baudrates was differing almost 8 % then during 9 bits the sampling moments would differ too much to get even one byte correctly.
I think that when the baud rates at the sender and the receiver are the same,  the transmission should succeed even at 2 megabaud rate well. (datasheet of 328).
I probably try Bluetooth next by acquiring a bluetooth usb stick to the host and a bluetooth circuit to Arduino to send. 800 kbytes/second should be possible in theory, which solves the transmission speed problem well.

Teensy is also an interesting idea, 800 kbytes/s with usb cable. How is that possible, different software or different hardware or both?

Coding Badly

Teensy is also an interesting idea, 800 kbytes/s with usb cable. How is that possible, different software or different hardware or both?

Both.  It uses an Atmel chip with an integrated USB controller.  The processor is able to communicate directly with the host computer via USB.

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!

via Egeo 16
Torino, 10131