1. Trang chủ
  2. » Giáo Dục - Đào Tạo

Bài giảng RS232 - phần 2

67 507 6
Tài liệu đã được kiểm tra trùng lặp

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Tiêu đề Bài Giảng Rs232 - Phần 2
Trường học Electronics Industries Association
Chuyên ngành Serial Communication
Thể loại Bài Giảng
Định dạng
Số trang 67
Dung lượng 6,13 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

giao tiep may tinh, Bài giảng RS232 - phần 2

Trang 2

• The D-subminiature or D-sub is a

common type of electrical

connector They are named for

their characteristic D-shaped

metal shield.

• A, B, C, D, or E denoting the shell

size, followed by the number of

pins or sockets, followed by

either P (plug) – M(Male)

or S (socket) – F (Female)

Trang 3

RS232 is an asynchronous or synchronous serial

communications protocol

• Personal computers first used DB25

connectors for their serial and parallel ports

EIA232 communication function and connector types for a personal computer and modem DCE devices are sometimes called

"Data Communications Equipment" instead of Data Circuit-terminating Equipment.

RS-232C

RS-232 stands for Recommend Standard number 232 and C is the latest revision of the standard The serial ports on most computers use a subset of the RS-232C standard The full RS-232C standard specifies a 25-pin "D" connector of which 22 pins are used Most of these pins are not needed for normal PC communications, and indeed, most new PCs are equipped with male D type connectors having only 9 pins.

RS232 on DB25 (RS-232C)

Trang 4

The public switched telephone network (PSTN) is the network of the world's public circuit-switched telephone networks It consists of telephone

lines, fiber optic cables, microwave transmission links, cellular networks, communications satellites, and undersea telephone cables, all inter-connected

by switching centers, thus allowing any telephone in the world to communicate with any other Originally a network of fixed-line analog telephone systems, the PSTN is now almost entirely digital in its core and includes mobile as well as fixed telephones.

Trang 5

When the PC serial port began to use 9-pin connectors, they were often labeled as DB9 instead of DE9 connectors, due to

an ignorance of the fact that B represented a shell size It is now common to see DE9 connectors sold as DB9 connectors.

RS232 on DB9 (EIA/TIA 574)

Trang 6

RS232 DB25 to DB9 converter RS232 DB9 pinout

Trang 7

EIA 561

RS232D uses RJ45 type connectors (similar to telephone connectors)

RS232 on RJ45 (RS-232D)

Trang 8

MODEM COMMUNICATION BETWEEN TWO PC’S

Trang 9

RS232 DB9 pinout RS 232 Voltage levels

SIGNAL VOLTAGE LEVELS VOLTS

LOGICAL STATE

CONTROL VOLTAGE LEVELS VOLTS

LOGICAL STATE

-3 to -25 OFF +3 to +25 ON

Trang 10

- The signal ground, ie the reference level for all signals

- The protective ground : Also known as Shield Ground This is the chassis

ground connection between DTE and DCE It should not be used as a signal

ground, and it must not be connected to signal ground Connecting

protective ground on both sides makes sure that no large currents flow

through Signal ground in case of an insulation defect on one side

Trang 11

DB9 Null Modem Cable

The Carrier Detect (CD) and the Ring Indicator (RI) lines are only available in connections to a modem Because most modems transmit status information to a PC when either a carrier signal is detected (i.e when a connection is made to another modem)

or when the line is ringing, these two lines are rarely used

Trang 12

Low?

Low?

START

Set Data Terminal Ready

Read Data Set Ready

Read Clear To Send

Set Ready To Send

Read Data Carrier Detect

Transmit

Yes No

No

No

Yes

Trang 13

DB9 Loopback Connector

Use loopback connectors to confirm proper operation

of the computer's serial port Once confirmed, insert the serial cable you plan to use and attach the loopback

to the end of the serial cable to verify the cable.

Connect to DTE (computer)

Trang 14

DB9 Null Modem Cable

Use this female-to-female cable in any application where you wish to connect two DTE devices (for example, two

computers) A male-to-male equivalent of this cable would

be used to connect two DCE devices.

Trang 15

Null Modem RS232 Lead

Trang 16

Asynchronous (RS-232) serial link

universal asynchronous receiver/transmitter or UART

Trang 17

Electrical characteristics

Charge Pump Voltage Doubler

Charge Pump Voltage Inverter

By Reversing the position of the Vout and Vin, the regulator becomes fractional gain (1/2).

Trang 22

The signal level inversion (logic 1 is -12V and logic 0 is +12V)

0

Trang 24

The first step to connecting a device to the RS-232 port is to transform the RS-232 levels into

0 and 5 Volts, AND, this is done by RS-232 Level Converters

The MAX-232 It includes a Charge Pump, which generates +10V and -10V from a single 5v supply This I.C also includes two receivers and two transmitters in the same package

RS-232 Level Converters

Trang 25

RS-232 Level Converters

Trang 26

RS-232 Level Converters

Trang 29

Relationship of Baud Rate to Maximum Distance

There are physical limits to how far serial data communication can occur over a piece of wire When you apply a voltage onto

a wire it takes time for that voltage to traverse the wire, and there are other unstable conditions that happen when you send

