工程师 - RS232接口

RS232介绍
RS-232是美国电子工业联盟制定的串行数据通信的接口标准,原始编号全稱是EIA-RS-232。它广泛用于计算机串行接口外设连接。 RS-232C标准,其中EIA代表美国电子工业协会,RS代表推荐标准,232是标识号,C代表RS232的第三次修改,在这之前,还有RS232B、RS232A。
目前的最新版本是由美国电信工业协会(TIA, Telecommunications Industry Association,由EIA所分出的一个组织)所发行的TIA-232-F,它同时也是美国国家标准ANSI/TIA-232-F-1997(R2002),此标准于2002年受到再确认。在 1997年由TIA/EIA发行当时的编号则是TIA/EIA-232-F与ANSI/TIA/EIA-232-F-1997。在此之前的版本是TIA/EIA-232-E。
它规定连接电缆和机械、电气特性、信号功能及发送过程。其他常用电气标准还有EIA-RS-422-A、EIA-RS-423A、EIA-RS-485。
目前在IBM PC机上的COM1、COM2接口,就是RS-232C接口。RS-232对电气特性、逻辑电平和各种信号线功能都作了规定。
由于RS-232-C的重大影响,即使自IBM PC/AT开始改用9针连接器起,目前已几乎不再使用RS-232中规定的25针连接器。一般人谈到RS-232此一接口时很有可能指的是RS-232-C。
= = = = = = = = 
在电信领域,RS-232 或建议标准 232 最初是 1960 年推出的一种用于数据串行通信传输的标准。它正式定义了连接计算机终端或 PC 等 DTE(数据终端设备)和调制解调器等 DCE(数据电路终端设备或数据通信设备)的信号。该标准规定了信号的电气特性和定时、信号的含义以及连接器的物理尺寸和引脚。
RS-232 标准常用于串行端口和串行电缆。它目前仍广泛应用于工业通信设备中。
与后来的 RS-422、RS-485 和以太网等接口相比,RS-232 的传输速度较低、最大电缆长度较短、电压摆幅较大、标准连接器较大、不具备多点功能和有限的多路传输能力。在现代个人电脑中,USB 已取代了 RS-232 的大部分外设接口功能。
In telecommunications, RS-232 or Recommended Standard 232 is a standard originally introduced in 1960 for serial communication transmission of data. It formally defines signals connecting between a DTE (data terminal equipment) such as a computer terminal or PC, and a DCE (data circuit-terminating equipment or data communication equipment), such as a modem. The standard defines the electrical characteristics and timing of signals, the meaning of signals, and the physical size and pinout of connectors.
The RS-232 standard had been commonly used with serial ports and serial cables. It is still widely used in industrial communication devices.
Compared with later interfaces such as RS-422, RS-485 and Ethernet, RS-232 has lower transmission speed, shorter maximum cable length, larger voltage swing, larger standard connectors, no multipoint capability and limited multidrop capability. In modern personal computers, USB has displaced RS-232 from most of its peripheral interface roles.
RS232 Pinout
以下是典型的标准 9 针公 RS232 连接器的引脚分布,这种连接器也称为 DB9 连接器。 公头和母头对接。RS232 cable一般是一边母头接电脑,一边公头接外设。
Below is the pinout of a typical standard male 9-pin RS232 connector, this connector type is also referred to as a DB9 connector.
如下图所示,计算机的串行 COM 端口(DTE)通常是一个公口,而连接到该端口的任何外围设备通常都是一个母口(DCE)。
A computer's serial COM port (DTE, Data Terminal Equipment) is usually a male port as shown below, and any peripheral devices you connect to this port usually has a female connector (DCE, Data Communication Equipment).
该表显示了带有信号名称和信号方向的引脚编号。注意,如果看母口的信号的话,就要反过来,水平对称的。比如,右上角第一pin是1号。
This table shows the pin numbers with signal names and the signal direction.
Pin
Signal
Signal Name
DTE Signal direction
1
DCD
Data Carrier Detect
In
2
RXD
Receive Data
In
3
TXD
Transmit Data
Out
4
DTR
Data Terminal Ready
Out
5
GND
Ground
-
6
DSR
Data Set Ready
In
7
RTS
Request to Send
Out
8
CTS
Clear to Send
In
9
RI
Ring Indicator
In
RS232 串行通信端口 DB9 连接器(有时称为 DE9 连接器或 D-sub 连接器)的引脚分配参考图。RS232 是一种串行数据通信信号协议。RS232 通常使用 D-sub 9 针或 25 针连接器。如今,RJ45(或 8P8C)模块连接器也常用于 RS232。
RS232 标准也曾使用 D-Sub 20 针连接器。现在很少使用这么大的连接器了。
通常情况下,RS232 D-sub 连接器的 TX 引脚表示数据从连接器流出,流入与其配对的连接器的 RX 引脚。这是两个设备之间的通信通道。
注意
对于三线 RS232 串行通信(非硬件握手或异步数据通信)布线,只需要 2、3(RX、TX)和 5(Gnd)针脚。
这意味着串行数据是根据预先设置的定时时钟发送的。
Reference pinout diagrams for DB9 connector (sometimes known as DE9 connector or D-sub connector) for RS232 serial communication ports. RS232 is a serial data communication signaling protocol. D-sub 9 pins or 25 pins connector is commonly used for RS232. These days RJ45 (or 8P8C) modular connector is also commonly used for RS232 purposes.
RS232 standard was also implemented using a D-Sub 20 pins connector. Nowadays is quite rare to use such a big connector.
Typically the TX pin of an RS232 D-sub connector represents data flowing out of the connector, flowing into the RX pin of its mating connector. This is a communication channel between two devices.
Note:
For 3 wires RS232 serial communication (non-hardware-handshaking or asynchronous data communication) wiring, you only need pin 2, 3 (RX, TX), and pin 5 (Gnd)
Meaning that the serial data is sent out based on a pre-set timing clock.
RS232线束里的信号线是一条线,RX\TX信号线不会变化。外设和电脑使用RS232线束连接时,RX和TX是交叉连接的(crossed)。
RJ45 RS232 Console Cable Pin Out
现代计算机系统使用 RJ45 模块插头进行 RS232 数据通信。常见的 IT 终端控制台电缆称为 “RS232 DB9 至 RJ45”。它通常用于访问 IT 设备的终端控制台。
The modern computer system uses RJ45 modular plug for its RS232 data communication. A common IT terminal console cable is known as “RS232 DB9 to RJ45”. This is typically for accessing the terminal console of IT equipment.
RJ45 转 RS232 控制台电缆用于将计算机连接到路由器、交换机或防火墙等网络设备上的串行控制台端口。一端通过 RJ45 连接器(8P8C,8 引脚)连接服务器,另一端通过 D-Sub 连接器(母头 9 引脚,通常称为 d-sub09 连接器)连接计算机。
An RJ45 to RS232 console cable is used to connect a computer to a serial console port on a network device, such as a router, switch, or firewall. One end is connected to the server with RJ45 connector (8P8C, 8 pins), and the other end is to a computer with a D-Sub connector (female 9 pins, often known as d-sub09 connector)
串行控制台电缆通常用于向服务器或设备(通常是思科设备,通常称为思科控制台电缆)发送串行配置命令。
A serial console cable is usually used for conveniently sending serial configuration commands to a server or equipment (usually Cisco equipment, often known as the Cisco Console Cable).
串行控制台电缆引脚分布图(RJ45 转 RS232 母口线)
Serial Console Cable Pin Out Diagram (RJ45 to RS232 female cable)
RS232 to USB
另一种常见的 RS232 电缆是 “USB 至 RS232 转换器电缆”。现代计算机硬件更多使用 USB 连接,因为它体积小,具有即插即用的特点。它常用于现代计算机与仍在使用 RS232 通信方式的工业设备之间。
Another common type of cable where RS232 is found is the “USB to RS232 converter cable“. Modern computing hardware uses USB connection more, due to its size and plug-and-play feature. It is commonly used between modern computer and industrial devices that still uses the RS232 communication method.
如下图:
RS232 Max Length
RS232 通常使用 9600bps 的数据波特率。这种波特率较低,电缆长度可达约 150 米(约 500 英尺)。
随着电缆上数据传输速度的增加,数据的物理信号很容易耦合到相邻的导线上。这会在电缆上产生噪声。噪声的形式可能是相邻数据线上的垃圾数据。为了减少相邻数据线的噪声影响,电缆的长度应保持较短。导线之间的绝缘层是电容,高频信号很容易通过。长度越短,电容越小,高频信号就越难耦合到相邻电缆上。
下表是根据波特率计算电缆长度的一般指南。请注意,这只是一般指南。电缆的材料和结构也会影响电缆的长度。为安全起见,最好留出 2% 的余量。 如果您真的想进一步拉长电缆长度,请确保您购买的是高质量的 RS232 电缆,并使用更好的串行数据协议来检测数据损坏并进行必要的数据重传。
The RS232 often uses a data baud-rate of 9600bps. This baud-rate is low and the cable length distance can be up to about 150 meters (about 500ft).
As the speed of data transmission increases on the cable, the physical signal of the data can easily be coupled to the adjacent wire. This induces noise onto the cable. The noise can be in the form of garbage data on the adjacent data wire. To reduce the effect of induced noise from the adjacent wire, the length is kept shorter. The insulation between wires is capacitance which high-frequency signals can easily pass over. The shorter length will keep the capacitance lower which makes it harder for the higher-frequency signal to be coupled over to the adjacent cable.
The following table is a general guide to the cable length base on the baud-rate. Please note that this is only a general guide. The material and the construction of the cable also play a part in the length of the cable. To be safe, it is better to have a margin factor of 2. If you really want to stretch the cable length further, ensure that you get yourself a high-quality RS232 cable and also use a better serial data protocol to detect data corruption and do the necessary data re-transmission.
RS232 电缆长度与数据波特率对照表参考指南
RS232 Cable Length to Data Baud-rate table reference guide
你可以很容易地做一个实验来了解相邻导线上的噪声影响。在两个 RS232 设备(或计算机)之间架设 3 根距离为 30 米至 50 米的导线(Tx、Rx、Gnd)。将导线绞在一起或用胶带粘起来,使导线之间的间隙尽可能小。导线之间最好没有间隙。将波特率设置为 19200bps(使用硬件握手)。
向 Tx 线传输一串字节,并观察从 Rx 线返回的垃圾字节。这些垃圾数据是从 Tx 线耦合到 Rx 线的信号。干扰噪声触发了接收器电路,使其以为接收到了有效的 RS232 物理信号。这些在 Rx 通道上接收到的错误触发字节是 Tx 线路产生的噪声。将波特率降至 9600bps。你会发现产生这种垃圾的概率会降低或没有。提高波特率也会增加产生噪音的概率。
You can easily do an experiment to see the effect of noise induced on the adjacent wire. Set up 3 wires (Tx, Rx, Gnd) of 30m to 50m distance between two RS232 devices (or computer). Have the wire twisted or taped up so that the gap between the wires is as small as possible. The best is no gap between the wires. Set up the baud-rate to 19200bps (with hardware handshaking).
Transfer a string of bytes into the Tx wire and observed the garbage bytes returning from the Rx wire. These garbage data are signals from the Tx wire coupled to the Rx wire. The disturbance noise triggered the receiver circuit thinking that a valid physical RS232 signal is received. These mis-triggered bytes received on the Rx channel are the noise induced from the Tx line. Change the baudrate lower to 9600bps. You will notice that the probability of this garbage generated is lesser or none. Increasing the baud-rate will also increase the probability of noise-induced.
RS232信号有效性
在 RS-232(推荐标准 232)中,信号电压被定义为代表二进制状态,通常用于串行通信。该标准为两种可能的状态规定了以下电压电平:
 1. 断言状态(逻辑 “0 ”或标记)
   - 电压范围: +3 至 +15 伏(相对于信号地线)
   - 描述: 在 RS-232 术语中,正电压代表 “断言 ”或 “标记 ”状态,相当于二进制通信中的逻辑 “0”。
 2. 非断言状态(逻辑 “1 ”或空白)
   - 电压范围: -3至-15伏(相对于信号地线)
   - 描述: 负电压表示 “断开 ”或 “空白 ”状态,对应二进制通信中的逻辑 “1”。
