<<

1

INTRODUCTION TO SERIAL RELAY COMMUNICATIONS

Caitlin Martin, BPA

Hands On Relay School 2013 2

Serial Communications

Outline 1. Overview 2. What is a Standard? 3. What is a Protocol? 4. RS-232 5. Cables 6. Flow Control 7. Terminal Emulator 8. Breakout Boxes 9. Converters 10. Review 3

SERIAL COMMUNICATION OVERVIEW 4

Typical Substation Configurations Connection FIN Connection

Maintenance HQ

Maintenance HQ

Modem

Polling Controller

Telephone Line Network System Substation Substation

Line Sharing Switch

Terminal Server

Modem Modem Modem Modem

Communication Communication Processor Revenue Revenue Processor Revenue Revenue Meter Meter Meter Meter

Digital Fault Recorder Digital Fault Recorder Relay (DFR) Relay (DFR)

Relay Relay

Ethernet Serial 5

What are Serial Communications?

• Serial communication is the process of sending serially, one bit at a time. • Used for long distances. • Synchronization isn’t as important.

• Parallel communication sends two or more data bits at a time over separate channels/pins. 6

WHAT IS A STANDARD? 7

What is a Standard?

• A standard is “something considered by an authority or by general consent as a basis of comparison; an approved model.” (Dictionary.com)

• But, when you are talking about communications a standard is a set of rules that determine the operating characteristics of the physical transport. • The standards are developed by authorities like Electronic Industries Association (EIA), IEEE, or IEC. • Each standard defines certain characteristics that make it unique: voltage levels, signal timing, signal function, and mechanical connectors. • Standards can also be written to specify protocols. How do they compare? Specs RS-232 (1969) RS-422 (older) RS-485 Standard USB 2.0 Cabling single ended single ended multi-drop multi-drop Can be multi-drop with hub, but typically single ended Number of Devices 1 transmit, 1 receive 5 transmitters, 10 32 transmitters or 32 127 including hubs receivers receivers Communication Full duplex Full duplex, half duplex Full duplex (Tx+,Tx- Half duplex (D+.D-) Mode ,Rx+,Rx-), half duplex (A- Tx-/Rx-, B- Tx+/Rx+) Maximum Distance 500 feet at 9600bps 4000 feet at 100kbps 4000 feet per segment at 15 feet 100kbps Maximum Data Rate 19.2kbps for 50 feet 10Mbps for 50 feet 10Mbps for 50 feet 480Mbps

Signaling unbalanced Balanced differential Balanced differential Balanced twisted pair and twisted pair twisted pair shielded Mark (data 1) -3V min. to -25V max B-A > 200mV B-A > 200mV 5V +/- 0.25V -2V min. to -6V max. -1.5 to -6V Space (data 0) 3V min. to 25V max B-A<-200mV B-A<-200mV 0V +/- 0.25V 2V min. to 6V max. +1.5 to 6V Input Level Minimum +/- 3V 0.2V difference 0.2V difference Output Current 500 mA (note that the 150mA 250mA 500mA to 900mA in driver ICs normally used general. in PCs are limited to 5A for charging 10mA) equipment 9

WHAT IS A PROTOCOL? 10

What is a Protocol?

• “A protocol is a series of prescribed steps to be taken, usually in order to allow for the coordinated action of multiple parties.”

• A communications protocol is the set of rules for data representation, authentication and error detection required to send information over a communications channel.

• The protocol is like the language that the device speaks. Both devices must speak the same language to communicate. 11

What is a Protocol?

• Industry protocols (open protocols & most can be over serial or communications): • ASCII • Developed in 1963 for character coding text between and devices. • DNP 3.0 • Developed for RTU client server communications. • Modbus • Created by Modicom in 1979. Used originally in Modicom PLCs, now you can see it used in many other devices.

• Manufacture protocols: • SEL’s Fast Meter, Fast Message, SEL ASCII • ABB’s SPAbus 12

What is a Protocol?

• Client/Server or Master/Slave • The Master or Client initiates communications, and the Slave or Server responds and sends data.

• Peer to Peer • Each device can act as a client or a server and initiate communications equally. 13

RS-232 14

RS-232 Standard

