RS-232 Communications
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 computer’s
serial port (know as COM or Comm port).
Why Serial Communications?
• Serial communication is the most simplistic
form of communication between two devices.
• It’s pretty intuitive once you see the pattern.
• It’s what started networking!
So What is RS-232?
• RS-232 is a standard by which two serial
devices communicate:
– The connection must be no longer than 50 feet.
– Transmission voltages are –15V and +15V.
– It is designed around transmission of characters
(of 7 bits of length).
RS-232 (cont.)
• One important aspect of RS-232 is that it is an
asynchronous form of communication.
• Asynchronous communication is important
because it is efficient; if no data needs to be
sent, the connection is “idle.” No additional
CPU overhead is required for an idle serial
line.
Logical Voltages
• RS-232 is a little non-intunitave at first.
• Logical 1 is –15VDC.
• Logical 0 is +15VDC.
• When the connection is idle, the hardware
ties the connection to logical 1.
RS-232 sw settings
• One byte of async data has:
– Start Bit = 1 (always) Stop bits = 1 (or 2)
Parity = NONE (or EVEN or
– Data Bits = 8 (or 7)
ODD)
+ 25
- 25
How Can You Transmit Data?
• RS-232 communication is dependent on a set
timing speed at which both pieces of
hardware communicate. In other words, the
hardware knows how long a bit should be high
or low.
• RS-232 also specifies the use of “start” and
“stop” bits.
Sending One Character
• Every time a character is sent, the same
communication occurs:
1. Start bit sent.
2. Seven data bits sent.
3. Stop bit sent.
• This communication is dependent on the fact that
both devices are sampling the bits at the same
rate! We’ll see what happens if this doesn’t
happen…
Ok, So What’s the Start Bit?
• The start bit is a logical 0 sent on the line to
tell the other device to start sampling.
• Remember, the logical 0 is +15VDC.
And the Stop Bit?
• The stop bit is a logical 1. –15VDC.
• A stop bit is always sent (per RS-232
standards).
To Talk the Talk…
• We’ve mentioned that both devices must
have the same speeds to talk, but they must
also know to handle problems.
• The transmission rate of serial devices is called
baud. It is the number of changes in the signal
per second.
A Sample Transmission
Common Serial Settings
• Most settings are read in the following form:
– Bits per second
– Number of data bits
– Parity
– Number of Stop bits
• If you want to know what Parity is right now,
read chapter 6.7. Otherwise, wait.
Common Serial Settings cont.
• Most everything comes out of the box with
9600,8,none,1. Including most Internet
related devices like routers.
• Another common (old-school) setting is
9600,7,even,2.
Line Sampling & Framing
• RS-232 hardware samples the line multiple times
during a single bit transmission.
• If the samples do not all have the same voltage, a
framing error occurs.
• A framing error should only occur if one device is
sending faster than the other device is set to receive.
• An intentional frame error can be caused by sending
a BREAK.
Full Duplex Transmission
• Full duplex transmission (FDX) occurs when
data is transmitted (or can be transmitted)
simultaneously by both devices. Special wiring
is needed for FDX.
Wiring RS-232
• The RS-232 specification denotes usage of a 25 pin
cable, where each pin has a specific usage.
• However, most devices never need to use all of the
pins, so the cabling requirements for specific devices
may vary.
• Many common serial devices (modems for example),
use a 9 pin serial connection.
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).
•
RS-232 Signals
Common 25 pin D-shell connector pinout used
for asynchronous data communications.
Pin Signal
1 PGND Protective
Ground
2 TXD Transmit Data
3 RXD Receive Data
4 RTS Ready To Send
5 CTS Clear To Send
6 DSR Data Set Ready
7 SG Signal Ground (serial port - PC side)
8 CD Carrier Detect
20 DTR Data Terminal
Ready
22 RI Ring Indicator
Connector Types
• The two different connectors are associated
with two major types of hardware
• The Computer Terminal Equipment (CTE) and
the Data Terminal Equipment (DTE).
Connector Types (cont.)
• For ease-of-use, a computer will transmit on
pin 2 and receive on pin 3 (the CTE,
remember).
• Vice versa: a modem will transmit on pin 3,
and receive on pin 2 (for the DTE).
Speed Limitations
• For people familiar with modem communications,
there is a speed limitation associated with the
transmission.
• 56k (56 kilobit) analog modems are pretty much the
fastest analog modems that consumers are going to
see. This limitation is due to telephone systems, not
the computer systems.
Speed Limitations (cont.)
• However, serial communications between devices
also has its own speed barrier.
• RS-232 was designed with the understanding that
the analog world is far from perfect.
• Digital is fast, analog is slow. RS-232 is analog,
therefore is it slow (in computing terms).
Why Is It Slow?
• t exists. The change
is not instantaneous.
• Sampling does not
occur immediately, so
it must wait t+t0
• Cable length increases
delay.
• Etc.
Noise
• Signal noise is bad. It is caused by a variety of
sources, all of which lead to lower speeds and
less reliable transmission.
• Shannon’s Theorem shows that the maximum
transmission rate of a voice call (analog) is
~30,000 bps (30kbps).
What is RS-485
• 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 long
distances in real world environments.
• How fast can RS-485 be?
– 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-232 vs RS-485
The architectural difference between RS-232 and RS-485 is
that 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 big difference to the software is that only one device
on a 485 bus can transmit at a time, whilst there is not
similar limitation on RS232 because is a peer-to-peer link .
• Mode of Operation
RS-232 SINGLE-ENDED
vs RS-485 RS-232 RS-485
DIFFERENTIAL
• Total Number of Drivers 1 DRIVER 32 DRIVER
and 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 in
High Z State Power On N/A N/A
• Max. Driver Current in
High 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