Communication protocol conversion method and device

By listening and processing the communication data between the PLC and the external device, and performing protocol conversion according to the communication rules, the communication incompatibility problem between the PLC and the external device is solved, the system architecture is simplified, the cost is reduced, and the system stability and flexibility is improved.

CN120378499APending Publication Date: 2025-07-25QINGDAO HAIER AIR CONDITIONING ELECTRONICS CO LTD +2
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410603751.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-15
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

In industrial automation systems, there is a problem of incompatibility between the PLC and external devices, resulting in increased system complexity and maintenance difficulties, and the hardware needs to be replaced or reconfigured every time the device is replaced or upgraded, which is expensive and lacks flexibility.

Method used

By monitoring the communication data between the PLC and external devices, determining exceptions based on the previously configured communication rules, and performing data processing and format conversion, implementing protocol conversion, avoiding the introduction of additional hardware, and simplifying system architecture and maintenance work.

Benefits of technology

It realizes efficient communication between PLC and external devices, reduces cost and space usage, improves the stability and reliability of the system, and enhances the flexibility and scalability of the system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120378499A_ABST
    Figure CN120378499A_ABST
Patent Text Reader

Abstract

The invention relates to the field of communication protocol conversion, and provides a communication protocol conversion method and device, and the method comprises the steps: monitoring communication data between a programmable logic controller (PLC) and external equipment, and obtaining monitoring data; determining whether the communication between the PLC and the external equipment is abnormal or not according to the previously configured communication rule; and processing the monitored data according to a communication rule on the basis of determining that the communication between the PLC and the external equipment is abnormal, and returning the processed data to a sender between the PLC and the external equipment, so as to send the processed data to a receiver or send the processed data to the receiver. The problem that communication protocols between the PLC and the external equipment are incompatible in the field of industrial automation is solved, normal communication between the PLC and the external equipment is achieved, cost and occupied space are reduced, system architecture and maintenance work are simplified, and stability and reliability of the system are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of communication protocol conversion, and in particular, to a communication protocol conversion method and apparatus. Background Art

[0002] In an industrial automation system, a programmable logic controller (PLC) plays a core role in monitoring and controlling mechanical equipment or production processes in real time. The communication between the PLC and peripheral devices (such as sensors, actuators, and human-machine interfaces (HMIs)) is achieved through various industrial communication protocols, including but not limited to Modbus, PROFIBUS, EtherNet / IP, etc. However, in a multi-brand or multi-type industrial automation environment, there are often situations where the communication protocols between the PLC and external devices are incompatible. Especially when the data addresses or command sets provided by external devices exceed the range supported by the PLC, effective communication cannot be directly carried out.

[0003] Currently, mainly through the PLC manufacturer to provide an integrated communication module or an optional expansion card to enhance the connection ability with external devices and solve the problem of incompatible communication protocols between the PLC and external devices.

[0004] However, although the above method solves the protocol compatibility problem to a certain extent, it increases additional costs, introduces additional complexity in system layout and maintenance, limits the system's rapid integration and upgrade capabilities, increases the system's complexity and maintenance difficulty; in addition, whenever new devices need to be added or existing devices need to be upgraded, it may be necessary to replace or reconfigure physical hardware, which is time-consuming and costly, and it is usually limited to specific manufacturers or device models, lacking flexibility, and may lead to vendor lock-in problems. Summary of the Invention

[0005] The present invention provides a communication protocol conversion method and apparatus to solve the defect of incompatible communication protocols between the PLC and external devices in the industrial automation field in the prior art, realizing normal communication between the PLC and external devices, reducing costs and space occupancy, simplifying the system architecture and maintenance work, and improving the stability and reliability of the system.

[0006] The present invention provides a communication protocol conversion method, including: listening to the communication data between a programmable logic controller (PLC) and an external device to obtain listening data; determining whether there is an abnormal communication between the PLC and the external device according to pre-configured communication rules; based on determining that there is an abnormal communication between the PLC and the external device, processing the listening data according to the communication rules, and returning the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or sending the processed data to the receiver.

[0007] It should be noted that by monitoring the communication data between the PLC and the external device and combining the pre-configured communication rules, it is determined whether there is an abnormal communication between the PLC and the external device. Thus, when there is an abnormal communication, the monitoring data is processed according to the communication rules to achieve normal communication between the PLC and the external device, avoid introducing additional hardware devices, reduce costs and space occupancy, avoid the situation of incompatible communication protocols between the PLC and the external device, and achieve more efficient and economical communication between the PLC and the external device. In addition, by configuring the communication rules to achieve centralized management, the system architecture and maintenance work are simplified, and the stability and reliability of the system are improved.

