Have you ever wondered about the long lines of zeros and ones often seen in sci-fi movies? Those digits represent data that is processed, transmitted, and stored by all digital devices. Digital devices handle data as highs and lows of voltage levels. A high or low voltage sustained for a specific period of time gets registered as a bit of data. Several bits of data, when combined, can translate to a meaningful message. In this Answer, we will briefly discuss how these data bits are transmitted on a serial communication channel, limiting our discussion to a specific communication protocol called UART.
Data can be transmitted over a single channel (serial communication) or multiple channels (parallel communication). In serial communication, data travels from the transmitter to the receiver in sequential order, one bit at a time.
Both communicating parties should know when to update or read the signal to transmit bits successfully.
UART stands for Universal Asynchronous Receiver/Transmitter. This serial communication protocol is asynchronous because the two communicating parties do not have any mechanism to synchronize with one another. Therefore, to make the communication useful, the two parties must agree on a baud rate and the data packet structure before they transmit or receive any bit. For a two-way communication channel, each party must implement both a receiver and a transmitter.
It is conventional to represent the transmitter as TX and the receiver as RX. The grounds (GND) of both parties are connected to ensure a common reference point for high and low voltage levels.
Baud rate is the bit transmission rate the two parties must agree on for successful communication. Since there is no synchronization mechanism, one party trusts the other to comply with this communication rate. Furthermore, the receiver is not certain when the transmitter will change the bit. So to ensure that no data is lost, the receiver monitors the channel using a clock 16 times faster than the baud rate and samples the data at the 8th rising edge of the monitoring clock.
The standard baud rates chosen for historical reasons were 4800, 9600, 19200, 38400, 57600, and 115200 bits per second, but, with appropriate software and hardware, we can reach much higher baud rates. Python’s pySerial library, for example, allows us to make UART serial communication channels with speeds up to
For the communicated bits to translate into something useful, we transmit them as data packets. Each packet contains start, stop, parity, and data bits. The least significant bit of the data packet is transmitted first, so the start bit is at the end of the data packet.
Like the baud rate, the data packet specification must be agreed upon by the two communicating parties before transmission.
The stop and start bits act as flags that indicate the start and the end of meaningful data transmission. The start bits are always 0, while the stop bits are always 1. We always dedicate a single bit for a start bit, but we can reserve one, one-and-a-half, or two bits for a stop bit. Stop and start bits are useful during data transmission but do not carry meaningful information and are discarded afterward.
Data bits carry the main message that we want to communicate. We get a few options for the number of data bits we can keep in a data packet: five, six, seven, or eight. Again, this value is set before the start of communication, and each data packet must contain this number of data bits.
The parity bit is an optional addition to the data packet. It enables us to perform a small check for the success of transmission. The receiver determines the parity of the data bits and matches it with the parity bit. If the parity matches, the transmission is not faulty. This check only caters to a single-bit change in the data packet.
Despite agreeing on the baud rate, the two communicating parties can lag due to technical limitations. To accommodate this, both communicating parties should establish FIFO buffers at their end to ensure that none of the bits are lost due to a lag.
Like every technology, UART has some advantages and disadvantages that should be considered before we decide to implement it for a specific use case. The table below compares some of the advantages and disadvantages of UART.
Advantages | Disadvantages |
Low hardware requirements | Communication only between two parties |
Synchronization not required | Slow as compared to parallel connections |
Parity bit allows for data check | Strict pre-communication requirements |
UART has a wide range of supported devices. Many devices, like Bluetooth modules and FPGAs, come with built-in UART communication ICs, and USB-to-UART modules for PCs are easily available. Wide support for devices, availability of UART communication libraries, and drivers for various platforms facilitate interoperability.
Despite all the benefits that it brings, UART should be avoided when high communication bandwidth and speed are required, and parallel communication options should be explored.
Free Resources