What is Serial Communication?
Serial communication is a method of transmitting data sequentially, one bit at a time, over a single wire or channel. This is in contrast to parallel communication, where multiple bits are transmitted simultaneously over multiple wires. Serial interfaces are very common because they require fewer interconnects (wires, pins, PCB traces, etc.) than parallel interfaces.
Key characteristics that differentiate the various serial protocols include:
- Synchronous vs asynchronous
- Full-duplex, half-duplex, or simplex communication
- Data transfer speeds (bitrates)
- Single-ended vs differential signaling
- Maximum cable length and number of devices supported
- Hardware flow control (handshaking)
- Command protocols and message formats
- Intended applications
Asynchronous Serial Protocols
Asynchronous serial protocols transmit data without a separate clock signal. The transmitting and receiving devices must be configured in advance to use the same timing parameters. Start and stop bits are used to synchronize each character or small data packet.
RS-232
RS-232 is one of the oldest serial communication standards, introduced in 1960 for teletypewriters. Some of its key characteristics include:
- Asynchronous communication
- Full-duplex
- Single-ended signaling
- Speeds up to 20 Kbps
- Maximum cable length ~15 meters
- Typically used point-to-point between two devices
- 9-pin D-sub connectors
- ±12V signaling not directly compatible with modern digital logic levels
While largely obsolete today, the RS-232 port can still be found on some computers and industrial equipment. Many ICs are available to convert between RS-232 and logic-level serial.
TTL Serial / UART
TTL (transistor-transistor logic) serial, also known as UART (universal asynchronous receiver-transmitter), is an asynchronous protocol that operates at logic level voltages (e.g. 0-5V or 0-3.3V).
- Asynchronous
- Full-duplex
- Single-ended signaling
- Speeds typically up to 1 Mbps, sometimes up to ~5 Mbps
- Maximum cable length ~1 meter at high speeds
- Point-to-point topology
UARTs are very common in microcontrollers and other embedded systems for short-range serial communication. The lack of multi-device bus support, limited speed and cable length are limitations.
Synchronous Serial Protocols
Synchronous serial protocols include a separate clock signal or embed clock information within the data stream. This provides timing coordination between transmitter and receiver.
I2C (Inter-Integrated Circuit)
I2C is a synchronous, half-duplex, multi-master serial bus developed by Philips Semiconductor (now NXP Semiconductors).
- Synchronous
- Half-duplex
- Two wires: serial data (SDA) and serial clock (SCL)
- 7-bit addressing for up to 128 devices
- Speed modes:
- Standard: 100 Kbps
- Fast: 400 Kbps
- Fast+: 1 Mbps
- High speed: 3.4 Mbps
- Hardware slave/general call addressing
- Clock stretching allows slaves to slow communication
- Maximum bus capacitance 400 pF, limiting practical length to a few meters
I2C is widely used to connect microcontrollers to sensors, memory devices, real-time clocks, and other peripherals. Advantages include the simple two-wire interface and wide support. Limitations include relatively low speeds, half-duplex operation, and short max cable length.
SPI (Serial Peripheral Interface)
SPI is a synchronous, full-duplex master-slave interface originally developed by Motorola, now widely used by many manufacturers.
- Synchronous
- Full duplex
- Minimum of three wires:
- SCLK: Serial clock (output from master)
- MOSI: Master out, slave in (data from master to slave)
- MISO: Master in, slave out (data from slaves to master)
- Chip select (CS) wire per slave
- No standard specified maximum speed, often 10+ Mbps. Some newer devices support 100+ Mbps.
- Typically limited to short distances (< 1m)
- Commonly used for interfacing SD cards, displays, external ADCs and DACs, etc. to a microcontroller
Advantages of SPI include full-duplex operation, high throughput, low power, and widespread availability. Downsides include more wires than I2C, no flow control, short distance limit, and lack of multi-master support.
Other Common Serial Protocols
USB (Universal Serial Bus)
USB is an industry standard for short-distance digital communication and power delivery.
- Half-duplex
- Differential signaling
- Two data wires (D+ and D-) plus VBUS (+5V) and GND
- Speed modes:
- Low: 1.5 Mbps
- Full: 12 Mbps
- Hi: 480 Mbps
- SuperSpeed: 5 Gbps
- SuperSpeed+: 10 Gbps
- SuperSpeed 20 Gbps: 20 Gbps
- Cable length up to ~5 meters
- Master/slave topology with host controller and devices
- Hot pluggable
USB is the most common interface for consumer electronics thanks to its versatility, high speed, and ease of use. However, it is not ideal for an embedded system where a simpler, lower cost interface may suffice.
CAN Bus (Controller Area Network)
CAN is a multi-master serial bus standard for connecting electronic control units (ECUs).
- Synchronous
- Half-duplex
- Differential signaling
- Speeds up to 1 Mbps
- Maximum bus length depends on speed, ranges from 40m @ 1Mbps to 1000m @ 50Kbps
- Multi-master with message priority and collision detection
- Originally developed for automotive, now used in industrial automation, medical, aerospace
CAN provides robust communication in noisy environments and is well-suited for distributed control systems. But it is relatively complex and lower throughput than other interfaces.
Comparison Table
Protocol | Async/Sync | Duplex | Max Speed | Max Length | Multi-Device | Differential? |
---|---|---|---|---|---|---|
RS-232 | Async | Full | 20 Kbps | ~15m | No | No |
TTL/UART | Async | Full | ~5 Mbps | ~1m | No | No |
I2C | Sync | Half | 3.4 Mbps | Few meters | Yes (128) | No |
SPI | Sync | Full | 10+ Mbps | <1m | Yes | No |
USB | Sync | Half | 20 Gbps | ~5m | Yes | Yes |
CAN | Sync | Half | 1 Mbps | 1000m | Yes | Yes |
FAQ
-
What is the difference between asynchronous and synchronous serial communication?
Asynchronous serial does not have a separate clock signal, so the transmitter and receiver must be configured in advance to the same speed. Synchronous serial includes a clock signal to coordinate timing. -
Why would I choose SPI over I2C?
SPI supports full-duplex communication and generally higher speeds than I2C. But it requires more wires (minimum 3 vs 2 for I2C). -
Can I use a TTL serial port to directly communicate with an old RS-232 device?
No, RS-232 uses different voltage levels than TTL. You need a level shifter or converter IC in between. -
What kind of serial ports will I typically find on a microcontroller?
Most modern microcontrollers include a UART (or several) for asynchronous serial, and SPI and I2C interfaces for synchronous serial. Fewer have USB, CAN, or other interfaces. -
What’s the best serial protocol for long-distance communication?
CAN and RS-422/485 are good options for long cables (100+ meters) because they use differential signaling. For even longer distances, serial fiber optic links can be used.
In summary, there are serial communication protocols optimized for a wide range of applications, from low-cost low-speed links to high-speed buses for the latest computing devices. I2C and SPI are the most common for short-range communications between ICs, while CAN and RS-422/485 excel at longer distances in noisy environments. USB dominates the consumer device market. Asynchronous TTL serial is still widely used for its simplicity. By understanding the key characteristics of each protocol, you can choose the best one for your project.
Leave a Reply