Method and system for converting MODBUS protocol to MPI / DP protocol

The method of converting MODBUS protocol to MPI/DP protocol solves the problem that RS232-MPI/DP adapter is not compatible with all HMIs, enables industrial bus access to more HMI devices, and increases the number of adaptations.

CN118573744APending Publication Date: 2024-08-30DONGGUAN AMOXUN AUTOMATION TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410630406.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-21
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

The existing RS232-MPI/DP adapter is not compatible with all HMIs, resulting in some HMIs being unable to access the industrial bus.

Method used

Through the method of converting the MODBUS protocol to the MPI/DP protocol, the MODBUS master station information is obtained, the data is verified, and the data is written into the MPI/DP shared memory area. MPI/DP obtains the data from the shared memory area to achieve protocol conversion.

Benefits of technology

The number of adaptations between Siemens PCs and HMIs has been increased, and the range of HMI devices that can be connected to the industrial bus has been expanded.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118573744A
    Figure CN118573744A
Patent Text Reader

Abstract

The invention discloses a method and system for converting an MODBUS protocol into an MPI / DP protocol, and the method comprises the steps: obtaining the information of an MODBUS master station, and carrying out the data verification of the information of the MODBUS master station; obtaining corresponding data through data verification, and writing the data into a memory area shared with the MPI / DP; and the MPI / DP obtains the data written by the MODBUS from the shared memory area. The communication mode between the MODBUS and the MPI / DP points to the same memory block at the same time, and data interaction is carried out through reading and writing of the memory, so that protocol conversion and conversion from the MODEBUS protocol to the MPI / DP protocol are completed, and the adaptation number of the Siemens PC and the HMI is increased.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of communication protocols, and in particular to a method and system for converting a MODBUS protocol to an MPI / DP protocol. Background Art

[0002] RS232-MPI / DP is a high-end adapter compatible with Siemens PC and HMI, fully supporting the RS232 serial port of PC and HMI to industrial field bus DP / MPI communication. However, it is not compatible with all HMI (touch screen) on the market, so a MODUBS protocol to MPI / DP method is integrated on the basis of the previous one, so that more HMI can be connected to the industrial bus. Summary of the invention

[0003] In this embodiment, a method and system for converting a MODBUS protocol to an MPI / DP protocol are provided to solve the problem in the related art that all HMIs are not compatible.

[0004] In a first aspect, the present invention provides a method for converting a MODBUS protocol to an MPI / DP protocol, the method comprising:

[0005] Obtain the information of the MODBUS master station and perform data verification on the information of the MODBUS master station;

[0006] Obtain the corresponding data through data verification and write the data into the memory area shared with MPI / DP;

[0007] MPI / DP gets the data written by MODBUS from the shared memory area.

[0008] In an optional embodiment, obtaining the information of the MODBUS master station and performing data verification on the information of the MODBUS master station includes:

[0009] Initialize a 16-bit register and set the register to all 1s;

[0010] Operate each byte of the data frame with the register;

[0011] Get the check code stored in the register.

[0012] In an optional embodiment, operating each byte of the data frame with the register includes:

[0013] XOR the value of the current byte of the data frame with its lower 8-bit register, and shift it 8 bits to the left;

[0014] XOR the register with a predefined fixed value.

[0015] In an optional embodiment, obtaining corresponding data through data verification and writing the data into a memory area shared with MPI / DP includes:

[0016] Take the keyword or a linear function value of the keyword as the MPI / DP address;

[0017] H(keyi)=key or H(keyi)=a*key+b, where a and b are constants;

[0018] The MPI / DP address needs to be obtained from the PLC.

[0019] In an optional embodiment, before obtaining the information of the MODBUS master station, the following operations need to be performed:

[0020] Communication between MPI / DP master stations is established, and the MPI / DP master stations obtain data sending rights through tokens.

[0021] In an optional embodiment, MPI / DP obtains data written by MODBUS from the shared memory area including:

[0022] MODBUS addressing is mapped on the MPI / DP master station number;

[0023] MODBUS searches for the I storage type, M storage type, Q storage type, and V storage type on the corresponding MPI / DP protocol;

[0024] Convert the data to be read and written by MODBUS into bit, byte, or word data required by MPI / DP.

