Protocol conversion method and device based on frame structure matching, equipment and medium
Through the protocol conversion method based on frame structure matching, the Modbus protocol is converted to the DL/T 645 protocol, which solves the problem that communication equipment in the low-voltage distribution station area cannot be integrated into the communication network, and realizes the interconnection between devices and the expansion capabilities of smart grid systems.
Patent Information
- Application Number
- CN202510180302.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-19
- Publication Date
- 2025-04-29
AI Technical Summary
The existing communication equipment in the low-voltage distribution station area is mostly based on the private Modbus protocol and cannot be directly integrated into the communication network of the low-voltage distribution station area, resulting in communication barriers.
The protocol conversion method based on frame structure matching is adopted to convert the Modbus protocol into the DL/T 645 protocol by parsing the received information, determining the frame structure, extracting and converting address-related data, mapping the function code and control code, and performing register mapping.
It realizes seamless conversion between the Modbus protocol and the DL/T 645 protocol, eliminates communication barriers between devices, realizes interconnection between devices, and supports more Modbus devices to access the smart grid system.
Smart Images

Figure CN119906765A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of low-voltage power distribution Internet of Things, and in particular to a protocol conversion method, device, equipment and medium based on frame structure matching. Background Art
[0002] With the surge in global demand for green energy, the intelligentization of low-voltage distribution areas is advancing at a rapid pace. In recent years, with the addition of low-voltage intelligent devices, their market share has risen sharply, which not only poses unprecedented challenges to the stability of the power grid, but also puts forward higher requirements for the flexibility and intelligence level of the power grid management system.
[0003] In the current distribution network communication scenario, many communication devices are still customized based on the private Modbus protocol and transmit data through RS-485 communication. These devices cannot be directly integrated into the communication network of the low-voltage distribution station area in terms of communication protocol and communication distance. Summary of the invention
[0004] The technical problem to be solved by the present invention is to provide a protocol conversion method, device, equipment and medium based on frame structure matching, which can effectively convert the private Modbus protocol into the DL / T 645 communication protocol that complies with the power grid standard, thereby achieving seamless connection with the low-voltage distribution station area communication network.
[0005] The technical solution adopted by the present invention to solve the technical problem is: to provide a protocol conversion method based on frame structure matching, comprising the following steps:
[0006] Parsing the received information to determine the frame structure of the information;
[0007] Extracting address-related data based on the frame structure of the information, and performing address domain conversion on the address-related data;
[0008] Based on the mapping relationship between the control code of the DL / T 645 protocol and the function code of the Modbus protocol, the function code or control code in the received information is mapped;
[0009] Based on the mapping relationship between the register position of the Modbus protocol and the frame of the DL / T 645 protocol, register mapping is performed on the received information.
[0010] When the address-related data is extracted based on the frame structure of the information and the address-related data is converted into an address domain, when the frame structure of the information is a frame structure of the Modbus protocol, the address data in the address domain of the frame structure of the Modbus protocol and the actual data in the data are placed together in the data domain of the DL / T 645 protocol.
[0011] When the address-related data is extracted based on the frame structure of the information and the address-related data is converted into the address domain, when the frame structure of the information is the frame structure of the DL / T 645 protocol, the first byte of the data domain in the frame structure of the DL / T 645 protocol is extracted and placed in the address domain in the frame structure of the Modbus protocol as the slave device address.
[0012] When the frame structure of the information is the frame structure of the DL / T 645 protocol, the mapping relationship between the control code based on the DL / T 645 protocol and the function code of the Modbus protocol is: the function code for reading data in the frame structure of the Modbus protocol is mapped to the first control code in the frame structure of the DL / T 645 protocol; the function code for writing register data in the frame structure of the Modbus protocol is mapped to the second control code in the frame structure of the DL / T 645 protocol; the function code for writing multiple register data in the frame structure of the Modbus protocol is mapped to the second control code in the frame structure of the DL / T 645 protocol.
[0013] When the frame structure of the information is a frame structure of the Modbus protocol, the mapping relationship between the control code based on the DL / T 645 protocol and the function code of the Modbus protocol is as follows: the function code for reading data in the frame structure of the Modbus protocol is mapped to the third control code in the frame structure of the DL / T645 protocol; the function code for writing register data in the frame structure of the Modbus protocol is mapped to the fourth control code in the frame structure of the DL / T 645 protocol; the function code for writing multiple register data in the frame structure of the Modbus protocol is mapped to the fourth control code in the frame structure of the DL / T 645 protocol.
[0014] The technical solution adopted by the present invention to solve the technical problem is: to provide a protocol conversion device based on frame structure matching, comprising:
[0015] A parsing module, used to parse the received information and determine the frame structure of the information;
[0016] An address domain conversion module, used for extracting address-related data based on the frame structure of the information, and performing address domain conversion on the address-related data;
[0017] The function code mapping module is used to map the function code or control code in the received information based on the mapping relationship between the control code of the DL / T 645 protocol and the function code of the Modbus protocol;
[0018] The register mapping module is used to perform register mapping on the received information based on the mapping relationship between the register position of the Modbus protocol and the frame of the DL / T 645 protocol.
[0019] When the frame structure of the information is a frame structure of the Modbus protocol, the address domain conversion module places the address data in the address domain of the frame structure of the Modbus protocol and the actual data in the data together in the data domain of the DL / T 645 protocol.
[0020] When the frame structure of the information is the frame structure of the DL / T 645 protocol, the address domain conversion module extracts the first byte of the data domain in the frame structure of the DL / T 645 protocol and places it into the address domain in the frame structure of the Modbus protocol as the slave device address.
[0021] When the frame structure of the information is the frame structure of the DL / T 645 protocol, the mapping relationship between the control code based on the DL / T 645 protocol and the function code of the Modbus protocol is: the function code for reading data in the frame structure of the Modbus protocol is mapped to the first control code in the frame structure of the DL / T 645 protocol; the function code for writing register data in the frame structure of the Modbus protocol is mapped to the second control code in the frame structure of the DL / T 645 protocol; the function code for writing multiple register data in the frame structure of the Modbus protocol is mapped to the second control code in the frame structure of the DL / T 645 protocol.
[0022] When the frame structure of the information is a frame structure of the Modbus protocol, the mapping relationship between the control code based on the DL / T 645 protocol and the function code of the Modbus protocol is as follows: the function code for reading data in the frame structure of the Modbus protocol is mapped to the third control code in the frame structure of the DL / T645 protocol; the function code for writing register data in the frame structure of the Modbus protocol is mapped to the fourth control code in the frame structure of the DL / T 645 protocol; the function code for writing multiple register data in the frame structure of the Modbus protocol is mapped to the fourth control code in the frame structure of the DL / T 645 protocol.
[0023] The technical solution adopted by the present invention to solve its technical problem is: to provide an electronic device, including a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above-mentioned protocol conversion method based on frame structure matching when executing the computer program.
[0024] The technical solution adopted by the present invention to solve its technical problem is: providing a computer-readable storage medium on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned protocol conversion method based on frame structure matching are implemented.
[0025] Beneficial Effects
[0026] Due to the adoption of the above-mentioned technical scheme, the present invention has the following advantages and positive effects compared with the prior art: the present invention performs address domain conversion, function code mapping and register mapping based on the frame structure of the DL / T 645 communication protocol and the Modbus communication protocol, thereby converting the private Modbus protocol into the standard DL / T 645 protocol, eliminating the communication barriers between Modbus devices of different brands and models, and realizing the interconnection between devices. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 It is a schematic diagram of the frame structure of the DL / T 645 communication protocol;
[0028] Figure 2 It is a schematic diagram of the Modbus communication protocol frame structure;
[0029] Figure 3 It is a schematic diagram of the conversion of the Modbus and DL / T 645 communication protocol frame structures;
[0030] Figure 4 It is a schematic diagram of the DL / T 645 communication protocol control code;
[0031] Figure 5 It is a flow chart of DL / T 645 protocol conversion. DETAILED DESCRIPTION
[0032] The present invention will be further described below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not intended to limit the scope of the present invention. In addition, it should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall within the scope limited by the appended claims of the application equally.
[0033] The first embodiment of the present invention relates to a protocol conversion device based on frame structure matching, which can be arranged between a master station device and a slave station device. The master station device adopts the DL / T 645 communication protocol, and its frame structure is as follows: Figure 1 As shown in the figure, it consists of 8 parts: start character, address field, frame start character, control code, data length, data field, check code and end character. The slave device adopts Modbus communication protocol, and its frame structure is as follows Figure 2 As shown, it consists of four parts: address field, function code, data and error check.
[0034] The protocol conversion device in this embodiment can be any low-voltage intelligent device, such as an area intelligent fusion terminal, a low-voltage intelligent circuit breaker, a data acquisition terminal, a protocol converter, etc., which is responsible for converting data frames of the Modbus protocol into data frames of the DL / T645 protocol.
[0035] In order to ensure smooth conversion from Modbus protocol to DL / T 645 protocol, the protocol conversion device of this embodiment can match and convert each field of Modbus protocol with the corresponding field of DL / T 645 protocol (see Figure 3 ), the protocol conversion device comprises:
[0036] The parsing module is used to parse the received information and determine the frame structure of the information. The received information can be parsed by the parsing module to determine the frame structure of the received information. When the frame structure of the received information is the frame structure of the Modbus protocol, it needs to be converted to the frame structure of the DL / T 645 protocol; when the frame structure of the received information is the frame structure of the DL / T 645 protocol, it needs to be converted to the frame structure of the Modbus protocol.
[0037] The address domain conversion module is used to extract address-related data based on the frame structure of the information and perform address domain conversion on the address-related data.
[0038] When the parsing module determines that the frame structure of the received information is the frame structure of the Modbus protocol, it means that the information is data transmission from the slave device to the master device. Therefore, it is necessary to convert the information of the frame structure of the Modbus protocol into the frame structure of the DL / T645 protocol. At this time, the address domain conversion module places the address data in the address domain of the frame structure of the Modbus protocol and the actual data in the data into the data domain of the DL / T 645 protocol to complete the address domain conversion. In this way, the receiving end can identify and parse data from different Modbus devices according to the Modbus address in the data domain.
[0039] When the parsing module determines that the frame structure of the received information is the frame structure of the DL / T 645 protocol, it means that the information is data transmission from the master device to the slave device. Therefore, it is necessary to convert the information of the frame structure of the DL / T 645 protocol into the frame structure of the Modbus protocol. At this time, the address domain conversion module extracts the first byte of the data domain in the frame structure of the DL / T 645 protocol as the slave device address and places it in the address domain in the frame structure of the Modbus protocol. In this way, the data can accurately find the corresponding device during downlink transmission.
[0040] The function code mapping module is used to map the function code or control code in the received information based on the mapping relationship between the control code of the DL / T 645 protocol and the function code of the Modbus protocol.
[0041] The function code in the frame structure of the Modbus protocol consists of 1 byte. Commonly used function codes include: 0×03 (read data), 0×06 (write register data) and 0×10 (write multiple register data). The control code of the frame structure of the DL / T 645 protocol also consists of 1 byte, of which the lower 5 bits indicate the function and the upper 3 bits indicate the transmission direction, etc. (see Figure 4 ).
[0042] In order to ensure that the function code of the frame structure of the Modbus protocol can be correctly mapped to the control code of the frame structure of the DL / T 645 protocol, this implementation adopts the following mapping rules:
[0043] Modbus function code 0x03: mapped to DL / T 645 control code 10001.
[0044] Modbus function code 0x06: mapped to DL / T 645 control code 10100.
[0045] Modbus function code 0x10: mapped to DL / T 645 control code 10100.
[0046] Since the DL / T 645 protocol has a transmission direction flag, the complete mapping of the modbus protocol function code is divided into two cases, namely, transmission from the master device to the slave device and transmission from the slave device to the master device.
[0047] When the master device transmits to the slave device:
[0048] a. Modbus function code 0x03: mapped to DL / T 645 control code 00010001.
[0049] b. Modbus function code 0x06: mapped to DL / T 645 control code 00010100.
[0050] c. Modbus function code 0x10: mapped to DL / T 645 control code 00010100.
[0051] When the slave device transmits to the master device:
[0052] a. Modbus function code 0x03: mapped to DL / T 645 control code 10010001.
[0053] b. Modbus function code 0x06: mapped to DL / T 645 control code 10010100.
[0054] c. Modbus function code 0x10: mapped to DL / T 645 control code 10010100.
[0055] When the frame structure of the received information is the frame structure of the DL / T 645 protocol, it means that the master device is transmitting to the slave device. At this time, the control code in the frame structure of the DL / T 645 protocol will be obtained, and the obtained control code will be converted into a Modbus function code according to the above mapping relationship; when the frame structure of the received information is the frame structure of the Modbus protocol, it means that the slave device is transmitting to the master device. At this time, the function code in the frame structure of the Modbus protocol will be obtained, and the obtained function code will be converted into a DL / T 645 control code according to the above mapping relationship. Through this mapping method, the accuracy and efficiency of data conversion between the Modbus protocol and the DL / T 645 protocol are ensured.
[0056] The register mapping module is used to perform register mapping on the received information based on the mapping relationship between the register position of the Modbus protocol and the frame of the DL / T 645 protocol.
[0057] This embodiment also makes detailed provisions for register mapping. Specifically, the data of the Modbus protocol is stored in registers, and different register positions store different data, while the data of the DL / T 645 protocol is represented by codes at fixed positions in the frame. Therefore, this embodiment predefines the mapping relationship between the register positions of the Modbus protocol and the frames of the DL / T 645 protocol. During conversion, it is only necessary to perform relevant mapping according to the mapping relationship. For example, the active power data in the Modbus protocol is stored in the register with address 49, and this embodiment maps it to the code '33333635' in the DL / T 645 protocol frame.
[0058] It is not difficult to find that this embodiment eliminates the communication barriers between Modbus devices of different brands and models by converting the private Modbus protocol into the standard DL / T 645 protocol, and realizes the interconnection between devices. Since the DL / T645 protocol is a standard protocol in the power grid field, this embodiment enables more Modbus devices to access the smart grid system, improves the system's expansion capabilities, and supports the access of more devices in the future. In addition, the conversion device of this embodiment simplifies the system architecture, reduces the complexity of connections between devices, and reduces the construction and maintenance costs of the system. The conversion device of this embodiment can adopt HPLC&HRF dual-mode communication, which not only has a long transmission distance, but also does not require additional communication lines, reducing the investment and maintenance costs of communication equipment.
[0059] The second embodiment of the present invention relates to a protocol conversion method based on frame structure matching, taking DL / T 645 protocol conversion as an example, as shown in FIG. Figure 5 As shown, the following steps are included:
[0060] Parsing the received information to determine that the frame structure of the information is a frame structure of the Modbus protocol;
[0061] Extracting address-related data based on the frame structure of the information, that is, extracting the address data in the address field in the frame structure of the Modbus protocol in advance, placing the address data and the actual data in the data in the frame structure of the Modbus protocol together in the data field of the DL / T 645 protocol, and completing the address field conversion;
[0062] Based on the mapping relationship between the control code of the DL / T 645 protocol and the function code of the Modbus protocol, that is, the function code 0x03 in the frame structure of the Modbus protocol is mapped to the control code 10010001 in the frame structure of the DL / T 645 protocol; the function code 0x06 in the frame structure of the Modbus protocol is mapped to the control code 10010100 in the frame structure of the DL / T 645 protocol; the function code 0x10 in the frame structure of the Modbus protocol is mapped to the control code 10010100 in the frame structure of the DL / T 645 protocol, the function code in the received information is mapped to obtain the control code of the DL / T 645 protocol, and the function code mapping is completed;
[0063] Based on the mapping relationship between the register position of the Modbus protocol and the frame of the DL / T 645 protocol, register mapping is performed on the received information.
[0064] Finally, the frame structure information of the DL / T 645 protocol is composed based on the address domain conversion result, the function code mapping result and the register mapping result, and the frame structure information of the DL / T 645 protocol is sent to the master station device.
[0065] It is worth mentioning that the present embodiment can also convert the information of the DL / T 645 protocol into the information of the Modbus protocol, and the conversion process is the same as that described in the first embodiment, which will not be repeated here.
[0066] The third embodiment of the present invention relates to an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the protocol conversion method based on frame structure matching of the second embodiment when executing the computer program.
[0067] The fourth embodiment of the present invention relates to a computer-readable storage medium having a computer program stored thereon. When the computer program is executed by a processor, the steps of the protocol conversion method based on frame structure matching of the second embodiment are implemented.
[0068] Those skilled in the art will appreciate that the embodiments of the present application may be provided as methods, systems, or computer program products. Therefore, the present application may adopt the form of a complete hardware embodiment, a complete software embodiment, or an embodiment in combination with software and hardware. Moreover, the present application may adopt the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage and optical storage, etc.) that contain computer-usable program code.
[0069] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0070] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to work in a specific manner, so that the instructions stored in the computer-readable memory produce a manufactured product including an instruction method, which is implemented in the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0071] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.
[0072] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art who is familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A protocol conversion method based on frame structure matching, characterized in that: The following steps are involved: Parsing the received information to determine the frame structure of the information; Extracting address-related data based on the frame structure of the information, and performing address domain conversion on the address-related data; Based on the mapping relationship between the control code of the DL / T 645 protocol and the function code of the Modbus protocol, the function code or control code in the received information is mapped; Based on the mapping relationship between the register position of the Modbus protocol and the frame of the DL / T 645 protocol, register mapping is performed on the received information.
2. The protocol conversion method based on frame structure matching according to claim 1, characterized in that: When the address-related data is extracted based on the frame structure of the information and the address-related data is converted into an address domain, when the frame structure of the information is a frame structure of the Modbus protocol, the address data in the address domain of the frame structure of the Modbus protocol and the actual data in the data are placed together in the data domain of the DL / T 645 protocol.
3. The protocol conversion method based on frame structure matching according to claim 1, characterized in that: When the address-related data is extracted based on the frame structure of the information and the address-related data is converted into the address domain, when the frame structure of the information is the frame structure of the DL / T 645 protocol, the first byte of the data domain in the frame structure of the DL / T 645 protocol is extracted and placed in the address domain in the frame structure of the Modbus protocol as the slave device address.
4. The protocol conversion method based on frame structure matching according to claim 1, characterized in that: When the frame structure of the information is the frame structure of the DL / T 645 protocol, the mapping relationship between the control code based on the DL / T 645 protocol and the function code of the Modbus protocol is: the function code for reading data in the frame structure of the Modbus protocol is mapped to the first control code in the frame structure of the DL / T 645 protocol; the function code for writing register data in the frame structure of the Modbus protocol is mapped to the second control code in the frame structure of the DL / T 645 protocol; the function code for writing multiple register data in the frame structure of the Modbus protocol is mapped to the second control code in the frame structure of the DL / T645 protocol.
5. The protocol conversion method based on frame structure matching according to claim 1, characterized in that: When the frame structure of the information is a frame structure of the Modbus protocol, the mapping relationship between the control code based on the DL / T 645 protocol and the function code of the Modbus protocol is as follows: the function code for reading data in the frame structure of the Modbus protocol is mapped to the third control code in the frame structure of the DL / T 645 protocol; the function code for writing register data in the frame structure of the Modbus protocol is mapped to the fourth control code in the frame structure of the DL / T 645 protocol; the function code for writing multiple register data in the frame structure of the Modbus protocol is mapped to the fourth control code in the frame structure of the DL / T 645 protocol.
6. A protocol conversion device based on frame structure matching, characterized in that: include: A parsing module, used to parse the received information and determine the frame structure of the information; An address domain conversion module, used for extracting address-related data based on the frame structure of the information, and performing address domain conversion on the address-related data; The function code mapping module is used to map the function code or control code in the received information based on the mapping relationship between the control code of the DL / T 645 protocol and the function code of the Modbus protocol; The register mapping module is used to perform register mapping on the received information based on the mapping relationship between the register position of the Modbus protocol and the frame of the DL / T 645 protocol.
7. The protocol conversion device based on frame structure matching according to claim 6 is characterized in that: When the frame structure of the information is a frame structure of the Modbus protocol, the address domain conversion module places the address data in the address domain of the frame structure of the Modbus protocol and the actual data in the data together in the data domain of the DL / T 645 protocol.
8. The protocol conversion device based on frame structure matching according to claim 6, characterized in that: When the frame structure of the information is the frame structure of the DL / T 645 protocol, the address domain conversion module extracts the first byte of the data domain in the frame structure of the DL / T 645 protocol and places it into the address domain in the frame structure of the Modbus protocol as the slave device address.
9. The protocol conversion device based on frame structure matching according to claim 6, characterized in that: When the frame structure of the information is the frame structure of the DL / T 645 protocol, the mapping relationship between the control code based on the DL / T 645 protocol and the function code of the Modbus protocol is: the function code for reading data in the frame structure of the Modbus protocol is mapped to the first control code in the frame structure of the DL / T 645 protocol; the function code for writing register data in the frame structure of the Modbus protocol is mapped to the second control code in the frame structure of the DL / T 645 protocol; the function code for writing multiple register data in the frame structure of the Modbus protocol is mapped to the second control code in the frame structure of the DL / T645 protocol.
10. The protocol conversion device based on frame structure matching according to claim 6, characterized in that: When the frame structure of the information is a frame structure of the Modbus protocol, the mapping relationship between the control code based on the DL / T 645 protocol and the function code of the Modbus protocol is as follows: the function code for reading data in the frame structure of the Modbus protocol is mapped to the third control code in the frame structure of the DL / T 645 protocol; the function code for writing register data in the frame structure of the Modbus protocol is mapped to the fourth control code in the frame structure of the DL / T 645 protocol; the function code for writing multiple register data in the frame structure of the Modbus protocol is mapped to the fourth control code in the frame structure of the DL / T645 protocol.
11. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the protocol conversion method based on frame structure matching as described in any one of claims 1 to 5 are implemented.
12. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the protocol conversion method based on frame structure matching as claimed in any one of claims 1 to 5 are implemented.