Asynchronous Serial Communication and standards

5,904 views 28 slides Apr 09, 2016
Slide 1
Slide 1 of 28
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28

About This Presentation

Describes principles of asynchronous serial communication. Explains and compares the principles and features of RS-232, RS-422 and RS-485 standards. Also outlines various registers and programming of PC16550 Universal Asynchronous Receiver/Transmitter provided by many microcontrollers,


Slide Content

Asynchronous Serial Data Communication
and Standards
Dr. N. Mathivanan
Visiting Professor
Department of Instrumentation and Control Engineering
National Institute of Technology,
TRICHY, TAMILNADU
INDIA

Parallel Communication Serial Communication
Cable Use large number of wires Use less number of wires
Cable length
Can’t use lengthy cables.
EMI limits data rate
Use long shield cables,
protected from EMI
Communication
modes
Only single shared path is
available.
Hence, can be only half-duplex
Can have separate paths for
transmission and reception.
Hence, can be full-duplex
Communication
error
Bits get corrupted due to
capacitance effects between
cable wires
Only one bit is communicated at
a time
Data rate It is faster.
Latest techniques offer faster
/ comparable rates.
E.g.: PCI-Ex, SATA
Serial Communication - Features
Dr. N. Mathivanan

Serial Communication Terminologies
•Mark and Space:
oLogic ‘H’ is Mark, Logic ‘L’ is Space
•BAUD rate:
oBaud rate & bit rate (bps) are different.
oNo. of time the serial communication signal changes (voltage level,
frequency or phase angle) in one sec. If for each bit voltage level
changes once, then bit rate = baud rate.
•Channel:
oPathway between communicating devices
oPhysical wire, media (propagating radiated energy)
•Protocol:
oSet of rules defining procedures – no. of bits, framing, formatting,
error detection methods, and control of comm. hardware
Dr. N. Mathivanan

•Network
oConnecting multiple devices to same media for resource sharing
•Point-to-point, Multi-drop, Multipoint
oPoint-to-point: Interface between devices having peer relationship
oMulti-drop: One transmitter communicating with multiple receivers
oMultipoint: Several devices communicating with several receivers
Interfacing using serial interfaces involves conversion of parallel data
bytes to stream of serial bits at transmitter end and detection,
collection & conversion of bits to bytes at receiver end. Transmitter &
receiver need to be synchronized for communication.
•Serial Communication Formats
oSynchronous communication
oAsynchronous communication
Dr. N. Mathivanan

•Synchronous communication
•Transmitter & receiver use common clock
•Used for short distance, high volume, in blocks (instead of
individual characters) and fast transfer
•Standards merge clock & data, eliminate separate wire for clock
(e.g. NRZ and bi-phase Manchester encoding)
•Synchronous serial communication interfaces: I2C, SPI,
Microwire, USB, IEEE1394 (FireWire)

Dr. N. Mathivanan

•Asynchronous communication
oFraming
Start bit, data bits, parity bit, stop bits – Popular format 8N1
oCharacter oriented
Standard communication speeds:
110, 150, 300, 600, 1200, 2400, 4800, 9600, ………., 115.2 kbaud




•Serial communication – Error checking methods
oChecksum method
oCyclic redundancy check
oError flags
Dr. N. Mathivanan

•Signal encoding
oRZ, NRZL, NRZL, Manchester, Manchester Differential







•Compression
oE.g.: Run-Length encoding, Huffman encoding
Dr. N. Mathivanan

•Serial communication modes
oSimplex, Half duplex, Full duplex
•Communication medium
oGenerally, metallic cables for distance up to 50 m,
oBeyond 50 m and up to 4 km, signal is converted to differential
and sent thro’ twisted pair cable,
oAbove 4 km, telephone line / fibre optic cable (has several
advantages) used.
•Serial communication – Classification of devices
oDTE (Data terminal equipment)
Devices used as source / destination for the data, E.g.: PC
oDCE (Data communication or Data carrier equipment)
Devices used in between DTEs, E.g.: Modem
Dr. N. Mathivanan

