Asynchronous Serial Communication and standards

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

Transcript of Asynchronous Serial Communication and standards

Page 1: Asynchronous Serial Communication and standards

Asynchronous Serial Communication

and Standards

Dr. N. Mathivanan Visiting Professor

Department of Instrumentation and Control Engineering

National Institute of Technology,

TRICHY, TAMILNADU

INDIA

Page 2: Asynchronous Serial Communication and standards

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

Page 3: Asynchronous Serial Communication and standards

Serial Communication Terminologies

• Mark and Space:

o Logic ‘H’ is Mark, Logic ‘L’ is Space

• BAUD rate:

o Baud rate & bit rate (bps) are different.

o No. 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:

o Pathway between communicating devices

o Physical wire, media (propagating radiated energy)

• Protocol:

o Set of rules defining procedures – no. of bits, framing, formatting,

error detection methods, and control of comm. hardware Dr. N. Mathivanan

Page 4: Asynchronous Serial Communication and standards

• Network

o Connecting multiple devices to same media for resource sharing

• Point-to-point, Multi-drop, Multipoint o Point-to-point: Interface between devices having peer relationship

o Multi-drop: One transmitter communicating with multiple receivers

o Multipoint: 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

o Synchronous communication

o Asynchronous communication Dr. N. Mathivanan

Page 5: Asynchronous Serial Communication and standards

• 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

Page 6: Asynchronous Serial Communication and standards

• Asynchronous communication

o Framing

Start bit, data bits, parity bit, stop bits – Popular format 8N1

o Character oriented

Standard communication speeds:

110, 150, 300, 600, 1200, 2400, 4800, 9600, ………., 115.2 kbaud

• Serial communication – Error checking methods

o Checksum method

o Cyclic redundancy check

o Error flags Dr. N. Mathivanan

Page 7: Asynchronous Serial Communication and standards

• Signal encoding

o RZ, NRZL, NRZL, Manchester, Manchester Differential

• Compression

o E.g.: Run-Length encoding, Huffman encoding

Dr. N. Mathivanan

Page 8: Asynchronous Serial Communication and standards

• Serial communication modes

o Simplex, Half duplex, Full duplex

• Communication medium

o Generally, metallic cables for distance up to 50 m,

o Beyond 50 m and up to 4 km, signal is converted to differential

and sent thro’ twisted pair cable,

o Above 4 km, telephone line / fibre optic cable (has several

advantages) used.

• Serial communication – Classification of devices

o DTE (Data terminal equipment)

Devices used as source / destination for the data, E.g.: PC

o DCE (Data communication or Data carrier equipment)

Devices used in between DTEs, E.g.: Modem

Dr. N. Mathivanan

Page 9: Asynchronous Serial Communication and standards

Asynchronous Serial Interface Standards

• RS-232, EIA/TIA-232-F

o The standard defines physical & electrical connection, voltage

levels, noise margin, speed, and distance.

o It is asynchronous interface,

o It provides point-to-point interface and peer relationship

between devices.

• Pins & Signals

o DCE devices have 25-pin socket, DTE devices have 25-pin plug

o IBM modifies the RS-232 25-pin definition to 9-pin serial port

o Applications use 2, 4 or all signals for communication

o Signals classified into: Data, Control, Common & Timing signals

Dr. N. Mathivanan

Page 10: Asynchronous Serial Communication and standards

o Data Signals

TxD – pin no. 3 in DTE, pin no. 2 in DCE

RxD – pin no. 2 in DTE, pin no. 3 in DCE

o Control 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

o Common Signals: SG Dr. N. Mathivanan

Page 11: Asynchronous Serial Communication and standards

• Signal voltage levels:

o RS-232 voltage levels different from TTL, CMOS voltage levels

o Uses bipolar voltages,

o Driver output and receiver input voltage profiles - noise margin +/- 2 V

o RS-232 uses single-ended signal transmission

o Interfacing RS-232 devices to TTL devices require RS-232

driver/receivers (E.g.: MAX232, MC1488 and MC1489A)

o Advantages of MAX232

Dr. N. Mathivanan

Page 12: Asynchronous Serial Communication and standards

• Linking embedded systems / PCs by phone line using modem

o Local PC monitors RI input, Remote PC activates RI

o Local PC activates DTR, Local modem responds by activating DSR, Local

PC monitors DCD, Modem asserts DCD if it receives carrier signal

o Data transfer begins using RTS, CTS handshaking

o Data transfer takes place via TxD, RxD

o When transfer is completed, disables DTR, modem inhibits DSR, DCD

