Serial Programming/RS-485

From Wikibooks, the open-content textbooks collection

Jump to: navigation, search

All bookshelves > Science bookshelf > Computer Science bookshelf > Serial communications bookshelf > RS-485 Technical Manual


NOTE: This is a very sparse document right now. You may want to check out wikipedia:RS-485 or wikipedia:RS-232 in the meantime for more information.

Contents

[edit] Introduction

(stub)

[edit] History

(stub)

[edit] Physical Layer

RS-485 is the physical layer for many higher-level protocols, including Profibus and other fieldbus systems, SCSI-2, SCSI-3, and BitBus. [1]

Unlike RS-232, which has a "transmit wire" and a "receive wire", RS-485 has a "transmit wire pair". Typically one wire is labeled "A" and the other is labeled "B", and the wires are twisted together (a "twisted pair"). This allows RS-485 to transmit over much longer distances, using equivalent wires and equivalent transmitters and receivers, than RS-232.

Many RS-485 implementations use 2 wires (1 pair). At all times, at most one device is transmitting on the pair, and all the other devices on the network are listening (half-duplex). It is the responsibility of user software to ensure that several different devices don't try to transmit at the same time; this can be a tricky coordination task.

Some RS-485 implementations (in particular, some Ethernet configurations) (also some Macintosh GPIO socket) use 4 wires (2 pairs) for point-to-point communication. One of the pairs is dedicated to PC-to-peripheral communication. The other pair is dedicated to peripheral-to-PC communication. Each pair can transmit at full speed whether or not the other pair is transmitting (full-duplex).


Typically the bit sequence is generated by a UART inside a microcontroller, which is wired to a RS-485 interface IC (also called a "RS485 Line Driver/Receivers" or "RS-485/RS422 Transceiver"). Many manufacturers make such interface chips [2] . From there the RS-485 signaling typically travels over CAT-5 cable [3] . At the other end of the cable is (typically) the same thing -- the connectors, the RS-485 interface IC, and a UART inside a microcontroller.

[edit] Requirements

A "four-wire system" is needed for full duplex communication. A "four-wire system" requires 3 twisted pairs (6 conductors). A "two-wire system" requires 2 twisted pairs (4 conductors). [4]

(stub)

[edit] Limitations

(stub)


Standard RS-485 is limited to a maximum speed of 35 Mbps with a network length of 12 meters, and 100 Kbps with a network length of 1200 meters. [5]


With interface devices that exceed standards and careful network design, higher throughput over longer cables is possible. [6]

[edit] Handshaking

There is no hardware handshaking in RS-485. If handshaking is required for RS-485 it can be done using X-On / X-Off handshaking protocol.

The RS-485 standard originally used half-duplex communication and handshaking signals such as RTS/CTS to control the direction of data flow. Many USB to serial converters come with ADDC (Automatic Data Direction Control) to automatically sense and control data direction, making the handshaking signal method obsolete.

[edit] RS-485 in the Real World

Now being used commonly in the pro audio industry to control digital audio and signal processors such as the DBX driverack and other manufacturers equivalent products. Preferred to RS232 due to cheaper cabling run costs and the common availability of cables (similar to RJ-45).

[edit] Applications

Applications

[edit] Nonstandard Connectors and Wiring

see the 4 wires in the socket? Localtalk only uses the outer pair.

The LocalTalk network uses RS-485-compatible differential signaling on standard 4-wire RJ11 telephone connectors and cable. LocalTalk only connects to the next-outermost pair of wires (the "outer pair" on a standard 4-wire cable).

The innermost pair of wires is ignored by LocalTalk, so the inner pair is often used for standard analog telephones.

(Is there a similar standard for RS-485 on a RJ45?)

RJ45 connections are used for RS-485 frequently, due to the ease of using the modular connectors and availability of cables and connectors. A RS-485 interface will usually use pins 7 and 8 for the two data lines, since they comprise a twisted pair. This avoids conflict with both Ethernet (Pins 1-3, 6) and analog phone (Pins 4-5). Grounding can be problematic depending on the application. Often, use of shielded CAT5/6 cable can give an adequate signal ground, although this is not recommended.

[edit] Physical Limitations in Practice

(stub)

From a software point of view, RS-485 looks very similar to RS-232. With 2 pairs of wires -- a dedicated "transmit" pair and a dedicated "receive" pair (similar to some Ethernet hardware), software can't tell the difference between RS-485 and RS-232.

But a lot of RS-485 hardware uses only 1 pair of wires (half-duplex). In that case, the major differences are

  • must "turn off the transmitter" when done transmitting a message, to allow other devices their turn using the shared medium
  • The hardware generally receives on the receiver every byte that was transmitted by every device on the shared medium, including the local transmitter. So software should ignore messages sent by itself.

I've been told that 10BASE-T Ethernet and SCSI cables use a bunch of RS-485 pairs -- is that right ? In the case of 8 bit SCSI this is not the case, the drivers are single wire with a 220/330 ohm terminator at each end of the buss. Half of the conductors in a 50 way cable are ground return wires. This applies to the 8 bit version of the original 50 way SCSI interface. Ultrawide SCSI does use differential drive but whether it is RS485 compatible, I don't know.

CAN bus Cables and Connectors shows standard (?) pinouts for connecting w:CANbus to RJ11 and DE9 connectors. (CANbus uses RS-485 signal levels and hardware, but not ASCII UARTs, right?) CANbus can use RS485 but can also use open collector, optical or its own drivers. In any discussion of these bus systems you need to make a distinction between the physical layer and software and protocol layers. An ASCII UART can use 485 with suitable driver chips...--AndrewJWilson 18:50, 22 June 2006 (UTC)


[edit] termination


Perhaps the most controversial part of RS-485 is what to do at the end of the line. There are a wide variety of popular techniques, each of which works great under one narrow range of conditions.

Bob Perrin lists the 4 most popular techniques[7]:

  • unterminated. This is the simplest system, and it works well as long as the data rate is below (FIXME) times the longest end-to-end length of cable.[8]. The "unterminated" is the only style that allows any number and length of branches in the bus.
  • one-way resistor termination. Only works if there is only one transmitter, which must be at one end of a linear bus.
  • two-way resistor termination. Only works with a linear bus, but allows transmitters anywhere along the bus.
  • AC termination. While AC termination may work well on backplanes[9], others discourage its use on RS-485 lines: "In practice, I have never seen [AC termination] do anything except butcher signal integrity."[10]



[edit] further reading

  1. http://www.interfacebus.com/Design_Connector_RS485.html
  2. "EIA-458 Bus Interface IC Manufacturers"
  3. "Cable Selection for RS-422 and RS-485 Systems"
  4. "RS422/485 Application Note"
  5. "Introduction to RS485" by Lammert Bies
  6. [http://www.maxim-ic.com/appnotes.cfm/an_pk/3884 Maxim application note 3884: "How Far and How Fast Can You Go with RS-485?"
  7. "The art and science of RS-485" by Bob Perrin 1999
  8. PicList Thread: "Reflections in RS485 PIC Network?" 1998.
  9. Bus Terminations
  10. "The art and science of RS-485: Termination" by Bob Perrin 1999

Not a book title page. Please remove {{alphabetical}} from this page.