interfacing 10
TRANSCRIPT
-
7/29/2019 Interfacing 10
1/34
Synchronous vs. Asynchronous
Synchronous- One-way communication
- Receiver and transmitter must have their clocking synchronized, .
- Requiring a constant stream of transmission
- Request for data is made, time is given for the request to be carriedout, and data is read.
Asynchronous- Utilizes start and stop bit to communicate the beginning and end of
data words to the receiver- No need for devices to be synchronized
-
7/29/2019 Interfacing 10
2/34
Data Word
Start Bit Signals the start of transmission of the data bits
Transition from logic 1 to logic 0
Data Bits
Generally 8 data bits (not including parity bit)
Transmitted and received least significant bit first
Stop Bit
Signals the end of a data word
Logic 1
-
7/29/2019 Interfacing 10
3/34
Parity Bit
Can be added to the transmitted data to check for and displayan error message when a bit is lost during transmission
Comes in two forms
Odd Parity
Sum of the 1s in the frame will be odd
The logical state (1 or 0) of the parity bit is selected to fulfill this condition
Even Parity
Sum of the 1s in a frame will be even
Number of 1s checked against the parity bit to determine ifany bits were lost during transmission
A two bit loss will go undetected with this method
-
7/29/2019 Interfacing 10
4/34
Data Word
-
7/29/2019 Interfacing 10
5/34
Baud and Bit Rates
Baud Rate
A baud is the reciprocal of the shortest pulse duration in
a data word inclusive of start, stop, data, and parity bits
Baud rate is the total number of bits transmitted persecond
Data Bit Rate
The number ofdata bits transmitted in one second.
Does not include the start or stop bits
-
7/29/2019 Interfacing 10
6/34
In this example:
1 start bit, 1 stop bit, 1 parity bit, 8 data bits, 11 bits per word, 300 baud rate
Bit Time = 1/(Baud rate) = 1/300 = 3.33 msec
Character Time = (total bits in word) x (bit time) = 11 x 3.33 = 36.6 msec
Data Bit Rate (including parity) = (data bits in word)/(character time)= 9/3.33 = 270
-
7/29/2019 Interfacing 10
7/34
RS232 and RS485Fundamentals
-
7/29/2019 Interfacing 10
8/34
What is RS232 RS-232 Signals
RS-232 Line Driver
RS-232 Speed
RS-232 SW settings
What is RS-485 RS-485 Line Driver
RS-485 Network
RS-485 Half-duplex
RS-485 Full-duplex RS-485 and DL devices
RS-232 vs RS-485
-
7/29/2019 Interfacing 10
9/34
RS-232
RS-232 is a popular communications interface for
connecting modems and data acquisition devices (i.e.
GPS receivers, electronic balances, data loggers, ...) to
computers.
RS-232 can be plugged straight into the computers
serial port (know as COM or Comm port).
-
7/29/2019 Interfacing 10
10/34
RS-232 Signals Architecturally RS-232 is a
bi-directional point to point
link.(serial port - PC side)
Two independent channels
are established for two-way
(full-duplex)
communications.
RS-232 can also carry
additional signals used for
flow control (RTS, CTS)
and modem control (DCD,
DTR, DSR, RI).
-
7/29/2019 Interfacing 10
11/34
Three major wires for the Serial interface:
Transmit ( Pin 2)
Receive ( Pin 3)
Ground Pin 7 (25 pin connector)
Pin 5 (9 pin connector)
Tx Tx
RxRx
GndGnd
Computer
Device
Transmit connects to Receive
-
7/29/2019 Interfacing 10
12/34
RS232 is well-established standard, developed by the EIA(Electronics Industry Association) in 1960s
Originally intended as an electrical specification to
connect computer terminals to modems
Defines the interface between a DTE and a DCE
DTE = Data Terminal Equipment (terminal)
DCE = Data Communications Equipment (modem)
A modem is sometimes called a dataset
A terminal is anything at the terminus of theconnection.
VDT (video display terminal), computer, printer, etc
-
7/29/2019 Interfacing 10
13/34
RS-232C RS-232C
Telephone
network
DTE DCE DCE DTE
-
7/29/2019 Interfacing 10
14/34
1s and 0s in RS-232C
A 1 is called a mark
A 0 is called a space
The idle state for an RS-232C line is a 1
(mark)
Idle state is called marking the line
-
7/29/2019 Interfacing 10
15/34
Data Transmission Example
Plot of the asynchronous RS-232C transmission of the ASCII charactera with odd parity:
0 1 0 0 0 0 1 1 0 1
Idle
state
Stop
bitStart
bit
Idle
state
ASCII character a 7 bits
LSB first
Parity
bit
time
TD
-
7/29/2019 Interfacing 10
16/34
RS-232C Connectors
The original standard specified a 25-pin connector
Today, a 9-pin connector is more common
E.g.,
DB9P
Note:
P = pin
Sometimes called a male
connector The mate for this is a DP25S, or
socket connector the female
-
7/29/2019 Interfacing 10
17/34
RS-232C Connectors
DB25P
DB9P
DB25S
DB9S
Where is pin 1? Where are pins 2, 3, 4, etc.?
Pin 1
Pin 1Pin 1
Pin 1
-
7/29/2019 Interfacing 10
18/34
RS-232C Pin Numbers1 2 3 4 5
9 8 7 6
DB9P
-
7/29/2019 Interfacing 10
19/34
RS-232C Pins, Signals, Directions
DB251
2
3
4
5
67
8
20
22
Signal NameCD Chassis Ground
TD Transmit Data
RD Receive Data
RTS Request To Send
CTS Clear To Send
DSR Data Set ReadySG Signal Ground
DCD Data Carrier Detect
DTR Data Terminal Ready
RI Ring Indicator
Direction-
DTE DCEDTE DCEDTE DCEDTE DCEDTE
DCE-
DTE DCEDTE DCEDTE DCE
DB9
2
3
7
8
65
1
4
9
Pin
-
7/29/2019 Interfacing 10
20/34
Common 25 pin D-shell connector pinout used for
asynchronous data communications.Pin Signal1 PGND Protective Ground2 TXD Transmit Data3 RXD Receive Data
4 RTS Ready To Send5 CTS Clear To Send6 DSR Data Set Ready7 SG Signal Ground
8 CD Carrier Detect
20 DTR Data Terminal Ready22 RI Ring Indicator
(serial port - PC side)
-
7/29/2019 Interfacing 10
21/34
RS-232 Line Driver Unbalanced Line Drivers
Each signal appears on the interface connector as a voltage with reference to a signal
ground.
The idle state (MARK) has the signal level negative with respect to common whereas
the active state (SPACE) has the signal level positive with respect to the same
reference.
-
7/29/2019 Interfacing 10
22/34
RS-232 Speed
How fast can RS-232 be? The maximum speed, according to the standard, is 20kbit/s.
However, modern equipment can operate much faster than this. (i.e. Lynxcan reach 115200 baud.)
The length of the cable also plays a part in maximum speed.The longer the cable and the slower the speed at which you can obtainaccurate results.
A large wire capacitance and inductance limits the maximum length of thecable and/or the maximum speed;
Moreover higher is the capacitance of the cable higher is the interferencebetween two adjacent signal wire.
50 feet (15m) @ max baudrate is commonly quoted as the maximumdistance.
RS-232 switch settings
-
7/29/2019 Interfacing 10
23/34
RS-232 switch settings
One byte of async data has:
Start Bit = 1 (always)
Data Bits = 8 (or 7)
Stop bits = 1 (or 2)
Parity = NONE (or EVEN or ODD)
-
7/29/2019 Interfacing 10
24/34
Computer and device must have the same settings for
Baud Rate
Parity
Stop bits
Baud Rate - data transmitted in bits/second
Parity - Check against faulty data transfer. If used, 8 (typically) data bits sent plus
parity bit. Responsibility of device to check parityStop Bits - denotes end a data string. Use 2 stop bits with SR510.
(Recommended)
S232 i l f
-
7/29/2019 Interfacing 10
25/34
RS232Typical Data format
Data Format:
Bit 0: Start bit
Bit 1-8: ASCII code of Data
Bit 9 : Parity Bit
Bit 10-11 : Stop bits
Each ASCII character requires about 12 bits to be transmitted or about 833s forcharacter.
Start
BitLSB
ASCII
MSBParity &
Stop Bits
Data in above example is sent LSB first (eg. ASCII A=01000001)
Logic of Data may be inverted. Control lines use positive logic
Time
Voltage
RS232 i h C l Li
-
7/29/2019 Interfacing 10
26/34
RS232 with Control Lines
(control lines not necessarily required in RS232) - some devices require them.
Handshake Control Lines.
CTS - Clear to Send - (eg. pin 5 on SR510 lock-in)
Set high (Asserted) by instrument to tell computer that instrument is ready to
receive data
DTR - Data Terminal Ready - (pin 20)
Set high by computer to tell instrument that Computer is ready to receive data.
-
7/29/2019 Interfacing 10
27/34
Testing out the RS232
Use Hyper Terminal (Windows XP)
Programs>>Accessories>>HyperTerminal
Set up Communications : Com 1, 19200 Baud, 8 Bits, no parity, 2 stop bits.
With Fiber-optic link connected to RS232, monitor the TX BNCconnection on the Oscilloscope.
Type commands in Hyperterminal to read/write data to the fiber-optic link.
(Connect TX to RX directly to make sure sense of logic is correct, etc.)
NOTE: Do not need flow control with our simple fiber link
-
7/29/2019 Interfacing 10
28/34
What is RS-485 RS-485 is a EIA standard interface which is very common
in the data acquisition world
RS-485 provides balanced transmission line which also
can be shared in Multidrop mode.
It allows high data rates communications over longdistances in real world environments.
RS-485 was designed for greater distance and higher
baudrates than RS-232.
According to the standard, 100kbit/s is the maximum
speed and distance up to 4000 feet (1200 meters) can be
achieved.
RS 485 Li D i
-
7/29/2019 Interfacing 10
29/34
RS-485 Line Driver Balanced Line Drivers
Voltage produced by the driver appears across a pair of signal wires thatransmit only one signal. Both wires are driven opposite.
RS-485 driver has always the Enable direction control signal.
Differential system provides noise immunity, because much of thecommon mode signal can be rejected by the receiver. So ground shiftsand induced noise signals can be nullified.
RS 485 Network
-
7/29/2019 Interfacing 10
30/34
RS-485 Network RS-485 provides Half-Duplex, Multidrop communications over a single twisted pair
cable.
The standard specifies up
to 32 drivers and 32
receivers can share a
multidrop network
Terminator resistors avoid
reflected signal
RS 485 Half duplex
-
7/29/2019 Interfacing 10
31/34
RS-485 Half-duplex Data logic uses Half-Duplex configurations for Data Collecting and
Master/Slave layouts.
Usually we talk about Multidropnetwork (i.e. MX4000,DPS9000)
Slave 1
TX
ENABLE
RX
Slave 2
TX
ENABLE
RX
Slave N
TX
ENABLE
RX
RTX485+
RTX485-
485GND
Master
TX
ENABLE
RX
RS 485 Full duplex
-
7/29/2019 Interfacing 10
32/34
RS-485 Full-duplex Potentially RS-485 interface can also use 4-wires to comunicate in multidrop mode but...
Scanner
TX
ENABLE
RX
TX485+
TX485-
RX485+
RX485-
485GND
TX
ENABLE
RX
Other device
-
7/29/2019 Interfacing 10
33/34
RS-232 vs RS-485
The architectural difference between RS-232 and RS-485 isthat 232 is a bi-directional point to point link, whereas 485 is
a single channel bus.
Electrically, each 232 signal uses a single wire with
symmetric voltages about a common ground wire. 485 uses
two wires to carry the single signal differentially.
The main difference is that only one device on a 485 bus can
transmit at a time, however there is no similar limitation inthe transmission for RS232 since it has a peer-to-peer link .
-
7/29/2019 Interfacing 10
34/34
RS-232 vs RS-485RS-232 RS-485
Mode of Operation SINGLE-ENDED DIFFERENTIAL
Total Number of Drivers 1 DRIVER 32 DRIVERand Receivers on One Line 1 RECEIVER 32 RECEIVER
Maximum Cable Length 50 FEET 4000 FEET Maximum Data Rate @Max length 20kb/s 100kb/s
Driver Output Signal Level(Loaded Min.) Loaded +/-5V to +/-15V +/-1.5V
Driver Output Signal Level(Unloaded Max) Unloaded +/-25V +/-6V
Driver Load Impedance 3k to 7k 54
Max. Driver Current inHigh Z State Power On N/A N/A
Max. Driver Current inHigh Z State Power Off +/-6mA @ +/-2v +/-100uA
Slew Rate (Max.) 30V/S N/A
Receiver Input Voltage Range +/-15V -7V to +12V
Receiver Input Sensitivity +/-3V +/-200mV
Receiver Input Resistance 3k to 7k 12k