[0025] Compared with the prior art, the method of converting the MODBUS protocol to the MPI / DP protocol of the present invention has the following beneficial effects:

[0026] The communication method between MODBUS and MPI / DP is to point to the same memory block at the same time, and to interact with data by reading and writing the memory to complete the protocol conversion, MODEBUS protocol to MPI / DP protocol, which increases the number of Siemens PC and HMI adaptations.

[0027] In a second aspect, the present invention provides a system for converting a MODBUS protocol to an MPI / DP protocol, comprising:

[0028] The acquisition module is used to obtain the information of the MODBUS master station and perform data verification on the information of the MODBUS master station;

[0029] The verification writing module is used to obtain the corresponding data through data verification and write the data into the memory area shared with MPI / DP;

[0030] The reading module is used by MPI / DP to obtain the data written by MODBUS from the shared memory area.

[0031] In a third aspect, the present invention provides a protocol converter, including the system for converting the MODBUS protocol to the MPI / DP protocol described in the second aspect.

[0032] In a fourth aspect, the present invention provides an electronic device, comprising a memory and a processor, wherein the memory stores at least one computer executable instruction, and the processor is configured to run the computer executable instruction, and when the computer executable instruction is executed by the processor, the method of converting the MODBUS protocol to the MPI / DP protocol described in the first aspect is implemented.

[0033] In a fifth aspect, the present invention provides a computer-readable storage medium, on which at least one computer-executable instruction is stored, and the processor is configured to run the computer-executable instruction. When the computer-executable instruction is executed by the processor, the method of converting the MODBUS protocol to the MPI / DP protocol described in the first aspect is implemented.

[0034] Compared with the prior art, the beneficial effects of the MODBUS protocol to MPI / DP protocol system, protocol converter, electronic device and storage medium of the present invention are the same as those of the above-mentioned MODBUS protocol to MPI / DP protocol method, so they are not repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0035] Figure 1 A flowchart of a method for converting a MODBUS protocol to an MPI / DP protocol in an embodiment provided by the present invention;

[0036] Figure 2 A flowchart of obtaining information of a MODBUS master station and performing data verification on the information of the MODBUS master station in an embodiment provided by the present invention;

[0037] Figure 3 A schematic diagram of converting the MODBUS protocol to the MPI / DP protocol in the embodiment provided by the present invention;

[0038] Figure 4 This is a schematic diagram of the logical token transfer between the master station and the slave station in the embodiment provided by the present invention. DETAILED DESCRIPTION

[0039] In order to more clearly understand the purpose, technical solutions and advantages of the present application, the present application is described and illustrated below in conjunction with the accompanying drawings and embodiments.

[0040] Unless otherwise defined, the technical terms or scientific terms involved in this application shall have the general meaning understood by people with ordinary skills in the technical field to which this application belongs. The words "one", "a", "a", "the", "these" and the like in this application do not represent quantitative restrictions, and they can be singular or plural. The terms "include", "comprise", "have" and any variants thereof involved in this application are intended to cover non-exclusive inclusions; for example, a process, method and system, product or device comprising a series of steps or modules (units) is not limited to the listed steps or modules (units), but may include unlisted steps or modules (units), or may include other steps or modules (units) inherent to these processes, methods, products or devices. The words "connect", "connected", "coupled" and the like involved in this application are not limited to physical or mechanical connections, but may include electrical connections, whether directly or indirectly. The "multiple" involved in this application refers to two or more. "And / or" describes the association relationship of associated objects, indicating that there can be three relationships. For example, "A and / or B" can mean: A exists alone, A and B exist at the same time, and B exists alone. Usually, the character " / " indicates that the objects associated with each other are in an "or" relationship. The terms "first", "second", "third", etc. involved in this application are only used to distinguish similar objects and do not represent a specific ordering of the objects.

[0041] First, the prior art and related concepts involved in the embodiments of the present invention are described:

[0042] MODBUS: MODBUS protocol is a universal language used in electronic controllers. Through this protocol, controllers can communicate with each other or through the network. It supports multiple electrical interfaces, including RS232, TCP / IP, etc. It can also be transmitted on various media, such as twisted pair, optical fiber, infrared, wireless, etc.