[0008] According to a communication protocol conversion method provided by the present invention, determining whether there is an abnormal communication between the PLC and the external device according to the pre-configured communication rules includes: identifying and parsing the monitoring data to obtain parsed data, where the parsed data includes the source protocol parsing type and the parsing address; determining the corresponding target protocol type according to the source protocol parsing type, the parsing address, and the pre-configured communication rules; where the communication rules include the source protocol type and the target protocol type corresponding to the source protocol type; verifying whether the parsing address conforms to the address range of the determined target protocol type, and determining that there is an abnormal communication between the PLC and the external device based on the parsing address not conforming to the address range of the determined target protocol type.

[0009] It should be noted that by identifying and parsing the monitoring data to find the pre-configured communication rules according to the parsing result and determining the corresponding target protocol type, the address range of the determined target protocol type is verified against the parsing address, thereby realizing the detection of abnormal communication between the PLC and the external device. In addition, by the pre-configured communication rules, centralized management is achieved, the system architecture and maintenance work are simplified, and the stability and reliability of the system are improved.

[0010] According to a communication protocol conversion method provided by the present invention, the communication rules further include an address mapping rule between the source protocol type and the target protocol type; based on determining that there is an abnormal communication between the PLC and the external device, processing the monitoring data according to the communication rules includes: based on determining that there is an abnormal communication between the PLC and the external device, determining the corresponding address mapping rule according to the source protocol parsing type, the parsing address, and the communication rules; performing address conversion on the parsing address according to the determined address mapping rule, and by configuring the address mapping rule, when there is an incompatible communication protocol between the PLC and the external device, address conversion can be realized by software, eliminating the need for a physical switch or gateway, reducing costs and improving the flexibility of the system.

[0011] A communication protocol conversion method provided by the present invention performs address conversion on the parsed address according to the address mapping rule, including: looking up the parsed address mapping rule according to the source protocol parsing type and the target protocol type corresponding to the determined source protocol parsing type to obtain the corresponding mapped address; using the mapped address as the mapping of the parsed address to perform address conversion. By means of the pre-configured address mapping rule, address conversion can be performed quickly, solving the problem of incompatible communication protocols between the PLC and external devices. Moreover, by configuring the address mapping rule, rapid development and deployment of new protocol conversion logic are allowed, enabling the system to quickly adapt to new communication standards, enhancing the scalability and compatibility of the system, and ensuring the availability and applicability of the system in the long term.

[0012] A communication protocol conversion method provided by the present invention determines the corresponding target protocol type according to the source protocol parsing type, the parsed address, and the pre-configured communication rule, including: looking up the communication rule according to the source protocol parsing type to obtain the target protocol type corresponding to the source protocol parsing type; determining the protocol type of the corresponding recipient according to the parsed address and the communication rule; determining whether the protocol type of the recipient is included in the target protocol type corresponding to the source protocol parsing type, and based on the inclusion, using the protocol type of the recipient as the corresponding target protocol type.

[0013] It should be noted that since the PLC may be correspondingly connected to multiple external devices, or one external device is connected to different PLCs, it is necessary to preliminarily screen the target protocol type according to the source protocol parsing type and the communication rule, and determine the protocol type of the recipient according to the parsed address and the communication rule, so as to determine whether the protocol type of the recipient is included in the preliminarily screened target protocol type, thereby ensuring the accuracy of the finally confirmed target protocol type and avoiding mis-determining the protocol type of the recipient in the case of multiple targets.

[0014] A communication protocol conversion method provided by the present invention determines whether there is a communication anomaly between the PLC and the external device according to the pre-configured communication rule, and further includes: identifying and parsing the monitored data to obtain the parsed data, where the parsed data includes the source protocol parsing type, the parsed address, and the data format; determining the corresponding target protocol type according to the source protocol parsing type, the parsed address, and the pre-configured communication rule; where the communication rule includes the source protocol type and the target protocol type corresponding to the source protocol type; verifying whether the data format conforms to the data format of the determined target protocol type, and based on the data format not conforming to the data format of the determined target protocol type, determining that there is a communication anomaly between the PLC and the external device.

[0015] It should be noted that by identifying and parsing the monitored data, the previously configured communication rules are searched according to the parsing results to determine the corresponding target protocol type, so as to verify whether the data format conforms to the data format of the determined target protocol type, realizing the detection of communication anomalies between the PLC and external devices; in addition, through the previously configured communication rules, centralized management is achieved, simplifying the system architecture and maintenance work, and improving the stability and reliability of the system.

