A PLC data interaction method based on publish-subscribe model

By introducing Pub/Sub communication in the publish-subscribe mode into the PLC system, the problem of inflexible device access in traditional industrial control systems is solved, dynamic device access and efficient data interaction are achieved, and the flexibility and scalability of the system are improved.

CN119603287BActive Publication Date: 2025-09-30SHENYANG INST OF AUTOMATION - CHINESE ACAD OF SCI
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411608198.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-12
Publication Date
2025-09-30
Estimated Expiration
2044-11-12

AI Technical Summary

Technical Problem

Traditional industrial control systems have fixed equipment access and cannot support the flexible access of new equipment, resulting in production stoppages and low production efficiency.

Method used

The PLC data interaction method based on the publish-subscribe model is adopted. Through the Pub/Sub communication mode, it supports dynamic access and data interaction of devices, and realizes flexibility and scalability between devices and PLC.

Benefits of technology

It supports dynamic device access without reconfiguration, improving the flexibility and data interaction efficiency of the PLC control system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119603287B_ABST
    Figure CN119603287B_ABST
Patent Text Reader

Abstract

The present invention discloses a PLC data interaction method based on a publish-subscribe model. The method of the present invention comprises: an IDE host computer configures the communication relationship between devices to obtain a device communication relationship configuration, and constructs an application for Topic data information processing; the IDE host computer compiles the application, and downloads the application and the device communication relationship configuration to the PLC; the PLC reads the device communication relationship configuration, establishes a Pub or Sub communication connection between devices, and associates it with a Topic through a communication program; allocates data cache to the Topic, and when the PLC is running, the communication program and the application exchange data through the Topic buffer, calls the communication program to process the Topic buffer data to the network for publishing and subscription, and dynamic access of new devices; and periodically calls the application to process the Topic data in the buffer. The method of the present invention can support dynamic access and acquisition of PLC control system data by devices without reconfiguration, thereby improving the flexibility and scalability of the PLC control system and improving the efficiency of data interaction between devices and the PLC.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of industrial control systems, and more particularly to a PLC data interaction method based on a publish-subscribe model. Background Art

[0002] With the rapid development of the Industrial Internet, the demand for the integration of IT and OT systems is growing stronger. The scope of industrial control systems has further expanded, from traditional, local OT-side industrial control systems consisting of PLCs and I / O to wider areas encompassing edge computing platforms, even cloud platforms, and IT systems. Information exchange between system devices is becoming increasingly extensive. The localized, fixed model of traditional industrial systems, limited by resources and scope, is no longer able to support application requirements. Opening up previously isolated data and information within industrial control systems and supporting flexible access and data acquisition from external devices has become the development direction of industrial control systems in this new era.

[0003] To ensure real-time and reliable data communication for industrial applications, traditional industrial control systems require devices to be centralized within a local area. Before the system is operational, it must be configured using an integrated development environment (IDE) on a host computer. This configuration targets devices connected to the PLC, configures the data interaction and communication relationships within the system, and then downloads the configuration to the PLC for execution. Since configured programs cannot be modified, the device data communication relationships are fixed. Therefore, the system cannot support the addition of new devices. Adding a new device requires stopping the system and redesigning the program and reconfiguring the communication relationships using the IDE, resulting in production downtime and reduced efficiency. Summary of the Invention

[0004] To address the above technical issues, the present invention provides a PLC data interaction method based on a publish-subscribe model. By changing the fixed device-binding connection between PLCs and devices, the present invention supports Topic-based Pub / Sub communication, enabling flexible device access and data interaction. Through the present method, industrial control systems can dynamically access and retrieve PLC control system data through Topic-based Pub / Sub communication, without the need for reconfiguration. This enhances the flexibility and scalability of PLC control systems and improves the efficiency of data interaction between devices and PLCs.

[0005] The present invention adopts the following technical solution: a PLC data interaction method based on the publish-subscribe model, comprising the following steps:

[0006] The IDE host computer scans the online devices and obtains the online devices and their IP addresses;

[0007] The IDE host computer configures the communication relationship between devices based on the acquired devices and IP addresses to obtain the device communication relationship configuration, and builds an application for processing Topic data information; wherein the device communication relationship includes the relationship between Pub and Sub, Reader, Writer, and Topic;

[0008] The IDE host computer compiles the application and downloads the configuration of the communication relationship between the application and the device to the PLC;

