Polling communication method and device
By receiving a communication task list built in a structured text language in the PLC controller and performing tasks sequentially, the problems of low polling communication efficiency and poor scalability under the Modbus protocol are solved, efficient communication and flexible device management are achieved, and the Maintenance cost.
Patent Information
- Application Number
- CN202110733291.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-06-30
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2041-06-30
AI Technical Summary
When using the Modbus communication protocol to control PLC, the existing polling communication methods are inefficient and poorly scalable, especially when the number of communication tasks is large or the equipment changes, it requires rewriting the source program, which increases the development and maintenance costs.
Receive a communication task list built in a structured text language through the human-computer interaction interface of the PLC controller, and performs communication tasks in turn according to the polling order of the task list. It is independent of the source program and supports dynamic update of the task list, avoiding the construction of communication functions Module steps.
It improves the efficiency and scalability of polling communication, reduces the modification requirements for PLC controller source programs, and reduces the development and maintenance costs.
Smart Images

Figure CN113515082B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of communication technology, and in particular to a polling communication method and device. Background Art
[0002] When using the Modbus communication protocol to control a PLC (Programmable Logic Controller) controller for polling communication, the controlled devices of the PLC controller are first determined, and then the communication tasks of each controlled device are determined according to the device information of each controlled device (including the device type and the number of each type of device, etc.) and the communication data (including the reading and writing method, data address and data volume of the communication data, etc.), wherein each controlled device includes at least one communication task, and finally a polling communication program is written according to the determined communication task and the polling communication program is used as a part of the source program of the PLC controller, so that the PLC controller can realize the polling communication of each controlled device by running the polling communication program. At present, the polling communication program is mainly written in a conventional PLC programming language, and the polling communication program written based on the conventional PLC programming language must first construct a corresponding communication function function module when executing each communication task, and then use this function module to execute the communication task. When the number of communication tasks is large, this method greatly reduces the efficiency of polling communication. In addition, when adding or reducing controlled devices, the polling communication program needs to be rewritten, that is, the source program of the PLC controller needs to be rewritten, which significantly increases the development and maintenance costs of the PLC controller communication.
[0003] Accordingly, the art needs a new polling communication solution to solve the above problems. Summary of the invention
[0004] The present invention aims to solve the above technical problem, that is, to solve the problem of how to improve the communication efficiency of polling communication and the scalability of communication tasks.
[0005] In a first aspect, the present invention provides a polling communication method, which is applied to a PLC controller, wherein the PLC controller is communicatively connected to at least one controlled device, and the method comprises:
[0006] Receiving a communication task list through the human-computer interaction interface of the PLC controller, wherein the communication task list is constructed using a structured text language and based on at least one communication task determined according to a preset communication requirement of the controlled device;
[0007] In response to the received polling communication instruction, each communication task is executed in sequence according to the polling order of each communication task in the communication task list to complete the polling communication.
[0008] In a technical solution of the above-mentioned polling communication method, the PLC controller includes a communication interface, and the step of "executing each communication task in sequence according to the polling order of each communication task in the communication task list" specifically includes:
[0009] For each round of polling communication in the communication task list, task information of each communication task in the communication task list is acquired in sequence through the communication interface according to the polling order of each communication task in the communication task list, and corresponding communication operations are performed according to the task information.
[0010] In a technical solution of the above polling communication method, the method further includes:
[0011] In response to a communication task list update instruction received before, at the same time as, or after receiving the polling communication instruction, the communication tasks in the communication task list are updated.
[0012] In a technical solution of the above-mentioned polling communication method, the PLC controller includes a communication interface, and before the step of "executing each communication task in turn according to the polling order of each communication task in the communication task list", the method further includes:
[0013] Acquiring configuration information of the communication interface through the human-computer interaction interface;
[0014] The communication interface is configured according to the configuration information so that when the step of "executing each communication task in sequence according to the polling order of each communication task in the communication task list" is performed, each communication task can be executed in sequence through the communication interface after the interface configuration is completed.
[0015] In a technical solution of the above-mentioned polling communication method, the task information includes a device address of the controlled device, a data reading and writing mode, a data address, a data quantity, and a data buffer address.
[0016] In a second aspect, a polling communication device is provided, which is applied to a PLC controller, wherein the PLC controller is communicatively connected to at least one controlled device, and the device comprises:
[0017] A communication task list receiving module, configured to receive a communication task list through a human-computer interaction interface of the PLC controller, wherein the communication task list is constructed using a structured text language and based on at least one communication task determined according to a preset communication requirement of the controlled device;
[0018] The polling communication execution module is configured to respond to the received polling communication instruction and execute each communication task in sequence according to the polling order of each communication task in the communication task list to complete the polling communication.
[0019] In a technical solution of the above polling communication device, the PLC controller includes a communication interface, and the polling communication execution module is further configured to perform the following operations:
[0020] For each round of polling communication in the communication task list, task information of each communication task in the communication task list is acquired in sequence through the communication interface according to the polling order of each communication task in the communication task list, and corresponding communication operations are performed according to the task information.
[0021] In a technical solution of the above-mentioned polling communication device, the device further includes:
[0022] The communication task list updating module is configured to update the communication tasks in the communication task list in response to a communication task list updating instruction received before, at the same time as, or after receiving the polling communication instruction.
[0023] In a technical solution of the above polling communication device, the PLC controller includes a communication interface, and the device further includes a communication interface configuration module, and the communication interface configuration module is configured to perform the following operations:
[0024] Acquiring configuration information of the communication interface through the human-computer interaction interface;
[0025] The communication interface is configured according to the configuration information, so that the polling communication execution module can execute each communication task in sequence through the communication interface with the interface configuration completed.
[0026] In a technical solution of the above-mentioned polling communication device, the task information includes a device address of the controlled device, a data reading and writing mode, a data address, a data quantity, and a data buffer address.
[0027] The above one or more technical solutions of the present invention have at least one or more of the following beneficial effects:
[0028] In the technical solution of the present invention, a communication task list can be received through the human-computer interaction interface of the PLC controller, wherein the communication task list is constructed by using a structured text language and at least one communication task determined according to the communication requirements of the preset controlled device; and then, in response to the received polling communication instruction, each communication task can be executed in sequence according to the polling order of each communication task in the communication task list to complete the polling communication. Since the communication task list is independent of the source program of the PLC controller, there is no need to modify the source program of the PLC controller when the communication task list needs to be changed, which greatly improves the scalability of the polling communication task. In addition, by querying the communication task list to execute a specific communication task, there is no need to first construct a functional module of a corresponding communication function and then use this functional module to execute the communication task, which overcomes the defect of low polling communication efficiency when the number of communication tasks is large in the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] The disclosure of the present invention will become more easily understood with reference to the accompanying drawings. It is easy for those skilled in the art to understand that these drawings are only for illustrative purposes and are not intended to limit the scope of protection of the present invention. Among them:
[0030] Figure 1 is a schematic flow chart of main steps of a polling communication method according to an embodiment of the present invention;
[0031] Figure 2 is a schematic flow chart of main steps of a polling communication method according to another embodiment of the present invention;
[0032] Figure 3 It is a schematic diagram of the main structural block diagram of a polling communication device according to an embodiment of the present invention.
[0033] Reference numerals list :
[0034] 11: Communication task list receiving module; 12: Polling communication execution module. DETAILED DESCRIPTION
[0035] Some embodiments of the present invention are described below with reference to the accompanying drawings. It should be understood by those skilled in the art that these embodiments are only used to explain the technical principles of the present invention and are not intended to limit the protection scope of the present invention.
[0036] In the description of the present invention, "module" and "processor" may include hardware, software or a combination of the two. A module may include hardware circuits, various suitable sensors, communication ports, and memories, and may also include software parts, such as program codes, or a combination of software and hardware. The processor may be a central processing unit, a microprocessor, a digital signal processor, or any other suitable processor. The processor has data and / or signal processing functions. The processor may be implemented in software, hardware, or a combination of the two. Non-temporary computer-readable storage media include any suitable media that can store program codes, such as magnetic disks, hard disks, optical disks, flash memory, read-only memory, random access memory, etc.
[0037] See attached Figure 1 , Figure 1 FIG. 1 is a flow chart of the main steps of a polling communication method according to an embodiment of the present invention. The polling communication method of this embodiment can be applied to a PLC controller, wherein the PLC controller can be connected to at least one controlled device for communication. Figure 1 As shown, the polling communication method in the embodiment of the present invention mainly includes the following steps S101 to S102.
[0038] Step S101: receiving a communication task list through the human-computer interaction interface of the PLC controller.
[0039] In this embodiment, the human-machine interaction interface refers to an interface that can exchange information with the PLC controller. Information can be input to the PLC controller through the human-machine interaction interface, and information output by the PLC controller can also be received through the human-machine interaction interface.
[0040] In this embodiment, the communication task list can be constructed by using structured text language (ST language) and at least one communication task determined according to the preset communication requirements of the controlled device. Among them, each communication task corresponds to corresponding task information, and the task information includes but is not limited to the device address of the controlled device, the data reading and writing mode, the data address, the amount of data, and the data cache address for sending / receiving data. The device address can be the communication address of the controlled device. The data reading and writing mode refers to the way of processing the communication data, which can include two modes of reading data and writing data. The data reading and writing mode corresponding to each communication task can be reading data or writing data. The data address can be the address of the data to be read from the communication data, or it can be the address of the data to be written into the communication data in the communication data. The amount of data can be the amount of data read or written. The data cache address can be the address of the data cache used to cache read or write data.
[0041] Step S102: In response to the received polling communication instruction, each communication task is executed in sequence according to the polling order of each communication task in the communication task list to complete the polling communication.
[0042] In this embodiment, the polling communication instruction may be automatically generated after the PLC controller is started, or may be received through a human-computer interaction interface.
[0043] In one example, assuming that the communication task list includes three communication tasks a, b and c in the order of polling from first to last, after receiving the polling communication instruction, communication tasks a, b and c can be executed in sequence to complete a round of polling communication, and after completing a round of polling communication, the next round of polling communication can be entered immediately or after a certain interval, that is, communication tasks a, b and c are executed again in sequence. In this way, communication tasks a, b and c are executed cyclically to realize the polling communication of the communication tasks in the communication task list.
[0044] It can be known from the above steps S101 to S102 that the present embodiment realizes the polling communication between the PLC controller and the controlled device by constructing a communication task list and controlling the PLC controller to cyclically execute the communication tasks in the communication task list in sequence. Since the communication task list and the source program of the PLC controller are independent of each other, there is no need to modify the source program of the PLC controller when the communication task list needs to be changed, such as adding or deleting communication tasks, which greatly improves the scalability of the polling communication task. In addition, by querying the communication task list to execute a specific communication task, there is no need to first construct a functional module of a corresponding communication function and then use this functional module to execute the communication task, thereby overcoming the defect of low polling communication efficiency when the number of communication tasks is large in the prior art.
[0045] The above step S102 is described in detail below.
[0046] In one implementation of the embodiment of the present invention, the PLC controller may include a communication interface, and the PLC controller may be connected to the controlled device through the communication interface. The communication interface may be a communication interface based on the Modbus communication protocol. In this implementation, for each round of polling communication in the communication task list, the communication tasks in the communication task list may be executed according to the following steps 11 to 12:
[0047] Step 11: According to the polling order of each communication task in the communication task list, the task information of each communication task is obtained in turn through the communication interface.
[0048] Step 12: Perform corresponding communication operations according to the task information.
[0049] In an example, assuming that the task information of a communication task includes: the device address is 1, the data reading and writing mode is reading data, the data address is 40001, the data quantity is 5, and the data cache address is DB11, then the above task information can be obtained through the communication interface. After obtaining the task information, the PLC controller can perform corresponding communication operations according to the task information, that is, read the communication data with a data address of 40001 (such as the temperature data in the air-conditioning operation data, the data quantity of the temperature data is 5) sent by the controlled device with a device address of 1 (such as the air-conditioning operation data), and use the data cache area with a data cache area address of DB11 to cache the above-mentioned read communication data (such as the temperature data in the air-conditioning operation data).
[0050] According to the above description of the present embodiment, it is known that the present embodiment does not need to modify the source program of the PLC controller when the communication task list needs to be changed (such as adding or reducing the communication tasks when adding or reducing the controlled devices communicating with the PLC controller). Therefore, the present embodiment can add or delete the communication tasks in the communication task list before the PLC controller performs polling communication, during the execution of polling communication, or after stopping the execution of polling communication, that is, update the communication tasks in the communication task list, and even if the communication tasks are updated during the execution of polling communication, it will not affect the normal execution of the communication tasks that have been set in the communication task list by the PLC controller. Specifically, in one implementation of the present embodiment, the communication tasks in the communication task list can be updated (including but not limited to: adding new communication tasks, deleting original communication tasks) in response to the communication task list update instruction received before, at the same time, or after receiving the polling communication instruction. If the communication task list update instruction is received before or after receiving the polling communication instruction, since the PLC controller has not started the polling communication, it will naturally not affect the polling communication of the PLC controller. If a communication task list update instruction is received at the same time as a polling communication instruction, such as adding a new communication task to the communication task list, the PLC controller can also respond to the polling communication instruction normally, that is, execute each communication task in sequence according to the polling order of each set communication task in the communication task list. Even if the above-mentioned newly added communication task is not executed in the first round of polling communication, the newly added communication task can be executed normally in the next round of polling communication.
[0051] In an implementation of the embodiment of the present invention, the polling communication method may include not only the above steps S101 and S102, but also the following step S1020 before executing step S102.
[0052] Step S1020: Acquire configuration information of the communication interface through the human-computer interaction interface, and perform interface configuration on the communication interface according to the configuration information.
[0053] It should be noted that, in the present embodiment, there is no need to execute step S1020 each time the PLC controller is controlled to perform polling communication. Technical personnel in this field can enter the configuration information of the communication interface through the human-computer interaction interface according to actual needs, such as when the PLC controller is running for the first time or when the configuration information of the communication interface needs to be modified, so that the PLC controller can obtain the configuration information of the communication interface through the human-computer interaction interface, configure the communication interface according to the configuration information, and then when executing step S102, each communication task can be executed in sequence through the communication interface with the interface configuration completed to complete the polling communication.
[0054] See attached Figure 2 , Figure 2 1 is a flow chart of the main steps of a polling communication method according to another embodiment of the present invention. The polling communication method of this embodiment can also be applied to a PLC controller, wherein the PLC controller includes a human-machine interaction interface and a communication interface, and the PLC controller can communicate with at least one controlled device through the communication interface. It should be noted that the human-machine interaction interface and the communication interface are respectively Figure 1 The human-computer interaction interface and the communication interface in the illustrated method embodiment are similar and will not be described in detail here for the sake of brevity.
[0055] like Figure 2 As shown, in this embodiment, the configuration information of the communication interface can be obtained through the human-computer interaction interface, and then the communication interface is configured to complete the interface initialization of the communication interface. After receiving the polling communication instruction, the task information of each communication task can be obtained through the communication interface according to the polling order of each communication task in the communication task list, and then the corresponding communication operation can be performed according to the task information. When performing the communication operation, data can be read and written from the data buffer area. If the communication fails, that is, the communication operation is not completed, an alarm is issued, the current communication task is terminated, and the next communication task is continued; if the communication is successful, that is, the communication operation is completed, the next communication task is continued.
[0056] like Figure 2 As shown, the communication task list may include n communication tasks (task 1 to task n). Taking task 1 as an example, the task information of task 1 may include: the device address is 1, the data read / write mode is read (read data), the data address is 40001, and the data buffer address is DB11. In this embodiment, after receiving the polling communication instruction, the PLC controller may continuously and cyclically execute tasks 1 to n in sequence to complete the polling communication.
[0057] It should be pointed out that although the various steps in the above embodiments are described in a specific order, those skilled in the art can understand that in order to achieve the effects of the present invention, different steps do not have to be performed in such an order. They can be performed simultaneously (in parallel) or in other orders. These changes are within the scope of protection of the present invention.
[0058] Furthermore, the present invention also provides a polling communication device.
[0059] See attached Figure 3 , Figure 3 FIG. 1 is a main structural block diagram of a polling communication device according to an embodiment of the present invention. Figure 3 As shown, the polling communication device in the embodiment of the present invention mainly includes a communication task list receiving module 11 and a polling communication execution module 12. In some embodiments, the communication task list receiving module 11 can be configured to receive a communication task list through the human-computer interaction interface of the PLC controller, wherein the communication task list is constructed using a structured text language and at least one communication task determined according to the preset communication requirements of the controlled device; the polling communication execution module 12 can be configured to respond to the received polling communication instruction and execute each communication task in turn according to the polling order of each communication task in the communication task list to complete the polling communication. Among them, the task information may include the device address of the controlled device, the data reading and writing mode, the data address, the data quantity, and the data buffer address. In one embodiment, the description of the specific implementation function can be found in step S101-step S102.
[0060] In one embodiment, the PLC controller may include a communication interface, and the polling communication execution module 12 may be further configured to perform the following operations:
[0061] For each round of polling communication in the communication task list, task information of each communication task is acquired in turn through the communication interface according to the polling order of each communication task in the communication task list, and corresponding communication operations are performed according to the task information. In one embodiment, the description of the specific implementation function can be found in step S102.
[0062] In one embodiment, the polling communication device may further include a communication task list update module, and in this embodiment, the communication task list update module may be configured to update the communication tasks in the communication task list in response to a communication task list update instruction received before, at the same time, or after receiving the polling communication instruction. In one embodiment, the description of the specific implementation function can be referred to in step S1020.
[0063] In one embodiment, the PLC controller includes a communication interface, and the polling communication device may further include a communication interface configuration module. In this embodiment, the communication interface configuration module is configured to perform the following operations:
[0064] The configuration information of the communication interface is obtained through the human-computer interaction interface; the communication interface is configured according to the configuration information, so that the polling communication execution module 12 can execute each communication task in sequence through the communication interface with the interface configuration completed.
[0065] The polling communication device is used to perform Figure 1-2 The polling communication method embodiment shown in the figure has similar technical principles, technical problems solved and technical effects produced. Technical personnel in this technical field can clearly understand that for the convenience and conciseness of description, the specific working process and related instructions of the polling communication device can refer to the contents described in the embodiment of the polling communication method, which will not be repeated here.
[0066] It is understood by those skilled in the art that the present invention implements all or part of the processes in the method of the above embodiment, and can also be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of each of the above method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device, medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory, random access memory, electric carrier signal, telecommunication signal and software distribution medium that can carry the computer program code. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.
[0067] Further, it should be understood that since the setting of each module is only for illustrating the functional units of the device of the present invention, the physical devices corresponding to these modules may be the processor itself, or a part of the software in the processor, a part of the hardware, or a part of the combination of software and hardware. Therefore, the number of each module in the figure is only schematic.
[0068] Those skilled in the art will appreciate that the modules in the device can be adaptively split or merged. Such splitting or merging of specific modules will not cause the technical solution to deviate from the principle of the present invention, and therefore, the technical solutions after splitting or merging will fall within the protection scope of the present invention.
[0069] So far, the technical solutions of the present invention have been described in conjunction with the preferred embodiments shown in the accompanying drawings. However, it is easy for those skilled in the art to understand that the protection scope of the present invention is obviously not limited to these specific embodiments. Without departing from the principle of the present invention, those skilled in the art can make equivalent changes or substitutions to the relevant technical features, and the technical solutions after these changes or substitutions will fall within the protection scope of the present invention.
Claims
1. A polling communication method, characterized in that: Applied to a PLC controller, the PLC controller is communicatively connected with at least one controlled device, the method comprising: Receiving a communication task list through the human-computer interaction interface of the PLC controller, wherein the communication task list is constructed using a structured text language and based on at least one communication task determined according to a preset communication requirement of the controlled device; In response to the received polling communication instruction, executing each communication task in sequence according to the polling order of each communication task in the communication task list to complete the polling communication; in, The communication task list is independent of the source program of the PLC controller; The PLC controller includes a communication interface, which is a communication interface based on the Modbus communication protocol. The step of "executing each communication task in sequence according to the polling order of each communication task in the communication task list" specifically includes: for each round of polling communication in the communication task list, according to the polling order of each communication task in the communication task list, obtaining the task information of each communication task in sequence through the communication interface, and executing corresponding communication operations according to the task information.
2. The polling communication method according to claim 1, characterized in that: The method further comprises: In response to a communication task list update instruction received before, at the same time as, or after receiving the polling communication instruction, the communication tasks in the communication task list are updated.
3. The polling communication method according to claim 1, characterized in that: The PLC controller includes a communication interface. Before the step of "executing each communication task in turn according to the polling order of each communication task in the communication task list", the method further includes: Acquiring configuration information of the communication interface through the human-computer interaction interface; The communication interface is configured according to the configuration information so that each communication task can be executed in sequence through the communication interface after the interface configuration is completed when executing the step of "execute each communication task in sequence according to the polling order of each communication task in the communication task list".
4. The polling communication method according to claim 1, characterized in that: The task information includes the device address of the controlled device, data reading and writing mode, data address, data quantity and data buffer address.
5. A polling communication device, characterized in that: Applied to a PLC controller, the PLC controller is communicatively connected with at least one controlled device, and the device comprises: A communication task list receiving module, configured to receive a communication task list through a human-computer interaction interface of the PLC controller, wherein the communication task list is constructed using a structured text language and based on at least one communication task determined according to a preset communication requirement of the controlled device; a polling communication execution module, configured to execute each communication task in sequence according to the polling order of each communication task in the communication task list in response to the received polling communication instruction, so as to complete the polling communication; in, The communication task list is independent of the source program of the PLC controller; The PLC controller includes a communication interface, which is a communication interface based on the Modbus communication protocol. The polling communication execution module is further configured to perform the following operations: for each round of polling communication in the communication task list, according to the polling order of each communication task in the communication task list, the task information of each communication task is obtained in turn through the communication interface, and corresponding communication operations are performed according to the task information.
6. The polling communication device according to claim 5, characterized in that: The device also includes: The communication task list updating module is configured to update the communication tasks in the communication task list in response to a communication task list updating instruction received before, at the same time as, or after receiving the polling communication instruction.
7. The polling communication device according to claim 5, characterized in that: The PLC controller includes a communication interface, and the device also includes a communication interface configuration module, wherein the communication interface configuration module is configured to perform the following operations: Acquiring configuration information of the communication interface through the human-computer interaction interface; The communication interface is configured according to the configuration information, so that the polling communication execution module can execute each communication task in sequence through the communication interface with the interface configuration completed.
8. The polling communication device according to claim 5, characterized in that: The task information includes the device address of the controlled device, data reading and writing mode, data address, data quantity and data buffer address.
Citation Information
Patent Citations
Security programmable logic controller communication system and communication method
CN106444602A
Systems and methods for self configuration of remote terminal units
CN106843169A
Control program test method and system
CN108153284A
Distributed batch processing system and procedures
DE19940078B4