• RS-232 was designed for computers to talk to . • Today it is used for much more than that. • Limitations of the standard: • Cannot multi-drop connections to more than two devices. • Large voltage swings are required to go from positive and negative values. • No specifications in the standard for powering devices. • Though manufacturers modify the standard to accomplish this. • Large connectors take up real estate on devices. • New standards fill in the gaps for RS-232 • RS-485 is Multi-drop and can be a smaller connector • USB has +5V output for powering devices and much smaller connectors 15 RS-232 Standard Voltage and logic assignments

Transition Region

One character consists at a minimum: framing by the start and stop bit and 7/8 data bits. Read from the MSB to the LSB, where a positive voltage above 3V is a logical 0, and a negative voltage below -3V is a logical 1. 16

What is the Problem? Question • You connect up to a relay, and open your software to communicate to it. You keep hitting enter but you are not getting anything back from the relay. What could be the problem?

Answer • There are several reasons why this could happen. Start with the physical connections. Is the device powered on? Are there any air gaps? Is it the correct cable? Is the cable broken? • Once you have verified the physical connections move onto software settings. Did you select the correct PC com port? Is it the correct protocol for communications? • If you still don’t get anything, verify the settings in the relay. You may expect it to be set a certain way, but you never know until you verify. This may be done from the front panel of a relay. 17 Data Transmission (Logical representation) 18

Data Bits, 7 or 8?

• More bits in a single data transmission equals more data that can be represented 7 • 7 bits, 2 = 128 possibilities 8 • 8 bits, 2 = 256 possibilities • 8 bits is known as extended ASCII which include additional characters in the 127 to 255 decimal range. 19

Parity Bit

• Parity bits are used for error detection, and can be calculated in two ways: even or odd. • When even parity is used the number of bits will contain an even amount of logical 1’s and will use the parity bit to maintain that. • When odd parity is used the number of bits will contain an odd amount of logical 1’s and will use the parity bit to maintain that. • Not capable of detecting all errors, only ones that cause an odd number of bits to change state. • Parity bits are typically not used in relay communications and when setting up communications the parity will be “none”. 20

Stop Bits, 1 or 2

• Start and stop bits frame a data transmission, and informs the receiver the start and stop of a data transmission. • The purpose of the stop bit is to allow the internal oscillator to re-sync with the system clock. It does this after every character of data. If it doesn’t re-sync it may read the next character improperly. • Stop bits allow the receiver to “catch it’s breath”. • If there are not enough stop bits the receiver may misinterpret the data similar to a mis-matched baud rate. • 1 stop bit is typically enough for PC to relay communications. 21 Three Character Data Stream with Stop Bits.

• One stop bit for each • Two stop bits for each character. character. 22 ASCII Protocol Character Start Bit Width Indicates Baud Rate

From start bit: ∆T = 105.556 μs F = 1/T = Start Bit 9473.64 Hz Most Significant Baud rate = 9600 bps Bit: 7

∆T = 416.667 μs ∆T/T = 3.947 0 1 2 3 4 5 6 7 4 bits Least ∆T = 211.111 μs Significant Stop Bit ∆T/T = 1.999 Bit, 0 2 bits 23

ASCII Protocol Character

∆T = 105.556

∆T/T = 1.0 1 bit 0 1 2 3 4 5 6 7

Parity & Stop Bits

Because the LSB is first in, we have to read the trace in reverse order to get the binary value 24

Binary to Decimal Conversion

Decimal value is 97 25 ASCII Protocol Chart Binary / Decimal / Hex 26

Easy Conversions Binary/Decimal/Hexadecimal

0 27

What is the problem? • Question • I type a command and the relay returns all gibberish, what is wrong?

• Answer • Most likely there is a baud rate mismatch between your PC and the relay, but they are close. Match your PC’s baud rate with the relay’s. • If some of the characters are gibberish there could be noise on the line. • If some of the characters are gibberish, but the gibberish is repeating. I have seen this with the wrong cable. Imagine hardware flow control being decoded as ASCII. If you refer to the equipment manual you can find the pin out for that device and verify you are using the correct cable. 28

Simplex versus Duplexes

• Simplex allows traffic to flow in only one direction. (radio signals)

