You are on page 1of 35

By: Azam Rafique

Instrumentation Engineer (TQCIC)

Why RS-232 or Serial communication?


Parallel Data transfer requires 8 data lines
Faster Not suitable for Long distance Communication

Costly

Serial Communication only requires 3 data lines But it transfers data, bit-by-bit

Types of Communication
There 3 types of communication Simplex Communication Duplex Communication

Half Duplex Communication Full Duplex Communication

Simplex Communication
It is a unidirectional Communication
Data transfer occurs in one direction

Examples: TV, Radio

Half Duplex Communication


Communication is two way, but one at a time
Communication can not occur simultaneously from

both ends when one device sends data, other has to listen
Example: Walkie talkie

Full Duplex Communication


Bidirectional Communication
Data transfer is simaltaneous Both devices can send and/or receive data at the same

time Requires two conductors + common ground


Examples: Ethernet, Landline

Protocols
A communications protocol is a system of digital

message formats and rules for exchanging those messages in or between computing systems An agreed-upon format for transmitting data between two devices A protocol may have a formal description Protocols may include signaling, authentication and error detection and correction capabilities

Protocols (cont)
Transmission Control Protocol (TCP)
User Datagram Protocol (UDP) Internet Control Message Protocol (ICMP)

Hypertext Transfer Protocol (HTTP)


Post Office Protocol (POP3) File Transfer Protocol (FTP) Internet Message Access Protocol (IMAP)

RS-232
RS-232 (Recommended Standard-232) is a standard

interface approved by the Electronic Industries Association (EIA) for connecting serial devices.
RS-232 is the interface that your computer uses to talk

to and exchange data with your modem and other serial devices. The serial ports on most computers use a subset of the RS-232C standard.

RS-232 (cont)
There are two basic types of serial communications,: Synchronous Asynchronous
The serial ports on IBM-style PCs are asynchronous

devices and therefore only support asynchronous serial communications.

Asynchronous Communication
Asynchronous means "no synchronization. The beginning and end of each byte of data must be

identified by start and stop bits. The start bit indicate when the data byte is about to begin and the stop bit signals when it ends. The requirement to send these additional two bits cause asynchronous communications to be slightly slower than synchronous. For example, a telephone conversation is asynchronous because both parties can talk whenever they like.

Asynchronous Communication Working


An asynchronous line that is idle is identified with a

value of 1, (also called a mark state). By using this value to indicate that no data is currently being sent, the devices are able to distinguish between an idle state and a disconnected line. When a character is about to be transmitted, a start bit is sent. A start bit has a value of 0, (also called a space state). Thus, when the line switches from a value of 1 to a value of 0, the receiver is alerted that a data character is about to come down the line.

Asynchronous Communication Working (cont)

Problems with Asynchronous Communication

Can you make out what data is coming?

Problems with Asynchronous Communication (cont)


No because you are not synchronized.
You need a way to know when a new byte start and

when a bit ends and new bit start. Suppose the line is low for some time that means a 0' but how many zeros? If we send data like 00001111 then line is first low for some time and high after that. Then how we know it is four '0's and four '1's?

Problems with Asynchronous Communication (cont)


Now theres a technique called baud rate, by which we set

the pulse duration at input as well as at output/receiver.

Baud rate: The number of times per second that a line changes state. In Serial Communication Baud Rate and bit rate (bps) is

same

Example: 00001111 @ baud rate of 9600, means a bit will change in 1/9600=104 uS, if it takes 416 uS for 4 zeros and 416 uS for 1s then we can detect that there are four zeros and four ones.

Synchronous Communication
Synchronous communication requires that each end

respond in turn without initiating a new communication. The sender and receiver must synchronize with one another before data is sent. A typical activity that might use a synchronous protocol would be a transmission of files from one point to another. As each transmission is received, a response is returned indicating success or the need to resend.

Synchronous Communication (cont)


With Synchronous communications, the two devices

initially synchronize themselves to each other, and then continually send characters to stay in sync. Synchronous communications allows faster data transfer rates than asynchronous methods, because additional bits to mark the beginning and end of each data byte are not required.

Synchronous Communication (cont)

