### RS422 / RS485 (differential) control with one PIC TTL output

RS422 or single master full duplex RS485 (where the PIC is the only 'master') Both RS422 and RS485 use a twisted pair cable to transmit signals over distances of up to 1km. Both use differential (A+, B-) signaling, but, unlike RS422, RS485 supports multiple 'masters' on the same cable. Full duplex uses 2 pairs, one for Tx the other for Rx, however bi-directional 'half-duplex' is supported over a single pair (so is more common, especially for long cable runs, which can be up to 1km !). A ground (shield) wire (C) is usually present. Driver voltages are typically +/-2.5v to +/-5v (max +/-6v) = the minimum 'specified' receiver difference is +/- 1.5v however most work down to +/-200mV (the max. voltage, referenced to chip ground, on any pin is -7 to +12). 'Idle' state is usually A more positive than B (which is taken as a '1') and (since the drivers are 'tri-state', idle is 'guaranteed' with the use of 'bias' resistors). The receiver is simply looking for the 'difference' between the A+ and B- wires. A difference of +200mV is taken as a '1' and -200mV as a '0'. The actual voltage levels on the two wires are thus irrelevant, it being the 'difference' that counts. This means you can, in fact, 'get away with' using TTL 0,+5 and +5,0 as the two states (so long as you 'bias' the other wire to +2.5v).

#### Termination

The 'ideal' RS422/485 system consists of a single linear cable (no branches) with 120 ohm resistors connected across the 2 wires at each end of the cable. Sometimes additional termination resistors are added between each wire and ground/V+ or ground/V-, however this is typically done only for 'long line' usage. RS485 can handle speeds of over 10 Mbits per second and line lengths of over 1 km. If you are operating anywhere near these values you must arrange your wiring close to the ideal and fit termination resistors HOWEVER at the more typical 4800/8600 baud and short distances, all the termaination resistors are often omitted.

#### The PIC drive

A PIC i/o pin will switch between 0v6 and Vdd-0v7 (for Vdd 5v, that's 4v3). If one of the RS422/485 wires is held half way between these two values (i.e. at 2v45) and the other driven direct by the PIC pin, we get a difference of 2v45-0.6 = 1v85 (well above the 200mV minimum) and 2v45-4v3 = -1v85, again well below the -200mV minimum). In practice the 'mid point' will be 2.5v (giving us +1.9 and -1.8) Note = the bus 'idle' state is PIC pin 'Hi' (so setting to 'input' mode (tri-state) using the weak internal pull-up (approx 22k) will work fine) Multi-master and RS484 half-duplex considerations The problem in a half-duplex or multi-master configuration is that the PIC is not the only device driving the lines. Any other master (or a half-duplex slave) will likely use the standard +/-6v, and whilst 6v is not a big issue, -6v is. In that situation, we have to add a Schottky diode (to prevent more than -0.3 appearing on the PIC i/o pin) plus a current limiting resistor (560R) to avoid blowing the remote transmitter (as it's -6v is 'shorted' to Gnd by the diode). This, by the way, means the same PIC i/o pin used as a input can receive the slave transmissions (as the diode 0v3 limit = '0' and 6v = '1')

#### Usage

RS485 is used for the 'Profibus' and 'Modbus' interface standards, and extensively used for CCTV camera control (for example, Pelco-P)