• Half Duplex allows communication in only one direction at a time. (walkie- talkie)

• Full Duplex can communication in both directions at a time. (phones) 29

Synchronous versus Asynchronous

• Whether synchronous or asynchronous the combination of the clock signal and the baud rate are used to determine when to take a sample and read it as a bit.

• Synchronous – Where the devices are using a common clock. The clock signal is sent along with the data on separate pins. • RS-422/RS-485 (can be) • RS-232 DB25 (can be)

• Asynchronous – Having no common timing reference but utilizing an independent reference. • RS-232 DB9 30

Asynchronous Communication

Each device has it’s own time source. The clock speed of the internal oscillator is determined by the Baud rate selection in each device’s software applications.

The first transition from “1” to “0” is the trigger used to start the oscillator 31

Asynchronous Communication

PC #1

Relay

Transmits At 9600 baud a At 9600 baud a Data transition is sample is taken Receives generated every 104 every 104 micro Data micro seconds seconds

PC #1

Relay

Transmits At 4800 baud a At 9600 baud a Data transition is sample is taken Receives generated every 208 every 104 micro Data micro seconds seconds 32

CABLES 33

Which Cable do I use? 34

Connectors

• Based on the standard DB-9 is actually a DE-9. DB-9 is the industry understood term.

• Circuit board mounted DB-9 connectors, like the ones in your PC, can be damaged by wiggling the cable while removing or connecting. i.e. Don’t pull the cable out by the cord. 35

Connectors

Connectors can be used with multiple standards. 36

DTE or DCE, which is it?

• DTE- Data Terminal Equipment • Computers can emulate terminals, and printers

• DCE- Data Circuit-terminating Equipment • Also known as Equipment • Modems, most relay configuration ports

• When a DTE talks to a DCE you use a straight through cable, i.e. the link between a and a modem.

• When a DTE talks to a DTE, or a DCE talks to a DCE you need a cable. i.e. the link between a computer and a printer.

• This unfortunately isn’t very standard. Relays typically are DCEs, but require manufacture unique cables to communicate. 37

DTE/DCEDTE Standard (Suggestion)DCE 38 DB‐25 DB‐25 DB‐9DB‐9 PIN PIN DTE (Male) DCE (Female) DTE (Male) DCE (Female) 1 Shield Shield 1 Carrier Detect (CD) Carrier Detect (CD) 2 Transmit Data (TX) Receive Data (RX) 2 Receive Data (RX) Transmit Data (TX) 3 Receive Data (RX) Transmit Data (TX) 3 Transmit Data (TX) Receive Data (RX) 4 Request to Send (RTS) Clear to Send (CTS) 4 Data Terminal Ready (DTR) Data Terminal Ready (DTR) 5 Clear to Send (CTS) Request to Send (RTS) 5 Signal Ground (SG) Signal Ground (SG) 6 Data Set Ready (DSR) Data Set Ready (DSR) 6 Data Set Ready (DSR) Data Set Ready (DSR) 7 Signal Ground (SG) Signal Ground (SG) 7 Request to Send (RTS) Clear to Send (CTS) 8 Carrier Detect (CD) Carrier Detect (CD) 8 Clear to Send (CTS) Request to Send (RTS) 9 Reserved for Testing Reserved for Testing 9 Ring Indicator (RI) Ring Indicator (RI) 10 Reserved for Testing Reserved for Testing 11 Unassigned Unassigned • Data is on TX & RX pins 12 Secondary Carrier Detect (SCD) Secondary Carrier Detect (SCD) 13 Secondary Clear to Send (SCS) Secondary Request to Send (SRS) 14 Secondary Transmit Data (STD) Secondary Receive Data (SRD) • Handshaking is on CTS/RTS or 15 Transmit Clock (TC) Transmit Clock (TC) DTR/DSR pins 16 Secondary Receive Data (SRD) Secondary Transmit Data (STD) 17 Receiver Clock (RC) Receiver Clock (RC) 18 Local Loopback Local Loopback • Modems use CD and RI pins 19 Secondary Request to Send (SRS) Secondary Clear to Send (SCS) 20 Data Terminal Ready (DTR) Data Terminal Ready (DTR) 21 Remote Loopback Remote Loopback • Synchronous Communications use 22 Ring Indicator (RI) Ring Indicator (RI) RC and XTC pins. 23 Data Rate Select (DSR) Data Rate Select (DSR) 24 External Clock (XTC) External Clock (XTC) 25 Test Mode Test Mode 39

