Upload
desaijpr
View
12
Download
0
Tags:
Embed Size (px)
DESCRIPTION
About serial communication
Citation preview
Serial Communication
(Recommended Standard-232)
J. arumugam
C & I Lab
Communication Principle
Every data communications system requires:
� A source of data (a transmitter or line driver), which
converts the information into a form suitable for
transmission over a link
� A receiver that accepts the signal and converts it back
into the original data
� A communications link that transports the signals. This
can be copper wire, optical fiber, and radio or satellite link
j arumugam PC - 100 2
Communication factors
� The type of signaling used.
� Defining a logical ‘1’ and a logical ‘0’.
� The codes that represent the symbols.
� Maintaining synchronization between transmitter and receiver.
� How the flow of data is controlled, so that the receiver is not swamped.
� How to detect and correct transmission errors.
– The physical factors are referred to as the ‘interface standard’; the
other factors comprise the ‘protocols’
– A protocol is one or a few sets of hardware and software rules
agreed to by all communication parties for exchanging data correctly
and efficiently.
j arumugam PC - 100 3
Communication Modes
�Simplex
�Half duplex
�Full duplex
A simplex system is one that is designed for sending messages
j arumugam PC - 100 4
A simplex system is one that is designed for sending messages
in one direction only.
Communication Modes cont�
� Half duplex occurs when data can flow in both directions, but in only
one direction at a time
� Full duplex system is designed for sending messages in both
directions simultaneously.
j arumugam PC - 100 5
Protocols
j arumugam PC - 100 6
Basic structure of an information frame defined by a protocol
RS 232 interface standard
� The RS-232 interface standard specifies the method of connection
of two devices DTE and DCE.
DTE: Data Terminal Equipment.
Example: Computer or Printer.
- DTE device communicates with a DCE device.
j arumugam PC - 100 7
DCE: Data Communications Equipment.
- Example: Modem, now also called Data Circuit-Terminating
equipment in RS-232E.
- A DCE device receives data from the DTE and retransmits via
another data communications link, such as the telephone system.
Typical serial data communications link
j arumugam PC - 100 8
DTE and DCE
DTE normally comes with a Male Connector, while DCE comes with a
Female Connector. (that is not always true).
Use the simple way below to confirm:
Measure Pin 3 (TxD) and Pin 5 (GND) of a DB-9 Connector with a Volt
Meter, if you get a voltage of -3V to -15V, then it is a DTE device.
j arumugam PC - 100 9
Meter, if you get a voltage of -3V to -15V, then it is a DTE device.
If the voltage is on Pin 2 (TxD) and Pin 5 (GND) of a DB-9 Connector
with a Volt Meter, if you get a voltage of -3V to -15V, then it is a DCE
device.
Note: The result for a DB-25 Connector is reversed
RS 232 Electrical signal characteristics
The RS-232 Transmitter is required to produce voltages in the range:
• Logic 1: –5 V to –25 V
• Logic 0: +5 V to +25 V
• Undefined logic level: +5 V to –5 V
• .
At the RS-232 Receiver the following voltage levels are defined:
• Logic 1: –3 V to –25 V
• Logic 0: +3 V to +25 V
• Undefined logic level: –3 V to +3 V
– Note: The RS-232 transmitter requires the slightly higher voltageto overcome voltage drop along the line.
j arumugam PC - 100 10
RS-232 Transmitters and Receivers
j arumugam PC - 100 11
Pin Functions for RS-232
DTE Pin Assignment (DB-9) DCE Pin Assignment (DB-9)
1 DCD Data Carrier Detect 1 DCD Data Carrier Detect
2 RxD Receive Data 2 TxD Transmit Data
j arumugam PC - 100 12
2 RxD Receive Data 2 TxD Transmit Data
3 TxD Transmit Data 3 RxD Receive Data
4 DTR Data Terminal Ready 4 DSR Data Set Ready
5 GND Ground (Signal) 5 GND Ground (Signal)
6 DSR Data Set Ready 6 DTR Data Terminal Ready
7 RTS Request to Send 7 CTS Clear to Send
8 CTS Clear to Send 8 RTS Request to Send
9 RI Ring Indicator 9 RI Ring Indicator
Pin Functions for RS-232
Data Typical purpose
RXD (pin 2) Serial Data Input Carries data from DCE to DTE
TXD (pin 3) Serial Data Output Carries data from DTE to DCE
j arumugam PC - 100 13
TXD (pin 3) Serial Data Output Carries data from DTE to DCE
Handshake
RTS (pin 7) Request to Send DTE requests the DCE prepare to receive data
CTS (pin 8) Clear to Send Indicates DCE is ready to accept data
DSR (pin 6) Data Set Ready DCE is ready to receive commands or data
DCD (pin 1) Data Carrier Detect DCE is connected to the telephone line
DTR (pin 4) Data Terminal Ready Indicates presence of DTE to DCE
Ground
GND (pin 5) Ground Common Ground
Other
RI (pin 9) Ring Indicator DCE has detected an incoming ring signal on the telephone line
Null-Modem connection
Using for DTE–DTE, DCE–DCE Devise Communication
j arumugam PC - 100 14
Straight / Null-Modem connection
Straight-through (DB-9) Crossover (Null-Modem) (DB-9)
Using for DTE - DCE Devise
Communication
Using for DTE–DTE, DCE–DCE
Devise Communication
(DTE) (DCE) (DTE) (DTE)
1 DCD ------- DCD 1 1 DCD DCD 1
2 RxD ------- TxD 2 2 RxD ------- TxD 3
3 TxD ------- RxD 3 3 TxD ------- RxD 2
j arumugam PC - 100 15
3 TxD ------- RxD 3 3 TxD ------- RxD 2
4 DTR ------- DSR 4 4 DTR ------- DSR 6
5 GND ------- GND 5 5 GND ------- GND 5
6 DSR ------- DTR 6 6 DSR ------- DTR 4
7 RTS ------- CTS 7 7 RTS ------- CTS 8
8 CTS ------- RTS 8 8 CTS ------- RTS 7
9 RI ------- RI 9 9 RI RI 9
Transmission characteristics
Signaling Rate (Baud Rate)
� The signaling rate of a communications link is a measure of how
many times the physical signal changes per second and is
expressed as the baud rate. An oscilloscope trace of the data
transfer would show pulses at the baud rate. For a 1000 baud rate,transfer would show pulses at the baud rate. For a 1000 baud rate,
pulses would be seen at multiples of 1 ms.
� With asynchronous systems, we set the baud rate at both ends of
the link so that each physical pulse has the same duration.
j arumugam PC - 100 16
Transmission characteristics
Data rate or Bit rate
� The data rate or bit rate is expressed in bits per second (bps), or
multiples such as Kbps, Mbps and Gbps (kilo, mega and gigabits
per second). This represents the actual number of data bits
transferred per second.
� An example is a 1000 baud RS-232 link transferring a frame of 10� An example is a 1000 baud RS-232 link transferring a frame of 10
bits, being 7 data bits plus a start, stop and parity bit. Here the Baud
Rate is 1000 baud, but the Data Rate is 700 bps.
� Baud rate and Bit rate, they are not the same. Whereas baud rate
indicates the number of signal changes per second, the bit rate
indicates the number of bits represented by each signal change.
j arumugam PC - 100 17
Transmission characteristics cont�
Bandwidth
� The single most important factor that limits communication speeds is
the bandwidth of the link. Bandwidth is generally expressed in hertz
(Hz), meaning cycles per second.
� Bandwidth is closely related to the transmission medium, ranging� Bandwidth is closely related to the transmission medium, ranging
from around 5000 Hz for the public telephone system to the GHz
range for optical fiber cable.
� As a signal tends to attenuate over distance, communications links
may require repeaters placed at intervals along the link, to boost the
signal level.
j arumugam PC - 100 18
Serial Data Communication Methods
�Asynchronous has no clock, but speed must be
agreed upon beforehand (baud rate).
Asynchronous System Synchronous System
�Synchronous communications requires clock.
Whoever controls the clock controls
communication speed.
j arumugam PC - 100 19
Asynchronous System
� Asynchronous Communication has no timing signal or clock.
� Instead, it inserts Start/Stop bits into each byte of data to
"synchronize" the communication.
� Uses less wires for communication (no clock signals)
� Simpler and more cost-effective.
� RS-232/RS-485/RS-422/TTL are the forms of Asynchronous
Communications.
� An asynchronous system is one in which each Character or Byte is
sent within a frame.
� Character-Oriented data transmission
� Transmitter and Receiver clocks are independent
j arumugam PC - 100 20
Asynchronous System
� The receiver does not start detection until it receives the first bit,
known as the ‘Start Bit’.
� The start bit is in the opposite voltage state to the idle voltage and
allows the receiver to synchronize to the transmitter for the following
data in the frame.
� The receiver reads in the individual bits of the frame as they arrive,� The receiver reads in the individual bits of the frame as they arrive,
seeing either the logic 0 voltage or the logic 1 voltage at the
appropriate time.
� The ‘clock’ rate (Baud rate) at each end must be the same so that
the receiver looks for each bit at the time the transmitter sends it.
� Asynchronous communication can have problems at high speeds
(above 100 kbps).
j arumugam PC - 100 21
Asynchronous Frame format
j arumugam PC - 100 22
An asynchronous frame may have the following format:
� Start bit: Signals the start of the frame.
� Data: Usually 7 or 8 bits of data.
� Parity bit: Optional error detection bit.
� Stop bit(s): Usually 1, 1.5 or 2 bits.
A value of 1.5 means that the level is held for 1.5 times as long as for a single bit
Data CodingASCII (American Standard Code for Information Interchange)
j arumugam PC - 100 23
Ex: D = ASCII code in binary 100 0100; Hex 44
Extended binary coded data interchange code (EBCDIC)
j arumugam PC - 100 24
Example of serial date sending
j arumugam PC - 100 25
Error detection method in asynchronous systems
� The simplest form of error checking in asynchronous systems is to
incorporate a parity bit, which may be even or odd.
� Even parity, the number of bits whose value is 1 in a given set are
counted. If that total is odd, the parity bit value is set to 1, making the
total count of 1's in the set an even number. If the count of ones in a
given set of bits is already even, the parity bit's value remains 0.
� In the case of odd parity, the situation is reversed. Instead, if the sum of
bits with a value of 1 is odd, the parity bit's value is set to zero. And if
the sum of bits with a value of 1 is even, the parity bit value is set to 1,
making the total count of 1's in the set an odd number.
j arumugam PC - 100 26
Error detection method in asynchronous systems
EVEN - Parity bit set so that there is an even number of 1 bits
ODD - Parity bit set so that there is an odd number of 1 bits
NONE - Parity bit is ignored, value is indeterminate
MARK - Parity bit is ALWAYS set to 1
SPACE - Parity bit is ALWAYS set to 0
j arumugam PC - 100 27
G I
EVEN - 0 0010 0111 1 0010 1001
ODD - 1 0010 0111 0 0010 1001
NONE - ? 0010 0111 ? 0010 1001
MARK - 1 0010 0111 1 0010 1001
SPACE - 0 0010 0111 0 0010 1001
LSB
Parity Parity
LSB
Synchronous System
� Synchronous Communication requires the sender and receiver to
share the same clock.
� The sender provides a timing signal to the receiver so that the
receiver knows when to "read" the data.
� Synchronous Communication generally has higher data rates and
greater error-checking capability.greater error-checking capability.
� A printer is a form of Synchronous Communication.
� The synchronous system packs many Characters or Bytes together
and sends them as a continuous stream, called a packet or a frame.
� Block-Oriented data transmission.
� Transmitter and Receiver clocks synchronized.
j arumugam PC - 100 28
Synchronous System
� In synchronous systems, the receiver initially synchronizes to the
transmitter’s clock pulses, which are incorporated in the transmitted
data stream. This enables the receiver to maintain its
synchronization throughout large messages, which could typically
be up to 4500 bytes (36 000 bits). This allows large frames to be
transmitted efficiently at high data rates.
� The synchronous system packs many characters together and
sends them as a continuous stream, called a packet or a frame.
� DTE accepts a clock signal generated by DCE
� No start, stop bits, but still frame synchronization words are needed
j arumugam PC - 100 29
Typical synchronous system frame format
Preamble: This comprises one or more bytes that allow the receiving unit
to synchronize with the frame.
SFD: The start of frame delimiter signals the beginning of the frame.
j arumugam PC - 100 30
Destination: The address to which the frame is sent.
Source: The address from which the frame originated.
Length: The number of bytes in the data field.
Data: The actual message.
FCS: The frame check sequence is for error detection. Each of these is
called a field.
Synchronous System(I2C or I2C : Inter‐Integrated Circuit – Philips)
� 2-wire (TWI) – Serial data (SDA) and Serial clock (SCL)
� Common ground wire (totally 3 wires)
� Half-duplex, synchronous, multi-master Without “chip select” or
arbitration
‐
j arumugam PC - 100 31
� Bus length: typical: inside the equipment, <1m, maximum: few meters
� There are no “slave‐select” lines – instead the devices have
“addresses” that are sent as part of the transmission protocol.
� Four max speeds (100 kbS (standard), 400 kbS (fast), 1 MbS (fast
plus), and 3.4 MbS (high‐speed)
I2C connection schematics
j arumugam PC - 100 32
Synchronous SystemSPI (Serial Peripheral Interface ‐ Motorola)
• Two types of devices, masters and slaves.
– We’ll consider only one master, but multiple slaves.
• Signals (full duplex)
j arumugam PC - 100 33
• Signals (full duplex)
– SCLK: Serial CLocK, set by Master
– MOSI: Master Out, Slave In
– MISO: Master In, Slave Out
– SS: Slave Select
• Each slave gets its own slave select (other lines are shared)
• Pulling line low selects slave
– Faster than I2C, (by few Mbps)
Serial data communication interface standards
� An interface standard defines the electrical and mechanical details
that allow equipment from different manufacturers to be connected
and able to communicate.
� The RS have produced several well known data interface standards:
�RS-232 and revisions�RS-232 and revisions
�RS-449 ( 37 pins )
�RS-423
�RS-422
�RS-485
�RS/TIA-530A ( Telecommunication Industry Association - TIA )
�RS/TIA-562
j arumugam PC - 100 34
RS-423 and RS-422
� The RS-423 interface standard
� Is an Unbalanced system similar to RS-232 with increased
range and data transfer rates and up to 10 line receivers
per line driver.
� The RS-422 interface system
� Is a Balanced system with the same range as RS-423,
with increased data rates and up to 10 line receivers per
line driver.
j arumugam PC - 100 35
Type of Serial data transmission lines
The choice between unbalanced and balanced
transmission lines is an important consideration when
selecting a data communications system.
� Unbalanced transmission line
� Balanced transmission line
j arumugam PC - 100 36
Unbalanced transmission line
� In an unbalanced system, the signal common reference
conductor is simultaneously shared by many signals and
other electronic circuitry.
� Only one wire carries the signal voltage, which is
referenced to a signal common wire, sometimes called
the signal ground.
� The transmitted signal is the voltage between the signal
conductor and the common reference conductor.
j arumugam PC - 100 37
Unbalanced transmission line cont�
� Theoretically, unbalanced transmission should work wellif the signal currents are small and the commonconductor has very low impedance.
� In practice, unbalanced systems only work over shortcommunication links.
� For long communication distances, the commonconductor does not have the same zero voltage at allpoints along its length or at its ends.points along its length or at its ends.
� The common conductor can also pick up noise and haveother voltages superimposed on it. Sometimes the shieldconductor is used as the common reference wire. Thispractice can introduce excessively high noise-levels andshould be avoided.
� Unbalanced transmission is used in the RS-232 and RS-423 interfaces.
j arumugam PC - 100 38
Data communication with unbalanced interfaces
j arumugam PC - 100 39
Balanced transmission line
� Balanced communication interfaces require two
conductors to transmit each signal.
� The voltage at the receiving end is measured as the
voltage difference between these two wires. This is
known as a balanced or differential system.
� This eliminates many of the interference problems
associated with the common reference wire.
j arumugam PC - 100 40
Data communications with balanced interfaces
j arumugam PC - 100 41
Balanced transmission line cont�
� The balanced transmission line permits a higher rate of
data transfer over longer distances.
� The differential method of data transfer is preferable in
industrial applications where noise can be a major
problem.problem.
� The disadvantage is that a balanced system requires two
conductors for every signal.
� Balanced transmission is used in most of the fast
interfaces such as RS-422 and RS-485.
j arumugam PC - 100 42
RS-485 interface standard
� The RS-485 is a balanced system with the same range
as RS-422, but with increased data rates and up to 32
transmitters and receivers possible per line.
� RS-485 allows higher speeds and much greater
distances than RS-232. Depending on their design, up to
32 devices can be connected together on a single pair of
wires, in Multidrop and/or Multimaster configuration.
j arumugam PC - 100 43
Multidrop
� In a Multidrop communication system, more then two
devices are connected together on a single transmission
medium. In such a system, each device must have a
unique address.
j arumugam PC - 100 44
Multimaster
� Multimaster communication system can have more then
one master device in network. For this to work, the
masters need a specified way to allow each other an
opportunity to transmit.
– The RS-485 interface standard is very useful for
instrumentation and control systems.
j arumugam PC - 100 45
Multidrop Network
Half-Duplex Network Using Terminating Resistors
j arumugam PC - 100 46
Full-Duplex Network Using Terminating Resistors
Pin Functions for RS-232/RS-485/RS-422
D-shell 9-pin connector
j arumugam PC - 100 47
NPort IA5150 4W/2W RS-485/RS-422 Pin Assignments
j arumugam PC - 100 48
RS-232/ RS-422/ RS-485
j arumugam PC - 100 49
Serial interface converters
EIA - Electronic Industries Association
j arumugam PC - 100 50
Block structure of RS-232/RS-485 converter