Asynchronous Serial Interface Standards
•RS-232, EIA/TIA-232-F
oThe standard defines physical & electrical connection, voltage
levels, noise margin, speed, and distance.
oIt is asynchronous interface,
oIt provides point-to-point interface and peer relationship
between devices.
•Pins & Signals
oDCE devices have 25-pin socket, DTE devices have 25-pin plug
oIBM modifies the RS-232 25-pin definition to 9-pin serial port
oApplications use 2, 4 or all signals for communication
oSignals classified into: Data, Control, Common & Timing signals
Dr. N. Mathivanan

oData Signals
TxD – pin no. 3 in DTE, pin no. 2 in DCE
RxD – pin no. 2 in DTE, pin no. 3 in DCE
oControl Signals
RTS, CTS – used by DTE for hardware handshaking,
DTE activates RTS when it has data to send, waits till CTS is activated by DCE
DTE starts transmitting, keeps RTS activated till the end of communication
DTR, DSR – used by DTE for hardware handshaking
DTE activates DTR to inform that it is on-line, ready to establish comm.
DCE activates DSR to inform that it is on-line, ready to establish comm.
DCD – used by modem (DCE)
Indicates DTE when it connects with another modem or detects carrier tone.
RI – used by modem
Indicates the presence of ringing signal on communication channel
oCommon Signals: SG
Dr. N. Mathivanan

•Signal voltage levels:
oRS-232 voltage levels different from TTL, CMOS voltage levels
oUses bipolar voltages,
oDriver output and receiver input voltage profiles - noise margin +/- 2 V
oRS-232 uses single-ended signal transmission
oInterfacing RS-232 devices to TTL devices require RS-232
driver/receivers (E.g.: MAX232, MC1488 and MC1489A)
oAdvantages of MAX232

Dr. N. Mathivanan

•Linking embedded systems / PCs by phone line using modem
oLocal PC monitors RI input, Remote PC activates RI
oLocal PC activates DTR, Local modem responds by activating DSR, Local
PC monitors DCD, Modem asserts DCD if it receives carrier signal
oData transfer begins using RTS, CTS handshaking
oData transfer takes place via TxD, RxD
oWhen transfer is completed, disables DTR, modem inhibits DSR, DCD
signals.
Dr. N. Mathivanan

•Communication between two DTEs
•Null Modem wiring
without handshaking, with handshaking, with loop-back handshaking

Dr. N. Mathivanan

•Daisy chaining




•RS-232 Characteristics
oUses single-ended signaling (unbalanced transmission)
oPeer-to-peer communication
oNetworking – daisy-chaining
oSpeed Max. – 19.6 kbps,
oDistance Max. – 20 m
oDrawbacks: noise immunity low, short distance, low speed
oStill popular and widely used for communication within 20 m.
Dr. N. Mathivanan

•RS-422 Standard
oCharacteristics
Uses differential signaling (balanced signaling)
Can be networked, master-slave, multi-drop, 1 driver & up to 7 receiver
Communicates up to 1.2 km at 100 kbps and up to 10 m at 10 Mbps
Backward compatible to RS-232
Apple Macintosh computers include RS-422 ports (LocalTalk)
Does not define connector, pin configuration
oDifferential signaling (balanced transmission)

Dr. N. Mathivanan

•RS-422 driver-output and receiver–input voltage profiles
•Pins designated as ‘A’ (or ‘+’) and ‘B’ (or ‘-’)
•Signals are defined based on voltage at ‘A’ w.r.t. ‘B’
•Common mode voltage within +/- 10 V.
•RS-232, TTL, RS-422 voltage levels - Illustration
Dr. N. Mathivanan

•RS-422 half-duplex (2-wire), full-duplex (4-wire) networks
oMaster transmitter can drive up to 7 slave receivers
oEcho cancellation logic needs to be implemented
Dr. N. Mathivanan

•RS-485 Standard
•Uses differential signaling (balanced transmission)
•Drivers & receivers have enable inputs, voltage profiles similar to
RS-422
•Common mode voltage range: +12 V to -7V
•Speed: 100 kbps if distance is 10 km, 10 Mbps if distance is less
than 20 m
•Multi-point communication
Dr. N. Mathivanan

RS-485 networks
oMulti master network,
oAllows up to 32 master/
slave combination
o2-wire network is used
in LAN,
o4-wire network uses 1
master, multiple slaves
oRequires termination
(120 Ω resistor)

