INTRODUCTION TO SERIAL RELAY COMMUNICATIONS
Transcript of INTRODUCTION TO SERIAL RELAY COMMUNICATIONS
INTRODUCTION TO SERIAL RELAY COMMUNICATIONSCaitlin Martin, BPA
Hands On Relay School 2013
1
Serial Communications
Outline1. Serial Communication Overview2. What is a Standard?3. What is a Protocol?4. RS-2325. Cables6. Flow Control7. Terminal Emulator8. Breakout Boxes9. Converters10. Review
2
SERIAL COMMUNICATION OVERVIEW
3
Communication Processor
Relay
Relay
Digital Fault Recorder (DFR)
Revenue Meter
Revenue Meter
Terminal Server
Network
Maintenance HQ
Substation
EthernetSerial
Communication Processor
Relay
Relay
Digital Fault Recorder (DFR)
Revenue Meter
Revenue Meter
Line Sharing Switch
Maintenance HQ
Substation
Modem
Polling Controller
Modem Modem Modem Modem
Telephone Line
System
Typical Substation ConfigurationsFIN ConnectionModem Connection
4
What are Serial Communications?
5
• Serial communication is the process of sending data 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.
WHAT IS A STANDARD?
6
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.
7
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 receivers
32 transmitters or 32 receivers
127 including hubs
Communication Mode
Full duplex Full duplex, half duplex Full duplex (Tx+,Tx-,Rx+,Rx-), half duplex (A-
Tx-/Rx-, B- Tx+/Rx+)
Half duplex (D+.D-)
Maximum Distance 500 feet at 9600bps 4000 feet at 100kbps 4000 feet per segment at 100kbps
15 feet
Maximum Data Rate 19.2kbps for 50 feet 10Mbps for 50 feet 10Mbps for 50 feet 480Mbps
Signaling unbalanced Balanced differential twisted pair
Balanced differential twisted pair
Balanced twisted pair and shielded
Mark (data 1) -3V min. to -25V max B-A > 200mV-2V min. to -6V max.
B-A > 200mV-1.5 to -6V
5V +/- 0.25V
Space (data 0) 3V min. to 25V max B-A<-200mV2V min. to 6V max.
B-A<-200mV+1.5 to 6V
0V +/- 0.25V
Input Level Minimum +/- 3V 0.2V difference 0.2V difference
Output Current 500 mA (note that the driver ICs normally used
in PCs are limited to 10mA)
150mA 250mA 500mA to 900mA in general.
5A for charging equipment
WHAT IS A PROTOCOL?
9
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.
10
What is a Protocol?• Industry protocols (open protocols & most can be over serial or
Ethernet communications):• ASCII
• Developed in 1963 for character coding text between computers 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
11
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.
12
RS-232
13
RS-232 Standard
14
• RS-232 was designed for computers to talk to modems. • 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
RS-232 StandardVoltage and logic assignments
Transition Region
15
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.
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.
16
Data Transmission(Logical representation)
17
Data Bits, 7 or 8?• More bits in a single data transmission equals more data that can be
represented• 7 bits, 27 = 128 possibilities• 8 bits, 28 = 256 possibilities• 8 bits is known as extended ASCII which include additional characters
in the 127 to 255 decimal range.
18
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”.
19
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.
20
Three Character Data Stream with Stop Bits.
21
• One stop bit for each character.
• Two stop bits for each character.
ASCII Protocol CharacterStart Bit Width Indicates Baud Rate
From start bit:∆T = 105.556
μsF = 1/T =
9473.64 Hz
Baud rate = 9600 bps
Start Bit
22
Least Significant
Bit, 0
Most SignificantBit: 7
∆T = 416.667 μs
∆T/T = 3.947
4 bits
∆T = 211.111 μs
∆T/T = 1.999
2 bits
0 1 2 3 4 5 6 7
Stop Bit
ASCII Protocol Character
Because the LSB is first in, we have to read the trace in reverse order to get the binary value
∆T = 105.556
∆T/T = 1.0
1 bit
Parity & Stop Bits
23
0 1 2 3 4 5 6 7
Binary to Decimal Conversion
24
Decimal value is 97
ASCII Protocol ChartBinary / Decimal / Hex
25
Easy Conversions Binary/Decimal/Hexadecimal
26
0
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.
27
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)
28
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
29
Asynchronous Communication
The clock speed of the internal oscillator is determined by the Baud rate selection in each device’s software applications.
Each device has it’s own time source.
The first transition from “1” to “0” is the trigger used to start the oscillator
30
Asynchronous Communication
PC #1
Transmits Data
At 9600 baud a transition is
generated every 104 micro seconds
At 9600 baud a sample is taken every 104 micro
seconds
Receives Data
PC #1
Transmits Data
At 4800 baud a transition is
generated every 208 micro seconds
At 9600 baud a sample is taken every 104 micro
seconds
Receives Data
Relay
Relay
31
CABLES
32
Which Cable do I use?
33
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.
34
Connectors
35
Connectors can be used with multiple standards.
DTE or DCE, which is it?
36
• DTE- Data Terminal Equipment• Computers can emulate terminals, and printers
• DCE- Data Circuit-terminating Equipment• Also known as Data Communication 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 computer and a modem.
• When a DTE talks to a DTE, or a DCE talks to a DCE you need a null modem 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.
DTE/DCE Standard (Suggestion)DTE DCE
37
38
• Data is on TX & RX pins
• Handshaking is on CTS/RTS or DTR/DSR pins
• Modems use CD and RI pins
• Synchronous Communications use RC and XTC pins.
PINDB‐25 DB‐25
DTE (Male) DCE (Female)
1 Shield Shield
2 Transmit Data (TX) Receive Data (RX)
3 Receive Data (RX) Transmit Data (TX)
4 Request to Send (RTS) Clear to Send (CTS)
5 Clear to Send (CTS) Request to Send (RTS)
6 Data Set Ready (DSR) Data Set Ready (DSR)
7 Signal Ground (SG) Signal Ground (SG)
8 Carrier Detect (CD) Carrier Detect (CD)
9 Reserved for Testing Reserved for Testing
10 Reserved for Testing Reserved for Testing
11 Unassigned Unassigned
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)
15 Transmit Clock (TC) Transmit Clock (TC)
16 Secondary Receive Data (SRD) Secondary Transmit Data (STD)
17 Receiver Clock (RC) Receiver Clock (RC)
18 Local Loopback Local Loopback
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
22 Ring Indicator (RI) Ring Indicator (RI)
23 Data Rate Select (DSR) Data Rate Select (DSR)
24 External Clock (XTC) External Clock (XTC)
25 Test Mode Test Mode
PINDB‐9 DB‐9
DTE (Male) DCE (Female)
1 Carrier Detect (CD) Carrier Detect (CD)
2 Receive Data (RX) Transmit Data (TX)
3 Transmit Data (TX) Receive Data (RX)
4 Data Terminal Ready (DTR) Data Terminal Ready (DTR)
5 Signal Ground (SG) Signal Ground (SG)
6 Data Set Ready (DSR) Data Set Ready (DSR)
7 Request to Send (RTS) Clear to Send (CTS)
8 Clear to Send (CTS) Request to Send (RTS)
9 Ring Indicator (RI) Ring Indicator (RI)
DTE to DCE
39
PINDB‐9
PINDB‐9
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)
• Typical direction of data flow: straight through.
3-Wire RS-232
40
PINDB‐9
PINDB‐9
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)
• Only three wires are necessary to communicate between two device for short distances: transmit, receive, and ground.
Cable Exercise 1
1
4
3
2
5
8
7
6
9
1
4
3
2
5
8
7
6
9
DB9Socket
DB9Pin
DCD DCD
Received Data
Received DataTransmitted Data
Transmitted Data
DTR DTR
Signal Ground Signal Ground
DSR DSR
Request to Send
Request to SendClear to Send
Clear to Send
Ring Indicator Ring Indicator
1
4
3
2
5
8
7
6
9
1
4
3
2
5
8
7
6
9
DB9Socket
DB9Socket
DCD DCD
Received Data Received Data
Transmitted Data Transmitted Data
DTR DTR
Signal Ground Signal Ground
DSR DSR
Request to Send Request to Send
Clear to Send Clear to Send
Ring Indicator Ring Indicator
DTE DCE DTE DTE
1
4
3
2
5
8
7
6
9
8
20
2
3
7
5
4
6
22
DB9Socket
DB25Pin
DCD DCD
Received Data
Received DataTransmitted Data
Transmitted Data
DTR DTR
Signal Ground Signal Ground
DSR DSR
Request to Send
Request to SendClear to Send
Clear to Send
Ring Indicator Ring Indicator
9 Pin DTE
25 Pin DCE
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
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.
DB9 connector with Sockets (female)
Cable Exercise 4
Cable Testers
45
• 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
46
1
2
3
4
5
6
7
8
9
1
2
3
4
5
6
7
8
9
DCE-DTE Straight Through
• DCE & DTE cable indications are specified by the type of end connector, not the device it will connect to.
• The cable tester will put a voltage on one pin and see if there are other pins with the same voltage.
• The connected pins are indicated by an illuminated LED.
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
Cable Tester Lab1. 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.
49
Cable Tester Lab
50
PINDB‐9
PINDB‐25
DTE (Male) DCE (Female)
1 Carrier Detect (CD) 1 Shield
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)
13 Secondary Request to Send (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
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.
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 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.
52
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.
53
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.
54
I
I induced
I induced
I
I induced
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.
55
Significant change in impedance
Vs
t
Sending end sees original signal, then the addition of the reflection.
FLOW CONTROL
56
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)
75%
25%
57600 Baud
9600 Baud
19200 Baud
Modem Buffer
58
Software Flow Control
75%
25%
57600 Baud
Modem BufferXOFF______
XOn______
59
Hardware Flow Control (RTS)
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.
60
75%
25%
Modem Buffer
RTS
CTS
ComputerModem
TX
CTS
RTS
RX
DTE DCE
TERMINAL EMULATOR
61
Basic Terminal Setup
62
• 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.
Basic Terminal Setup
63
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.
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.
64
BREAKOUT BOXES
65
RS-232 Breakout Boxes
66
• 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.
RS-232 Breakout boxes
67
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.
RS-232 Break Out Box
68
DTE DCE
9-25 Adaptor
9-25
Ada
ptor
Straight ThroughDB9-DB9 Cable
Modify the connection with the breakout box
Straight ThroughDB9-DB9 Cable
LEDs indicate traffic from DTE to DCE. Switch direction of connections
to see LEDs for the other direction.
RS-232 Breakout Boxes
69
• 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.
RS-232 Monitor- Mini Tracker
70
• 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)
• Can tell if flow control is being used.
Green LED: below 3 voltsRed LED: above 3 volts
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?
71
REVIEW
72
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
73
Breakout Box Cheat Sheet
74
Source: http://www.pccompci.com/rs232-cable-technology.html