An RS-485 Network
USB/RS-485 converter, or an RS-232/RS-485 converter that connects to an
RS-232 port. Microcontroller ports can interface to RS-485 transceivers.
To control the driver-enable inputs, the nodes can use automatic driver-enable
circuits as described in Chapter 7 or software-controlled driver-enable lines.
The methods used to control the driver-enable lines determine in part whether
the nodes need to insert delays before sending or responding to commands.
1
6
At one end of the network, three resistors in series hold the inputs high when
no drivers are enabled on the network. The 130Ω resistor provides a parallel line
termination and the two 620Ω resistors provide biasing. At the other end of the
network, a 120Ω resistor provides a parallel termination. If the line is electri-
cally short as defined in Chapter 7, you don’t need terminating or biasing resis-
tors.
4
For the network wires, unshielded twisted pair works well. Include a ground
wire to each node unless you’re sure that all nodes already have a common sig-
nal-ground connection.
+4$
The example network uses a command/response protocol. You can expand on
the protocol as needed, adding additional commands, error codes, error check-
ing of received communications, or other features.
Each secondary node has a unique assigned address from 97 to 122, which cor-
respond to ASCII codes for the characters a–z. The primary node doesn’t have
an address. Each command has a value from 48 to 57, which correspond to
ASCII codes for the characters 0–9.
Messages from the primary node use this format:
Byte 0 is a “:” character that signals the start of a message.
Byte 1 is the address of the node being addressed.