DTE to DCE

• Typical direction of data flow: straight through.

DB‐9 DB‐9 PIN PIN DTE DCE

1 Carrier Detect (CD) 1 Carrier Detect (CD)

2 Receive Data (RX) 2 Transmit Data (TX)

3 Transmit Data (TX) 3 Receive Data (RX)

4 Data Terminal Ready (DTR) 4 Data Terminal Ready (DTR)

5 Signal Ground (SG) 5 Signal Ground (SG)

6 Data Set Ready (DSR) 6 Data Set Ready (DSR)

7 Request to Send (RTS) 7 Clear to Send (CTS)

8 Clear to Send (CTS) 8 Request to Send (RTS)

9 Ring Indicator (RI) 9 Ring Indicator (RI) 40

3-Wire RS-232

• Only three wires are necessary to communicate between two device for short distances: transmit, receive, and ground.

DB‐9 DB‐9 PIN PIN DTE DCE

1 Carrier Detect (CD) 1 Carrier Detect (CD)

2 Receive Data (RX) 2 Transmit Data (TX)

3 Transmit Data (TX) 3 Receive Data (RX)

4 Data Terminal Ready (DTR) 4 Data Terminal Ready (DTR)

5 Signal Ground (SG) 5 Signal Ground (SG)

6 Data Set Ready (DSR) 6 Data Set Ready (DSR)

7 Request to Send (RTS) 7 Clear to Send (CTS)

8 Clear to Send (CTS) 8 Request to Send (RTS)

9 Ring Indicator (RI) 9 Ring Indicator (RI) Cable Exercise 1

DTE DCE DTE DTE DB9 DB9 DB9 DB9 Socket Pin Socket Socket

DCD 1 1 DCD DCD 1 1 DCD Received Data 2 2 Transmitted Data Received Data 2 2 Received Data Transmitted Data 3 3 Received Data Transmitted Data 3 3 Transmitted Data DTR 4 4 DTR DTR 4 4 DTR Signal Ground5 5 Signal Ground Signal Ground5 5 Signal Ground DSR 6 6 DSR DSR 6 6 DSR Request to Send 7 7 Clear to Send Request to Send 7 7 Request to Send Clear to Send 8 8 Request to Send Clear to Send 8 8 Clear to Send Ring Indicator9 9 Ring Indicator Ring Indicator9 9 Ring Indicator 9 Pin 25 Pin DTE DCE DB9 DB25 Socket Pin

DCD 1 8 DCD Received Data 2 3 Transmitted Data Transmitted Data 3 2 Received Data DTR 4 20 DTR Signal Ground5 7 Signal Ground DSR 6 6 DSR Request to Send 7 4 Clear to Send Clear to Send 8 5 Request to Send Ring Indicator9 22 Ring Indicator Cable Exercise 2

DB9 connector with Pins (male)

1. Is it a DTE or DCE device? 2. Does it follow the standard, if not where? 3. What cable would you use to communicate from a PC. Cable Exercise 3

DB9 connector with Sockets (female)

1. Is it a DTE or DCE device? 2. Does it follow the standard, if not where? 3. What cable would you use to communicate from a PC. Cable Exercise 4 45

Cable Testers

• Verify proper cable, or that the cable is still intact.

• Cable testers come with connector types and will apply a voltage at one pin at a time and will indicate where the same voltage shows up by lighting the LED(s). Standard and Non-standard Cables

• DCE & DTE cable indications are DCE-DTE specified by the type of end Straight Through connector, not the device it will 1 1 connect to. 2 2

3 3

• The cable tester will put a voltage 4 4

on one pin and see if there are 5 5 other pins with the same voltage. 6 6

7 7 • The connected pins are indicated by an illuminated LED. 8 8

46 9 9 Standard and Non-standard Cables Adaptors

• DB9 to DB25 • Null Modem • Gender Changers • Male-to-Male • Female-to-Female • Port Extenders or Port Savers • Male-to-Female • And, any combination of above 49