[0016] According to a communication protocol conversion method provided by the present invention, based on determining a communication anomaly between the PLC and external devices, the monitored data is processed according to the communication rules, including: based on determining a communication anomaly between the PLC and external devices, according to the determined target protocol type, the parsed data is reorganized in data format, so as to realize the normal communication between the PLC and external devices through data format conversion when there is an incompatibility in the communication protocol between the PLC and external devices, eliminating the need for a physical switch or gateway, reducing costs and improving the flexibility of the system.

[0017] According to a communication protocol conversion method provided by the present invention, the parsed data is reorganized in data format according to the determined target protocol type, including: reorganizing the parsed data according to the data format of the target protocol type; or, determining a data format conversion rule according to the source protocol type, data format and communication rules; wherein, the communication rules further include a data format conversion rule that defines the data format conversion between the source protocol type and the corresponding target communication protocol; reorganizing the parsed data according to the data format conversion rule.

[0018] It should be noted that by the data format of the target protocol type, the parsed data format is reorganized, or according to the communication rules, a data format conversion rule is determined, and the parsed data format is reorganized according to the data format conversion rule, so that the source protocol parsing type is adapted to the corresponding determined target protocol type, thereby avoiding the incompatibility between the source protocol parsing type and the target protocol type; in addition, by configuring the data format conversion rule, the conversion of common industrial communication protocols is supported, ensuring that its compatibility and functionality are maintained in the face of the continuously evolving communication standards.

[0019] A communication protocol conversion method provided by the present invention returns the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or sends the processed data to the receiver, including: determining whether the external device is connected to the port of the PLC according to the pre-stored port connection relationship between the external device and the PLC; based on the external device being connected to the port of the PLC, sending the processed data to the sender so that the sender sends the processed data to the receiver; based on the external device not being connected to the port of the PLC, sending the processed data to the receiver through the communication interface.

[0020] It should be noted that by determining that the external device is connected to the PLC port, the processed data is returned to the sender between the external device and the PLC, so that the sender directly communicates with the receiver, and in the case where the external device is not connected to the PLC port, by allocating a virtual communication interface for the external device to adapt to and support more external devices to be connected to the PLC, avoiding the situation that the limited PLC ports are occupied and new external devices or communication protocols cannot be added, and improving the scalability and flexibility of the system.

[0021] The present invention also provides a communication protocol conversion device, including: a monitoring module that monitors the communication data between the programmable logic controller PLC and the external device to obtain monitoring data; an exception judgment module that determines whether there is a communication exception between the PLC and the external device according to the pre-configured communication rules; an exception handling module that, based on determining that there is a communication exception between the PLC and the external device, processes the monitoring data according to the communication rules and returns the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or sends the processed data to the receiver.

[0022] It should be noted that the monitoring module monitors the communication data between the PLC and the external device, so that the exception judgment module determines whether there is a communication exception between the PLC and the external device according to the monitoring data combined with the pre-configured communication rules. Thus, when there is a communication exception, the exception handling module processes the monitoring data according to the communication rules to achieve normal communication between the PLC and the external device, avoiding the introduction of additional hardware devices, reducing costs and space occupancy, avoiding the situation of communication protocol incompatibility between the PLC and the external device, and realizing more efficient and economical communication between the PLC and the external device; in addition, by configuring the communication rules, centralized management is realized, the system architecture and maintenance work are simplified, and the stability and reliability of the system are improved.

[0023] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, and when the processor executes the program, it implements the communication protocol conversion method as described in any one of the above.

[0024] The present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the communication protocol conversion method as described in any one of the above is implemented.

[0025] The present invention also provides a computer program product, including a computer program, and when the computer program is executed by a processor, the communication protocol conversion method as described in any one of the above is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the drawings in the following description are some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.

[0027] Figure 1 is one of the flow diagrams of the communication protocol conversion method provided by the present invention;

[0028] Figure 2 is the second flow diagram of the communication protocol conversion method provided by the present invention;

[0029] Figure 3 is the structural diagram of the communication protocol conversion device provided by the present invention;

[0030] Figure 4 is the structural diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0031] To make the objectives, technical solutions, and advantages of the present invention clearer, the following will clearly and completely describe the technical solutions in the present invention with reference to the accompanying drawings in the present invention. Obviously, the described embodiments are some, but not all, of the embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by those of ordinary skill in the art without creative efforts fall within the protection scope of the present invention.

[0032] Illustration 1 depicts a flow diagram of a communication protocol conversion method of the present invention. The execution subject of the method is a touch device with touch function, and the method includes:

[0033] S11, monitoring the communication data between a programmable logic controller (PLC) and an external device to obtain monitored data;

[0034] S12, determining whether there is a communication anomaly between the PLC and the external device according to pre-configured communication rules;

