A few days ago, I saw discussions in my technical group about the topic of “TTL, RS232, and RS485 transmission distances“.
Today, I took some time to share relevant content.
Many readers might not know what TTL, RS232, and RS485 are, so this section provides a brief overview of them.
TTL: Transistor-Transistor Logic, a type of logic level.
For example: 0V represents a logic low level, and 5V represents a logic high level. The logic high level output from the serial port pins of an STM32 microcontroller is 3.3V.
You might ask: What is a logic level?
Logic levels are specific voltage states or signal states that usually represent “0/1” or “on/off” or “ON/OFF” or “LOW/HIGH”, etc.
With the rapid development of electronic technology, the voltage of logic high levels is also decreasing, for example, DDR5 memory operates at a supply voltage of only 1.1V.
RS232, also known as 232, stands for EIA-RS-232.
EIA: Electronic Industry Association, the American Electronic Industry Association.
RS: Recommended Standard, which represents a recommended standard.
232: represents the identification number.
RS232 has multiple versions, such as RS232A, RS232B, RS232C···F, etc., with RS-232C being the most commonly used today.
RS232 was initially used for modems, so its pin definitions relate to modem transmission.
Early on, RS232 commonly used 25-pin connectors (DB25), which were used for devices like early printers and fax machines, though they are rarely used now.
Many people may not have seen them; when I was in college, I used this DB25 interface to download programs to the MSP430.
Now, the DB9 connector is commonly used, which I believe everyone is familiar with, but we usually only use pins 2, 3, and 5.
DB9 still retains its place on many computer rear panels; even if it is not on the rear panel, it is still available on the motherboard. (Recently, when I built a computer, I specifically bought an external DB9 interface.)
RS485 can be said to have developed on the basis of RS232, aimed at “increasing anti-interference capability and signal transmission distance“.
RS232 uses voltage to represent logic high and low levels, for example: ±15V.
RS485 uses differential voltage, which means the voltage difference between two signal lines (A and B) represents the logic high and low levels.
RS232 supports full-duplex communication, while RS485 is half-duplex communication.
In college, teachers might tell you that the transmission distance of RS232 is 15 meters. Or, you might see in some books that the transmission distance of RS485 is 1200 meters.
Communication transmission distance is related to many factors; the actual distance can differ significantly from theoretical values. In some cases, transmitting RS485 over 500 meters might even be problematic.
Communication transmission distance is influenced by communication methods, baud rate, connection cables, interference, and many other factors, and here I will briefly discuss these issues in conjunction with UART communication.
The communication methods mentioned here refer to the different communication methods such as “TTL, RS232, and RS485” in the title.
Under normal circumstances, the communication distance is: TTL < RS232 < 485.
TTL is usually used within a board (on the same board), for example: communication between the serial port of chip A and the serial port of chip B.
RS232 is still used in many scenarios, typically for communication between devices, usually connected by DB9 or two signal wires. (In a previous project, I expanded 8 serial ports using a computer PCI card, which used RS232.)
RS485 is used more in industrial products, where multiple devices can connect on the 485 bus, allowing for longer transmission distances and stronger anti-interference capabilities.
Baud rate, 1 baud means transmitting 1 symbol per second. Baud (Bd) is the unit for symbols.
You can think of it as the speed of signal transmission, for example: serial port 9600 bps.
The higher the baud rate, the higher the frequency, and under the same conditions, the shorter the transmission distance.
The baud rate of a serial port can be quite high, for example: 115200 bps, but transmitting at this baud rate over RS232 might cause issues after just 10 meters.
Connection cables are also a key factor; the material (copper, aluminum, iron), thickness, and whether they are shielded can all affect the transmission distance of signals.
In a clean environment (like a laboratory or office), differences might not be noticeable, but in more complex environments (like factories, especially those with large machinery), you will feel the difference.
Thus, RS485 uses differential signals with twisted pairs, and better quality cables with shielding show advantages in industrial environments.
Those who have worked on industrial products know that not only are EMC requirements high, but communication requirements are also stringent.
If a large device starts up nearby, it can easily disrupt your communication (or cause chip resets, crashes, etc.).
You might think RS485 can transmit 1200 meters, but in a factory, even 200 meters of communication might fail.
In summary, to increase transmission distance while ensuring stable signal transmission, it is usually necessary to stay as far away from interference sources (large machinery), increase shielding measures, and reduce transmission rates (baud rate), etc.