Dr. N. Mathivanan

Comparison of RS-232, RS-422 and RS-485
Characteristic
parameter
RS-232 RS-422 RS-485
1.
Wiring for
communication
Single-ended Differential Differential
2. Signal type Unbalanced Balanced Balanced
3. Output voltage
Logic 0
+ 5 to + 15 V
w.r.t GND
+ 2 to + 6 V
on terminal A w.r.t B
+ 2 to + 6 V
on terminal A wr.t B
Logic 1
- 5 to - 15 V
w.r.t GND
- 2 to - 6 V
on terminal A w.r.t B
- 2 to - 6 V
on terminal A wr.t B
4. Data rate 20 kbps (max)
10 Mbps at 15 m
100 kpbs at 1200m
10 Mbps at 15 m
100 kpbs at 1200 m
5. Maximum cable length 15 m 1.2 km 10 km
6. Maximum drivers 1 1 32
7. Maximum receivers 1 7 32
8. Source impedance 300 Ω 100 Ω 100 Ω
9. Load impedance 3 to 7 kΩ 4 kΩ
10 Direction Uni-direction Uni-direction Bi-direction
11 Communication type Full-duplex
Half-duplex – 2-wire
Full-duplex – 4-wire
Half-duplex
12
Point-to-point /
master-slave
Point-to-point Master-slave Master-slave
Dr. N. Mathivanan

Universal Asynchronous Receiver Transmitter (UART)
•Basic functions of UART
oConverts ll
el
data to stream of bits, adds framing bits, transmits at set rate
oReceives stream of bits, removes framing bits, converts to ll
el
data
•16C550 type UART (most common type in microcontrollers, PC)
oInputs & Outputs are TTL compatible
oSpeed: 0 – 1.5x10
6
baud
oProgrammable baud rate generator,
oIndependent transmitter and receiver blocks
oSeparate 16 byte FIFOs for transmitter and receiver
o8-bit registers – 12 nos. (data, control and status registers)
oProgrammed in two stages:
Initialization,
Operation control: Transmitting characters, Receiving characters
Dr. N. Mathivanan

•Registers
oDivisor Latch Low (DLL) byte, High (DLH) byte registers
For programming baud rate generator for transmitter
oTransmitter Holding Register (THR)
Data byte to be transmitted is placed in this register
oReceiver Buffer Register (RBR)
Data byte received by UART is read from this register
oFIFO Control Register (FCR)
Used to clear FIFOs, set trigger level,
oLine Control Register (LCR)
Control framing, allow access of DLL/DLH/THR/RBR register
oLine Status Register (LSR)
Indicates error in reception, status of transmitter/receiver


Dr. N. Mathivanan

oModem Control Register (MCR)
Controls loopback mode, controls RTS/CTS, DSR/DTR, RI, DCD
oModem Status Register (MSR)
Indicates status changes on DCD, RI, DSR, CTS inputs
oInterrupt Enable, Interrupt Identification Register (IER, IIR)
Control interrupt generation on THR empty, RBR full
oScratch pad register (SCR)
Not used in communication, but used to hold temp. data
Dr. N. Mathivanan

•16C550D Block Diagram UART
Dr. N. Mathivanan

•UART Programming (Algorithm)
oInitializing
Program DLL and DLH registers
Define serial communication format (Program LCR register)
Reset FIFOs (Program FCR register)
Reset FIFO to enable transmission
oTransmitting characters
Wait till Transmitter becomes ready
Write a byte of character into THR register
If more bytes are to be transmitted, write into THR till transmitter
FIFO becomes full.
oReceiving characters
Checks if data has been received (by polling LSR)
If received, checks if any error in communication (LSR)
If no error, get data from RBR.
Dr. N. Mathivanan

Application - Example
•Remote I/O modules
oCommunicate with host system through serial interfaces
oMicrocontroller based embedded systems
oSmall, intelligent, remotely powered,
oProvides varieties of analog/digital, input/output interfaces
Dr. N. Mathivanan

Dr. N. Mathivanan
Remote data acquisition

Reference
•PC Based Instrumentation: Concepts and Practice
N. Mathivanan, PHI Learning, V Printing, 2014
Dr. N. Mathivanan