[0009] The PLC Runtime reads the device communication relationship configuration, establishes Pub or Sub communication connections between devices, and associates them with Topics through the communication program;

[0010] The PLC Runtime allocates data cache for the Topic to form a Topic buffer;

[0011] When the PLC is running, the communication program and the application program exchange data through the Topic buffer. The Runtime periodically calls the communication program to process the publication and subscription of the Topic buffer data to the network and the dynamic access of new devices; at the same time, it periodically calls the application program to process the Topic data in the buffer.

[0012] The Pub or Sub communication connection between devices and the Topic association are established through the communication program. Specifically, the communication program establishes Pub and Sub ends, establishes Readers and Writers, establishes Topic, and binds Topic Readers and Writers according to the device communication relationship configuration.

[0013] When the PLC is running, the communication program and the application program exchange data through the Topic buffer, including the following steps:

[0014] The communication program copies the subscribed topic received from the network to the corresponding position of the Topic's Sub buffer;

[0015] The application reads the Topic's Sub buffer and processes the subscribed Topic data information;

[0016] The application writes the processed output data to the Topic's Pub buffer;

[0017] The communication program publishes the information output by the application to the pub buffer topic to the network.

[0018] Allocating data cache to a Topic includes the following steps:

[0019] Allocation is performed based on Topic, with each Topic occupying one address space unit; it is divided into Pub Topic cache and Sub Topic cache.

[0020] The Pub Topic cache is used to store topics that applications need to publish to the network. Topic content is written by applications and read by communication programs and published to the network.

[0021] The Sub Topic buffer is used to store subscribed topics received from the network. Topic content is written by the communication program and read and processed by the application.

[0022] The Runtime periodically calls the communication program to process Topic buffer data to the network for publishing and subscription, and dynamic access of new devices, including the following steps:

[0023] When a new device is connected, it sends a Topic subscription request to the PLC. When subscribing to a configured Topic, the communication program adds the new device to the Reader list bound to the Topic. This allows the new device to subscribe to Topic data when the PLC publishes a Topic externally.

[0024] For data information publishing devices, set up one or more Publishers. A Publisher contains at least one Writer; a Writer is used to publish a Topic;

[0025] The device receiving the data information sets up one or more Subscribers, each of which contains at least one Reader; a Reader is used to subscribe to a Topic;

[0026] Data information is a Topic. Readers and Writers that publish and subscribe to the same Topic are bound to the Topic. Each Topic is bound to at least one Reader and at least one Writer.

[0027] A PLC data interaction system based on a publish-subscribe model, comprising:

[0028] The IDE host computer is used to scan online devices and obtain the devices and their IP addresses; based on the obtained devices and IP addresses, it configures the communication relationships between the devices to obtain the device communication relationship configuration, and builds an application program for Topic data information processing logic; wherein the device communication relationship includes the relationship between Pub and Sub, Reader, Writer, and Topic; compiles the application program, and downloads the application program and the device communication relationship configuration to the PLC;

[0029] The PLC is used to read the device communication relationship configuration through the Runtime, establish Pub or Sub communication connections between devices, and associate them with Topics through the communication program; the Runtime allocates data cache for the Topic to form a Topic buffer; when the PLC is running, the communication program and the application exchange data through the Topic buffer, and the Runtime periodically calls the communication program to process the Topic buffer data to the network for publishing and subscription and dynamic access of new devices; at the same time, it periodically calls the application to process the Topic data in the buffer.

[0030] The Topic buffer is a buffer allocated based on Topic, with each Topic occupying one address space unit. It includes:

[0031] The Pub Topic cache is used to store topics that applications need to publish to the network. Topic content is written by applications and read by communication programs and published to the network.

[0032] The Sub Topic buffer is used to store subscribed topics received from the network. Topic content is written by the communication program and read and processed by the application.

[0033] The PLC is provided with at least one Publisher and at least one Subscriber;

[0034] A Publisher contains at least one Writer; a Writer is used to publish a Topic;

[0035] A Subscriber contains at least one Reader; a Reader is used to subscribe to a Topic.

[0036] The device for publishing data information has one or more Publishers. A Publisher contains at least one Writer. A Writer is used to publish a Topic.

[0037] The device settings for receiving data information include one or more Subscribers, each of which contains at least one Reader; a Reader is used to subscribe to a Topic;