[0043] MPI / DP: Both MPI / DP are based on RS485 networks, but they use different communication protocols and are used in different places. MPI / DP is used for 300 / 400, while DP is generally used for master-slave communication, for field-level real-time communication, and has a high communication rate.

[0044] Further, the difference between MPI and DP is that MPI supports a maximum of 32 bus devices, DP supports a maximum of 127 bus devices, and the response time of MPI is 2 times slower than that of DP.

[0045] like Figure 1 and Figure 2 As shown, in an embodiment of the present invention, a method for converting a MODBUS protocol to an MPI / DP protocol is provided. Figure 1 It is a flowchart of the method of converting the MODBUS protocol to the MPI / DP protocol of the present invention, referring to Figure 1 and Figure 2 , the method comprising:

[0046] S100: Obtain the information of the MODBUS master station and perform data verification on the information of the MODBUS master station;

[0047] S110: Obtain corresponding data through data verification, and write the data into the memory area shared with MPI / DP;

[0048] S120: MPI / DP obtains the data written by MODBUS from the shared memory area.

[0049] It should be noted that MODBUS and MPI / DP run independently, and the communication method between the two is to point to the same memory block at the same time and exchange data by reading and writing memory.

[0050] Specifically, combined Figure 2 As shown, obtaining the information of the MODBUS master station and performing data verification on the information of the MODBUS master station include:

[0051] S101, initializing a 16-bit register and setting the register to all 1s;

[0052] It should be noted that the function of the register is to store binary code. It is composed of flip-flops with storage function. One flip-flop can store 1 bit of binary code, so a register that stores n bits of binary code needs to be composed of n flip-flops. Set the register to all 1, that is (`0xFFFF`).

[0053] S102, performing operation on each byte of the data frame and the register;

[0054] S103, obtaining the check code stored in the register.

[0055] Further, operating each byte of the data frame with the register includes:

[0056] XOR the value of the current byte of the data frame with its lower 8-bit register, and shift it 8 bits to the left;

[0057] XOR the register with a predefined fixed value.

[0058] It should be noted that, in this embodiment, the predefined fixed value is (`0xA001`).

[0059] In this embodiment, obtaining corresponding data through data verification and writing the data into a memory area shared with MPI / DP includes:

[0060] Take the keyword or a linear function value of the keyword as the MPI / DP address;

[0061] H(keyi)=key or H(keyi)=a*key+b, where a and b are constants;

[0062] The MPI / DP address needs to be obtained from the PLC.

[0063] Furthermore, before obtaining the information of the MODBUS master, the following operations need to be performed:

[0064] Communication between MPI / DP master stations is established, and the MPI / DP master stations obtain data sending rights through tokens.

[0065] It should be noted that MODBUS is used as a slave device, while MPI / DP is multi-master and multi-slave. The master uses a token to determine whether the device has the authority to send data, while the slave can only passively wait for the master to wake up before sending data. In addition, for MPI / DP masters to communicate, they first need to establish a handshake process, and releasing the connection also requires closing it through commands.

[0066] Combination Figure 4 As shown, Figure 4 The logical token transfer diagram between the master station and the slave station is shown as an example, in which TS represents the current station, PS represents the previous station, and NS represents the next station.

[0067] It should be further explained that the token is a symbol of data transmission. The data transmission between each master station has a strict time polling. The calculation formula is:

[0068] minTTR=na*(TTC+highTMC)+K*lowTMC+mt*RETTMC

[0069] Among them, na is the number of master stations; K is the estimated number of low-priority message cycles for each token rotation; TTC is the token rotation time; TMC is the message cycle time, which depends on the message length; Mt is the number of message retry cycles for each token rotation; Ret tmc is the message retry cycle time.

[0070] Furthermore, because data transmission is uncertain and the length of the line is different, the specific delay time TD is introduced, and the expression is TD=TTD / TBIT.

[0071] For example, when there is no repeater, the line length is 200m, TTD is about 1us, the baud rate is 500K, and TD is 0.5bit.

[0072] It should be noted that MPI / DP has 11 working states:

[0073] 0: offline

[0074] The first state entered after power-on, can also be entered through other working states.

[0075] 1: Listen_Token

