Consider a DC power supply with an output socket interface that has three pins: positive, negative, and ground. Accordingly, the load’s plug should also have three pins corresponding to the power supply side to correctly obtain power supply.
Note that there are three essential conditions that must be met:
The first is that the shape, size, pin diameter, and length of the plug and socket pins must correspond one-to-one; otherwise, the connection cannot be completed. This stipulates the physical structure and pin definitions of the plug combination.
The second is that the output voltage of the power supply must meet the requirements of the load side; otherwise, the electrical parameters cannot be satisfied. This determines the voltage specifications of the plug combination.
The third is that the output impedance of the power supply must match the input impedance of the load; otherwise, proper power supply cannot be achieved. This determines the operational characteristics of the power supply.
These three points essentially define the normative protocol of the power supply plug combination at the physical level.
Now, let’s look at communication interfaces. In the ISO/OSI model related to computer information exchange, the physical layer is the lowest layer (Layer 1), which specifies the mechanical appearance of the interface, pin definitions, interface levels, and byte formats.
The byte format here refers to how many data bits are in a byte, how many start/stop bits there are, and how many parity bits there are. Generally, a byte has 8 data bits, 1 start bit (stop bit), and 1 parity bit. Note: Start and stop bits can be combined.
Next, let’s examine the operational modes of communication interfaces and networks.
When we make a phone call, we find that both parties can talk and listen simultaneously; this is called full duplex (two-way operation mode); if one party cannot listen while speaking, and cannot speak while listening, but either party has the ability to speak and listen, this is called half duplex, similar to a walkie-talkie communication style.

(Note: These images are excerpts from a PPT I made at ABB regarding MODBUS communication; they are somewhat dated, but the basic content is correct. These images are for reference.)
RS422 and RS232 interfaces are full duplex interfaces, while RS485 is a half duplex interface.
For half duplex interfaces, there must be a communication initiator; thus, the RS485 interface and network must have a master station and several slave stations, with a specified number of slaves. Generally, the number of slaves is 32.
The relationship between the RS485 master and slave stations seems to be merely a difference in communication modes, but essentially it is a reasonable allocation of control rights over the communication bus among the parties involved.
Now, let’s look at bus connection issues.
Using the power supply as an example, we can draw a main line from the power supply and then parallel several branches to supply several loads. As long as the power supply’s power requirements are met, this is evidently feasible.
However, if we use the same method to draw out the RS485 communication line, is it feasible? The answer is no. We must first draw a line from the communication master station to the first communication slave station, then draw a second line from the first slave station to the second slave station, and so on until the last slave station. At the end of the communication line, a termination resistor must be added. If a break occurs at any point on this communication line, communication on subsequent links will also be interrupted. This wiring method is vividly referred to as the daisy chain connection method, or chain connection method, while the power supply wiring method is called the star connection method.


From an electrical wiring perspective, the link is parallel. However, from a communication perspective, the link is daisy-chained, representing an orderly connection one after another.
Now we can summarize:
The wiring method for the RS485 bus network must be a daisy chain connection method, and it is a half duplex communication method; RS232 is a point-to-point wiring method, belonging to full duplex communication. Whether it is the RS232 interface or the RS485 interface, they must comply with the communication specifications of the physical layer.
Next, let’s look at the MODBUS-RTU communication protocol:
Having a physical layer communication interface, does that mean communication can occur? The answer is no. The physical layer communication interface only provides the conditions for communication. However, if neither party understands what the other is saying, or if the communication methods and syntax structures do not match, communication cannot occur.
In the OSI model, above the physical layer is the data link layer. The MODBUS-RTU protocol is a data link layer protocol; as long as both parties use the MODBUS-RTU protocol, it ensures that the communication language is in a format that both can understand.
Note the term “statement” here. The physical layer defines bytes, which are equivalent to words in a language, while the data link layer organizes bytes into statements, i.e., frames. Frames define the syntax structure of the statements used by both parties in communication.
MODBUS is also master-slave structured. Similar to the bus control at the physical layer, the master-slave relationship here specifies the control rights over the communication bus. The master station first issues commands, occupying the bus; then it vacates the bus for the slave station to write response codes; after the slave completes, it returns the bus to the master station.
Now let’s look at the frame structure defined by ISO’s HDLC, which is the syntax structure of communication statements, as follows:

