A UART (Universal Asynchronous Receiver/Transmitter) interface is a widely used serial communication protocol for transferring data between devices, such as microcontrollers, computers, and various peripherals. UART communication is asynchronous, meaning it doesn't rely on a shared clock signal between the sender and receiver. Instead, it uses a predefined baud rate to determine the speed at which data is transmitted.

In this article we'll define what the baud rate and output rate are exactly, and help you understand how to select the correct baud rate depending on the quantity of data being output to avoid saturating the serial output.

Definition

Bits and Bytes

Bits are the smallest increment of data and hold a single binary value of 0 or 1.

A byte is a group of 8 bits.

UART frame

A UART frame typically includes 1 start bit and 1 or 2 stop bits (usually 1) during transmission, and sometimes even a parity bit that is used for error checking and can be set to odd, even, mark, space, or no parity.

So for each byte transmitted over UART, 10, 11 or 12 bits are transmitted per frame depending on the combination of stop bits and parity bit.

A transmission configuration of 8N1 for example will mean that for each byte transmitted there is 1 start bit (implicit here), 8 data bits, no parity bit, and 1 stop bit, for a total of 10 bits.

Baud

Baud is the number of symbols transferred per second. 1 baud is equivalent to one bit per second.

The following formula can be used to calculate how many bits per second are transferred.

Baud = number of bytes x total bits per frame x output rate of message (in Hz), where total bits per frame = data bits, + start bit + stop bit + parity bit if used.

Baud rate

The Baud rate, expressed in bits per second (bps) is the rate of symbols transferred across a transmission medium per second.

The standard baud rates are the following: 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800, 921600.

It is important to have the same baud rate configured on each side of the communication.

Output rate

The output rate is the number of times a message is output per second. For example outputting a specific message at 50Hz means that we will output the same message 50 times per second, so every 0.02 seconds.

Selecting the correct baud rate for a specific amount of data output per second

To select an appropriate baud rate, it is important to know how many bits will be output per second. Let's take the example of our sbgECom protocol. Each message is encapsulated in a 9 byte frame described in our firmware manual. If we want to output the EKF Euler message that is 32 bytes long (the description can also be found in the firmware manual), then we'll have the following:

FieldSYNC 1SYNC 2MSGCLASSLENDATACRCETX
Size (bytes)1111232 (EKF Euler here)21
DescriptionSync. wordSync. wordMessage IDMessage ClassLenth of DATA sectionPayload data16 bit CRCEnd of frame
Value0xFF0x5A-----0x33
Total size (bytes)41

So to output this message we'll need to be able to output 41 bytes per second.

Let's assume we are using the common UART configuration of 8N1 as defined above. In this case, the total bits per Frame is 10 (8 data bits + 1 start bit + 1 stop bit).

If we want to output this 41 bytes message at an output rate of 50Hz at 8N1, then we'll have: 41 bytes x 10 bits per frame x 50 Hz = 20500 bits per second or 20500 bauds.

So in order to transmit 20500 bits per second, we will need a baud rate of at least 38400. If a lower baud rate like 19200 was selected, then the port would saturate.

Recommended baud rate

In general, a common baud rate to use is 115200, but it might not be enough for the amount of data needed for some applications. For post-processing where we require IMU data at 200Hz, you will need to use a baud rate if at least 230400.

When outputting multiple messages, you can do a sum of the bits transmitted per second over UART, for each message at their specific output rate, to determine how many bits total are transmitted per second.

Calculating the amount of bytes per second that can be output for a specific baud rate

Instead of calculating which minimum baud rate would be needed for a specific amount of data being output, we can calculate the total amount of bytes per second that can be output at a specific baudrate before saturation.

Let's assume we are using the common UART configuration of 8N1 here too and have to use a baudrate of g. We can use the following formula:

Bytes per second = baud rate / total bits per frame.

So, at a baud rate of 115200 bps with an 8N1 configuration, we can send 11520 bytes per second.

Length of cable vs baud rate

The baud rate selected will have an impact on the maximum length of cable we can use in the application. The higher the baud rate, the shorter the cable will need to be for the signal to arrive properly on the other end. You can use the table below to determine what length of cable to use depending on the baud rate selected with RS232 or RS422.

RS232/RS422 : A standard defining the signals between two devices (the signal names, their purpose, voltage levels, connectors and pinouts).


Length of Cable (m)
Baud rateRS232RS422
28 800 bps and below100250
57 600 bps50250
115 200 bps25250
230 400 bps12.5250
460 800 bps5100
921 600 bps250

How to check for port saturation

The sbgCenter can be used with SBG Systems products to check for port saturation. The transmit status in the Interfaces window will show a "ok" status when everything is good, and a "no" status when the port is saturating. This status is taken directly out of the system if the SBG_ECOM_LOG_SYSTEM_STATUS message is output.

For example in the image below we can see the Port A transmit is ok but the Port E transmit is saturating.

saturation

It is also possible to check if any product is close to saturating its output with our sbgDataLogger. You can see below the input status will be green if everything is ok and will change to orange or red depending on the amount of bytes received per second compared to the baud rate selected.

no saturation

datalogger saturation

most saturation