[0035] S13. Based on the determination of abnormal communication between the PLC and the external device, process the monitored data according to the communication rules, and return the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or send the processed data to the receiver.

[0036] It should be noted that a touch device such as a touch screen can be used to write corresponding macro instructions or configurations according to the above method, and the macro instructions are executed based on the processor of the touch device, so that the touch device can read the data stream of the communication between the PLC and the external device, process tasks such as monitored data and sending. In addition, the communication rules can be set based on the communication protocols of the actually involved Programmable Logic Controller (PLC) and the external device and the conversion rules between different protocols, and are configured when writing the macro instructions or configurations. When the communication rules change, such as being updated or needing to be replaced, the parameters for defining the communication rules part in the macro instructions or configurations can be updated, or the communication rules part in the macro instructions or configurations can be directly replaced, and the written macro instructions or configurations and the communication rules can be stored in the storage unit of the touch device, which is not further limited here.

[0037] It should be noted that the addresses in this specification are PLC register addresses or external device addresses. In addition, the step numbers "S1N" in this specification do not represent the sequence of the communication protocol conversion method. The following specifically combines Figure 2 to describe the communication protocol conversion method of the present invention.

[0038] Step S11: Monitor the communication data between the programmable logic controller PLC and the external device to obtain the monitored data.

[0039] It should be noted that when the PLC and the external device communicate, the PLC can send communication data to at least one external device, or at least one external device sends communication data to the PLC. Therefore, by monitoring, the data stream of the communication between the PLC and the external device is obtained, which is convenient for subsequently determining whether the PLC and the external device can communicate normally according to the pre-configured communication rules.

[0040] Step S12: Determine whether there is abnormal communication between the PLC and the external device according to the pre-configured communication rules.

[0041] In an alternative embodiment, determining whether there is a communication anomaly between the PLC and an external device according to pre-configured communication rules includes: identifying and parsing monitored data to obtain parsed data, where the parsed data includes a source protocol parsing type and a parsed address; determining a corresponding target protocol type according to the source protocol parsing type, the parsed address, and the pre-configured communication rules; where the communication rules include a source protocol type and a target protocol type corresponding to the source protocol type; verifying whether the parsed address conforms to the address range of the determined target protocol type, and determining that there is a communication anomaly between the PLC and the external device based on the parsed address not conforming to the address range of the determined target protocol type.

[0042] Further, verifying whether the parsed address conforms to the address range of the determined target protocol type further includes: determining that the communication is normal based on the parsed address conforming to the address range of the determined target protocol type.

[0043] It should be noted that by identifying and parsing the monitored data, searching for the pre-configured communication rules according to the parsing result, determining the corresponding target protocol type, and thus verifying whether the parsed address conforms to the address range of the determined target protocol type, the detection of communication anomalies between the PLC and the external device is realized; in addition, through the pre-configured communication rules, centralized management is realized, the system architecture and maintenance work are simplified, and the stability and reliability of the system are improved.

[0044] It should be noted that when configuring the source protocol type and the target protocol type corresponding to the corresponding source protocol type, the communication rules need to be set according to the communication protocols of the PLC and the external device. For example, when the PLC sends communication data to at least one external device, the corresponding source protocol type is determined according to the PLC, and the target protocol type is determined according to each external device communicating with the PLC. No further limitation is made here.

[0045] In addition, determining a corresponding target protocol type according to the source protocol parsing type, the parsed address, and the pre-configured communication rules includes: searching for communication rules according to the source protocol parsing type to obtain the target protocol type corresponding to the source protocol parsing type; determining the protocol type of the corresponding recipient according to the parsed address and the communication rules; determining whether the protocol type of the recipient is included in the target protocol type corresponding to the source protocol parsing type, and based on the inclusion, taking the protocol type of the recipient as the corresponding target protocol type.

[0046] It should be noted that since a PLC may be correspondingly connected to multiple external devices, or an external device is connected to different PLCs, it is necessary to preliminarily screen the target protocol type according to the source protocol parsing type and communication rules, and determine the protocol type of the receiving party according to the parsing address and communication rules, so as to determine whether the protocol type of the receiving party is included in the preliminarily screened target protocol type, thereby ensuring the accuracy of the finally confirmed target protocol type and avoiding mis-determining the protocol type of the receiving party in the case of multiple targets.

[0047] In another optional embodiment, it is determined whether there is a communication anomaly between the PLC and the external device according to the pre-configured communication rules, including: identifying and parsing the monitored data to obtain parsed data, where the parsed data includes the source protocol parsing type, parsing address, and data format; determining the corresponding target protocol type according to the source protocol parsing type, parsing address, and pre-configured communication rules; where the communication rules include the source protocol type and the target protocol type corresponding to the source protocol type; verifying whether the data format conforms to the data format of the determined target protocol type, and determining that there is a communication anomaly between the PLC and the external device based on the data format not conforming to the data format of the determined target protocol type.