[0076] After initialization of its operating parameters, the FDL of the master station will enter the "Listen_Token" state if it is ready to enter the logical token ring. In this state, the FDL of the master station will monitor the bus in order to identify the master station already in the logical token ring. For this purpose, the token frame will be analyzed and the active station list (LAS) will be generated using the station address contained in the token frame.

[0077] 2: Active_Idle

[0078] Main working status.

[0079] 3: Claim_Token

[0080] After the "Active_Idle" state, the FDL will enter the "Claim_Token" state, and when its TTO time expires, it will enter the "Listen_Token" state. In the "claim_Token" state, it will reinitialize the logical token ring or start initialization. When reinitializing, the station status table (LAS and GAPL) is still valid, and it will immediately enter the "Use_Token" state.

[0081] 4: Use_Token

[0082] After receiving a token or after reinitialization, the FDL will enter the "Use_Token" state. In this state the FDL can execute high priority and low priority message cycles. When entering this state, the TRR (actual rotation time) is read from the token rotation timer and this timer will be restarted. One high priority message cycle is always allowed. The execution of subsequent high priority or low priority message cycles, or generally low priority message cycles, is only possible if TRR∠TTR (target rotation time) at the moment of execution.

[0083] 5: Await_Data_Responses

[0084] After transmitting an active frame, the FDL enters this state. The FDL waits for one slot time in order to receive an acknowledgement or reply frame.

[0085] 6: Check_Access_Time

[0086] In this state, the effective token holding time is calculated by calculating the difference TTR-TRR. Only when there is still a valid token holding time, FDL can enter the "Use_Token" state again, otherwise FDL will enter the "Pass_Token" state.

[0087] 7: Pass_Token

[0088] In the "Pass_Token" state, the FDL will attempt to pass the token to the next station (NS) in the logical token ring. When transmitting the token frame, the FDL will use the synchronization monitoring method to check whether the transceiver is working correctly.

[0089] 8: Check_Token_Pass

[0090] In the "Check_Token_Pass" state, the FDL waits for a slot time in order to wait for the response of the station to which it has transmitted the token. This waiting time is used for the delay between the reception of the token frame and to ensure the transmission of the response of the addressed station.

[0091] 9: Await_Status_Response

[0092] The FDL enters this state from the "Pass_Token" state after indicating no successor during initialization or GAP maintenance. In this state, the FDL waits for a time slot time in order to obtain a response frame.

[0093] 10: Passive_Idle

[0094] After its parameters have been initialized, the FDL of this slave will enter the "Passive_Idle" state and listen to the bus. If a possible active frame (send / request frame) addressed to this station is received, the FDL will respond or answer as required, except for frames with a global address and token frames addressed to itself. Token frames are discarded.

[0095] Furthermore, MPI / DP obtains data written by MODBUS from the shared memory area including:

[0096] MODBUS addressing is mapped on the MPI / DP master station number;

[0097] MODBUS searches for the I storage type, M storage type, Q storage type, and V storage type on the corresponding MPI / DP protocol;

[0098] Convert the data to be read and written by MODBUS into data of bit, byte, and word types required by MPI / DP. It should be noted that MODBUS addressing is mapped on the MPI / DP master station number. The address required by MODBUS is found in the mapping table corresponding to the I storage type, M storage type, Q storage type, and V storage type on the MPI / DP protocol. The interpolation search algorithm can be used for data mapping: find the middle position according to the length, and now find this position according to the series range where the key is located. The position to be searched P = low + (key-a[low]) / (a[high]-a[low])×(high-low) is achieved through this algorithm. The average time required for the search is ((n+1)log2(n+1)) / n-1, which greatly reduces the search time.

[0099] The present invention provides a system for converting a MODBUS protocol to an MPI / DP protocol, comprising:

[0100] The acquisition module is used to obtain the information of the MODBUS master station and perform data verification on the information of the MODBUS master station;

[0101] The verification writing module is used to obtain the corresponding data through data verification and write the data into the memory area shared with MPI / DP;

[0102] The reading module is used by MPI / DP to obtain the data written by MODBUS from the shared memory area.

[0103] The present invention provides a protocol converter, comprising the system for converting the MODBUS protocol to the MPI / DP protocol described in the second aspect.