a "pulse" down the wire and change voltages too quickly.

Baud Rate Maximum Distance (in feet) Maximum Distance (in meters)

Trang 33

RS-232 Transceiver

COM1

DB-9 connector

COM1

DB-9 connector

Trang 42

Schmitt Trigger using Op-Amp

vout = A(v2 – v1)

The comparator will switch when V+=0 Then

The effect of using a Schmitt trigger

(B) instead of a comparator (A).

Typical hysteresis curve (Non-inverting)

Non-inverting Schmitt trigger

Inverting Schmitt trigger

The difference between the trip points

is the hysteresis H and is given as

Let's say you detect a low-to-high transition at 2.5 V A 100

mV hysteresis would mean that the low-to-high transition

is detected at 2.55 V and the high-to-low transition is detected at 2.45 V, a 100 mV difference.

Vcc = Voltage Common Collector Bipolar Vee = Voltage Common Emitter Bipolar Vss = Voltage Common Source FET Vdd = Voltage Common Drain FET

s s

R

R V

R

R V

R

R H

2

12

12

1  (  )  2

Trang 47

8250 and Compatible UARTs

UART usually stands for Universal Asynchronous Receiver / Transmitter and is a chip located on a serial card, it allows connection with modems and other devices Most card manufacturers integrate UART into other chips which can also control parallel port, games port, floppy or hard disk drives and are typically surface mount devices.

• One of such chips is presented in 8250 line, which includes 16450, 16550, 16650, & 16750 UARTS, this line is usually used in PCs.

16550 chip is compatible with 8250 &

16450 chips The only two differences

are pins 24 & 29 8250 Chip Pin 24 has

chip selection which works as chip

activity indicator Pin 29 is not used in

8250/16450 UARTs These pinouts have

different purpose in 16550 chip Their

purpose is: Transmit Ready and

Receive Ready This pinouts allow DMA

(Direct Memory Access) usage These

Pins have two different modes of

operation Mode 0 supports single

transfer DMA where as Mode 1

supports Multi-transfer DMA.

Trang 49

Pin 12 CS0 Chip Select 0 - Active High Pin 13 CS1 Chip Select 1 - Active High Pin 14 nCS2 Chip Select 2 - Active Low

Trang 58

Bit 5: Sets the "sticky" parity bit The parity bit is always the same value, "high" (1) or "low" (0).

0: The parity bit is set by the input word.

1: The parity bit is 0 is bit 4 is 1, the parity bit is 1 if bit 4 is 0.

1 0

1 0 1 High Parity (Sticky)

1 1 1 Low Parity (Sticky)

Mark Parity High Parity (Sticky)

In this case the parity bit will always be a logical "1" While this may

seem a little unusual, this is put in for testing and

diagnostics purposes If you want to make sure that the

software on the receiving end of the serial connection is

responding correctly to a parity error, you can send a Mark

or a Space parity, and send characters that don't meet

what the receiving UART or device is expecting for parity

In addition for Mark Parity only, you can use this bit as an

extra "stop bit" Keep in mind that RS-232 standards are

expecting a logical "1" to end a serial data word, so a

receiving computer will not be able to tell the difference

between a "Mark" parity bit and a stop bit In essence, you

can have 3 or 2.5 stop bits through the use of this setting

and by appropriate use of the stop bit portion of this

register as well This is a way to "tweak" the settings on

your computer in a way that typical applications don't allow

you to do, or at least gain a deeper insight into serial data

settings.

Space Parity Low Parity (Sticky)

Like the Mark parity, this makes the parity bit "sticky", so it doesn't

change In this case it puts in a logical "0" for the parity bit

every time you transmit a character There are not many

practical uses for doing this other than a crude way to put

in 9 data bits for each serial word, or for diagnostics

purposes.

Trang 61

000 0100 4 04 EOT^D End of Transmission

Trang 62

C7 set high to access the Baud rate divider

0 1odd

Trang 64

odd

Trang 65

VS 2010 C#

using System;

using System.Collections.Generic; using System.ComponentModel; using System.Data;

using System.Drawing;

using System.Text;

using System.Windows.Forms; using System.IO.Ports;

delegate void SetTextCallback (string text);

public fclsRS232Tester()

{

InitializeComponent();

string[] ports = SerialPort.GetPortNames();

foreach (string port in ports)

{

cmbComSelect.Items.Add(port);

}

}

Trang 66

private void cmbComSelect_SelectionChangeCommitted(object sender, EventArgs e)

Trang 67

private void btnSend_Click(object sender, EventArgs e) {

if (port.IsOpen) port.WriteLine (txtOut.Text);

else MessageBox.Show("Serial port is closed!", "RS232 tester", MessageBoxButtons.OK, MessageBoxIcon.Error);

txtOut.Clear(); }

private void btnClear_Click(object sender, EventArgs e) { txtIn.Clear(); }

private void port_DataReceived_1(object sender, SerialDataReceivedEventArgs e) {

SetTextCallback d = new SetTextCallback(SetText);

this.Invoke(d, new object[] { text });

}

else this.txtIn.Text += text; }

VS 2010 C#

Ngày đăng: 05/04/2013, 11:54

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

w