[0048] It should be added that finding the communication rules according to the source protocol parsing type to obtain the target protocol type corresponding to the source protocol parsing type can be referred to the above description and will not be repeated here. In addition, verifying whether the data format conforms to the data format of the determined target protocol type further includes: determining that the communication between the PLC and the external device is normal based on the data format conforming to the data format of the determined target protocol type.

[0049] It should be noted that by identifying and parsing the monitored data, finding the pre-configured communication rules according to the parsing result to determine the corresponding target protocol type, thereby verifying whether the data format conforms to the data format of the determined target protocol type, the detection of communication anomalies between the PLC and the external device is realized; in addition, through the pre-configured communication rules, centralized management is realized, the system architecture and maintenance work are simplified, and the stability and reliability of the system are improved.

[0050] Step S13, based on determining that there is a communication anomaly between the PLC and the external device, process the monitored data according to the communication rules, and return the processed data to the sender between the PLC and the external device, so as to send the processed data to the receiver, or send the processed data to the receiver.

[0051] In an alternative embodiment, the communication rules further include an address mapping rule between the source protocol type and the target protocol type. Accordingly, based on determining that communication between the PLC and the external device is abnormal, the monitoring data is processed according to the communication rules, including: based on determining that communication between the PLC and the external device is abnormal, the corresponding address mapping rule is determined according to the source protocol parsing type, the parsed address, and the communication rules; and the parsed address is subjected to address conversion according to the determined address mapping rule.

[0052] It should be noted that by configuring the address mapping rule, when there is an incompatibility between the communication protocols of the PLC and the external device, address conversion can be achieved through software, eliminating the need for a physical switch or gateway, reducing costs, and improving the flexibility of the system.

[0053] Furthermore, performing address conversion on the parsed address according to the determined address mapping rule includes: searching for the parsed address mapping rule according to the source protocol parsing type and the target protocol type corresponding to the determined source protocol parsing type to obtain the corresponding mapped address; and using the mapped address as the mapping of the parsed address to perform address conversion.

[0054] It should be noted that through the pre-configured address mapping rule, address conversion can be performed quickly to solve the problem of communication protocol incompatibility between the PLC and the external device. And by configuring the address mapping rule, it allows for the rapid development and deployment of new protocol conversion logic, enabling the system to quickly adapt to new communication standards, enhancing the scalability and compatibility of the system, and ensuring the availability and applicability of the system in the long term.

[0055] In another alternative embodiment, based on determining that communication between the PLC and the external device is abnormal, the monitoring data is processed according to the communication rules, including: based on determining that communication between the PLC and the external device is abnormal, the parsed data is reorganized in data format according to the determined target protocol type, so that when there is an incompatibility between the communication protocols of the PLC and the external device, normal communication between the PLC and the external device can be achieved through data format conversion, eliminating the need for a physical switch or gateway, reducing costs, and improving the flexibility of the system.

[0056] Furthermore, reorganizing the parsed data in data format according to the determined target protocol type includes: reorganizing the parsed data in data format according to the data format of the target protocol type; or determining the data format conversion rule according to the source protocol type, the data format, and the communication rules, where the communication rules further include a data format conversion rule that defines the data format conversion between the source protocol type and the corresponding target communication protocol; and reorganizing the parsed data in data format according to the data format conversion rule.

[0057] It should be noted that, through the data format of the target protocol type, the parsed data format is reorganized, or according to the communication rules, the data format conversion rules are determined, so as to reorganize the parsed data format according to the data format conversion rules, making the source protocol parsing type compatible with the corresponding determined target protocol type, thereby avoiding the incompatibility between the source protocol parsing type and the target protocol type; in addition, by configuring the data format conversion rules, the conversion of common industrial communication protocols is supported, ensuring that its compatibility and functionality are maintained in the face of the constantly evolving communication standards.

[0058] In an alternative embodiment, the processed data is returned to the sender between the PLC and the external device to send the processed data to the receiver, or the processed data is sent to the receiver, including: determining whether the external device is connected to the port of the PLC according to the pre-stored port connection relationship between the external device and the PLC; based on the external device being connected to the port of the PLC, the processed data is sent to the sender, so that the sender sends the processed data to the receiver; based on the external device not being connected to the port of the PLC, a communication interface is allocated to send the processed data to the receiver.