[0038] Data information is a Topic. Readers and Writers that publish and subscribe to the same Topic are bound to the Topic. Each Topic is bound to at least one Reader and at least one Writer.

[0039] The present invention has the following beneficial effects and advantages:

[0040] The present invention can support dynamic access of devices to a PLC control system without reconfiguration, thereby improving the flexibility and scalability of the PLC control system and increasing the efficiency of data interaction between the device and the PLC. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] Figure 1 A schematic diagram of an embodiment of an industrial control system supporting dynamic device access according to the present invention;

[0042] Figure 2 This is a flow chart of an embodiment of a PLC data interaction method based on a publish-subscribe model according to the present invention;

[0043] Figure 3 A flow chart of an embodiment of data exchange between a communication program and an application program through a Topic buffer during operation of a PLC device according to the present invention;

[0044] Figure 4 This is a schematic diagram of an embodiment of the process of dynamically accessing a PLC to perform data interaction with a device of the present invention. DETAILED DESCRIPTION

[0045] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.

[0046] See also Figure 1 , a schematic diagram of an embodiment of an industrial control system supporting dynamic device access of the present invention.

[0047] Industrial control systems are composed of various types of industrial equipment, including programmable logic controllers (PLCs), I / O devices, edge devices, and computers. These devices are connected and communicate data via a network. The PLC, as the master control unit of an industrial control system, is responsible for the operational processing logic of the devices within its control range. Before a PLC can be fully operational, it must be configured and its application written and compiled using the user integrated development environment (IDE) on a computer. The resulting executable file is then downloaded to the PLC, where it is called and executed by the runtime environment within the PLC.

[0048] The publish-subscribe model (Pub / Sub) is an asynchronous messaging model in the IT field, offering more flexible data transmission. Publishers publish messages to specific topics without worrying about who receives them. Subscribers only care about topics of interest and receive messages only for those topics they subscribe to. The publish-subscribe model allows for the dynamic addition and removal of subscribers, and the publisher and subscriber relationships associated with a topic can change at any time.

[0049] Applying Pub / Sub communication to industrial control systems can address system communication flexibility issues. However, traditional industrial control systems rely on fixed device-binding connections and employ fixed-cycle synchronous communication. This is not compatible with Pub / Sub's asynchronous communication based on Topic binding. Therefore, Pub / Sub communication cannot be directly applied to traditional industrial control systems. The interaction method between the PLC application and the communication program must be modified to enable the PLC to support Pub / Sub communication.

[0050] See also Figure 2 The present invention provides a flow chart of an embodiment of a PLC data interaction method based on a publish-subscribe model, including:

[0051] Step 201: The industrial control system equipment is started and put online;

[0052] Step 202: The IDE scans the online devices and obtains the online devices and IP addresses.

[0053] Step 203: Based on the acquired devices and IP addresses, configure the communication relationships between devices and write an application program for the Topic data information processing logic. The communication relationships include the relationships between roles (Publisher / Subscriber), readers (Reader), writers (Writer), and topics (Topic).

[0054] See also Figure 1, showing an embodiment of the Pub / Sub communication relationship configured in an industrial control system. Different from the C / S method and On the fly method commonly used in the prior art, the present invention adopts the Pub / Sub communication method. The data information publishing device participating in the communication (including the PUB end, which can be any type of device) can set one or more Publishers, and each Publisher contains at least one Writer. The data information receiving device (including the SUB end, which can be any type of device) can set one or more Subscribers, and each Subscriber contains at least one Reader. The data information is a Topic, and the Readers and Writers that publish and subscribe to the same Topic are bound to the Topic. Each Topic can be bound to multiple Readers and Writers. Figure 1 The communication relationship configured in is as follows: Publisher1 and Subscriber1 are set up in the PLC device. Publisher1 contains two Writers. Writer1 publishes Topic1, and Writer2 publishes Topic2. Subscriber1 contains two Readers. Reader1 subscribes to Topic3, and Reader2 subscribes to Topic4. The IO device can be a switch input device. Publisher2 is set up and contains two Writers. Writer1 publishes Topic3, and Writer2 publishes Topic4. The edge device can be a computing and execution unit. Subscriber2 is set up and contains three Readers. Reader1 subscribes to Topic1, Reader2 subscribes to Topic2, and Reader3 subscribes to Topic3. If the IO device publishes Topic3, the communication protocol will forward it according to the Reader subscribed to Topic3. Both the PLC and the edge device can receive data from the subscribed Topic3.