Under the MODBUS communication protocol, different command function codes have different frame structures. For the read register command, the frame structure for the MODBUS master station is: 2 bytes of address code, 1 byte of function code, 2 bytes of data address code, and 2 bytes of CRC check code; the frame structure for the MODBUS slave response is: 2 bytes of function code, 1 byte of total number of response bytes, N bytes of response data, and 2 bytes of CRC check code.
Although the physical layer protocol and data link layer protocol are different, the execution of the data link layer protocol must be based on the requirement that the physical layer connections of both parties have been established and can exchange information without barriers.
This rule must be thoroughly executed in the seven-layer protocol of the ISO/OSI model. In the ISO/OSI model, the lower-level protocols of both parties must establish a transparent and fault-free connection and information exchange relationship for the upper-level protocols. In other words, the hierarchical relationship between layers must be absolute.
Above the data link layer is the network layer. Its task is to form the information exchange network of the field bus.
The functions of the network layer include: packaging communication frames into data packets and then sending the data packets to the other party.
Since the network structures of both parties may differ, the same type of network requires a bridge to connect, while different types of networks require a gateway to connect.
There may be multiple channels between networks. Data packets can choose from various paths when sending. The component responsible for selecting paths is called a router. The router not only determines the actual data exchange network path but can also construct virtual network paths and decide the order of data packet transmission. Therefore, the router is the most complex and critical equipment in the network layer.
In the OSI model, the physical layer + data link layer + network layer is collectively referred to as the field bus, and its communication interface is the 8-pin RJ45 crystal head. It is evident that RJ45 is completely different from RS232/RS485/RA422.
The data packets at the network layer are combinations of data frames. In simple terms, a data packet is a short article or a unit of data to be transmitted.
The routing issues and reception combination issues of data packets at the network layer are shown in the following diagrams:


We see that at the network layer, the router first determines the routing path during communication, and then sends the packets to the other party. After the other party receives the packets, it combines them in order and unpacks them into the actual document.
It is important to note that: with the presence of routers at the network layer, the network layer supports star network structures.
Now let’s focus on the ISO/OSI seven-layer model, as follows:

Since the questioner did not mention higher-level protocols, we will also ignore them. However, it is important to clarify that: from the network layer upwards, the information units sent between layers are already complete messages. The OSI model also specifies the syntax structure of messages, which will be omitted due to space constraints.
It is worth noting that: the communication interfaces of RS232/RS485/RS422 and their definitions are very clear. This includes pin levels, pin function definitions, and the data flow timing relationships during information sending and receiving at the interface; all of these must be accurate and strict, otherwise, information exchange cannot be executed.
When a PLC exchanges information with a certain power meter, and these power meters comply with the RS485/MODBUS-RTU communication specifications, what do we need to do?
The first step is to wire according to the daisy chain structure communication link requirements, connecting the PLC’s communication interface with N power meter interfaces. The last power meter’s end must be equipped with a 100-ohm termination resistor.
The second step is to determine the addresses of these N power meters according to the principle of increasing addresses, for example, 01H, 02H, 1FH, etc. Here, H indicates hexadecimal, and 1F represents 16 + 15 = 31.
The third step is to set the communication rate specified by the power meters in the PLC programming software.
The fourth step is to set the MODBUS communication codes according to the data area address codes of the power meters in the PLC programming software, as well as the cyclic relationships of each slave station.
Note that the MODBUS communication codes here meet the requirements of the PLC’s IEC 61131-3 programming module; general PLC ladder diagrams do not have this function. Ladder diagrams meet the requirements of IEC 61131-1 but do not meet the requirements of IEC 61131-3.
The fifth step is to allocate a dedicated data area in the PLC’s memory to store the information read from the power meters after processing, so that higher-level master stations can read the information. This data area is called a data point table, sometimes also referred to as a communication protocol.
Finally, of course, there is the startup test. There is a lot of content involved, and I will not elaborate further due to space constraints.
Let’s look at an example of reading data on an RS485 network using MODBUS-RTU:
A certain power meter has an address of 01H. At memory position 2000 of the power meter, there are six data points for three-phase current and three-phase voltage, each occupying two bytes, totaling 12 bytes.
The communication rate of this power meter is 9600 bps. What does this mean? Bps indicates a 0/1, which is a bit, meaning that this bus can send 9600 bits per second. We already know that a byte has 8 data bits, 1 start bit, and 1 parity bit, totaling 10 bits, so if the communication rate of the power meter is 9600 bps, then in one second, it can send:9600/10=960 bytes.
We also know that the frame structure for the master station’s read data (downlink frame) includes 1 byte of address, 1 byte of function code, 2 bytes of memory address, 2 bytes of data quantity, and 2 bytes of CRC check code, totaling 8 bytes. Therefore, the time occupied by the master station sending the read data MODBUS communication frame is: 8X10/9600=8.33 milliseconds.
For this example, we know that the MODBUS-RTU read data command is 0X03H, which is the 03 command. Note the notation here: 0X is the prefix, the middle 03 is the command, and the final H indicates hexadecimal.
The specific communication frame is: 01 03 07 D0 00 06 C5 45, where 0X01H is the address, 0X03H is the command, 0X07D0H is the memory address 2000, 0X0006H indicates reading six consecutive words, which are the current and voltage parameters in memory, and 0XC545H is the CRC check code for 01 03 07 D0 00 06.
Then the response frame (uplink frame) structure of the power meter is: 1 byte of address, 1 byte of function code, 1 byte of data area byte count, 12 bytes of data, and 2 bytes of CRC check code, totaling 17 bytes, with a time of:17X10/9600=17.7 milliseconds.
The specific response communication frame from the meter is: 01 03 0C 00 64 0064 0064 00 DC 00 DC 00 DC D6 F5, where 0X01H and 0X03H have the same meaning as before, 0X0CH indicates that there are 12 bytes in the upload data area, 0X0064H indicates that phase A current is 100A, the following two groups are phase B and phase C currents, both 100A, 0X00DCH indicates that phase A voltage is 220V, followed by two groups for phase B and phase C voltages, both 220V, and finally 0XD6F5H is the CRC check code.
From the master station initiating the downlink communication frame, waiting 10 milliseconds for the slave to respond, and then receiving the uplink communication frame from the slave, the total time is:

