baud rate question, practical limits

Hi
I have a fairly n00bish question regarding the practical implications of baudrate upon communication speed. From wikipedia and other sources, bps means bits-per-second. I’ve also learned that it can be interpreted as symbols-per-second, from when one character was one bit (not sure where I got that gem), because baud rate isn’t actually bits-per-second, but more like a synchronization rate.

So, my question is fairly simple: at, say, 9600, does that equate to 9600 characters per second, or 960 (10-bit) characters per second? My brother-in-law is a senior telecoms engineer, so I can ask him for some clarification too.

Ultimately, I’m trying to compare the relative merits and demerits of serial-USB and ethernet transports
And apologies for any glaring errors in these assumptions.

Brendan

Every character requires 10 bits - the start bit, the 8 data bits and a stop bit. So 9600 baud is about 960 characters per second.

If you have a suitable program on your PC an Uno or Mega will probably be able to operate at 1,000,000 baud. The Serial Monitor only works up to 115200 baud.

If you use a Leonardo it can communicate significantly faster - at the full USB data rate. But it can be more tricky to work with because, unlike the Uno and Mega, it does not have a dedicated chip for the USB connection.

...R

Hi thanks for the reply; I ask because I'm trying to ascertain if using an ethernet cable connection (via UDP into MaxMSP), would offer greater communication speed than serial-USB. The [serial] object in Max adheres to the upper limit of 115k, btw. In a related thread, I think I mentioned that I've been told that switching to ethernet might not offer the 'blazing' speeds that I imagine. Just looking for some simple real world figures I can refer to, so thanks for contributing

Brendan

. . . I forgot to mention, I was stress-testing Arduino -> serial-USB (using the Serial monitor window), sending 35 discrete 10bit random numbers, and at 115200 the messages became garbled; when I pulled back down to 38400, everything returned to normal.

[quote author=brendan mccloskey date=1430569422 link=msg=2214185] thanks for the reply; I ask because I'm trying to ascertain if using an ethernet cable connection (via UDP into MaxMSP), would offer greater communication speed than serial-USB. The [serial] object in Max adheres to the upper limit of 115k, btw. In a related thread, I think I mentioned that I've been told that switching to ethernet might not offer the 'blazing' speeds that I imagine. Just looking for some simple real world figures I can refer to, so thanks for contributing [/quote]

When using USB-to-Serial connection, you can easily use 500000 baud with Arduino boards and your PC.

While the "serial monitor" just supports 115200, many other PC terminal software programs will as happily communicate at 500000 baud as the Arduino board will do.

Ok, so the garbling I saw was just the Serial monitor trying to keep up. I'll try stress-testing within MaxMSP to see if the stream is actually disturbed, thanks.

There is a difference between speed and buffer capacity. Sending at higher speeds only works if the receiver is taking data from the buffer fast enough.

That said I have not noticed any problem using the Serial Monitor at 115200 baud. Post your code so others can try it.

Random numbers are not much use for testing because you never know what to expect.

…R

[quote author=brendan mccloskey date=1430570911 link=msg=2214219] Ok, so the garbling I saw was just the Serial monitor trying to keep up. I'll try stress-testing within MaxMSP to see if the stream is actually disturbed, thanks. [/quote]

What is 'MaxMSP'?

Do you mean that piece of code you can download here: http://playground.arduino.cc/interfacing/MaxMSP#ArduinoMax_InOut_forDummies

If I'd make a guess: This software is not only "for dummies", it's indeed "from dummies - for dummies".

If you use any code that is too slow to process data error-free at only 115200 baud, it is far too slow to process data at 500000 baud.

Hi Max is indeed NOT "for dummies", it's a graphical programming environment, for digital media artists and designers. I should have stated that earlier.

  • the random numbers are constrained and defined within an iterative for loop, so I know what to expect in Max, the sketch code is below, and in reviewing it I just realised my error (dummy indeed!)
//Each time round the for loop
//fakeVal =  a unique random range

word fakeVal;
word baudRate = 57600;//stupid error is here, expecting word to understand 115200
byte totalReads = 35;
//shift the random range up each time
word base = 0;
word top = 100;

void setup() {
  Serial.begin(115200)// so I fixed it here;
}

