|RS-485 Multidrop Networking
RS-485, due to its low-cost, simplicity, and robustness, has become widely used in many industrial networking applications. Many microcontrollers provide a serial port that can become a node on an RS-485 network with the addition of an inexpensive RS-485 transceiver. RS-485 wiring uses simple and inexpensive twisted pair wiring. And RS-485's use of differential transmission makes it quite robust even in noisy industrial environments.
Unfortunately, RS-485 is only a physical layer interface. And even then, there is no specification for connectors. You are on your own with respect to the higher layer protocols.
The need for additional protocols is clear when you consider that RS-485 allows for multiple nodes to connect to the same wire, much the same as party-line phone service did in decades past. When you wanted to use a phone on a party-line, you had to pick up the handset and listen first to make sure nobody else on the party-line was talking already. If the line was clear, you were free to dial out. If more than one party tried to use the phone at the same time, the result was confusion. The same is true for RS-485. Every node on the network can generally listen at the same time. However, only one node can talk at any given time. If more than one node attempts to talk at once, the message will be garbled. So, a higher level protocol is necessary to ensure that every node will get a chance to talk and that its message will get through ungarbled.
Some systems deal with this problem partly through wiring. Some systems will require that one device be a master and all others slaves. Then the transmitter of the master is wired to the receiver of all the slaves and vice versa. Then there will be no problems as long as the slaves accept the rule that slaves only speak when spoken to.
However, the master/slave relationship does not always fit well. Often, a peer relationship better describes the interactions between network nodes. In order to realize such a relationship in an RS-485 network, it will be necessary to have some higher-level protocols.
OSI Network Model
To understand networking in general, you should be aware of the OSI Network Model. A network can be described as having several layers of functionality. The OSI Network Model defines seven layers of functionality which from highest level to lowest level are: application, presentation, session, transport, network, data link, and physical.
If you are thinking about creating your own networking protocol, you may want to study the OSI model and data communications in general, before you get too far along. A good place to start would be with the textbook Data and Computer Communications by William Stallings.
How many of the OSI layers will be needed in your application will depend on the capabilities you wish to achieve in your network. But, assuming a peer-to-peer network, you'll minimally need to have a data link layer. Without it, you'll have a party-line nightmare. The data link layer will ensure that messages are not garbled and will permit everyone an opportunity to talk.
Additional protocols may also be necessary if you wish to route traffic from your network to other networks. Or, if you have multiple applications on a single node that may need to talk at the same time over the network.
Of course the easiest solution would be to use an existing protocol.
Cimetrics offers BACnet, a sophisticated network protocol originally designed for communications of environmental systems. It works over a variety of physical layers including RS-485 and Ethernet. Cimetrics also offers a simple 9-bit serial protocol well suited to standalone RS-485 networks.
High Tech Horizon has developed a free and open protocol called SNAP or Scalable Node Address Protocol that can be used with half- and full-duplex, master/slave, and peer-to-peer systems.