RS485 board/Why RS485/01. A difference, not a level
Why RS485 · 01 of 11

A difference, not a level

A UART wire works across a desk and fails across a room, because the receiver compares one wire with its own ground and noise moves the wire. RS485 sends every bit on two wires at once, one up and one down, and the receiver only looks at the difference between them.

One wire against a ground

A UART sends a byte as a wire going high and low. The receiver decides each bit by comparing that wire with its own ground: above about half the supply is a 1, below is a 0. Anything that pushes the wire past halfway — a motor starting nearby, a relay closing, the two ends' grounds sitting a volt apart — becomes a wrong bit.

Across a desk that almost never happens. Across a room, past a motor, it happens often enough to matter.

Two wires and a difference

RS485 sends every bit on a pair of wires called A and B. For a 1, A goes above B; for a 0, B goes above A. The receiver ignores where each wire sits and looks only at A − B.

A level against a difference
every bit right
The wire
Noise2.0 V
Receiver looks at
A − B
Decides at
± 200 mV
Bits wrong
0
Every bit right, however loud. The noise lands on A and on B alike, and the receiver subtracts one from the other, so it cancels. The driver swings A − B by at least 1.5 V and the receiver needs only 200 mV of it.

Noise that reaches the cable lands on both wires, so it pushes A and B the same way by the same amount, and the subtraction takes it out again. The driver makes A − B at least 1.5 V, and the receiver needs only 0.2 V of it, so there is a lot of room left for everything a long cable does to the signal.

That only holds while the two wires collect the same noise, which is why A and B travel as a twisted pair: two wires twisted around each other, so neither is ever further from the noise than the other.

What that buys

  • Distance. The standard covers runs up to about 1200 m, at slow data rates.
  • More than two devices. Up to 32 standard receivers can share one pair, taking turns to talk.
  • Nothing new in the sketch. The board turns UART into RS485 and back, so the sketch still calls Serial.write() and Serial.read(). What it adds is one pin that says whether this board is talking or listening, which is the subject of RE and DE are joined.

When it does not work

My UART link works on the desk and fails on a 5 m cable.

That is what a single-ended wire does: the longer it is, the more noise it collects and the more the two ends' grounds differ, and the receiver sees both as data. This is the job RS485 does. Put a board at each end and send the same bytes through them.

Can I use RS485 between two pins on the same board?

You can, and the next build does, to prove the boards work. But on a desk a plain UART wire is simpler and just as good. RS485 earns its two chips when the wire is long, runs past motors or mains, or has to reach more than two devices.

Is RS485 a protocol, like Modbus?

No. RS485 only says how the bits travel: two wires, a difference, and what counts as a 1 and a 0. What the bytes mean is up to you, or up to a protocol such as Modbus RTU laid on top. These boards carry any bytes a UART sends.

Where this goes next

Two kinds of board, six of each, and which one goes with your microcontroller.

What is in the box

Edit this page — content/books/rs485/a-difference-not-a-level.mdx

Community

Questions about this product

See what other owners have asked, and read their solutions.

This page covers several products. Choose yours to see the right discussions.

Discuss this article

Ask about this page. The answer stays here, on the page it belongs to, for whoever hits the same wall next.

Browse Modules and blocks on the forum