要点:
- 与典型的逻辑电平(0V 为逻辑 “0”,正电压为逻辑 “1”)相比,信号电压电平是反相的。
- RS-232 标准允许在确切的电压范围内有一定的灵活性,但在实际应用中,电压通常接近 ±12V。
- 介于 -3V 和 +3V 之间的电压是未定义的,被视为 “死区”,这意味着它们不能可靠地代表任何一种二进制状态。
这一电压范围有助于 RS-232 在相对较长的距离内保持可靠的通信,最长可达 15 米(50 英尺),具体取决于电缆质量和传输速度。
In RS-232 (Recommended Standard 232), signal voltages are defined to represent binary states, typically for serial communication. The standard specifies the following voltage levels for the two possible states:
1. Asserted State (Logical "0" or Mark)
   - Voltage Range: +3 to +15 volts (relative to the signal ground)
   - Description:** In RS-232 terminology, a positive voltage represents the "asserted" or "mark" state, which corresponds to a logical "0" in binary communication.
2. Deasserted State (Logical "1" or Space)
   - Voltage Range: -3 to -15 volts (relative to the signal ground)
   - Description: A negative voltage represents the "deasserted" or "space" state, corresponding to a logical "1" in binary communication.
Key Points to Remember:
- The signal voltage levels are inverted compared to typical logic levels (where 0V is logical "0" and a positive voltage is logical "1").
- The RS-232 standard allows some flexibility in the exact voltage ranges, but typically voltages closer to ±12V are common in practical implementations.
- Voltages between -3V and +3V are undefined and considered as a "dead zone," meaning they do not reliably represent either binary state.
This voltage range helps RS-232 maintain reliable communication over relatively long distances, up to 15 meters (50 feet) depending on cable quality and speed of transmission.
在RS-232标准中定义了逻辑一和逻辑零电压级数,以及标准的传输速率和连接器类型。信号大小在正的和负的3-15v之间。RS-232规定接近零的电平是无效的,逻辑一规定为负电平,有效负电平的信号状态称为传号marking,它的功能意义为OFF,逻辑零规定为正电平,有效正电平的信号状态称为空号spacing,它的功能意义为ON。电平有效范围在±3至±15伏之间。根据设备供电电源的不同,±5、±10、±12和±15这样的电平都是可能的。
mark和space是从电传打字机中来的术语。电传打字机原始的通信是一个简单的中断直流电路模式,类似与圆转盘电话拨号的中的信号。Marking状态是指电路是断开的,spacing状态就是指电路是接通的。一个space就表明有一个字符要开始发送了,相应的停止的时候,停止位就是marking。当线路中断的时候,电传打字机不打印任何有效字符,周期性的连续收到全零信号。
RS232实测电压
使用RS232的五根线进行通讯,RX/TX/GND/RTS/CTS,编号2/3/5/7/8。
RX/TX交叉连接,RTS/CTS也是交叉连接。
流控功能过程如下:
1,外设请求发送数据,assert 它的RTS信号,即电脑端的CTS信号。
2,电脑端可以接受数据,则assert 它的RTS信号,即设备端的CTS信号。
3,设备端发送数据后,deassert它的RTS信号。
RS232线束信号(同电脑端信号)
编号
空闲电压
RTS有效
CTS有效
RX
2
0V
0V
0V
TX
3
-3V
-3V
-3V
GND
5
0V
0V
0V
RTS
7
-3V
5V
-3V
CTS
8
0V
0V
5V
RX收到数据的波形,是0V和5V的方波。
TX发数据的波形,是-3V和5V的方波。
默认状态为高,logic 1,电压:RX 0V,TX -3V。状态低,logic 0,电压:RX 5V, TX 5V。
参考:
  • 16
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

夜流冰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值