Go Down

### Topic: Max Baud Rate for Arduino Uno (Read 26138 times)previous topic - next topic

#### nitin29

#15
##### Aug 29, 2011, 01:02 am
Looking continuous on the screen, I can see a lag every 2-3 sec on Teraterm in which the lines are updated. It may be related to the buffer.

Now, a new question came to my mind. Ok, I can set the 1Mbps - 2Mbps on these terminal but am I really getting these transfer rates?

If I do some maths, I have "51,255,65,2,0;" data packet, each of which is 10 Bytes, and in 2 second, the txt file becomes around 25KB = 25000 * 8 bit = 200000 bits, so the transfer rate is indeed 100Kbps instead of 2Mbps!

Any thought?
-- Nitin

#### retrolefty

#16
##### Aug 29, 2011, 01:27 am
Quote
Still wiondering if receiveing would work too at such speed.

Well keep in mind that if you are using interrupts that interupts are disabled while inside your ISR, and if the recieve characters are screaming in the receiver pin with interrupts disabled, dropping characters are possible.

Lefty

#### ilektron

#17
##### Aug 29, 2011, 07:57 am
2Mbs = interrupt occurring at 200Khz (assuming 1 start, 1 stop, 0 parity) , which gives you 16Mhz/200Khz = 80 clock cycles in between interrupts.  If assume single cycle instructions, after saving and restoring context for the ISR, reading the data, and whatever else you need to do, you are looking at not a lot of time.
http://ilektron-x.blogspot.com - Hacking and General Electronics Goodness

#### robtillaart

#18
##### Aug 29, 2011, 08:20 am
I understand a continuous stream at this speed is beyond Arduino's caps, but if bursts of data could be send this fast it opens up possibilities.

Quote
If I do some maths, I have "51,255,65,2,0;" data packet, each of which is 10 Bytes, and in 2 second, the txt file becomes around 25KB = 25000 * 8 bit = 200000 bits, so the transfer rate is indeed 100Kbps instead of 2Mbps!

Any thought?

numbers look quite realistic to me. It just means that you are communicating approx 5% of the time (rest of the time using for measurements, math, formatting etc)
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### robtillaart

#19
##### Aug 29, 2011, 10:02 amLast Edit: Aug 29, 2011, 10:07 am by robtillaart Reason: 1
Confirmed 2Mbit on Arduino 2009 ==> win7/64 realterm.exe

100K chars took 594 msec @ 200000 baud = 168350 bytes/second   =   5.94 microsec/byte

Note this test sketch leaves no room for additional math so I consider this speed as an upper limit.

Code: [Select]
`void setup(){  Serial.begin(2000000);      unsigned long t1 = millis();  for (long i=0; i< 10000; i++)  {   Serial.println("12345678");  // 10 bytes incl \r\n    }  unsigned long t2 = millis() - t1;    Serial.println();  Serial.println(t2);  }void loop(){}`
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### dc42

#20
##### Aug 29, 2011, 11:46 amLast Edit: Aug 29, 2011, 11:47 am by dc42 Reason: 1
If your need is to get reliable high speed data transfer from your device to a PC via USB, it might be better to use a board that has native USB support (rather than serial over USB) such as the Teensy.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

#### nitin29

#21
##### Aug 29, 2011, 05:05 pmLast Edit: Aug 29, 2011, 05:18 pm by nitin29 Reason: 1
Now, I feel completely cheated with transfer rates and terminal program.  :0
I have set the transfer rate of 250Kbps. But, what I get from the captured file shows me a transfer rate of only 48.8Kbps.

Code from another sensor:
Code: [Select]
`void loop(){  Serial.print(Dx(), DEC);  Serial.print(",");  Serial.print(Dy(), DEC);  Serial.print(";");}`

This could be because of ,"DEC" argument?
I don't see any math in my codes?

@dc42: But, isn't Atmega8 at Arduino Uno  also natively support USB protocoll? What difference it will make anyhow?

So, all this data transfer downgrade is because of terminal program that is capturing data or Arduino Uno?
-- Nitin

#### robtillaart

#22
##### Aug 29, 2011, 05:25 pm

No it is because the Serial datastream cannot send bursts of bytes one after another. Each byte is a packet with some interpacket space in between. So you can get ~70% efficiency at max. But as the Arduino is single tasking that number can even be a bit lower.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### nitin29