[0055] Step 204: The IDE compiles the application and downloads the configuration of the communication relationship between the application and the device to the PLC;

[0056] Step 205: The PLC Runtime reads the device communication relationship configuration and establishes a communication link and topic association between the devices through the communication program;

[0057] Among them, the PLC Runtime is the runtime environment of the PLC, which is responsible for creating task threads for applications compiled by the IDE and scheduling the execution of applications according to the configuration. At the same time, it also runs the basic functional programs of the PLC, including communication programs, online debugging programs, programs for interacting with the IDE, operating system kernel interface handlers, etc. After the Runtime reads and parses the device communication relationship configuration, it calls the communication program, which establishes the Publisher and Subscriber ends in the device according to the device communication relationship configuration, establishes the Reader contained in the Subscriber end and the Writer contained in the Publisher end, registers the Topic, and binds the Reader and Writer that publish and subscribe to the Topic.

[0058] Step 206: The PLC Runtime allocates data cache for the Topic;

[0059] Data caches are allocated based on topics, with each topic occupying one unit of address space. They are divided into a Pub Topic cache and a Sub Topic cache. The Pub Topic cache stores topics that applications need to publish to the network. Topic content is written by applications and read and published to the network by communication programs. The Sub Topic cache stores subscribed topics received from the network. Topic content is written by communication programs and read, processed, and read by applications.

[0060] Step 207: When the PLC is running, the communication program and the application program exchange data through the Topic buffer. The Runtime periodically calls the communication program to process the Topic buffer data to the network for publishing and subscribing, and for dynamic access of new devices. At the same time, the application program is periodically called to process the Topic data in the buffer.

[0061] See also Figure 3 , Figure 3 This is a flow chart of an embodiment of data exchange between a communication program and an application program through a Topic buffer during operation of a PLC device according to the present invention, including:

[0062] Step 301: The communication program copies the subscribed topic received from the network to the corresponding position of the Topic's sub buffer.

[0063] Step 302: The application reads the Topic Sub buffer and processes the subscribed Topic data information;

[0064] Step 303: The application writes the processed output data into the Topic's Pub buffer.

[0065] Step 304: The communication program publishes the information output by the application to the pub buffer topic to the network.

[0066] See also Figure 4 , which is a schematic diagram of an embodiment of the process of dynamically accessing a PLC to perform data interaction with a device of the present invention;

[0067] The PLC runtime runs a data processing application and a communication program. Topic data buffers are set up for both the application and the communication program. Topic 1 is the topic the PLC subscribes to, and Topic 2 is the topic the PLC publishes. Currently, only the Sub2 endpoint is subscribed to Topic 2. Therefore, after the communication program reads the data placed in the Topic 2 buffer by the application, it publishes Topic 2 data only to the Sub2 node.

[0068] When a new device, Sub3, joins the control system and sends a subscription request to the PLC for the configured Topic2, the communication program handles the discovery and dynamic addition of the new device. The program adds the Reader for the new device, Sub3, to the list of readers bound to Topic2. When the PLC publishes the Topic, it publishes Topic2 data to the Sub2 and Sub3 nodes, allowing the new device, Sub3, to subscribe to Topic2 data. This entire process requires no changes to the application or data buffer configuration, so no reconfiguration is required.

[0069] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.

[0070] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present invention. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present invention. Therefore, the present invention is not limited to the embodiments shown herein but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A PLC data interaction method based on publish-subscribe mode, characterized in that: The following steps are involved: The IDE host computer scans the online devices and obtains the online devices and their IP addresses; The IDE host computer configures the communication relationship between devices based on the acquired devices and IP addresses to obtain the device communication relationship configuration, and builds an application for processing Topic data information; wherein the device communication relationship includes the relationship between Pub and Sub, Reader, Writer, and Topic; The IDE host computer compiles the application and downloads the configuration of the communication relationship between the application and the device to the PLC; The PLC Runtime reads the device communication relationship configuration, establishes Pub or Sub communication connections between devices, and associates them with Topics through the communication program; The PLC Runtime allocates data cache for the Topic to form a Topic buffer; When the PLC is running, the communication program and the application program exchange data through the Topic buffer. The Runtime periodically calls the communication program to process the Topic buffer data to the network for publishing and subscription and dynamic access of new devices. At the same time, it periodically calls the application program to process the Topic data in the buffer. Allocating data cache to a Topic includes the following steps: Allocation is performed based on Topic, with each Topic occupying one address space unit; it is divided into Pub Topic cache and Sub Topic cache. The Pub Topic cache is used to store topics that applications need to publish to the network. Topic content is written by applications and read by communication programs and published to the network. The Sub Topic buffer is used to store subscribed topics received from the network. Topic content is written by the communication program and read and processed by the application.

