yaobin.wen

Yaobin's Blog

View on GitHub
10 October 2022

A quick review of serial communication

by yaobin.wen

(Updated on 2023-04-04)

1. What is serial communication?

Serial communication is a communication method that uses one or two transmission lines to send and receive data, one bit at a time.

The following figure from [4] shows serial communication:

Serial communication

In contrast, parallel communication transfers multiple bits at the same time. They usually require buses of data - transmitting across eight, sixteen, or more wires.

The following figure from [4] shows parallel communication:

Parallel communication

The two ways of communication can be compared as follows:

Parameter Serial Communication Parallel Communication
Transmission One bit at one clock pulse A chunk of data at a time
Number of lines 1 N lines for transmitting N bits
Communication speed low fast
Cost Low High
Situation Preferred for long distance Preferred for short distance

2. RX and TX

A serial communication device should have two serial pins:

The following figure from [5] shows how RX and TX pins are wired:

RX and TX wiring

When sending data, the sender sets the signal on the wire to the corresponding bit state, and the receiver samples the signal on the wire to get the bit state. Therefore, it’s important that the sender and the receiver work in the same frequency (i.e., baud rate, see below). Otherwise, the receiver will just reads wrong data.

There are two common ways to guarantee the two devices work in the same frequency: using a clock (i.e., synchronous) or not using a clock (i.e., asynchronous).

3. Serial communication: synchronous vs asynchronous

Serial communication protocols can be sorted into two groups: synchronous and asynchronous.

In synchronous transmission:

In asynchronous transmission:

4. Serial communication standards

RS-232C/RS-422A/RS-485 are EIA (Electronic Industries Association) communication standards (where “RS” means “Recommended Standard”).

Standard Alias Purpose of signal lines Timing of signal lines Connectors
RS-232C EIA-232 Defined Defined Defined
(D-sub 25-pin or D-sub 9-pin connectors)
RS-422A EIA-422A Defined Defined Not defined
(adopt D-sub 25-pin and D-sub 9-pin)
RS-485 EIA-485 Defined Defined Not defined
(adopt D-sub 25-pin and D-sub 9-pin)

Other notes:

Parameter RS-232C RS-422A RS-485
Transmission mode Simplex Multi-point simplex Multi-point multiplex
Max. connected devices 1 driver
1 receiver
1 driver
10 receivers
32 drivers
32 receivers
Max. transmission rate 20Kbps 10Mbps 10Mbps
Max. cable length 15m 1200m 1200m
Operation mode Single-ended
(unbalanced type)
Differential
(balanced type)
Differential
(balanced type)
Features Short distance
Full-duplex
1:1 connection
Long distance
Full-duplex, half-duplex
1:N connection
Long distance
Full-duplex, half-duplex
N:N connection

5. Signal assignments and connectors

The figure from [1] describes the D-sub 9-pin signal assignments and signal lines that are defined in RS-232C.

D-sub 9-pin connector

Pin No. Signal Name Description
1 DCD Data Carrier Detect
2 RxD Received Data
3 TxD Transmitted Data
4 DTR Data Terminal Ready
5 SG Signal Ground
6 DSR Data Set Ready
7 RTS Request To Send
8 CTS Clear To Send
9 RI Ring Indicator
CASE FG Frame Ground

6. Equipment types & connection methods

There are two types of equipment:

When connecting two devices of different types together, one needs to use a straight through cable. When connecting two devices of the same type together, one needs to use a crossover cable:

Device 1 Device 2 Connection
DCE DCE crossover
DCE DTE straight through
DTE DCE straight through
DTE DTE crossover

7. Transmission modes

There are three transmission modes:

Suppose we have two devices A and B that are connected via a serial cable, then:

8. Baud rate

Baud rate is the rate at which information is transferred. Its unit is bits per second (bps). The user needs to set the baud rate on both the sender and the receiver.

9. Parity bit

Parity bit is used to find errors in data transfer. Three different configurations are available:

10. Universal Asynchronous Receiver/Transmitter (UART)

A universal asynchronous receiver/transmitter (UART) is a block of circuitry that acts as an intermediary between parallel and serial interfaces. On one end of the UART is a bus of eight-or-so data lines (plus some control pins), on the other is the two serial wires - RX and TX. The figure from [5] shows this:

Super-simplified UART interface

11. Serial Peripheral Interface (SPI)

Serial peripheral interface (SPI) is a synchronous solution for serial communication. The following figure from [6] shows the components in SPI:

SPI communication

Because only the controller can generate clock signals, when the controller needs to receive data from the peripheral, the controller needs to “expect” that, i.e., when sending the command, the controller needs to know in prior whether the command will return something or not. “In practice this isn’t a problem, as SPI is generally used to talk to sensors that have a very specific command structure.” [6]

References

Tags: Tech