Cable Tester Lab

1. Draw the wires for the pin out for a DB9 to DB25 straight through on the next slide.

2. Make that cable with an adaptor, and test out your drawing by using a cable tester to find the pin out. 50

DB‐9 DB‐25 PIN PIN DTE (Male) DCE (Female)

1 Carrier Detect (CD) 1 Shield Cable Tester Lab 2 Receive Data (RX) 2 Receive Data (RX) 3 Transmit Data (TX) 3 Transmit Data (TX)

4 Data Terminal Ready (DTR) 4 Clear to Send (CTS)

5 Signal Ground (SG) 5 Request to Send (RTS)

6 Data Set Ready (DSR) 6 Data Set Ready (DSR)

7 Request to Send (RTS) 7 Signal Ground (SG)

8 Clear to Send (CTS) 8 Carrier Detect (CD)

9 Ring Indicator (RI) 9 Reserved for Testing

10 Reserved for Testing

11 Unassigned

12 Secondary Carrier Detect (SCD)

Secondary Request to Send 13 (SRS)

14 Secondary Receive Data (SRD)

15 Transmit Clock (TC)

16 Secondary Transmit Data (STD)

17 Receiver Clock (RC)

18 Local Loopback

19 Secondary Clear to Send (SCS)

20 Data Terminal Ready (DTR)

21 Remote Loopback

22 Ring Indicator (RI)

23 Data Rate Select (DSR)

24 External Clock (XTC)

25 Test Mode 51

What is the problem?

Question • I am trying to talk to a new relay and it did not come with a cable. I found a cable that matched the pin out in their application guide, but it is the wrong gender. What can I do?

Answer • Gender changers. Gender changers come in male-to- male or female-to-female for changing the gender of the cable, and not the pin out. 52

What is the problem?

Question • I am trying to talk to a new relay and it did not come with a cable. I found a straight through cable, but it requires a null modem. What can I do?

Answer • Null modem adaptors, the adaptors come in male-to- female so they do not change the gender of the connector, but they do modify the pin out to match a null modem cable. This means a gender changer may also be needed. 53

What is the problem?

Question • I need to talk to a device that requires a manufacture specific cable, and I find a null modem cable and a gender changer. I connect them and I can communicate. Why does this work, and why might you not want to do this?

Answer • The data pins for the device follow the pin out for a null modem cable, but does require a different gender. The flow control pins may not line up and will only work without flow control. • You have to be careful using cables not meant for a device because there may be voltage on one of the pins designed to power a device that can fry your PC’s com port. 54

Noise in Communications • Noise in communication signals are typically created by near by equipment or cables that experience over voltages. • The over voltage can be induced onto near by communication cables creating a change in voltage that can be interpreted as a binary change of state and corrupt the data. • RS-485 uses twisted pair wires in the cable to make it immune to noise. Noise is likely to be the same on both wires, so if they are subtracted from each other all that is left is the original communications signal. • Another way of preventing noise from effecting a communication cable is to use a shielded cable that has a thin metal wrap to prevent noise from entering the cables.

I I

I induced I induced

I induced 55

Reflections in a Cable • When a signal goes through a cable, and approaches a significant change in impedance, part of the signal is reflected back. • The reflection can increase the voltage of the original signal, and can be interpreted incorrectly as communications. • The change in impedance can be caused by an imperfection in the cable, or improper terminating at the ends of the cable. • RS-232 is terminated internally to the equipment where the signal will be absorbed typically is not an issue. Other standards with multiple devices need to be properly terminated. Significant change in impedance

Vs Sending end sees original signal, then the addition of the reflection. t 56

FLOW CONTROL When do you want to use Handshaking?

• Handshaking = Flow Control. • Handshaking introduces the devices to each other and establishes paths of communication before the data can be sent. • When data is being lost because the buffer is overflowing, then handshaking needs to be used. • This is more likely to occur with there are mismatched baud rates in the communication path. Flow Control (Handshaking)

57600 9600 19200 Baud Baud Baud

Modem Buffer

75%

25%

58 59

Software Flow Control

57600 Baud XOn______

XOFF______Modem Buffer

75%

25% 60

Hardware Flow Control (RTS)

