Você está na página 1de 34

Synchronous vs.

Asynchronous
Synchronous
One-way communication Receiver and transmitter must have their clocking synchronized, . Requiring a constant stream of transmission Request for data is made, time is given for the request to be carried out, and data is read.

Asynchronous
- Utilizes start and stop bit to communicate the beginning and end of data words to the receiver - No need for devices to be synchronized

Data Word
Start Bit
Signals the start of transmission of the data bits Transition from logic 1 to logic 0

Data Bits
Generally 8 data bits (not including parity bit) Transmitted and received least significant bit first

Stop Bit
Signals the end of a data word Logic 1

Parity Bit
Can be added to the transmitted data to check for and display an error message when a bit is lost during transmission Comes in two forms
Odd Parity
Sum of the 1s in the frame will be odd
The logical state (1 or 0) of the parity bit is selected to fulfill this condition

Even Parity
Sum of the 1s in a frame will be even

Number of 1s checked against the parity bit to determine if any bits were lost during transmission

A two bit loss will go undetected with this method

Data Word

Baud and Bit Rates


Baud Rate
A baud is the reciprocal of the shortest pulse duration in a data word inclusive of start, stop, data, and parity bits Baud rate is the total number of bits transmitted per second

Data Bit Rate


The number of data bits transmitted in one second.
Does not include the start or stop bits

In this example:

1 start bit, 1 stop bit, 1 parity bit, 8 data bits, 11 bits per word, 300 baud rate

Bit Time = 1/(Baud rate) = 1/300 = 3.33 msec Character Time = (total bits in word) x (bit time) = 11 x 3.33 = 36.6 msec Data Bit Rate (including parity) = (data bits in word)/(character time)= 9/3.33 = 270

RS232 and RS485 Fundamentals

What is RS232
RS-232 Signals RS-232 Line Driver RS-232 Speed RS-232 SW settings

What is RS-485
RS-485 Line Driver RS-485 Network RS-485 Half-duplex RS-485 Full-duplex RS-485 and DL devices

RS-232 vs RS-485

RS-232
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 computers serial port (know as COM or Comm port).

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).

Three major wires for the Serial interface: Transmit ( Pin 2) Receive Ground ( Pin 3) Pin 7 (25 pin connector) Pin 5 (9 pin connector)

Tx
Computer

Tx
Device

Rx
Gnd

Rx
Gnd Transmit connects to Receive

RS232 is well-established standard, developed by the EIA (Electronics Industry Association) in 1960s Originally intended as an electrical specification to connect computer terminals to modems

Defines the interface between a DTE and a DCE


DTE = Data Terminal Equipment (terminal) DCE = Data Communications Equipment (modem) A modem is sometimes called a data set A terminal is anything at the terminus of the connection.
VDT (video display terminal), computer, printer, etc

DTE

DCE

DCE

DTE

RS-232C

Telephone network

RS-232C

1s and 0s in RS-232C
A 1 is called a mark

A 0 is called a space
The idle state for an RS-232C line is a 1 (mark)
Idle state is called marking the line

Data Transmission Example


Plot of the asynchronous RS-232C transmission of the ASCII character a with odd parity:

Idle state TD 0 1

Start bit 0 0 0 0 1

Stop bit 1 0 1 time Parity bit

Idle state

ASCII character a 7 bits LSB first

RS-232C Connectors
The original standard specified a 25-pin connector Today, a 9-pin connector is more common E.g.,
DB9P Note: P = pin Sometimes called a male connector The mate for this is a DP25S, or socket connector the female

RS-232C Connectors
Pin 1 DB25P DB25S Pin 1

Pin 1

DB9P

DB9S

Pin 1

Where is pin 1?

Where are pins 2, 3, 4, etc.?

RS-232C Pin Numbers


1 2 3 4 5

DB9P

RS-232C Pins, Signals, Directions


Pin DB25 1 2 3 4 5 6 7 8 20 22 DB9 2 3 7 8 6 5 1 4 9 Signal Name CD Chassis Ground TD Transmit Data RD Receive Data RTS Request To Send CTS Clear To Send DSR Data Set Ready SG Signal Ground DCD Data Carrier Detect DTR Data Terminal Ready RI Ring Indicator Direction DTE DCE DTE DCE DTE DCE DTE DCE DTE DCE DTE DCE DTE DCE DTE DCE

Common 25 pin D-shell connector pinout used for asynchronous data communications.
Pin 1 2 3 4 5 6 7 8 20 22 Signal PGND Protective Ground TXD Transmit Data RXD Receive Data RTS Ready To Send CTS Clear To Send DSR Data Set Ready SG Signal Ground CD Carrier Detect DTR Data Terminal Ready RI Ring Indicator

(serial port - PC side)

RS-232 Line Driver


Unbalanced Line Drivers

