The difference between the interfaces of 485 and 232

To connect things to each other, a “bridge” is needed. Computers to computers, or computers to terminals, still need media. Data transmission between them can use two methods: serial communication and parallel communication. The serial communication method is widely used because of its fewer lines, low cost, and line diversity, especially in long-distance transmission.

With the development of science and technology, communication interfaces are becoming more and more abundant. Common ones are RS232, RS422, RS485, etc. RS is the abbreviation of “Recommended Standard” in English. In the Chinese market, there are currently two most commonly used communication interfaces for connecting to computers: RS232 and RS485.

Both are serial ports, so what is the difference between RS232 and RS485?

1. Composition structure

RS232 uses three-core wire communication, and RS485 uses two-core wire communication. They can both use the DB9 interface. In specific use, the transmission distance of RS232 is relatively short, while the transmission distance of RS485 is relatively long.

RS232 uses 3 wires (RX, tx, GND), transmitting and receiving at the same time, and is more efficient than RS485. However, 3 wires are inconvenient to expand the network, and are suitable for single-point rapid communication between two devices over short distances.

RS485 uses 2 wires (D, D-) to send and receive alternately. The 2 wires are convenient for multiple devices to be connected in series to form a network, and are suitable for medium and long-distance communication between multiple devices.

2. Network structure

RS232 is 1:1 communication, that is, one-to-one.

RS485 is a 1:n communication method, that is, one-to-many. The RS485 interface allows the connection of up to 128 transceivers on the bus, one of which serves as the master and the others as slaves. The polymorphic slaves are distinguished by address codes.

3. Programming

From the perspective of microcontroller programming, RS232 and RS485 only have different driver chips. RS485 is half-duplex and RS232 is full-duplex. There is a difference during programming.

The RS485 chip cannot receive and send at the same time, so the microcontroller as the host must delay before receiving the data after issuing the command. When RS485 is sending, it needs to be converted to the sending state, the sending is completed, and then converted to the receiving state.

Half-duplex mode: The devices on both sides of the communication are both transmitters and receivers. The two devices can transmit data to each other, but they can only transmit data in one direction at a time. For example, a walkie-talkie is a half-duplex device because only one party can talk at a time.

Full-duplex mode: The devices on both sides of the communication are both transmitters and receivers. The two devices can transmit data in both directions at the same time. For example, a telephone is a full-duplex device because both parties can speak at the same time.

Kontakt