[0104] The present invention provides an electronic device, comprising a memory and a processor, wherein the memory stores at least one computer executable instruction, and the processor is configured to run the computer executable instruction. When the computer executable instruction is run by the processor, the method for converting the MODBUS protocol to the MPI / DP protocol described in the first aspect is implemented.

[0105] The present invention also provides a computer-readable storage medium, on which at least one computer-executable instruction is stored, and the processor is configured to run the computer-executable instruction. When the computer-executable instruction is run by the processor, the method of converting the MODBUS protocol to the MPI / DP protocol described in the first aspect is implemented.

[0106] The electronic device may include a processor, a communications interface, a memory, and a communications bus, wherein the processor, the communications interface, and the memory communicate with each other via the communications bus. The processor may call the logic instructions in the memory to execute the following method:

[0107] Obtain the information of the MODBUS master station and perform data verification on the information of the MODBUS master station;

[0108] Obtain the corresponding data through data verification and write the data into the memory area shared with MPI / DP;

[0109] MPI / DP gets the data written by MODBUS from the shared memory area.

[0110] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods of each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0111] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, i.e., they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Those of ordinary skill in the art may understand and implement it without creative effort.

[0112] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0113] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for converting MODBUS protocol to MPI / DP protocol, characterized in that: The method comprises: Obtain the information of the MODBUS master station and perform data verification on the information of the MODBUS master station; Obtain the corresponding data through data verification and write the data into the memory area shared with MPI / DP; MPI / DP gets the data written by MODBUS from the shared memory area.

2. The method for converting the MODBUS protocol to the MPI / DP protocol according to claim 1, characterized in that: Obtain the information of the MODBUS master station and perform data verification on the information of the MODBUS master station, including: Initialize a 16-bit register and set the register to all 1s; Operate each byte of the data frame with the register; Get the check code stored in the register.

3. The method for converting the MODBUS protocol to the MPI / DP protocol according to claim 2, characterized in that: The operation of each byte of the data frame with the register comprises: XOR the value of the current byte of the data frame with its lower 8-bit register, and shift it 8 bits to the left; XOR the register with a predefined fixed value.

4. The method for converting the MODBUS protocol to the MPI / DP protocol according to claim 1, characterized in that: Obtaining the corresponding data through data verification and writing the data into the memory area shared with MPI / DP includes: Take the keyword or a linear function value of the keyword as the MPI / DP address; H(keyi)=key or H(keyi)=a*key+b, where a and b are constants; The MPI / DP address needs to be obtained from the PLC.

5. The method for converting the MODBUS protocol to the MPI / DP protocol according to claim 1, characterized in that: Before obtaining the information of the MODBUS master, you need to perform the following operations: Communication between MPI / DP master stations is established, and the MPI / DP master stations obtain data sending rights through tokens.

6. The method for converting MODBUS protocol to MPI / DP protocol according to claim 1, characterized in that: MPI / DP obtains data written by MODBUS from the shared memory area including: MODBUS addressing is mapped on the MPI / DP master station number; MODBUS searches for the I storage type, M storage type, Q storage type, and V storage type on the corresponding MPI / DP protocol; Convert the data to be read and written by MODBUS into bit, byte, or word data required by MPI / DP.

7. A system for converting MODBUS protocol to MPI / DP protocol, characterized in that: include: The acquisition module is used to obtain the information of the MODBUS master station and perform data verification on the information of the MODBUS master station; The verification writing module is used to obtain the corresponding data through data verification and write the data into the memory area shared with MPI / DP; The reading module is used by MPI / DP to obtain the data written by MODBUS from the shared memory area.

8. A protocol converter, characterized in that: A system for converting the MODBUS protocol to the MPI / DP protocol as claimed in claim 7.

9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, the memory stores at least one computer executable instruction, the processor is configured to execute the computer executable instruction, and the computer executable instruction is executed by the processor to implement the method for converting the MODBUS protocol to the MPI / DP protocol according to any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores at least one computer-executable instruction, and the processor is configured to execute the computer-executable instruction. When the computer-executable instruction is executed by the processor, the method for converting the MODBUS protocol to the MPI / DP protocol according to any one of claims 1 to 6 is implemented.