1. History of Serial Ports
First of all, the serial port is an essential tool for anyone working with hardware and embedded software, especially when debugging a system with an MCU or CPU. Generally, the first thing we do during debugging is to light up the GPIO, and the second is to establish a communication link through the serial port.
The serial port is a very versatile device interface, commonly used as a communication interface for instruments and equipment, often for remote data collection or remote control. The development of serial ports is relatively straightforward, making it one of the favorite interfaces for many engineers.
After completing the GPIO lighting, we generally hope to implement serial printing functionality, which allows us to print some register information for easier debugging.
Due to my unique experience, for me, the serial port can be elaborated in detail, enough to fill a book! It should not be less than 200 pages.
In 2008, when I first joined Huawei, I encountered a special historical period where the embedded field was fiercely competitive.
1. Intel and AMD boldly claimed that the X86 system would enter the embedded field to capture the PowerPC market. (Later, Intel succeeded, with general-purpose servers dominating almost all telecom core devices—blade servers, rack servers).
2. At that time, MIPS, ARM, and PowerPC were closely matched, but multi-core ARM was immature and could not be widely applied in the telecom field. MIPS gradually faded due to its poor quality performance despite its excellent cost-performance ratio and high performance.
3. PowerPC also began to introduce multi-core processors in response to pressure from other processors.
My job at that time involved developing circuits for X86 processors as embedded systems. I encountered a problem: the traditional X86 architecture had already evolved very maturely as a PC. The hardware structure of PCs is significantly different from that of embedded SoCs.
Below the CPU is the Northbridge, responsible for high-speed peripherals, while the Southbridge is responsible for low-speed interface peripherals, and there is also an SIO responsible for even lower-speed peripherals.
The full name of SIO is Super I/O.
The Super I/O chip is generally located at the lower left or upper left of the motherboard. The main chips used include Winbond and ITE, providing control processing functions for standard I/O interfaces on the motherboard. The term “super” refers to its integration of processing functions for PS/2 keyboard, PS/2 mouse, serial COM, and parallel LPT interfaces, all of which are slow I/O devices in computers. They are all located at the back right of the motherboard. Its main functions include processing serial data transmitted from devices like keyboards, mice, and serial interfaces, converting them into parallel data, and also handling data transmission and processing for parallel interfaces and floppy drive interfaces. SuperIO connects to the Southbridge via a simplified PCI bus known as the LPC bus.
Such a complex hardware structure is also due to Intel’s strong shipment volume, forming its own system and standards.
Therefore, the RS232 serial port on traditional PC motherboards is realized through SuperIO. On X86, it is also accessed through fixed addresses.
As we are familiar with ARM, whether Cortex-M or Cortex-A, both an MCU and CPU come with a serial port—UART;
From the block diagram of the STM32F103 MCU selected for iBox, we can see a bunch of UART and USART interfaces.
However, in the embedded X86 system design requirements I faced at that time, there was no need for parallel ports, PS2, hardware monitoring, or FDC.
H/W Monitor: An application program that reads all measurement values from computer-accessible hardware sensors.
FDC: Provides an interface between the main processor and the floppy drive (Floppy drive—those who understand this are revealing their age).
Parallel port: Four modes are available: standard parallel port (SPP), bidirectional parallel port (BPP), enhanced parallel port (EPP), and extended capabilities parallel port (ECP). The input/output mode can be controlled via DIR.
Recognizing the above image reveals one’s age again.
KBC: The circuit provides functions including a keyboard and a PS2 mouse. The controller accepts serial data from the keyboard and mouse, checks for parity, and outputs this data to its output buffer. Some basic settings can be inferred from its read/write commands.
UART: Finally, we arrive at the protagonist of this article, UART, or the serial port. In older desktop computers or laptops, there is usually a UART that complies with the RS232 level standard.
Regarding various level standards for serial ports, we previously published related content:
UART, RS-232, RS-422, RS-485.
The UART output from the SuperIO is generally also TTL level, which needs to connect to an RS232 chip, then to a DB9 interface.
The addressing space of the X86 system is somewhat complex: in addition to memory space, there is also IO space. For detailed content, click:
Processor Series (7) – Addressing Space.
The IO space is where these low-speed peripherals like serial ports are accessed and read/written during X86 development:
From the UART Device Configuration Registers, we know that the base addresses for UART1~UART4 are 03F8H, 02F8H, 03E8H, and 02E8H, respectively.
GPIO: General-purpose input/output pins.
ACPI: ACPI is a system for controlling computer power.
For traditional telecom embedded systems implemented by PowerPC, other functions aside from the serial port are not required. At the same time, some NorFlash, registers, and sensor data need to be accessed via the MPI interface, which the SuperIO chip cannot achieve.
Additionally, due to the multifunctionality of SuperIO, it is large and has many pins.
Therefore, in the design requirements at that time, using a SuperIO was not suitable. Thus, we chose a CPLD to implement LPC interface control for the UART interface.
Since I have worked on such a project, I am particularly familiar with the working process of UART. Furthermore, we initially designed many registers according to our ideas, with addresses designed as we thought, resulting in commercial software like Windows and commercial Linux not being able to directly recognize the serial port. Later, we reverted to the base addresses: 03F8H, 02F8H, 03E8H, 02E8H.
2. Working Principles of Serial Ports
1. Let’s use a phone call as an example to explain the working principle of a serial port:
When making a phone call, speaking is serial, that is, saying one word at a time.
The sender sends information to the receiver serially:
Because the other party hears one word at a time, each word is sent to the other party in chronological order.
If we use GPIO to transmit signals, we can only transmit “high” and “low” levels; the signal can either be “high” or “low”. Therefore, when this pin transmits information, it has only two states, similar to a beacon tower, either “on” or “off”.
So when we use GPIO for lighting, it generally indicates two states: “on” and “off”.
However, these two states cannot meet our information transmission needs. Thus, we hope to transmit a series of “on” and “off” states to convey more complex information, similar to the principles of telegraphs or naval signal lights.
2. How to convert serial data to parallel?
Like making a phone call, we need to listen to a complete sentence, receive all the words, and then form words and sentences, receiving a complete sentence to understand its meaning.
Those who have studied digital circuits should still remember “shift registers”, right?
The rough idea is:
Initial state: Set A3A2A1A0 = 1011.
Then the output of Q3, at each clock cycle, outputs A3A2A1A0 serially in that order.
This utilizes the characteristics of D flip-flops.
If we use an 8-bit shift register, we can use the time of 8 clock cycles to send a group of 8-bit data through one wire.
The receiving process is similar, but in reverse:
3. Hey! XXXX Goodbye
When we make a phone call, we usually start with “Hello!”.
This is a signal notifying the other party: “I am going to start talking now”.
Because during a phone call, we cannot see each other, we do not know each other’s expressions, eyes, actions, or if they are listening to you. Therefore, we use a piece of information to notify the other party that communication is about to begin.
In the communication process of the serial port, similarly, we need to notify the other party: I am about to start communication.
In fact, many interface principles are similar: first, there needs to be a normal state, then a different state is sent to inform the other party that it has started!
For UART, there must first be a normal state—high level (as for why it is high level, there are various explanations, personally, I think it should not matter, reversing it does not affect either).
We need to send a message to the receiver, indicating that I am about to transmit data. The simplest method is to suddenly pull the level low, so that a falling edge can be detected, or a low level can be detected, indicating that we can consider the transmission has started.
UART has chosen such a simple and straightforward method:
The above figure shows that the low level at Start actually represents a start signal. We call this the “start bit”.
Similarly, when making a phone call, we need to say, “Goodbye”.
When I call my dad, he usually doesn’t say goodbye, leading to situations where I haven’t finished speaking, and he hangs up, causing me to have to redial.
This “goodbye” carries an additional meaning, indicating: “communication can stop now!”
So, UART also needs such a piece of information to notify the other party that I have finished speaking, and you can process it now.
This is the “stop bit”, and the method is also very simple: “high level”!
As shown in the above figure, STOP.
4. Baud Rate—Speech Speed
Since the A in UART stands for asynchronous:
(Universal Asynchronous Receiver/Transmitter)
Asynchronous means that when I send you a signal, I do not send you a clock;
The receiver needs:
1. The clock error between the sender and receiver cannot be too large.
2. The clocks for analyzing data on both sides need to be basically consistent.
For example:
If the sender sends a signal at 9600 baud rate, but the receiver’s baud rate is set to 19200, the start bit is fine because it can receive that falling edge, the low level. Therefore, it will parse the data, but errors will occur. We can analyze the signal:
In the white numbers, the intention sent at 9600 baud is: 01000001.
The result is that the receiver’s baud rate at 19200 is double that of 9600, and the sampling rate is also double, leading to the parsed data being: 00011000.
This creates an “error”.
This is why, when connecting serial ports, both sides need to unify the “baud rate”.
3. Level Standards for Serial Ports
1. TTL
Generally, the serial port tools used inside the board directly use TTL level standard UART, which is simple and easy to use, with low cost. The downside is that it cannot be transmitted over long distances.
2. RS-232 Standard
RS-232 is a serial physical interface standard established by the Electronic Industry Association (EIA) in the United States. RS is an abbreviation for “Recommended Standard”, and 232 is the identification number. RS-232 specifies the electrical and physical characteristics, only applying to the data transmission path, and does not include the data processing methods. It should be noted that many people often mistakenly refer to RS-232, RS-422, and RS-485 as communication protocols, which is incorrect. They are merely mechanical and electrical interface standards for UART communication (at most, they pertain to the physical layer of network protocols).
This standard specifies the use of a 25-pin DB-25 connector, detailing the signal content for each pin of the connector, as well as the electrical levels for various signals. Later, IBM’s PC simplified RS-232 to a DB-9 connector, which has become the de facto standard today. The industrial control RS-232 port typically only uses RXD (2), TXD (3), and GND (5) lines.
Early PCs were equipped with RS-232 interfaces, so when we needed to use UART, we chose RS-232. However, nowadays, personal computers, not only laptops but also desktops, no longer feature RS-232 interfaces. People see that computer motherboards lack DB9 ports. Therefore, current development boards typically choose TTL UART or directly UART to USB interfaces on the development board.
In embedded systems, the term serial port generally refers to the UART port, but we often cannot distinguish it from the COM port, as well as the relationships between RS232, TTL, etc. In fact, UART and COM refer to the physical interface form (hardware), while TTL and RS-232 refer to the level standards (electrical signals).
UART has four pins (VCC, GND, RX, TX), using TTL levels, where low level is 0 (0V) and high level is 1 (3.3V or more).
3. RS-485/RS-422 Standard
RS-232 Interface can achieve point-to-point communication, but this method cannot implement networking functions. Therefore, to solve this problem, a new standard RS-485 was developed. RS-485 uses differential signaling, also known as balanced transmission, utilizing a pair of twisted wires, defining one wire as A and the other as B.
Under normal circumstances, the positive voltage between the sending drivers A and B is +2 to +6V, representing one logical state, while the negative voltage is -2 to -6V, representing another logical state. There is also a signal ground C, and RS-485 has an “enable” terminal, which is optional in RS-422.
RS-422’s electrical performance is identical to that of RS-485. The main difference lies in: RS-422 has four signal lines: two for sending and two for receiving. Because RS-422 separates the receiving and sending lines, it can simultaneously receive and send (full duplex). Therefore, RS-422 is suitable for communication between two stations, star networks, and ring networks, but cannot be used in bus networks; RS-485 has only two signal lines and can only operate in half-duplex mode, commonly used in bus networks.
1. Electrical characteristics of RS-485: Logic “1” is represented by the voltage difference between the two lines being + (2~6)V; Logic “0” is represented by the voltage difference being – (2~6)V. The signal voltage levels of RS-232-C are lower than those of RS-485, making it less likely to damage the interface circuit chips, and these levels are compatible with TTL levels, facilitating connections with TTL circuits.
2. The maximum data transmission rate of RS-485 is 10Mbps.
3. RS-485 interfaces use a combination of balanced drivers and differential receivers, enhancing the ability to resist common mode interference, meaning they have good noise immunity.
4. The maximum communication distance of RS-485 is about 1219M, with a maximum transmission rate of 10Mb/S. The transmission rate is inversely proportional to the transmission distance. At a transmission rate of 100Kb/S, the maximum communication distance can be achieved; for longer distances, RS-485 repeaters are needed. The RS-485 bus generally supports up to 32 nodes, but with special RS-485 chips, it can reach 128 or 256 nodes, and in some cases, up to 400 nodes.
RS-423 is an unbalanced serial communication interface.
RS-422 is a balanced serial communication interface.
RS-485 is a serial communication bus.
Due to the early emergence of the RS-232 interface standard, it inevitably has some shortcomings, mainly four points:
(1) The signal voltage levels of the interface are relatively high, which can easily damage the interface circuit chips, and because the 232 levels are not compatible with TTL levels, a level conversion circuit is required to connect with TTL circuits.
(2) The transmission rate is relatively low; in asynchronous transmission, the baud rate is 20Kbps. However, due to the adoption of new UART chips, the baud rate has reached 115.2Kbps (1.832M/16).
(3) The interface uses one signal line and one signal return line, forming a common ground transmission method, which is prone to common mode interference, leading to weak noise immunity.
(4) The transmission distance is limited; the maximum standard transmission distance is 50 meters, but in practice, it can only be used for about 15 meters.
(5) RS-232 only allows one-to-one communication and does not consider forming a serial bus. (This point is crucial; in many control scenarios, one device controls multiple devices. If the master device needs to communicate point-to-point with each slave device, the wiring will become a spider web).
Unbalanced serial communication interfaces RS-423, RS-449.
Balanced serial communication interfaces RS-422.
RS-422 (EIA RS-422-A Standard) is the serial port connection standard for Apple’s Macintosh computers. RS-422 uses differential signaling. RS-232 uses unbalanced ground-referenced signals. Differential transmission uses two wires to send and receive signals. Compared to RS-232, it has better noise immunity and longer transmission distances, which is a significant advantage in industrial environments.
4. Comparison between RS-232 and RS-485
1. Noise immunity: The RS485 interface uses a combination of balanced drivers and differential receivers, providing good noise immunity. The RS232 interface uses one signal line and one signal return line, forming a common ground transmission method, which is prone to common mode interference.
2. Transmission distance: The maximum standard transmission distance for RS485 is 1200 meters (at 9600bps), but it can actually reach up to 3000 meters. The RS232 transmission distance is limited to a maximum standard value of 50 meters, but in practice, it is only usable for about 15 meters.
3. Communication capability: The RS-485 interface allows up to 128 transceivers to be connected on the bus, enabling users to easily establish a device network using a single RS-485 interface. RS-232 only allows one-to-one communication.
4. Transmission rate: RS-232 has a lower transmission rate; in asynchronous transmission, the baud rate is 20Kbps. The maximum data transmission rate for RS-485 is 10Mbps.
5. Signal lines: The RS485 interface forms a half-duplex network and generally requires only two signal lines. The RS-232 interface typically uses three lines: RXD, TXD, and GND.
6. Electrical voltage levels: In RS-485, logic “1” is represented by the voltage difference between the two lines being + (2~6)V; logic “0” is represented by the voltage difference being – (2~6)V. In RS-232-C, the voltage of any signal line is at a negative logic relation: logic “1” is -5 to -15V; logic “0” is +5 to +15V.
5. Comparison between RS-422 and RS-485
The electrical performance of RS-485 is identical to that of RS-422. The main differences are:
1. RS-422 has four signal lines: two for sending (Y, Z) and two for receiving (A, B). Since RS-422 separates the receiving and sending, it can simultaneously receive and send (full duplex).
2. RS-485 has only two data lines: sending and receiving are both A and B. Because RS-485 shares two lines for sending and receiving, it cannot simultaneously receive and send (half duplex).
RS-485 standards use balanced transmission and differential reception data transceivers to drive the bus, with specific specifications:
The input resistance of the receiver RIN ≥ 12kΩ.
The driver can output a common mode voltage of ±7V.
The input capacitance ≤ 50pF.
In the case of 32 nodes, with 120Ω termination resistors configured, the driver must still output a voltage of at least 1.5V (the size of the termination resistor is related to the parameters of the twisted pair used).
The input sensitivity of the receiver is 200mV (i.e., (V+) – (V-) ≥ 0.2V indicates signal “0”; (V+) – (V-) ≤ -0.2V indicates signal “1”).
Due to the characteristics of RS-485, including long distances, multi-node (32 nodes), and low transmission line costs, the EIA RS-485 has become the preferred standard for data transmission in industrial applications.
(1) RS-485 electrical characteristics: The sender logic “0” is represented by the voltage difference between the two lines being + (2 ~6)V; logic “1” is represented by the voltage difference being – (2 ~6)V. The receiver logic “0” is represented by A being higher than B by more than 200mV, while logic “1” is represented by A being lower than B by more than 200mV.
(2) The maximum data transmission rate of RS-485 is 10Mbps. However, since RS-485 often needs to communicate with the RS-232 port of a PC, the actual maximum is generally around 115.2Kbps. Due to high transmission rates, the transmission distance of RS-485 often decreases, so it is usually around or below 9600bps.
(3) RS-485 interfaces use a combination of balanced drivers and differential receivers, providing good noise immunity.
(4) The maximum standard transmission distance for RS-485 is 1200 meters (at 9600bps), but it can actually reach 3000 meters. The RS-485 interface allows up to 128 transceivers to be connected on the bus, meaning that users can easily establish a network using a single RS-485 interface. Because the RS-485 interface forms a half-duplex network, it generally requires only two signal lines. RS-485 international standards do not specify RS-485 connector standards, so terminal blocks or DB-9, DB-25 connectors can be used.
When using the RS-485 interface, for specific cable diameters, the maximum allowable cable length for data signal transmission from generator to load is a function of the data signal rate, which is mainly limited by signal distortion and noise. The maximum cable length and the relationship with the signal rate are obtained using 24AWG copper twisted telephone cables (diameter 0.51mm), with inter-wire bypass capacitance of 52.5PF/M, and terminal load resistance of 100 ohms (cited from GB11014-89 Appendix A). When the data signal rate drops below 90Kbit/S, assuming the maximum allowable signal loss is 6dBV, the cable length is limited to 1200m. In practice, it can achieve greater cable lengths.When using cables of different diameters, the maximum cable lengths obtained will vary.For example:When the data signal rate is 600Kbit/S, using 24AWG cable, the maximum cable length is 200m; if using 19AWG cable (diameter 0.91mm), the cable length can exceed 200m; if using 28AWG cable (diameter 0.32mm), the cable length can only be less than 200m.
For long-distance communication with RS-485, it is recommended to use shielded cables, with the shield layer serving as the ground.
6. Three Factors Affecting RS-485 Bus Communication Speed and Reliability
Signal Reflection in Communication Cables
During communication, two signal factors cause signal reflection: impedance discontinuity and impedance mismatch.
Impedance discontinuity occurs when the signal encounters a very small or no cable impedance at the end of the transmission line, causing reflection at that point. This principle of signal reflection is similar to light reflecting when entering another medium. To eliminate such reflections, a terminal resistor matching the characteristic impedance of the cable must be connected at the end of the cable to ensure continuity. Since signals on the cable are transmitted bidirectionally, a similar terminal resistor can be connected at the other end of the communication cable.
Theoretically, as long as a terminal resistor matching the characteristic impedance of the cable is connected at the end of the transmission cable, signal reflection should not occur. However, in practical applications, due to the characteristic impedance of the transmission cable and the communication baud rate, it is impossible for the characteristic impedance to match the terminal resistor completely, so some level of signal reflection will still exist.
The second cause of signal reflection is the impedance mismatch between the data transceiver and the transmission cable. This leads to reflection, primarily manifested when the communication line is idle, causing data chaos across the network.
The impact of signal reflection on data transmission ultimately arises because the reflected signal triggers the comparator at the input of the receiver, causing the receiver to receive erroneous signals, resulting in CRC check errors or entire data frame errors.
In signal analysis, the parameter used to measure the strength of reflected signals is the RAF (Reflection Attenuation Factor). Its calculation formula is as follows:
RAF=20lg(Vref/Vinc) (1)
Where: Vref—Voltage size of the reflected signal; Vinc—Voltage size of the incident signal at the connection point between the cable and the transceiver or terminal resistor.
The specific measurement method is illustrated in the figure. For example, if the peak-to-peak value of the incident sine wave at 2.5MHz is +5V, and the peak-to-peak value of the reflected signal is +0.297V, then the reflection attenuation factor of this communication cable at 2.5MHz is:
RAF=20lg(0.297/2.5)=-24.52dB
To mitigate the impact of reflected signals on communication lines, noise suppression and adding bias resistors are commonly used methods. In practical applications, for relatively small reflected signals, the method of adding bias resistors is often used for simplicity. The principle of how to improve communication reliability through bias resistors in communication lines.
Signal Attenuation in Communication Cables
The second factor affecting signal transmission is the attenuation of signals during transmission through the cable. A transmission cable can be viewed as an equivalent circuit composed of distributed capacitance, distributed inductance, and resistance.
The distributed capacitance C of the cable mainly arises from the two parallel conductors of the twisted pair. The resistance of the conductors has a negligible effect on the signal. The signal loss is primarily due to the LC low-pass filter formed by the distributed capacitance and distributed inductance of the cable. The attenuation coefficients for LAN standard two-core cables used in PROFIBUS (the standard cable selected for Siemens DP bus) at different baud rates are shown in the table.
Attenuation Coefficients of Cables
Pure Resistive Load in Communication Cables
The third factor affecting communication performance is the size of the pure resistive load (also known as DC load). This refers to the pure resistive load primarily consisting of terminal resistors, bias resistors, and RS-485 transceivers.
In the EIA RS-485 specification, it was noted that RS-485 drivers can output at least 1.5V differential voltage under the condition of 32 nodes and configured with 150Ω terminal resistors. The input resistance of a receiver is 12kΩ, and the equivalent circuit of the entire network is illustrated in the figure. Based on this calculation, the load capacity of the RS-485 driver is:
RL=32 input resistances in parallel with 2 terminal resistors = ((12000/32)×(150/2))/((12000/32)+(150/2))≈51.7Ω
Currently, commonly used RS-485 drivers include MAX485, DS3695, MAX1488/1489, and SN75176A/D used by Holley, some of which can achieve a load capacity of 20Ω. Without considering many other factors, based on the relationship between driving capacity and load, the maximum number of nodes a driver can support will far exceed 32.
When the communication baud rate is relatively high, the use of bias resistors on the line is essential. The connection method for bias resistors is illustrated in the figure. Their role is to pull the level away from 0V when there is no data (idle mode) on the line, as shown in the figure. This way, even if small reflected signals or interference occur in the line, the data receivers connected to the bus will not malfunction due to the arrival of these signals.
Through the following example, we can calculate the size of the bias resistor:
Terminal resistor Rt1=Rr2=120Ω;
Assuming the maximum peak-to-peak value of the reflected signal Vref≤0.3Vp-p, then the negative half-cycle voltage Vref≤0.15V; the reflection current Iref caused by the reflected signal on the terminal resistor ≤0.15/(120||120)=2.5mA. Generally, the hysteresis voltage value of RS-485 transceivers (including SN75176) is 50mV, i.e.:
(Ibias-Iref)×(Rt1||Rt2)≥50mV
Thus, we can calculate the bias current produced by the bias resistors Ibias≥3.33mA
+5V=Ibias(Rup+Rdown+(Rt1||Rt2)) (2)
From equation (2), we can calculate Rup=Rdown=720Ω.
In practical applications, there are two methods for adding bias resistors to the RS-485 bus:
(1) Distributing the bias resistors evenly among each transceiver on the bus. This method adds bias resistors to each transceiver connected to the RS-485 bus, providing a bias voltage to each transceiver.
(2) Using a pair of bias resistors on a section of the bus. This method is effective against significant reflected or interference signals on the bus. It is worth noting that adding bias resistors increases the load on the bus.
7. Relationship Between Load Capacity of RS-485 Bus and Length of Communication Cable
When designing the network configuration (bus length and number of loads) for an RS-485 bus, three parameters should be considered: pure resistive load, signal attenuation, and noise margin. The first two parameters have been discussed previously, and now we will discuss noise margin (Noise Margin). The noise margin of RS-485 bus receivers should be at least greater than 200mV. The previous discussions assumed a noise margin of zero. In practical applications, to enhance the bus’s anti-interference capability, we hope the system’s noise margin is better than that specified in the EIA RS-485 standard. The relationship between the number of loads on the bus and the length of the communication cable can be seen from the following formula:
Vend=0.8(Vdriver-Vloss-Vnoise-Vbias)(3)
Where: Vend is the signal voltage at the end of the bus, which is set to 0.2V during standard measurement; Vdriver is the output voltage of the driver (which depends on the number of loads. For 5 to 35 loads, Vdriver=2.4V; when the number of loads is less than 5, Vdriver=2.5V; when the number of loads exceeds 35, Vdriver≤2.3V); Vloss is the loss of the signal during transmission in the bus (related to the specification and length of the communication cable), and the standard cable’s attenuation coefficient is provided in the table; based on the formula, the attenuation coefficient b=20lg(Vout/Vin), we can calculate Vloss=Vin-Vout=0.6V (Note: the communication baud rate is 9.6kbps, and the cable length is 1km; if the baud rate increases, Vloss will also increase); Vnoise is the noise margin, which is set to 0.1V during standard measurement; Vbias is the bias voltage provided by the bias resistors (typical value is 0.4V).
Equation (3) multiplies by 0.8 to prevent the communication cable from entering a fully loaded state. From equation (3), we can see that the size of Vdriver is inversely proportional to the number of loads on the bus, while the size of Vloss is inversely proportional to the length of the bus. The other parameters are only related to the type of driver used. Thus, once the RS-495 driver is selected, the number of loads on the bus directly correlates with the maximum distance that signals can be transmitted. The specific relationship is: within the allowable range of the bus, the more loads, the shorter the distance signals can be transmitted; the fewer loads, the longer the distance signals can be transmitted.
8. Impact of Distributed Capacitance on RS-485 Bus Transmission Performance
The distributed capacitance of the cable mainly arises from the two parallel conductors of the twisted pair. Additionally, there is also distributed capacitance between the conductors and ground, although it is small, it cannot be ignored during analysis. The impact of distributed capacitance on bus transmission performance primarily occurs because the transmitted signal is a fundamental wave signal, and the signal expression only has “1” and “0”. In special bytes, such as 0x01, the signal “0” allows sufficient charging time for the distributed capacitance, while when the signal “1” arrives, due to the charge in the distributed capacitance, it cannot discharge in time, causing (Vin+) – (Vin-) to exceed 200mV, leading the receiver to mistakenly identify it as “0”, ultimately resulting in CRC check errors and incorrect transmission of the entire data frame. The specific process is illustrated in the figure.
Due to the distributed effects on the bus, data transmission errors occur, leading to reduced overall network performance. Two solutions to this issue include:
(1) Reducing the data transmission baud rate;
(2) Using cables with low distributed capacitance to improve the quality of the transmission line.
Simply connecting the A and B ends of various interfaces with a pair of twisted wires without grounding the RS-485 communication link’s signal may work under certain conditions, but it poses hidden dangers for the system. The RS-485 interface uses differential signaling to transmit signals without the need for a reference point to detect the signal system; it only needs to detect the potential difference between the two wires. However, it is important to note that the transceiver can only function correctly when the common mode voltage does not exceed a certain range (-7V to +12V). When the common mode voltage exceeds this range, it can affect communication reliability or even damage the interface.
4. Transmission Distance of Serial Cables
The serial interface refers to the sequential transmission of data one bit at a time, characterized by a simple communication line, requiring only a pair of transmission lines for bidirectional communication (telephone lines can be directly used as transmission lines), significantly reducing costs, especially suitable for long-distance communication, but with slower transmission speeds. The transmission distance of serial communication can range from a few meters to several kilometers. Based on the direction of information transmission, serial communication can be further divided into simplex, half-duplex, and full-duplex.
In summary:
The two most basic ways of serial communication are synchronous serial communication and asynchronous serial communication.
Synchronous serial refers to SPI (Serial Peripheral Interface), which, as the name suggests, is a serial peripheral device interface. The SPI bus system is a synchronous serial peripheral interface that allows MCUs to communicate with various peripheral devices in a serial manner to exchange information; TRM450 is an SPI interface.
Asynchronous serial refers to UART (Universal Asynchronous Receiver/Transmitter), which is a chip that converts parallel input into serial output, typically integrated into the motherboard. UART includes both TTL level serial ports and RS232 level serial ports. TTL level is 3.3V, while RS232 is a negative logic level, defining +5 to +12V as low level and -12 to -5V as high level. MDS2710, MDS SD4, EL805, etc. are RS232 interfaces, while EL806 has a TTL interface.
Serial interfaces are categorized by electrical standards and protocols, including RS-232-C, RS-422, RS-485, etc. RS-232-C, RS-422, and RS-485 standards only specify the electrical characteristics of the interface without addressing connectors, cables, or protocols.
RS-232:
Also known as the standard serial port, it is the most commonly used serial communication interface. It was established in the 1970s by the Electronic Industry Association (EIA) in conjunction with Bell Systems, modem manufacturers, and computer terminal manufacturers as a standard for serial communication. Its full name is “Serial Binary Data Exchange Interface Standard Between Data Terminal Equipment (DTE) and Data Communication Equipment (DCE).” The traditional RS-232-C interface standard has 22 wires and uses a standard 25-pin D-type plug (DB25), which was later simplified to a 9-pin D-type socket (DB9), and the 25-pin plug socket is now rarely used in applications.
RS-232 adopts an unbalanced transmission method, known as single-ended communication. Because the voltage difference between the sending level and receiving level is only about 2V to 3V, its common mode rejection capability is poor, and coupled with the distributed capacitance on the twisted pair, its maximum transmission distance is about 15 meters, with a maximum speed of 20kb/s. RS-232 is designed for point-to-point communication (i.e., only one pair of receiving and sending devices), with a driver load of 3 to 7 kΩ. Therefore, RS-232 is suitable for communication between local devices.
RS-422
The full name is “Electrical Characteristics of Balanced Voltage Digital Interface Circuits”, which defines the characteristics of the interface circuit. A typical RS-422 is a four-wire interface. In fact, there is also a signal ground wire, totaling five wires. Its DB9 connector pin definitions. Due to the high input impedance of the receiver and stronger driver capability than RS232, it allows multiple receiving nodes to be connected on the same transmission line, supporting up to 10 nodes. That is, one master device (Master) and the others as slave devices, with no communication between slave devices, allowing RS-422 to support bidirectional communication from point to multiple devices. The input impedance of the receiver is 4k, thus the maximum load capacity of the sender is 10×4k+100Ω (termination resistance). The maximum transmission distance for RS-422 is 1219 meters, with a maximum transmission rate of 10Mb/s. The length of the balanced twisted pair is inversely proportional to the transmission rate; only at baud rates below 100kb/s can the maximum transmission distance be achieved. The maximum transmission rate can only be achieved over very short distances. Typically, the maximum transmission rate on a 100-meter long twisted pair is only 1Mb/s.
RS-485
RS-485 is developed based on RS-422, so many electrical specifications of RS-485 are similar to those of RS-422. Both use balanced transmission and require termination resistors on the transmission line. RS-485 can be configured in both two-wire and four-wire modes; the two-wire configuration allows true multi-point bidirectional communication, while the four-wire connection, similar to RS-422, can only achieve point-to-multiple communication, meaning there can only be one master device and the rest are slave devices. However, RS-485 has improved capabilities, allowing up to 32 devices to be connected on the bus in either configuration.
Another difference between RS-485 and RS-422 is their common mode output voltages: RS-485 is between -7V and +12V, while RS-422 is between -7V and +7V. The minimum input resistance for RS-485 receivers is 12kΩ, while for RS-422, it is 4kΩ. Since RS-485 meets all the specifications of RS-422, RS-485 drivers can be used in RS-422 networks.
Like RS-422, RS-485 has a maximum transmission distance of about 1219 meters and a maximum transmission rate of 10Mb/s. The length of the balanced twisted pair is inversely proportional to the transmission rate; only at baud rates below 100kb/s can the maximum cable length be used. The maximum transmission rate can only be achieved over very short distances. Typically, the maximum transmission rate on a 100-meter long twisted pair is only 1Mb/s.
👇 Click Follow for timely delivery of technical content! 👇

-
Comprehensive Understanding of MOSFETs, One Article is Enough
-
Summary of Common Power Automatic Switching Circuits
-
27 Common Power Symbols in Circuit Design!
-
A Senior Student Self-Manufactured 555 Chip for Learning Digital Circuits
-
Discussing MOSFETs from a Practical Perspective
-
Detailed Explanation of IIC Principles—Worth a Look
-
Sharing a PID Library Directly for Project Development! Very Useful!
