ROBOTICS 101Concept explainer

Communication Buses: UART, I2C, SPI, CAN

Sensors, motor drivers, and computers on a robot talk over a few standard buses. Each one sends bits as high and low voltages on wires, but they differ in how many wires they use, how they keep time, and how they decide who talks.

Four buses

UART uses one wire each way and no clock. Both sides agree on a baud rate in advance. A frame is a start bit (0), eight data bits with the lowest bit first, and a stop bit (1).

I2C uses two shared wires, a clock (SCL) and data (SDA). The controller sends a 7-bit address, and only the device with that address answers by pulling SDA low for an acknowledge (ACK). Many sensors can share the same two wires.

SPI uses a clock, a data line each way (MOSI and MISO), and a chip select per device. It sends and receives at the same time and runs much faster than I2C.

CAN uses a twisted wire pair and lets any node talk. If two start at once, a 0 (dominant) beats a 1 (recessive) on the wire. A node that sends a 1 but sees a 0 knows it lost and stops. The frame with the lowest ID always wins without being damaged:

$$\text{bus} = a \wedge b \qquad \text{winner} = \min(\text{ID}_A,\ \text{ID}_B)$$

What to notice

On UART, set the receiver to the wrong baud rate and its sample points drift off the bit centers, so it reads a different byte. On I2C, change the address away from 104 (hex 0x68, a common IMU address) and no device answers, so the ACK slot stays high. On CAN, give the two nodes different IDs and watch the higher one drop out at the first bit where they differ.