DTE DCE Computer Modem

TX RX RTS CTS CTS RTS

Modem Buffer

75% Some applications use hardware flow control (DTR) which utilizes the DTR and DSR pins in the same way as RTS and CTS. To utilize hardware flow control you must have the correct cable for that device. 25% 61

TERMINAL EMULATOR 62

Basic Terminal Setup

• Session Type • COM (Serial) • Telnet (Ethernet) • Parameters • Baud Rate, bits per second • Parity, # of bits and if even or odd for error checking • Stop Bits, 1 or 2 • Flow Control • Xon/Xoff for software • Hardware • Port Number, specifies a physical or virtual port on your computer • Terminal • Type and ID, VT100, created in 1978 • Sessions List • Can save settings for known connections. 63

Basic Terminal Setup

Another important setting is Local Echo. Depending on the device, what you type may not be displayed on your window.

If you cannot see what you are typing turn on Local Echo.

If you are seeing double characters for everything you type then turn off Local Echo.

This does not effect what is sent to the device, just how it is viewed on your window. 64

Terminal Emulators

• Terminal emulators now come with a lot of manufacturer’s software but require the same connection settings for serial communications.

• A benefit is the software may hide some of the settings because when you select a specific device it knows it is configured to communicate by default and only allow you to adjust editable settings like the baud rate. 65

BREAKOUT BOXES 66

RS-232 Breakout Boxes

• Breakout boxes can be used to: • Make your own cables for troubleshooting. • Monitor communications to verify which pins are being used in communications by inserting the breakout box within the communication path. • It lets you 'patch' the signals between the input and the output sides. • For a straight through connection you put the rocker switch for that pin to Closed or ON. • If you want to route the signal elsewhere you put it to Open or OFF and use a jumper from the terminal posts from one side to the other. 67

RS-232 Breakout boxes

A good breakout box will have: • LED indication for every pin. • Multi-state/multiple LEDs to indicate a space, mark, or the transition region. • Is battery powered and has an ON/OFF switch. • Includes multiple jumpers. 68

RS-232 Break Out Box

Straight Through Straight Through DB9-DB9 Cable DB9-DB9 Cable 9-25 Adaptor

DTE DCE 9-25 Adaptor

LEDs indicate traffic from DTE to DCE. Modify the connection Switch direction of connections to see LEDs for the other direction. with the breakout box 69

RS-232 Breakout Boxes

• Modifications: • Let pins go across by turning the rocker switch to ON or Closed. • Pin 2 ON Pin 2 will connect Pin 2 to Pin 2. • Turn OFF or Open the pins and connect them somewhere else with a jumper. • Pin 2 OFF Pin 2, jumper Pin 2 to Pin 3. • Pin 3 OFF Pin 3, jumper Pin 3 to Pin 2. • Pin outs are for DB25. 70

RS-232 Monitor- Mini Tracker

• Put an RS-232 monitor in the communication path and the LEDs will light up when they are activated. • Watch the communications only. Can’t modify connections. • Verify correct cable (TX goes to RX, and RX goes to TX)

Green LED: below 3 volts • Can tell if flow control is Red LED: above 3 volts being used. 71

Lab Exercises

• First test your computer’s com port by creating a loop back connector with an RS-232 Breakout box and at 50 baud. • You will be able to transmit and receive what you are typing in a terminal emulator.

• Next, connect to your lab partner with an RS-232 Breakout box in the circuit at 50 baud with no handshaking. • You will need to create a null modem cable with two straight through DB9 to DB9 cables and your breakout box. Use adaptors as needed to make this work • What you transmit your partner will receive. You just created instant messaging! Turn on local echo to see what you are typing.

• Talk to lab partner with hardware handshaking enabled. • Which additional pins light up with handshaking enabled? 72

REVIEW 73 How do I Troubleshoot a Communication Problem?

• Collect information from all devices (baud rate, addressing, handshaking, etc.) • Search the device’s manual for communications

• Verify physical connections (air gap, cable type, low voltage levels, etc.)

• Verify protocol specifications

• Tools • Cable tester • RS-232 breakout box • Protocol analyzer 74

Breakout Box Cheat Sheet

Source: http://www.pccompci.com/rs232-cable-technology.html