[0059] It should be noted that by determining that the external device is connected to the PLC port, the processed data is returned to the sender between the external device and the PLC, so that the sender directly communicates with the receiver, and in the case where the external device is not connected to the PLC port, by dynamically allocating a virtual communication interface for the external device, more external devices are adapted and supported to be connected to the PLC, avoiding the situation that the limited PLC ports are occupied and new external devices or communication protocols cannot be added, and improving the scalability and flexibility of the system.

[0060] In an alternative embodiment, after the processed data is returned to the sender between the PLC and the external device to send the processed data to the receiver, or the processed data is sent to the receiver, it includes: generating a log according to the above processing situation to record communication anomalies.

[0061] In summary, the embodiments of the present invention determine whether there is a communication anomaly between the PLC and the external device by listening to the communication data between the PLC and the external device and combining the pre-configured communication rules, so that when there is a communication anomaly, the monitored data is processed according to the communication rules to achieve normal communication between the PLC and the external device, avoiding the introduction of additional hardware devices, reducing costs and space occupation, avoiding the incompatibility of communication protocols between the PLC and the external device, and achieving more efficient and economical communication between the PLC and the external device; in addition, by configuring the communication rules to achieve centralized management, the system architecture and maintenance work are simplified, and the stability and reliability of the system are improved.

[0062] The communication protocol conversion device provided by the present invention will be described below. The communication protocol conversion device described below can be correspondingly referred to the communication protocol conversion method described above.

[0063] Figure 3 The structural schematic diagram of a communication protocol conversion device is shown. The device includes:

[0064] A monitoring module 31 monitors the communication data between a programmable logic controller (PLC) and an external device to obtain monitoring data;

[0065] An exception judgment module 32 determines whether there is a communication exception between the PLC and the external device according to the pre-configured communication rules;

[0066] An exception handling module 33, based on determining that there is a communication exception between the PLC and the external device, processes the monitoring data according to the communication rules, and returns the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or sends the processed data to the receiver.

[0067] In an alternative embodiment, the exception judgment module 32 includes: a data parsing unit that identifies and parses the monitoring data to obtain parsed data, where the parsed data includes a source protocol parsing type and a parsing address; a protocol type determination unit that determines the corresponding target protocol type according to the source protocol parsing type, the parsing address, and the pre-configured communication rules; where the communication rules include a source protocol type and a target protocol type corresponding to the source protocol type; an exception judgment unit that verifies whether the parsing address conforms to the address range of the determined target protocol type, and based on the parsing address not conforming to the address range of the determined target protocol type, determines that there is a communication exception between the PLC and the external device.

[0068] Furthermore, the exception judgment unit is further configured to: based on the parsing address conforming to the address range of the determined target protocol type, determine that the communication is normal.

[0069] In addition, the protocol type determination unit includes: a search subunit that searches for communication rules according to the source protocol parsing type to obtain the target protocol type corresponding to the source protocol parsing type; a first protocol type determination subunit that determines the protocol type of the corresponding receiver according to the parsing address and the communication rules; a second protocol type determination subunit that determines whether the protocol type of the receiver is included in the target protocol type corresponding to the source protocol parsing type, and based on the inclusion, uses the protocol type of the receiver as the corresponding target protocol type.

[0070] In another alternative embodiment, the anomaly determination module 32 includes: a data parsing unit that identifies and parses the monitored data to obtain parsed data, where the parsed data includes the source protocol parsing type, the parsed address, and the data format; a protocol type determination unit that determines the corresponding target protocol type according to the source protocol parsing type, the parsed address, and the pre-configured communication rules, where the communication rules include the source protocol type and the target protocol type corresponding to the source protocol type; and an anomaly determination unit that verifies whether the data format conforms to the data format of the determined target protocol type, and determines that there is an anomaly in the communication between the PLC and the external device based on the data format not conforming to the data format of the determined target protocol type.

[0071] In an alternative embodiment, the communication rules further include an address mapping rule between the source protocol type and the target protocol type. Accordingly, the anomaly handling module 33 includes: a rule determination unit that determines the corresponding address mapping rule according to the source protocol parsing type, the parsed address, and the communication rules based on determining that there is an anomaly in the communication between the PLC and the external device; and an address conversion unit that performs address conversion on the parsed address according to the determined address mapping rule.

[0072] Further, the address conversion unit includes: a mapped address lookup subunit that looks up the parsed address mapping rule according to the source protocol parsing type and the target protocol type corresponding to the determined source protocol parsing type to obtain the corresponding mapped address; and an address mapping subunit that uses the mapped address as the mapping of the parsed address to perform address conversion.

[0073] In another alternative embodiment, the anomaly handling module 33 includes: a data reorganization unit that reorganizes the data format of the parsed data according to the determined target protocol type based on determining that there is an anomaly in the communication between the PLC and the external device.