2. A PLC data interaction method based on publish-subscribe mode according to claim 1, characterized in that: The Pub or Sub communication connection between devices and the Topic association are established through the communication program. Specifically, the communication program establishes Pub and Sub ends, establishes Readers and Writers, establishes Topic, and binds Topic Readers and Writers according to the device communication relationship configuration.

3. A PLC data interaction method based on publish-subscribe mode according to claim 1, characterized in that: When the PLC is running, the communication program and the application program exchange data through the Topic buffer, including the following steps: The communication program copies the subscribed topic received from the network to the corresponding position of the Topic's Sub buffer; The application reads the Topic's Sub buffer and processes the subscribed Topic data information; The application writes the processed output data to the Topic's Pub buffer; The communication program publishes the information output by the application to the pub buffer topic to the network.

4. A PLC data interaction method based on publish-subscribe mode according to claim 1, characterized in that: The Runtime periodically calls the communication program to process Topic buffer data to the network for publishing and subscription, and dynamic access of new devices, including the following steps: When a new device is connected, it sends a Topic subscription request to the PLC. When subscribing to a configured Topic, the communication program adds the new device to the Reader list bound to the Topic. This allows the new device to subscribe to Topic data when the PLC publishes a Topic externally.

5. A PLC data interaction method based on publish-subscribe mode according to claim 1, characterized in that: For data information publishing devices, set up one or more Publishers. A Publisher contains at least one Writer; a Writer is used to publish a Topic; The device receiving the data information sets up one or more Subscribers, each of which contains at least one Reader; a Reader is used to subscribe to a Topic; Data information is a Topic. Readers and Writers that publish and subscribe to the same Topic are bound to the Topic. Each Topic is bound to at least one Reader and at least one Writer.

6. A PLC data interaction system based on publish-subscribe mode, characterized in that: include: The IDE host computer is used to scan online devices and obtain the devices and their IP addresses; based on the obtained devices and IP addresses, it configures the communication relationships between the devices to obtain the device communication relationship configuration, and builds an application program for Topic data information processing logic; wherein the device communication relationship includes the relationship between Pub and Sub, Reader, Writer, and Topic; compiles the application program, and downloads the application program and the device communication relationship configuration to the PLC; The PLC is used to read the device communication relationship configuration through the Runtime, establish Pub or Sub communication connections between devices, and associate them with Topics through the communication program; the Runtime allocates data cache for the Topic to form a Topic buffer; when the PLC is running, the communication program and the application program exchange data through the Topic buffer, and the Runtime periodically calls the communication program to process the Topic buffer data to the network for publishing and subscription and dynamic access of new devices; and at the same time, periodically calls the application program to process the Topic data in the buffer; The Topic buffer is a buffer allocated based on Topic, with each Topic occupying one address space unit. It includes: The Pub Topic cache is used to store topics that applications need to publish to the network. Topic content is written by applications and read by communication programs and published to the network. The Sub Topic buffer is used to store subscribed topics received from the network. Topic content is written by the communication program and read and processed by the application.

7. A PLC data interaction system based on publish-subscribe mode according to claim 6, characterized in that: The PLC is provided with at least one Publisher and at least one Subscriber; A Publisher contains at least one Writer; a Writer is used to publish a Topic; A Subscriber contains at least one Reader; a Reader is used to subscribe to a Topic.

8. A PLC data interaction system based on publish-subscribe mode according to claim 6, characterized in that: Also includes: The device for publishing data information has one or more Publishers. A Publisher contains at least one Writer. A Writer is used to publish a Topic. The device settings for receiving data information include one or more Subscribers, each of which contains at least one Reader; a Reader is used to subscribe to a Topic; Data information is a Topic. Readers and Writers that publish and subscribe to the same Topic are bound to the Topic. Each Topic is bound to at least one Reader and at least one Writer.

Citation Information

Patent Citations

  • Power distribution network data transmission method using publishing and subscribing communication model

    CN104617666A

  • Power line carrier communication terminal control device, system and method

    CN105577736A