void loop() {
  base = 0;//must be intitalised every loop  
  top = 100;
  for (int i = 0; i

So, to summarise, 115200 works fine. I now have a better understanding of the meaning and effect of the baudrate; and also to check my code more closely LOL.

Brendan

[quote author=brendan mccloskey date=1430575276 link=msg=2214304]

word baudRate = 57600;//stupid error is here, expecting word to understand 115200

[/quote]

You'd better use:

const long baudRate = 115200L;

The maximum value that a "word" (unsigned int) can hold is 65535.

Yes, I realised that 115200 exceeds a word's upper limit. Doh! It was stupid making the baudrate a variable. If I do anything similar I'll use a long.

@Robin2, in Max the serial buffer defaults to 2048 bytes, I haven't been able to spot any great change by lowering or raising this value.

Thanks again for all the contributions everyone, I consider the OP answered

Brendan

[quote author=brendan mccloskey date=1430579597 link=msg=2214392]@Robin2, in Max the serial buffer defaults to 2048 bytes, I haven't been able to spot any great change by lowering or raising this value. [/quote] But do you know how fast it is taking data from the buffer?

The Arduino can manage 500,000 baud with a 64 byte buffer.

...R

Hi Robin I might be getting a little out of my depth now; but I'm polling the serial port (in MaxMSP) at a 1ms interval, so 1kHz. When you say 500k baud at 64byte buffer, do you mean output, via serial-USB? These numbers are becoming increasingly abstract :(

Still, ethernet is commonly 100 Mbits/s right?. 100 million bits.

Baud is always symbols per second in the sense of state-changes per second on the actual medium, so it cannot be the same as characters per second for a serial protocol, only for a parallel interface. An 8-wire parallel bus can represent 256 symbols, a 1-wire serial line can only represent 2 symbols if binary. Many wire-protocols use 3 symbols by the way, but not standard serial interfaces.

Hi Mark I think I can say I'm now definitely out of my depth. I'm aware of (only) the following facts, please do point out the errors: - Arduino uses a serial to USB converter chip, that allows serial communication via USB - USB 2.0 allows up to 480 Mbits/s, though this does not apply to serial over USB (my stress-testing has peaked at 115200 bps, but I think MaxMSP is to blame, not Arduino - see Robin2 and jurs comments above) - Ethernet CAT5 allows for up to 100Mbits/s

If I want to optimise unidirectional communication speed from Arduino (to MaxMSP) should I stick with serial-USB at 57600bps, or use the ethernet breakout board I have just bought? Speed is not the only consideration though, as ethernet connectivity will allow me to access OpenSoundControl (OSC) protocol too.

Apologies if there are too many variables in the above

Brendan

[quote author=brendan mccloskey link=msg=2214764 date=1430598212] Still, ethernet is commonly 100 Mbits/s right?. 100 million bits. [/quote]

I'm going to have to drag you back to Earth here. You are using hardware operating at (probably) 16 MHz. The SPI interface has a maximum clock speed of CLK/2 - that is 125 nS per bit, and there is a slight overhead between bytes.

http://www.gammon.com.au/spi

According to my calculations there, the maximum theoretical SPI speed would be 888,888 bytes per second (and that probably wouldn't be achieved). Turning that into bits, that would be:

888888 * 8 = 7111104 bits per second

So, approx 7 Mbit/s, nowhere near 100 MBit/s.

I mention this because you talk to the Ethernet card using SPI. And indeed there would be overheads in the card - probably quite a lot (for example, turning the data into packets).

The other consideration here is, where is this data coming from? You could conceivably pump out the 7 MBit/s out the SPI port - if you did not spend any time whatsoever obtaining this data. In which case there wouldn't be much point.

I feel as if we are seeing an X-Y problem here.

[quote author=brendan mccloskey date=1430598212 link=msg=2214764]I might be getting a little out of my depth now; but I'm polling the serial port (in MaxMSP) at a 1ms interval, so 1kHz. When you say 500k baud at 64byte buffer, do you mean output, via serial-USB? These numbers are becoming increasingly abstract :( [/quote] Working backwards. I mean that the Arduino can communicate bi-directionally with a PC at high speed using a 64 byte input buffer and a 64 byte output buffer - provided of course, the program on the Arduino removes the incoming bytes from the buffer fast enough so it does not fill up.

If you empty your MaxMSP input buffer at 1 msec intervals, and if the buffer is 2048 bytes, then the highest data rate will be a bit less than 2048 bytes per milli second - otherwise the buffer will overflow. On that basis it is hard to understand why it won't easily work at 115200 baud

However I suspect maxMSP is a complex pieces of software and there may be lots of other things happening that we are not aware of (and, for the avoidance of doubt, which I don't plan to become aware of). What does the maxMSP documentation have to say on the matter.

...R

Thank you Nick. I had assumed that the quoted speed for ethernet communication is dependent on far too many environment variables to be applicable to my specific set up, and you have clarified that for me.

@Robin2. I will try tweaking the buffer size in MaxMSP, and the amount of data coming from Arduino, to see if I can get some stability at 115200. Apologies again for my apparent ignorance in this, I have no engineering/computer science background - I'm building a customised digital musical instrument (based on multiple force sensors), and I'm chasing optimal tactile responsiveness.

Could I ask you for a subjective recommendation (idiosyncrasies of MaxMSP nothwithstanding): would you choose a serial-USB or ethernet connection (peer-to-peer)?

Brendan

. . . regarding Max, the docs are (uncharacteristically) a little light on the serial object's buffersize

"bufsize (1 integer) sets the buffer size for the serial object".

Thanks again for enlightening (rhymes with "frightening") me everyone. Nick, your link looks like a good read.

[quote author=brendan mccloskey date=1430646889 link=msg=2215345] . . . regarding Max, the docs are (uncharacteristically) a little light on the serial object's buffersize [/quote] It's not so much the size that matters, but how the data is processed, and what other activities are going on which might limit the ability to respond to high baud rate data. Or, put simply, what baudrate does the documentation recommend ?

...R