Each signal appears on the interface connector as a voltage with reference to a signal ground. The idle state (MARK) has the signal level negative with respect to common whereas the active state (SPACE) has the signal level positive with respect to the same reference.

RS-232 Speed
How fast can RS-232 be?
The maximum speed, according to the standard, is 20kbit/s. However, modern equipment can operate much faster than this. (i.e. Lynx can reach 115200 baud.) The length of the cable also plays a part in maximum speed. The longer the cable and the slower the speed at which you can obtain accurate results. A large wire capacitance and inductance limits the maximum length of the cable and/or the maximum speed;

Moreover higher is the capacitance of the cable higher is the interference between two adjacent signal wire.
50 feet (15m) @ max baudrate is commonly quoted as the maximum distance.

RS-232 switch settings


One byte of async data has:
Start Bit = 1 (always) Data Bits = 8 (or 7)

Stop bits = 1 (or 2) Parity = NONE (or EVEN or ODD)

Computer and device must have the same settings for Baud Rate Parity

Stop bits
Baud Rate - data transmitted in bits/second Parity - Check against faulty data transfer. If used, 8 (typically) data bits sent plus parity bit. Responsibility of device to check parity Stop Bits - denotes end a data string. Use 2 stop bits with SR510. (Recommended)

RS232 Typical Data format


Time

Data Format: Bit 0: Start bit


Voltage

Bit 1-8: ASCII code of Data


Bit 9 : Parity Bit Bit 10-11 : Stop bits Start Bit LSB ASCII Data in above example is sent LSB first (eg. ASCII A=01000001) Logic of Data may be inverted. Control lines use positive logic MSB Parity & Stop Bits

Each ASCII character requires about 12 bits to be transmitted or about 833s for character.

RS232 with Control Lines


(control lines not necessarily required in RS232) - some devices require them.

Handshake Control Lines.


CTS - Clear to Send - (eg. pin 5 on SR510 lock-in) Set high (Asserted) by instrument to tell computer that instrument is ready to receive data

DTR - Data Terminal Ready - (pin 20) Set high by computer to tell instrument that Computer is ready to receive data.

Testing out the RS232


Use Hyper Terminal (Windows XP) Programs>>Accessories>>HyperTerminal Set up Communications : Com 1, 19200 Baud, 8 Bits, no parity, 2 stop bits. With Fiber-optic link connected to RS232, monitor the TX BNC connection on the Oscilloscope. Type commands in Hyperterminal to read/write data to the fiber-optic link. (Connect TX to RX directly to make sure sense of logic is correct, etc.) NOTE: Do not need flow control with our simple fiber link

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. 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-485 Line Driver


Balanced Line Drivers
Voltage produced by the driver appears across a pair of signal wires that transmit only one signal. Both wires are driven opposite. RS-485 driver has always the Enable direction control signal. Differential system provides noise immunity, because much of the common mode signal can be rejected by the receiver. So ground shifts and induced noise signals can be nullified.

RS-485 Network
RS-485 provides Half-Duplex, Multidrop communications over a single twisted pair cable.

The standard specifies up to 32 drivers and 32 receivers can share a multidrop network
Terminator resistors avoid reflected signal

RS-485 Half-duplex
Data logic uses Half-Duplex configurations for Data Collecting and Master/Slave layouts. Usually we talk about Multidrop network (i.e. MX4000,DPS9000)
TX ENABLE RX

Slave 1

RTX485+ RTX485TX ENABLE RX

TX ENABLE RX

Slave 2

485GND
Master

TX ENABLE RX

Slave N

RS-485 Full-duplex
Potentially RS-485 interface can also use 4-wires to comunicate in multidrop mode but...

TX ENABLE

TX485+ TX485TX

RX485+ RX485485GND

ENABLE RX

RX

Other device Scanner

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 main difference is that only one device on a 485 bus can transmit at a time, however there is no similar limitation in the transmission for RS232 since it has a peer-to-peer link .

RS-232 vs RS-485
RS-232 RS-485

Mode of Operation Total Number of Drivers and Receivers on One Line Maximum Cable Length Maximum Data Rate @Max length Driver Output Signal Level (Loaded Min.) Loaded Driver Output Signal Level (Unloaded Max) Unloaded Driver Load Impedance Max. Driver Current in High Z State Power On Max. Driver Current in High Z State Power Off Slew Rate (Max.) Receiver Input Voltage Range Receiver Input Sensitivity Receiver Input Resistance

SINGLE-ENDED 1 DRIVER 1 RECEIVER 50 FEET 20kb/s +/-5V to +/-15V +/-25V 3k to 7k N/A +/-6mA @ +/-2v 30V/S +/-15V +/-3V 3k to 7k

DIFFERENTIAL 32 DRIVER 32 RECEIVER 4000 FEET 100kb/s +/-1.5V +/-6V 54 N/A +/-100uA N/A -7V to +12V +/-200mV 12k

Você também pode gostar