If there are 31 identical meters waiting for the master station to access one by one, then the total time from the master station starting to access the first meter to the last response completion is:

The 1.12 seconds here is the reading data cycle for these 31 meters at a communication rate of 9600 bps, ignoring the waiting time for the master station to send the downlink communication frame again, so the actual time will be slightly longer.
Believe that by now, everyone should have a deeper understanding of the communication frames under MODBUS-RTU.
Just a reminder: a word consists of two bytes. Generally, a byte can only express 8 switch quantities. However, for analog quantities, words must be used to express them. For example, a current of 1250A is represented as 04E2H in hexadecimal, requiring 2 bytes to express completely. Therefore, various power meters express analog quantities using words.
The following are some commonly used function codes for MODBUS, i.e., command codes:

The following are examples of downlink and uplink communication frames for the PLC reading the data point table of the ASCO controller:

Let me explain a few related issues:
1) Some field buses use tokens to solve the bus control issue.
It is easy to think that if a slave station has an urgent matter that requires the master station’s service, but MODBUS stipulates polling rules, it may be too late by the time it gets its turn. Therefore, many field buses have invented a special thing called a token. The token is short, only one byte, and can be quickly passed on the bus. The token is passed among the stations; whoever gets the token becomes the master station and can publish information. If the current station has nothing to publish, it passes the token to the next station, thus solving the bus occupation issue.
2) When a link breaks, to avoid communication interruption, dual master station measures can be adopted. The two master stations (PLC’s two RS485 interfaces) are connected by a handshake line, with the main RS485 open during normal operation, while the auxiliary RS485 is floating. The floating RS485, although connected to the bus, is in a high-impedance state equivalent to being completely disconnected. When a break occurs, the slave station confirms and immediately opens communication, connecting communication from both ends of the link.
Sometimes, ring communication measures are also taken. Due to space constraints, I will not elaborate.
3) MODBUS can operate at the network layer, at which point the protocol becomes MODBUS-TCP, but it still conforms to the master-slave structure.
4) The MODBUS protocol was invented by Modicon, a company in the United States, whose mission is: the MODBUS protocol is a free and open protocol. Later, Modicon was acquired by Schneider Electric, which inherited Modicon’s practice, and MODBUS remains a free and open protocol. Since MODBUS has become Schneider’s protocol, Schneider extended it to the network layer, constructing the MODBUS-TCP protocol at the network layer, as well as the internally proprietary MODBUS-PLUS protocol. Due to space constraints, descriptions of these two protocols will be omitted here.
5) Regarding the differences between RS232 and RS485
Those who have studied analog and digital circuits know about differential circuits. Differential circuits have common-mode rejection ratios, which can eliminate common-mode errors. The RS485 interface has this characteristic. Therefore, the transmission distance of the RS232 interface is only a few meters, while the transmission distance of RS485/RS422 interfaces can reach 1200 meters.


