EmbeddedRelated.com

RS-485

Category: Protocols | Also known as: rs485

RS-485 (also written RS485, formally TIA-485) is a differential, multi-drop serial bus standard that defines the electrical layer for half- or full-duplex communication over twisted-pair wiring at data rates up to 35 Mbps (over short cables) and cable lengths up to roughly 1200 m (at low bit rates); speed and distance are a tradeoff and the highest rates and longest runs are not simultaneously achievable. It specifies driver and receiver electrical characteristics but does not define a data frame format or protocol -- those are left to higher-layer standards such as Modbus or DMX512.

In practice

RS-485 is common in industrial, building-automation, and instrumentation systems where multiple nodes must share a single bus over long distances. A typical deployment connects 32 unit-load receivers (or more with high-impedance transceivers) on a single twisted pair, with a 120-ohm termination resistor at each end of the cable. Common transceiver ICs include the MAX485, SP3485, and SN75176 families; many modern MCUs also integrate RS-485 support directly in their USART peripherals (for example, the STM32 USART DE pin drives a direction-enable signal automatically in hardware).

Because many RS-485 deployments use a single twisted pair for both transmit and receive (half-duplex), each node must switch its driver on before transmitting and off immediately after the last bit, then switch back to receive mode. Full-duplex implementations using two differential pairs are also used where continuous bidirectional communication is needed. Getting direction-control timing right in half-duplex configurations is a frequent source of bugs: enabling the driver too late drops the first byte, and disabling it too early truncates the last byte. Hardware-assisted direction control (available on some STM32 and other USART peripherals) eliminates this problem by asserting and deasserting the DE/RE lines automatically based on the transmit shift register state.

RS-485 does not specify a framing or application protocol. In embedded systems, Modbus RTU is the most widely deployed upper-layer protocol on RS-485 buses, and DMX512 is standard in lighting control. The blog post "Using a board with NuttX RTOS as an RS-485 / Modbus Slave Device" walks through a practical implementation of this stack. Because RS-485 carries no inherent message framing, higher-layer software must implement addressing, timeouts, and collision avoidance.

Cable quality and termination matter significantly at higher bit rates. At low baud rates over short cables, many systems operate reliably without proper termination, which can mask problems that appear when baud rate is increased or cable length grows. Proper impedance matching, cable shielding, and -- in electrically noisy environments -- galvanic isolation between bus and MCU ground are worth considering early in a design.

Discussed on EmbeddedRelated

Frequently asked

What is the difference between RS-485 and RS-232?
RS-232 uses single-ended signaling (voltage referenced to a common ground) and is point-to-point, typically limited to a few meters at standard baud rates. RS-485 uses differential signaling across a twisted pair, which gives it strong common-mode noise rejection, multi-drop capability (many nodes on one bus), and useful cable runs up to around 1200 m at low bit rates. RS-232 is simpler to implement for short-range, two-device links; RS-485 is the better choice for multi-node or long-cable industrial environments.
How do I handle the transmit/receive direction switching in software?
In a software-controlled approach, assert the DE (driver enable) pin before writing bytes to the UART TX register, transmit all bytes, wait until the transmit shift register is fully empty (check the USART TXE and TC flags, not just the TX buffer empty flag), then deassert DE and re-enable the receiver. Using only the TX-buffer-empty flag is a common bug that deasserts DE before the last byte has actually left the shift register. Some MCUs -- including several STM32 USART peripherals -- can control the DE pin automatically in hardware, which is the preferred solution when available.
How many devices can share one RS-485 bus?
The TIA-485 standard defines bus loading in terms of unit loads, with a classic limit of 32 unit loads per bus segment. A standard transceiver is specified as one unit load, but many modern transceivers are specified as 1/4 or 1/8 unit load, allowing 128 or 256 devices per segment. Bus repeaters or RS-485 hubs can extend these limits further. Practical limits are also affected by cable capacitance, termination, and bit rate.
Does RS-485 require termination resistors?
At high bit rates or over long cables, yes. Termination resistors (typically 120 ohms, matching the characteristic impedance of the twisted pair) are placed at both ends of the bus to prevent reflections. At low baud rates over short cables, many systems work without termination, but whether this is acceptable depends on cable length, edge rate, and topology -- it is not reliable practice for production designs. Failing to terminate is a frequent cause of intermittent errors that only appear under load, at temperature, or with longer cables.
What higher-layer protocols are commonly used on top of RS-485?
RS-485 defines only the electrical layer. The most widely used upper-layer protocol in industrial embedded systems is Modbus RTU, which provides a simple master-slave framing and CRC scheme. DMX512 is the standard in stage lighting and architectural lighting control. Proprietary protocols are also common in HVAC, motor drives, and metering equipment. The blog post 'Using a board with NuttX RTOS as an RS-485 / Modbus Slave Device' covers a practical Modbus-over-RS-485 implementation.

Differentiators vs similar concepts

RS-485 is often confused with RS-422. RS-422 is also a differential standard but is point-to-point (one driver, up to ten receivers) and is typically used for full-duplex links. RS-485 supports multiple drivers on the bus (multi-drop, multi-master capable with appropriate arbitration), making it suitable for bus topologies. RS-485 transceivers are generally electrically compatible with RS-422 receivers in point-to-point configurations, though exact interoperability depends on common-mode voltage ranges and bus topology; an RS-422 transmitter is not suitable for driving a multi-drop RS-485 bus. RS-485 is also distinct from RS-232, which is single-ended, strictly point-to-point, and limited to much shorter cable runs.