#23
##### Aug 29, 2011, 05:45 pm
I am only interested in data transfer rate of 250Kbps excluding all the inter packet & background operation down by Arduino or serial protocol.  Sensor data is available at Arduino168 at the rate of 125Kbps.

Do you know, how can this be done? As I have checked with the 2 Mbps, I only got around 100Kbps with Realterm. If I can get around 250Kbps, I would be fine.

Thanks
-- Nitin

#### nitin29

#24
##### Aug 29, 2011, 06:04 pmLast Edit: Aug 29, 2011, 06:08 pm by nitin29 Reason: 1
More updates: I tested the Arduino again (in hope to increasing the actual transfer rates). I tested upto 10Mbps.
I could made it work upto 4 Mbps!

But, a big but...the transfer rate to the txt file is somehow stuck to a max of 50 Kbps.
-- Nitin

#### robtillaart

#25
##### Aug 29, 2011, 06:16 pm
4Mbps failed for me (Arduino2009)  so I think above 2Mbps there starts the gray area, at least with the standard Serial class.

Think you can get a factor 2 if you hand optimize the code (but that is the max), but then still you will get stuck at 200K. Then you have to look for compression of the datastream etc.

Quote
I am only interested in data transfer rate of 250Kbps excluding all the inter packet & background operation down by Arduino or serial protocol.

You should investigate SPI communication as Serial will not do 250Kbps , a good starting point may be - http://www.gammon.com.au/forum/?id=10892 -
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### robtillaart

#26
##### Aug 29, 2011, 06:18 pm
Quote
Sensor data is available at Arduino168 at the rate of 125Kbps.

Can you tell more, datasheet?
How do you get this into the Arduino?
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### nitin29

#27
##### Aug 29, 2011, 06:25 pm
Quote

About the purpose, I have several Avago optical navigation sensors which I have to tests for performance and collect the data. The Serial Port interface of sensor has 2 Mhz as max. frequency. For your reference, ADNS 6090 (one of the sensor I am using): http://www.avagotech.com/docs/AV02-1362EN

Now, I wish to send some register addresses and retrieve some values in a continuous loop in bit banging way. The values I am interested are, Delta X, Delta Y, Shutter Value and Surface Quality. All are 8 bit register (Only one of sensor has 16 bit for Delta X and Delta Y, which are broken down as  Delta X_L & Delta X_H, both 8 bit so double write & read effort). Register read is sequential.

Now, doing some maths, if 2 Mhz clock has 0.5 usec per cycle. If 8 bit is written (arduino->sensor)and then 8 bit is read (sensor->arduino), a total of 16 cycles of 8 usec for sensor. So, data is available at Arduino  with 125 Kbps/Khz (for a single register readout). Then Arduino must be using some 8 cycles or 1 cycle of 62 nsec each per register for sending data->tx line and assume sampling frequency by nyquist to be double of data available frequency. then question is how much baud rate should be sufficient? About 230.4 Kbps?

I suppose the data (each byte) would be sequentially goes to the serial port.
-- Nitin

#### robtillaart

#28
##### Aug 29, 2011, 06:40 pm
Quote
Now, doing some maths, if 2 Mhz clock has 0.5 usec per cycle. If 8 bit is written (arduino->sensor)and then 8 bit is read (sensor->arduino), a total of 16 cycles of 8 usec for sensor.

OK that's the theory,

disclaimer 0% experience with this sensor:
to write a register you have to send the address or so of the register, and then the data, for reading the same so the bandwidth needed doubles quite easily.

Have you implemented the readout of the sensor and timed it?  How fast can registers be fetched in practice?.

Code: [Select]
`void setup(){  Serial.begin(9600);  Serial.begin("start");  unsigned long before = micros();  for (long i=0; i<1000; i++)  {     // insert code to fetch one register to a var here  }  unsigned long duration = micros() - before;  Serial.println(duration);}void loop(){}`
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

#### nitin29

#29
##### Aug 29, 2011, 07:12 pm
I checked with your code. The usec value is 353748 usec.
Hmm...per register call would be around 0.3537 ms...which would be 2.8 Kbps.

Is this rate so slow because I am using bit banging?
-- Nitin

Go Up

Please enter a valid email to subscribe