From the diagram, we see that although the RS232 and RS485 interfaces have the same appearance, their performance and information exchange modes differ, resulting in different anti-interference capabilities.
6) When the distance is very long, the RS485 interface can also connect to fiber optics, but it requires a pair of fiber optic converters. The reason for a pair is that one is used for electrical-to-optical conversion, while the second is used for optical-to-electrical conversion. The communication medium between the fiber optic transceivers is fiber optic or optical cable. (Note: fiber optics are the core of optical cables, do not confuse them as two different things.)
Fiber optics are divided into single-mode and multi-mode. Single-mode fiber is thinner, and light reflects less during transmission, resulting in less distortion, with a transmission distance of over 15 km; multi-mode fiber is thicker, and light reflects more during transmission, resulting in greater distortion, with a transmission distance of 1.5 km.

7) The CRC check code is a binary division without borrowing, used to check whether the received information is erroneous.


Note that here f(x) is the MODBUS communication frame without the CRC check code, and the divisor is CRC16. The CRC in the frame is the remainder after the calculation.
Before the master station sends the frame, it calculates the CRC for the frame and appends the CRC remainder to the end of the frame to send to the slave. After the slave receives the frame, it first performs a CRC calculation on the part of the frame without the CRC to check for correctness; if incorrect, the slave requests the master to resend.
Similarly, when the slave sends information to the master, the master also checks the data’s correctness based on the CRC. If an error is found, it requests the slave to resend.
8) Regarding MODBUS-RTU, MODBUS-ASC, and MODBUS-TCP
If the byte representation of data in MODBUS uses BCD code, it is called MODBUS-RTU; if the byte representation of data in MODBUS uses ASCII code, it is called MODBUS-ASC; if MODBUS operates at the network layer, it is called MODBUS-TCP.
The content of ASCII code is as follows:

In practical use, most MODBUS applications use BCD code, so MODBUS-RTU is widely used.
The BCD code is as follows:

It is worth noting that: in protocol usage, the values in the data frame are expressed in hexadecimal. For example, a current of 100A is written as 0X64H, while a voltage of 380V is written as 0X17CH.
9) Regarding the twisted communication lines and grounding used in RS485 networks
We know that there will be distributed capacitance between two parallel cables, and distributed capacitance will weaken the signal strength. To eliminate distributed capacitance, the two parallel wires of the communication line need to be twisted together at a certain length; this type of wire is called twisted pair. The twisting length of twisted pair has specifications, which are closely related to the communication rate. In practical use, the appropriate twisted pair should be selected according to the communication rate.
The outer layer of the twisted pair has a shielding layer. The shielding layer must be grounded at a single point and must not be grounded at both ends simultaneously to prevent ground currents from causing interference. In actual wiring, independent grounding for each segment is adopted, and it is forbidden to connect the shielding layers of all segments to a unified ground.
10) Regarding the daisy chain communication link connection method
An absolute daisy chain network does not exist. In fact, in the communication network constructed using the daisy chain wiring method, each node is a terminal, connected to each slave station via twisted pair, and these twisted pairs form a similar star structure. We might as well refer to this wiring method as quasi-star wiring under the chain network.
In engineering practice, it has been proven that the length of quasi-star wiring should not exceed 70cm. Once exceeded, communication instability may occur.
In fact, 70cm has become an unwritten quality inspection specification in the industry.
A 100-ohm termination resistor can be added or not at low communication rates, but when the communication rate is high (above 19.2 kbps), it is recommended to add it. For example, in the RS485 network under PROFIBUS, the termination resistor is already embedded in the terminal device, and it can be added or removed by simply toggling a switch.
The purpose of the termination resistor is to absorb reflected waves.
When we tightly tie a rope between two trees and then strike one side of the rope, we will see a propagating wave traveling to the other end and can observe a reflected wave. If the striking frequency is appropriate, a standing wave will appear in the middle of the rope, which is called a standing wave.
For communication, whether it is reflected waves or standing waves, they will severely affect communication quality. The termination resistor is used to absorb reflected waves and can also elevate the final slave station’s signal level.
Both RS485 and MODBUS concepts need to be mastered through practice; it is difficult to understand and grasp them solely by reading text. If this article can benefit your practical activities, I would be very pleased.
Statement
The articles published by this account are for learning and communication purposes only, with no commercial use, paying tribute to the original authors. We apologize for not being able to find the original authors of some articles that have been reprinted multiple times. If there is any infringement, please contact the editor, and we will promptly delete the article or pay for reprinting and indicate the source. Thank you for your support!
(Source: Network, copyright belongs to the original author)
Share ยท Win-Win
The electrical circle, a circle with attitude