[0074] Further, the data reorganization unit includes: a data reorganization subunit that reorganizes the data format of the parsed data according to the data format of the target protocol type; or, a rule lookup subunit that determines the data format conversion rule according to the source protocol type, the data format, and the communication rules, where the communication rules further include a data format conversion rule that defines the data format conversion between the source protocol type and the corresponding target communication protocol; and a data reorganization subunit that reorganizes the data format of the parsed data according to the data format conversion rule.

[0075] In an alternative embodiment, the exception handling module 33 further includes: a port connection status determination unit that determines whether an external device is connected to a port of the PLC according to a pre-stored port connection relationship between the external device and the PLC; a data sending unit that, based on the external device being connected to the port of the PLC, sends the processed data to the sender so that the sender sends the processed data to the receiver; and a data sending unit that, based on the external device not being connected to the port of the PLC, allocates a communication interface to send the processed data to the receiver.

[0076] In an alternative embodiment, the device further includes: a log generation module that generates a log according to the above processing situation to record communication exceptions after returning the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or after sending the processed data to the receiver.

[0077] In summary, in the embodiment of the present invention, the monitoring module monitors the communication data between the PLC and the external device, and the exception determination module determines whether there is a communication exception between the PLC and the external device according to the monitored data in combination with the pre-configured communication rules. Thus, when a communication exception occurs, the exception handling module processes the monitored data according to the communication rules to achieve normal communication between the PLC and the external device, avoid introducing additional hardware devices, reduce costs and space occupancy, avoid the situation of communication protocol incompatibility between the PLC and the external device, and achieve more efficient and economical communication between the PLC and the external device. In addition, by configuring the communication rules to achieve centralized management, the system architecture and maintenance work are simplified, and the stability and reliability of the system are improved.

[0078] Figure 4 Schematically shows an entity structure diagram of an electronic device, as Figure 4 shown, the electronic device may include: a processor 410, a communications interface 420, a memory 430, and a communication bus 440. Among them, the processor 410, the communications interface 420, and the memory 430 communicate with each other through the communication bus 440. The processor 410 can call logical instructions in the memory 430 to execute a communication protocol conversion method, which includes: monitoring communication data between a programmable logic controller PLC and an external device to obtain monitored data; determining whether there is a communication exception between the PLC and the external device according to pre-configured communication rules; based on determining that there is a communication exception between the PLC and the external device, processing the monitored data according to the communication rules, and returning the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or sending the processed data to the receiver.

[0079] In addition, when the logic instructions in the above-mentioned memory 430 are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods described in various embodiments of the present invention. The foregoing storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, read-only memories (ROM, Read-Only Memory), random access memories (RAM, Random Access Memory), magnetic disks, or optical discs.

[0080] On the other hand, the present invention also provides a computer program product. The computer program product includes a computer program stored on a non-transitory computer-readable storage medium. The computer program includes program instructions. When the program instructions are executed by a computer, the computer can execute the communication protocol conversion method provided by the above-mentioned various methods. The method includes: listening to the communication data between a programmable logic controller PLC and an external device to obtain listening data; determining whether there is a communication abnormality between the PLC and the external device according to pre-configured communication rules; based on determining that there is a communication abnormality between the PLC and the external device, processing the listening data according to the communication rules, and returning the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or sending the processed data to the receiver.

[0081] On another aspect, the present invention also provides a non-transitory computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it is implemented to execute the communication protocol conversion method provided by the above-mentioned various methods. The method includes: listening to the communication data between a programmable logic controller PLC and an external device to obtain listening data; determining whether there is a communication abnormality between the PLC and the external device according to pre-configured communication rules; based on determining that there is a communication abnormality between the PLC and the external device, processing the listening data according to the communication rules, and returning the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or sending the processed data to the receiver.

[0082] The device embodiments described above are merely illustrative. 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, that is, they may be located in one place or distributed to multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purpose of the solution of this embodiment. Those of ordinary skill in the art can understand and implement it without creative efforts.

[0083] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment 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 essence of the above technical solution, or the part that contributes to the prior art, can be embodied in the form of a software product. The computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions for causing 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.

[0084] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit them. Although the present invention has been described in detail with reference to the foregoing embodiments, those of ordinary skill in the art should understand that they can still modify the technical solutions recorded in the foregoing embodiments or equivalently replace some of the technical features. These modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A communication protocol conversion method, characterized in that, Including: Monitoring the communication data between a programmable logic controller (PLC) and an external device to obtain monitoring data; Determining whether there is an abnormal communication between the PLC and the external device according to a pre-configured communication rule; Based on determining that there is an abnormal communication between the PLC and the external device, processing the monitoring data according to the communication rule, and returning the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or sending the processed data to the receiver.

