Only one line of data is transmitted at a time, and only one bit can be transmitted at a time using serial communication. One byte must be transmitted eight times in order to be received. Serial communication refers to the transmission of data strings via a single wire, which is why it's called a serial port.
In the event of low-rate requirements, sending data over a single line is extremely convenient and practical.
The asynchronous serial communication requires the format indicated below in order to send and receive proper data in a normal manner.
Figure. 1
There are various parameters in the serial port's communication parameters, including baud rate, start bit, data bit, parity bit, and stop bit.
Serial communication is mainly divided into 232, 485, 422 three communication methods, what is the difference between these three?
01 232 Communications
Figure. 2
RX, TX, and GND are the three lines that make up 232 communication. TX is linked to RX, RX is linked to TX, and GND is linked to GND, In this case, transmitting and receiving are handled by separate lines, allowing data to be transferred and received at the same time, a technique known as full-duplex communication.
To elaborate on this, full-featured serial communication, also known as a standard serial port, is another function of serial communication. Some devices process data faster than others due to data flow between two devices. Several control pins were added on the basis of RX and TX to assure normal data transfer, and finally, 9 pins were added, which is the common DB9, as shown in the diagram below.
Figure. 3
Many controllers, human-machine interfaces, PLCs, and other devices nowadays do not use traditional serial ports for serial communication, instead of using three lines of RX, TX, and GND.
02 485 communication
Figure. 4
485 was created to address the issue of 232's short communication distance.
The + and - two lines, often known as A and B lines, are all that are required for 485 communication. As data signals, the differential level signals of the two lines A and B are conveyed. Because these two lines are utilized for both sending and receiving, they can only be used for one of these functions at a time. As a result, 485 is a half-duplex mode of communication.
This is how the efficiency of 232 full-duplex is sacrificed in order to accomplish the expense of its great transmission distance.
03 422 Communications
The appearance of 422 is to realize the full-duplex communication method of 232 while also increasing the transmission distance to 485. The 422 is also known as 485-4, whilst the 485 is known as 485-2. The following diagram is a schematic illustration of 422 because 485-2 is two lines and 485-4 is four lines.
Figure. 5
422 is the result of dividing 232's RX into two lines, RX+ and RX-, and TX into TX+ and TX-. This allows you to send and receive data at the same time, as well as have a longer transmission distance of up to 485. However, such a beneficial communication strategy is rarely used. 232 and 485 are the most regularly utilized.
1. The computer can communicate with the device using the USB to a serial port, but it cannot communicate with the device if it is replaced by the screen?
1) It's possible that the computer's USB to the serial port is linked to the device using the conventional serial port function, which means that other pins are used in addition to RX, TX, and GDN. Some pins on Omron and Mitsubishi PLCs, for example, must be short-circuited in order to communicate with the screen.
2) The computer scans the baud rate parameters while communicating with the controller or PLC, and adaptive screen communication may have fewer parameters than the equipment. There is a procedure for altering the baud rate for communication interaction in PLCs such as Mitsubishi and Keyence.
3) Another possibility is that the wiring method used is improper. Because male and female headers are required on some DB9s. There will be locations where TX is connected to TX and RX is connected to RX if you don't pay attention, so pay attention.
4) It should be noted that some serial helpers may be utilized to send test data to the controller at times. Please remind me because the parity check on some serial helpers does not work.
2. The screen of home A can communicate with the device, but the screen of home B cannot communicate?
1) Verify that the wiring is in order and that the RX and TX are compatible.
2) Check to see if the ground wire is connected.
3) Are there any more pins that need to be shorted in addition to RX, TX, and GND?
4) Whether the communication protocol is comprehensive or inconsistent, as well as the baud rate.
3. In the past, communication was possible without a ground wire. Why does a ground wire need to be changed for another device?
Because certain devices employ isolated power supply, this question is similar to the prior one. It used to be possible to communicate without grounding, but it's possible that the ground wire has been connected, allowing communication. It can be replaced with an isolated power supply, and because the grounds of the two devices are isolated, the ground wires on the serial port must be connected.
4. One device is 232, the other is 422, and there is no conversion device, what should I do?
Because these two are full-duplex, receiving and transmitting are divided, and 422 is only transmitted as a differential signal, I also mentioned the wiring of 422 and 232 just now.
Connect the RX+ of the 422 to the 232's TX, and the RX- of the 422 to the 232's GND,
Connect the TX+ of the 422 to the 232's RX, and the TX- of the 422 to the 232's GDN.
If the 422 device wants to convey data, it can do so by sending it to the 232's RX. Because TX and GND produce a differential signal to 422, 422 can receive data after the TX of 232 sends data.
5. No problem with 232 communication, no problem with 485 communication, after using 232 to 485, the communication is unstable?
The greatest distinction between 232 and 485 in terms of communication concept is the difference between full duplex and half duplex. The application layer, on the other hand, sends and receives data in either full-duplex or half-duplex mode.
However, 485 must be handled. Because it is half-duplex, it must be ensured that only sent or received data can pass via the path. The data will clash if both transmitting and receiving are enabled. As a result, the master station device, or the party that actively directs, must strictly manage the frequency with which data commands are sent. Of course, certain 232 to 485 devices are better, and this can be improved, but the master station must still control, and changing the communication rate is relatively sluggish.
6. What is the best way to achieve two screens or two master stations accessing Modbus devices through 485?
There is essentially one master and several slaves in 485 communication. Some clients, on the other hand, prefer to use two screens to access a Modbus device in practice. There is currently no viable option.
7. Weakness of serial communication?
1) When dealing with signal interference, it's best to utilize insulated cables and adhere to stringent wiring guidelines, such as grounding. Connecting a terminating resistor to match is also considered in some 485 communications. If the number is 232, keep the line short. Try to avoid data exchange of large messages in the communication protocol.
2) The baud rate matching issue Because the different crystal oscillators utilized produce inaccuracy in the computed baud rate of some devices, particularly controllers. As a result, at some baud speeds, such as 9600 baud, there is an error. What effect does the presence of errors have? Because the receiver performs a bit-by-bit calculation. If a message is too long, there will be an accumulation of errors, and the calculation will be skewed. As a result, there are some places where serial communication is unreliable, and care should be taken to prevent transmitting packets with very long data.
3) In some circumstances when there may be interference, you may want to consider utilizing odd parity or even parity since, while the likelihood of mistakes is low, if parity is added, at least erroneous packets can be filtered. Lose. It's as if there's no verification, and then the communication data is incorrect, and I'm not sure what to do. To avoid data errors, try using protocols with checksums.
4) Serial communication is inherently slow; therefore, please limit the data response requirements, as the serial transmission is slower than Ethernet. In addition, unlike a CPU, serial transmission is not multi-threaded. Even if you apply it to the software and how to utilize multi-threading to process the data, there is only one port at the bottom, and only one bit and one byte can be passed at a time since the data is sent out one port and one line. Because some customers communicate at a 9600 baud rate, how much data can be processed in how many milliseconds?
However, serial communication must be realistic, thus a thorough understanding of the protocol is beneficial to application development, testing, and communication.
8. Why not use synchronous communication?
As previously stated, synchronous communication is dependent on the clock signal. Who initiates this clock signal is a problem. A master device is frequently necessary to initiate a clock signal in synchronous communication in order to read the slave module's data. There are screen-reading PLCs and screen-reading data in practice. There is no master-slave relationship in asynchronous serial communication; both parties play equal roles and can transmit and receive data from each other. The CPU uses synchronous communication to read some modules, and the CPU begins the clock signal, such as reading the SD card module (which can be done via SPI ) and some sensor modules.