RS-232 Pins
9 pin # 3 2 7 8 6 4 1 25 pin# 2 3 4 5 6 20 8 Acronym TxD RxD RTS CTS DSR DTR DCD Full name Transmit Data Receive Data Request To Send Clear To Send Data Set Ready Data Terminal Ready Data Carrier Detect Direction -- --- ---- -Description Transmits bytes out of computer or device Receives bytes into computer or device RTS/CTS flow control RTS/CTS flow control This device is ready to communicate This device is ready to communicate Modem connected to another Ringing on telephone line

9
5

22
7

RI
SG

Ring Indicator
Signal Ground

--

* IBM PCs have Asynchronous Serial Communication

Baud Rates
As there is no "clock" line so for synchronization accurate

timing is required so transmissions are carried out with certain standard speeds. The speeds are measured in bits per second. Number of bits transmitted is also known as baud rate. Some standard baud rates are

1200 2400 4800 9600 19200 38400 57600 115200

Null Modem
Null modem is a communication method to connect

two DTEs (devices) directly using an RS-232 serial cable.


The RS-232 standard is asymmetrical as to the definitions

of the two ends of the communications link so it assumes that one end is a DTE and the other is a DCE e.g. a modem. With a null modem connection the transmit and receive lines are cross-linked. Depending on the purpose, sometimes also one or more handshake lines are crosslinked. Several wiring layouts are in use because the null modem connection is not covered by a standard.

Null Modem Cable

Working of Asynchronous RS-232 Using Handshake Signal


DTR: When a device is ready an it's serial port activated. This signal is raised when a process OPENs the serial port. DSR: The DCE is ready and on RTS: This signal is raised by the DTE when it is ready to receive new data from the DCE device. Lowered when the computer cannot cope fast enough with the data coming in. Gives the DTE control of the flow of data coming from the DCE.

Working of Asynchronous RS-232 Using Handshake Signal (cont)


CTS: if this signal is raised, the DTE can send data to the DCE. Lowered, the DTE must stop sending data. DCD: The DCE has established a communication with a remote DCE device.
RI: Modem Indicates the computer that telephone is

Ringing.

RS-232 Protocol
RS 232 Voltage levels -3 to -25 (Logic HIGH) +3 to +25 (Logic LOW) Data bit sequence IDEAL (Logic HIGH) Start bit (Logic LOW) First bit as LSB (B0) . . . 8th bit as MSB (B7) Parity bit (if pre-set in settings) Stop bits (can be 1 or 2 depends on settings)

RS-232 Protocol (cont)

Why such an High Voltage Levels?


To make it work over long cables high voltages are sent

from each transmitter, Since due to cable resistance the voltage reduces the further the signal has to travel.

TTL Logic Voltage Levels

MAX-232
MAX-232 converts RS-232 Voltage levels to make it

compatible with TTL Logic. The MAX232 inverts and shifts the level so that idle become high (+5V) and the start bit is low (0V). MAX232 is a dual driver/receiver and typically converts the RX, TX, CTS and RTS signals. The drivers provide RS-232 voltage level outputs (approx. 7.5 V) from a single + 5 V supply via onchip charge pumps and external capacitors. The receivers reduce RS-232 inputs (which may be as high as 25 V), to standard +5V TTL levels

MAX-232 Voltage Level Conversion


RS232 Line Type & Logic Level Data Transmission (Rx/Tx) Logic 0 Data Transmission (Rx/Tx) Logic 1 Control Signals (RTS/CTS/DTR/DSR) Logic 0 Control Signals (RTS/CTS/DTR/DSR) Logic 1

RS232 Voltage
+3 V to +15 V -3 V to -15 V -3 V to -15 V

TTL Voltage to/from MAX232 0V 5V 5V

+3 V to +15 V

0V

MAX-232 Pins

Interfacing with uC

References

wikipedia.org http://www.webopedia.com/TERM/P/protocol.html http://www.taltech.com/support/entry/serial_intro http://www.aggsoft.com/rs232-pinout-cable/pinoutand-signal.htm http://web.engr.oregonstate.edu/~traylor/ece473/lectu res/uart.pdf http://www.radioelectronics.com/info/telecommunications_networks/r s232/signals-voltages-levels.php

References
http://www.electronics-tutorials.ws/logic/logic_1.html
http://www.petervis.com/electronics%20guides/MAX

232/MAX232.html

You might also like