signals.

Dr. N. Mathivanan

Page 13: Asynchronous Serial Communication and standards

• Communication between two DTEs

• Null Modem wiring

without handshaking, with handshaking, with loop-back handshaking

Dr. N. Mathivanan

Page 14: Asynchronous Serial Communication and standards

• Daisy chaining

• RS-232 Characteristics

o Uses single-ended signaling (unbalanced transmission)

o Peer-to-peer communication

o Networking – daisy-chaining

o Speed Max. – 19.6 kbps,

o Distance Max. – 20 m

o Drawbacks: noise immunity low, short distance, low speed

o Still popular and widely used for communication within 20 m.

Dr. N. Mathivanan

Page 15: Asynchronous Serial Communication and standards

• RS-422 Standard

o Characteristics

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

o Differential signaling (balanced transmission)

Dr. N. Mathivanan

Page 16: Asynchronous Serial Communication and standards

• 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

Page 17: Asynchronous Serial Communication and standards

• RS-422 half-duplex (2-wire), full-duplex (4-wire) networks

o Master transmitter can drive up to 7 slave receivers

o Echo cancellation logic needs to be implemented

Dr. N. Mathivanan

Page 18: Asynchronous Serial Communication and standards

• 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

Page 19: Asynchronous Serial Communication and standards

RS-485 networks

o Multi master network,

o Allows up to 32 master/

slave combination

o 2-wire network is used

in LAN,

o 4-wire network uses 1

master, multiple slaves

o Requires termination

(120 Ω resistor)

Dr. N. Mathivanan

Page 20: Asynchronous Serial Communication and standards

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

Page 21: Asynchronous Serial Communication and standards

Universal Asynchronous Receiver Transmitter (UART)

• Basic functions of UART

o Converts llel data to stream of bits, adds framing bits, transmits at set rate

o Receives stream of bits, removes framing bits, converts to llel data

• 16C550 type UART (most common type in microcontrollers, PC)

o Inputs & Outputs are TTL compatible

o Speed: 0 – 1.5x106 baud

o Programmable baud rate generator,

o Independent transmitter and receiver blocks

o Separate 16 byte FIFOs for transmitter and receiver

o 8-bit registers – 12 nos. (data, control and status registers)

o Programmed in two stages:

Initialization,

Operation control: Transmitting characters, Receiving characters

Dr. N. Mathivanan

Page 22: Asynchronous Serial Communication and standards

• Registers

o Divisor Latch Low (DLL) byte, High (DLH) byte registers

For programming baud rate generator for transmitter

o Transmitter Holding Register (THR)

Data byte to be transmitted is placed in this register

o Receiver Buffer Register (RBR)

Data byte received by UART is read from this register

o FIFO Control Register (FCR)

Used to clear FIFOs, set trigger level,

o Line Control Register (LCR)

Control framing, allow access of DLL/DLH/THR/RBR register

o Line Status Register (LSR)

Indicates error in reception, status of transmitter/receiver

Dr. N. Mathivanan

Page 23: Asynchronous Serial Communication and standards

o Modem Control Register (MCR)

Controls loopback mode, controls RTS/CTS, DSR/DTR, RI, DCD

o Modem Status Register (MSR)

Indicates status changes on DCD, RI, DSR, CTS inputs

o Interrupt Enable, Interrupt Identification Register (IER, IIR)

Control interrupt generation on THR empty, RBR full

o Scratch pad register (SCR)

Not used in communication, but used to hold temp. data

Dr. N. Mathivanan

Page 24: Asynchronous Serial Communication and standards

• 16C550D Block Diagram UART

Dr. N. Mathivanan

Page 25: Asynchronous Serial Communication and standards

• UART Programming (Algorithm)

o Initializing

Program DLL and DLH registers

Define serial communication format (Program LCR register)

Reset FIFOs (Program FCR register)

Reset FIFO to enable transmission

o Transmitting 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.

o Receiving 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

Page 26: Asynchronous Serial Communication and standards

Application - Example

• Remote I/O modules

o Communicate with host system through serial interfaces

o Microcontroller based embedded systems

o Small, intelligent, remotely powered,

o Provides varieties of analog/digital, input/output interfaces

Dr. N. Mathivanan

Page 27: Asynchronous Serial Communication and standards

Dr. N. Mathivanan

Remote data acquisition

Page 28: Asynchronous Serial Communication and standards

Reference

• PC Based Instrumentation: Concepts and Practice

N. Mathivanan, PHI Learning, V Printing, 2014

Dr. N. Mathivanan