2. The communication protocol conversion method according to claim 1, wherein Determining whether there is an abnormal communication between the PLC and the external device according to a pre-configured communication rule includes: Identifying and parsing the monitoring data to obtain parsed data, where the parsed data includes a source protocol parsing type and a parsing address; Determining a corresponding target protocol type according to the source protocol parsing type, the parsing address, and a pre-configured communication rule; where the communication rule includes a source protocol type and a target protocol type corresponding to the source protocol type; Verifying whether the parsing address conforms to the address range of the determined target protocol type, and based on the parsing address not conforming to the address range of the determined target protocol type, determining that there is an abnormal communication between the PLC and the external device.

3. The communication protocol conversion method according to claim 2, characterized in that The communication rule further includes an address mapping rule between the source protocol type and the target protocol type; Based on determining that there is an abnormal communication between the PLC and the external device, processing the monitoring data according to the communication rule includes: Based on determining that there is an abnormal communication between the PLC and the external device, determining a corresponding address mapping rule according to the source protocol parsing type, the parsing address, and the communication rule; Performing an address conversion on the parsing address according to the determined address mapping rule.

4. The communication protocol conversion method according to claim 3, wherein, Performing an address conversion on the parsing address according to the address mapping rule includes: Searching for the parsing address mapping rule according to the source protocol parsing type and the target protocol type corresponding to the determined source protocol parsing type to obtain a corresponding mapped address; Using the mapped address as the mapping of the parsing address to perform an address conversion.

5. The communication protocol conversion method according to claim 2, wherein Determining a corresponding target protocol type according to the source protocol parsing type, the parsing address, and a pre-configured communication rule includes: Searching for the communication rule according to the source protocol parsing type to obtain a target protocol type corresponding to the source protocol parsing type; Determining a protocol type of the corresponding receiver according to the parsing address and the communication rule; Determining whether the protocol type of the receiver is included in the target protocol type corresponding to the source protocol parsing type, and based on inclusion, using the protocol type of the receiver as the corresponding target protocol type.

6. The communication protocol conversion method according to claim 1, characterized in that Determining whether there is an abnormal communication between the PLC and the external device according to a pre-configured communication rule further includes: Identifying and parsing the monitoring data to obtain parsed data, where the parsed data includes a source protocol parsing type, a parsing address, and a data format; Determine the corresponding target protocol type according to the source protocol parsing type, the parsing address, and the pre-configured communication rules; wherein, the communication rules include the source protocol type and the target protocol type corresponding to the source protocol type. Verify whether the data format conforms to the data format of the determined target protocol type, and based on the fact that the data format does not conform to the data format of the determined target protocol type, determine that the communication between the PLC and the external device is abnormal.

7. The communication protocol conversion method according to claim 6, wherein Based on determining that the communication between the PLC and the external device is abnormal, process the monitored data according to the communication rules, including: Based on determining that the communication between the PLC and the external device is abnormal, perform data format reorganization on the parsed data according to the determined target protocol type.

8. The communication protocol conversion method according to claim 7, characterized in that Performing data format reorganization on the parsed data according to the determined target protocol type includes: Perform data format reorganization on the parsed data according to the data format of the target protocol type; or, Determine a data format conversion rule according to the source protocol type, the data format, and the communication rules; wherein, the communication rules further include a data format conversion rule that defines the data format conversion between the source protocol type and the corresponding target communication protocol. Perform data format reorganization on the parsed data according to the data format conversion rule.

9. The communication protocol conversion method according to claim 1, wherein Return the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or send the processed data to the receiver, including: Determine whether the external device is connected to the port of the PLC according to the pre-stored port connection relationship between the external device and the PLC. Based on the external device being connected to the port of the PLC, send the processed data to the sender so that the sender sends the processed data to the receiver. Based on the external device not being connected to the port of the PLC, allocate a communication interface to send the processed data to the receiver.

10. A communication protocol conversion device, characterized in that, Including: A monitoring module that monitors the communication data between a programmable logic controller (PLC) and an external device to obtain monitored data. An abnormality determination module that determines whether the communication between the PLC and the external device is abnormal according to the pre-configured communication rules. An abnormality processing module that, based on determining that the communication between the PLC and the external device is abnormal, processes the monitored data according to the communication rules and returns the processed data to the sender between the PLC and the external device to send the processed data to the receiver, or sends the processed data to the receiver.

11. An electronic device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the communication protocol conversion method according to any one of claims 1 to 9.

12. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the communication protocol conversion method according to any one of claims 1 to 9.

Citation Information

Cited By

  • Multi-protocol conversion gateway data interaction method, system and device and storage medium

    CN121173882A