Programmable logic controller control method, device, equipment and readable storage medium

By dividing the online modification part of the PLC program into an interruptible and resumable part and a blocking part, and loading it during the non-disruptive time period, the problem of control cycle jitter caused by online modification of the PLC program is solved, ensuring stable operation of the production line and reducing downtime maintenance.

CN114327626BActive Publication Date: 2024-11-22SHENZHEN INOVANCE TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111502620.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-12-09
Publication Date
2024-11-22
Estimated Expiration
2041-12-09

AI Technical Summary

Technical Problem

Existing technologies can easily lead to control cycle jitter when modifying programmable logic controller (PLC) programs online, affecting the stability of products on the production line and resulting in high downtime maintenance costs.

Method used

By dividing the online modification part into an interruptible and resumable part and a blocking part, and utilizing the uninterrupted time period of the control program for loading, the modification is ensured to be completed without affecting the operation of the existing control program.

Benefits of technology

This allows modifications to be made during the operation of the control program without causing excessive jitter in the control cycle, ensuring stable operation of the production line and reducing the need for downtime maintenance.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114327626B_ABST
    Figure CN114327626B_ABST
Patent Text Reader

Abstract

The present invention discloses a programmable logic controller control method, device, equipment and readable storage medium, belonging to the field of programmable logic controller. The present invention obtains the corresponding online modification part when the control program is executed, and the online modification part includes an interruptible continuation part and a blocking part; obtains the actual execution time period of the control program, and calculates the non-disturbance time period based on the control cycle and the actual execution time period; schedules the interruptible continuation part to be loaded in the non-disturbance time period; when it is detected that the interruptible continuation part is fully loaded, the execution of the control program in the next control cycle is blocked, and the blocking part is loaded at the beginning of the next control cycle to complete the modification of the control program, so as to ensure that the program can be modified during the operation of the control program, and the control cycle is not caused too much jitter as a whole.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of programmable logic controllers, and in particular to a programmable logic controller control method, device, equipment and readable storage medium. Background Art

[0002] With the development of Programmable Logic Controller (PLC), its performance is getting stronger and stronger, and it undertakes more and more control tasks and logic, so the scale of user programs running on PLC and the equipment controlled by it are becoming more and more complex. In the actual production line, as the material and product requirements change, the control parameters of the program and the control logic of the terminal are not static.

[0003] The existing technical solutions mostly adopt the method of downloading and replacing the program after stopping the machine, which will cause the interruption of the user's control logic and require the re-initialization of the environmental data. If the change of such control parameters requires the production line to be shut down for maintenance, it will bring huge maintenance costs. Therefore, the method of modifying the PLC program online is now mostly adopted.

[0004] However, online modification of the PLC program usually leads to jitter in the control cycle. The accumulation of such jitter is reflected in the equipment action, which may cause deviations in the actual execution effect, thus affecting the product stability of the production line. Summary of the invention

[0005] The main purpose of the present invention is to provide a programmable logic controller control method, device, equipment and readable storage medium, aiming to reduce the adverse effects of program modification of the programmable logic controller on the production line and ensure the normal and stable operation of the online equipment of the production line.

[0006] To achieve the above object, the present invention provides a programmable logic controller control method, the programmable logic controller control method comprising the following steps:

[0007] When the control program is executed, a corresponding online modification part is obtained, wherein the online modification part includes an interruptible continuation part and a blocking part, and the control program is provided with a corresponding control cycle;

[0008] Acquire an actual execution time period of the control program, and calculate a non-disturbance time period based on the control cycle and the actual execution time period;

[0009] Scheduling the interruptible continuation portion to be loaded during the disturbance-free time period;

[0010] When it is detected that all the interruptible continuation parts have been loaded, the execution of the control program in the next control cycle is blocked, and the blocked part is loaded at the beginning of the next control cycle to complete the modification of the control program.

[0011] Optionally, the step of obtaining an actual execution time period of the control program and calculating a non-disturbance time period based on the control cycle and the actual execution time period includes:

[0012] Acquire a first actual execution time period of the control program in a current control cycle;

[0013] The current remaining time period of the current control cycle is calculated and used as the non-disturbance time period.

[0014] Optionally, the step of obtaining an actual execution time period of the control program and calculating a non-disturbance time period based on the control cycle and the actual execution time period includes:

[0015] Tracking and counting a preset number of the control programs in the second actual execution time period of the historical control cycle, and calculating the historical remaining time period;

[0016] A minimum remaining time period is selected from the historical remaining time periods as the non-disturbance time period.

[0017] Optionally, the step of scheduling the interruptible continuation part to be loaded during the disturbance-free time period includes:

[0018] Scheduling the interruptible and continuing part to be loaded during the non-disturbance time period, and confirming whether the interruptible and continuing part has been completely loaded;

[0019] If loading is not completed, obtain the undisturbed time period corresponding to the next control cycle, and cyclically execute the steps of scheduling the interruptible continuation part to be loaded during the undisturbed time period, and confirming whether the interruptible continuation part has been fully loaded, until the interruptible continuation part has been fully loaded.

[0020] Optionally, when the control program is executed, a corresponding online modification part is obtained, the online modification part includes an interruptible continuation part and a blocking part, and before the step of setting the control program with a corresponding control cycle, the method further includes:

[0021] confirming a part of the online modification part that affects the operation of the control program, and dividing the online modification part;

[0022] dividing the part of the online modification part that affects the operation into a blocking part;

[0023] The portion of the online modification portion that does not affect the operation is divided into an interruptible and continuable portion.

[0024] Optionally, the step of dividing the part of the online modification part that affects the operation into a blocking part comprises:

[0025] taking the part of the online modification part that affects the operation as the initial blocking part;

[0026] Obtaining a third actual execution time of the history of the control program, and calculating an estimated loading time of the initial blocking portion;

[0027] confirming whether the estimated loading time of the initial blocking portion meets the execution condition based on the third actual running time and the control period;

[0028] If the estimated loading time does not satisfy the execution condition, the size of the initial blocking part is compressed to obtain the blocking part.

[0029] Optionally, after the step of blocking the execution of the control program in the next control cycle after detecting that all the interruptible continuation parts have been loaded, and loading the blocked part at the beginning of the next control cycle to complete the modification of the control program, the method further comprises:

[0030] Obtaining the modified target program and executing the target program;

[0031] The resources occupied by the portion of the control program replaced by the online modification portion are released.

[0032] In addition, to achieve the above object, the present invention also provides a programmable logic controller control device, the device comprising:

[0033] An acquisition module, used for acquiring a corresponding online modification part when the control program is executed, wherein the online modification part includes an interruptible continuation part and a blocking part, and the control program is provided with a corresponding control cycle;

[0034] A calculation module, used for obtaining an actual execution time period of the control program, and calculating a non-disturbance time period based on the control cycle and the actual execution time period;

[0035] A scheduling module, used for scheduling the interruptible continuation part to be loaded during the non-disturbance time period;

[0036] The data refresh module is used to block the execution of the control program in the next control cycle when it is detected that the interruptible continuation part is fully loaded, and load the blocked part at the beginning of the next control cycle to complete the modification of the control program.

[0037] Optionally, the calculation module is further used for:

[0038] Acquire a first actual execution time period of the control program in a current control cycle;

[0039] The current remaining time period of the current control cycle is calculated and used as the non-disturbance time period.

[0040] Optionally, the calculation module is further used for:

[0041] Tracking and counting a preset number of the control programs in the second actual execution time period of the historical control cycle, and calculating the historical remaining time period;

[0042] A minimum remaining time period is selected from the historical remaining time periods as the non-disturbance time period.

[0043] Optionally, the scheduling module is further used to:

[0044] Scheduling the interruptible and continuing part to be loaded during the non-disturbance time period, and confirming whether the interruptible and continuing part has been completely loaded;

[0045] If loading is not completed, obtain the undisturbed time period corresponding to the next control cycle, and cyclically execute the steps of scheduling the interruptible continuation part to be loaded during the undisturbed time period, and confirming whether the interruptible continuation part has been fully loaded, until the interruptible continuation part has been fully loaded.

[0046] Optionally, the acquisition module is further used to:

[0047] confirming a part of the online modification part that affects the operation of the control program, and dividing the online modification part;

[0048] dividing the part of the online modification part that affects the operation into a blocking part;

[0049] The portion of the online modification portion that does not affect the operation is divided into an interruptible and continuable portion.

[0050] Optionally, the acquisition module is further used to:

[0051] taking the part of the online modification part that affects the operation as the initial blocking part;

[0052] Obtaining a third actual execution time of the history of the control program, and calculating an estimated loading time of the initial blocking portion;

[0053] confirming whether the estimated loading time of the initial blocking portion meets the execution condition based on the third actual running time and the control period;

[0054] If the estimated loading time does not satisfy the execution condition, the size of the initial blocking part is compressed to obtain the blocking part.

[0055] Optionally, the data refreshing module is further used for:

[0056] Obtaining the modified target program and executing the target program;

[0057] The resources occupied by the portion of the control program replaced by the online modification portion are released.

[0058] In addition, to achieve the above-mentioned purpose, the present invention also provides a programmable logic controller control device, which includes: a memory, a processor, and a programmable logic controller control program stored in the memory and executable on the processor, and when the programmable logic controller control program is executed by the processor, the steps of the programmable logic controller control method as described above are implemented.

[0059] In addition, to achieve the above-mentioned purpose, the present invention also provides a readable storage medium, on which a programmable logic controller control program is stored. When the programmable logic controller control program is executed by a processor, the steps of the programmable logic controller control method as described above are implemented.

[0060] The programmable logic controller control method, device, equipment and readable storage medium proposed in the present invention obtain the corresponding online modification part when the control program is executed, and the online modification part includes an interruptible continuation part and a blocking part, and the control program is provided with a corresponding control cycle; obtain the actual execution time period of the control program execution, and based on the control cycle and the actual execution time period, calculate the non-disturbance time period between the actual execution time period and the control cycle; schedule the interruptible continuation part to be loaded in the non-disturbance time period; when it is detected that the interruptible continuation part is fully loaded, block the execution of the control program of the next control cycle, and load the blocking part at the beginning of the next control cycle to complete the modification of the control program, so as to ensure that the program can be modified during the operation of the control program without causing excessive jitter to the control cycle as a whole. BRIEF DESCRIPTION OF THE DRAWINGS

[0061] Figure 1 It is a schematic diagram of the structure of a programmable logic control device in a hardware operating environment involved in an embodiment of the present invention;

[0062] Figure 2It is a flow chart of the first embodiment of the programmable logic controller control method of the present invention;

[0063] Figure 3 A schematic diagram of a control cycle when a control program is running stably in one embodiment of the present invention;

[0064] Figure 4 A schematic diagram of an online modification process after optimization of the programmable logic controller control method according to the present invention;

[0065] Figure 5 It is a flow chart of a second embodiment of a programmable logic controller control method of the present invention;

[0066] Figure 6 A schematic diagram of an online modification process of selecting the minimum remaining time slice as the interruptible continuation part loading time in the third embodiment of the programmable logic controller control method of the present invention;

[0067] Figure 7 It is a schematic diagram of a replacement implementation method of the online modification part of the present invention;

[0068] Figure 8 It is a schematic diagram of an embodiment of a programmable logic controller control device of the present invention.

[0069] The realization of the purpose, functional features and advantages of the present invention will be further explained in conjunction with embodiments and with reference to the accompanying drawings. DETAILED DESCRIPTION

[0070] It should be understood that the specific embodiments described herein are only used to explain the present invention, and are not used to limit the present invention.

[0071] Reference Figure 1 , Figure 1 This is a schematic diagram of the structure of a programmable logic controller control device in the hardware operating environment involved in the embodiment of the present invention.

[0072] like Figure 1As shown, the programmable logic controller control device may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Among them, the communication bus 1002 is used to realize the connection and communication between these components. The user interface 1003 may include a display screen (Display), an input unit such as a keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface and a wireless interface. The network interface 1004 may optionally include a standard wired interface and a wireless interface (such as a wireless fidelity (WIreless-FIdelity, WI-FI) interface). The memory 1005 may be a high-speed random access memory (Random Access Memory, RAM) memory, or a stable non-volatile memory (Non-Volatile Memory, NVM), such as a disk memory. The memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0073] Those skilled in the art will understand that Figure 1 The structure shown in the figure does not constitute a limitation on the programmable logic controller control device, and may include more or less components than shown in the figure, or combine certain components, or arrange the components differently.

[0074] like Figure 1 As shown, the memory 1005 as a storage medium may include an operating system, a data storage module, a network communication module, a user interface module and a programmable logic controller control program.

[0075] exist Figure 1 In the programmable logic controller control device shown, the network interface 1004 is mainly used for data communication with other devices; the user interface 1003 is mainly used for data interaction with the user; the processor 1001 and the memory 1005 in the programmable logic controller control device of the present invention can be set in the programmable logic controller control device, and the programmable logic controller control device calls the programmable logic controller control program stored in the memory 1005 through the processor 1001, and executes the programmable logic controller control method provided by the embodiment of the present invention.

[0076] The embodiment of the present invention provides a programmable logic controller control method, referring to Figure 2 , Figure 2 The figure is a flow chart of a first embodiment of a programmable logic controller control method of the present invention.

[0077] In this embodiment, the programmable logic controller control method includes:

[0078] Step S10, when the control program is executed, obtaining a corresponding online modification part, the online modification part includes an interruptible continuation part and a blocking part, and the control program is provided with a corresponding control cycle;

[0079] Step S20, obtaining an actual execution time period of the control program, and calculating a non-disturbance time period based on the control cycle and the actual execution time period;

[0080] Step S30, scheduling the interruptible continuing part to be loaded during the non-disturbance time period;

[0081] Step S40, when it is detected that all the interruptible and continuing parts have been loaded, the execution of the control program in the next control cycle is blocked, and the blocked part is loaded at the beginning of the next control cycle to complete the modification of the control program.

[0082] The programmable logic controller control method of this embodiment is used in the modification of the programmable logic controller program. In a control cycle of the PLC program, the user always hopes to increase the load of the controller as much as possible to improve the utilization rate of the controller, reduce the total number of equipment in the production line, and thus reduce the cost of the production line. When modifying online, the communication, data reception and replacement with the integrated development environment (IDE, Integrated Development Environment) will inevitably lead to the inability to start the subsequent control cycle in time. Only after all online modifications are completed and the new data is linked in place can the next control cycle be started. Therefore, this embodiment provides a programmable logic controller control method to realize non-disturbance heat modification of the PLC program. In this embodiment, the control program is a program running on the programmable logic controller; the control cycle is a fixed cycle preset by the user, and the user's control program will be fixedly called once in each control cycle. Considering the difference in program logic per cycle and the delay of hardware action, the control cycle is usually longer than the actual execution time of the control program, that is, a margin is left to ensure the stability of the programmable logic controller control system. Specifically, the length of the control cycle can be set according to actual conditions.

[0083] For ease of understanding, in one embodiment, refer to Figure 3 , Figure 3 Schematic diagram of a control cycle when a control program is running stably in one embodiment of the present invention.

[0084] exist Figure 3In the figure, the control cycle is set to 10ms. A rectangle in the figure represents the total time of a control cycle. The black part in the figure represents the actual execution time of the control program, and the white part is the remaining time after the control program is actually executed. The actual execution time of the control program is not greater than the total time of the control cycle.

[0085] When the user's control program can be stably started on time every 10ms, the system is stable. When the start time of the control program deviates from the expected time, the control program jitters. In the online modification of the program, the time required for a series of modification operations, that is, the time required for the online modification part, is generally much longer than the average remaining time of the control program in each cycle, which will instantly increase the jitter of the next control cycle.

[0086] This embodiment utilizes the remaining time between the actual execution time and the control cycle during the operation of the PLC program to load the online modification part of the control program, and decomposes the online modification part into two parts, namely, an interruptible continuation part that can be interrupted / continued multiple times and a blocking part that needs to be blocked for execution, and makes the operation time of the latter as short as possible. Without interrupting the existing control program, the interruptible continuation part is loaded in a non-disturbance time period. After completing the download of the interruptible continuation part, the execution of the control program is blocked at the beginning of the next control cycle, and the blocking part is loaded, thereby realizing non-disturbance hot modification of the control program.

[0087] The following is a detailed description of each step:

[0088] Step S10, when the control program is executed, obtaining a corresponding online modification part, the online modification part includes an interruptible continuation part and a blocking part, and the control program is provided with a corresponding control cycle;

[0089] In one embodiment, while the control program is being executed, the programmable logic controller obtains the online modification part, which includes: an interruptible continuation part and a blocking part, and the control program is set with a control cycle accordingly. Among them, the online modification part is the data required to modify the currently executed control program, and the online modification part is divided into an interruptible continuation part and a blocking part manually or according to a preset calculation rule; the interruptible continuation part is the part where data can be interrupted / continued to be transmitted, that is, the part that can be loaded intermittently multiple times, and this part of data can include the part required for auxiliary online modification in addition to the modification content corresponding to the control program; the blocking part is the part that cannot be completed in batches during the data modification process and needs to be completed at one time, and the loading or execution of this part requires blocking the operation of the original control program.

[0090] Step S20, obtaining an actual execution time period of the control program, and calculating a non-disturbance time period based on the control cycle and the actual execution time period;

[0091] In one embodiment, the programmable logic controller obtains the actual execution time period required for the execution of the control program, compares the actual execution time period with the control cycle, and obtains the non-disturbance time period. The non-disturbance time period is a time period that does not interfere with the execution of the control program. It can be understood that this embodiment uses the idle time from the end of the control program execution to the beginning of the next control cycle to load the online modification data, that is, the interruptible continuation part can be loaded within this time period, and any time period selected within this period can be used as the non-disturbance time period. Therefore, it is necessary to calculate the non-disturbance time period to load the interruptible continuation part in the online modification part.

[0092] Further, in one embodiment, the step of obtaining the actual execution time period of the control program and calculating the disturbance-free time period based on the control cycle and the actual execution time period includes:

[0093] Step S21, obtaining the first actual execution time period of the control program in the current control cycle;

[0094] In one embodiment, the first actual execution time period corresponding to the current control cycle of the control program is obtained. It can be understood that to obtain the disturbance-free time period, it is necessary to first know when the control program is completed. In this embodiment, the programmable logic controller obtains the time period required for the execution of the currently executing control program, that is, the first actual execution time period.

[0095] Step S22, calculating and obtaining the current remaining time period of the current control cycle, and taking the current remaining time period as the non-disturbance time period.

[0096] In one embodiment, after obtaining the first actual execution time period, the current remaining time period of the current control cycle is calculated, and the current remaining time period is used as the non-disturbance time period. Specifically, in the control cycle, after obtaining the first actual execution time period, the period from the end of the first actual execution time period to the end of the current control cycle is the remaining time period. In this embodiment, the remaining time period in each control cycle is used as the non-disturbance time period, and the remaining time after the control program is executed is maximized to load the interruptible and continued part.

[0097] Step S30, scheduling the interruptible continuing part to be loaded during the non-disturbance time period;

[0098] In one embodiment, after obtaining the non-disturbance time period, the interruptible continuation part is scheduled to be loaded in the non-disturbance time period. The interruptible continuation part is scheduled to be loaded in the non-disturbance time period, so that some work of online modification can be performed without affecting the execution of the control program. Specifically, the data of the interruptible continuation part is loaded, but the download of these new data will not be submitted to the control program that is running in the control cycle, so as to achieve the purpose of not affecting the operation of the original control program.

[0099] Further, in one embodiment, the step of scheduling the interruptible continuation part to be loaded in the disturbance-free time period includes:

[0100] Step S31, scheduling the interruptible and continuing part to be loaded in the non-disturbance time period, and confirming whether the interruptible and continuing part has been completely loaded;

[0101] In one embodiment, the interruptible continuation part is scheduled to be loaded in the non-disturbance time period, and whether the interruptible continuation part is fully loaded is confirmed. Specifically, in the process of loading the interruptible continuation part in the non-disturbance time period, it is necessary to confirm whether the interruptible continuation part is fully loaded. It is understandable that the interruptible continuation part can be scheduled to be loaded in the non-disturbance time period once or multiple times, depending on the loading situation of the interruptible continuation part. For example, if the interruptible continuation part has a lot of data and cannot be loaded in the non-disturbance time period corresponding to a control cycle, it needs to be loaded in multiple non-disturbance time periods.

[0102] Step S32, if the loading is not completed, obtain the disturbance-free time period corresponding to the next control cycle, and cyclically execute the steps of scheduling the interruptible continuation part to be loaded in the disturbance-free time period, and confirming whether the interruptible continuation part has been fully loaded, until the interruptible continuation part has been fully loaded.

[0103] In one embodiment, if the interruptible continuation part is not fully loaded in the non-disturbance time period, then the non-disturbance time period of the next control cycle is obtained, and the steps of scheduling the interruptible continuation part to be loaded in the non-disturbance time period and confirming whether the interruptible continuation part is fully loaded are cyclically executed, and the step is stopped when the interruptible continuation part is fully loaded. Specifically, if only a part of the interruptible continuation part can be loaded in the current non-disturbance time period, then the loading is suspended when the control program of the next control cycle starts running, and the loading of the interruptible continuation part is continued in the non-disturbance time period of the next cycle, and it is confirmed whether the loading of the interruptible continuation part is completed. If the loading is not completed, the non-disturbance time period of the next cycle is continued to be obtained for loading, and this is repeated until it is detected that the loading of the interruptible continuation part is fully completed.

[0104] Step S40, when it is detected that all the interruptible and continuing parts have been loaded, the execution of the control program in the next control cycle is blocked, and the blocked part is loaded at the beginning of the next control cycle to complete the modification of the control program.

[0105] In one embodiment, when it is detected that the interruptible continuation part is fully loaded, the execution of the control program of the next control cycle is blocked, and the blocking part is loaded at the beginning of the next control cycle to complete the modification of the control program. It can be understood that after the interruptible continuation part is loaded, it is equivalent to the completion of the data preparation work. Next, the part that will affect the operation of the control program needs to be loaded. In order to enable the execution of the program within the control cycle, rather than not executing the program in a control cycle due to online modification, the blocking part is loaded by occupying a short period of time at the beginning of the next control cycle, that is, delaying the execution of the program, so as to quickly complete the modification of the program. It should be noted that the next control cycle is a control cycle after the current control cycle, which can be the next control cycle or a control cycle after several control cycles, that is, after the current interruptible continuation part is loaded, it can be freely selected to complete the blocking part of the next control cycle or wait for 1 to 2 more cycles to appropriately reduce the overall load of the system. This embodiment ensures that the program can be executed within the control cycle, and makes the execution time as close as possible to the start time of the control cycle to reduce the jitter of the control cycle.

[0106] For ease of understanding, in one embodiment, the above example is used. Figure 4 , Figure 4 The schematic diagram of the online modification process after the optimization of the programmable logic controller control method according to the present invention is used to illustrate this embodiment.

[0107] exist Figure 4 In the figure, the gray part is the loading time of the online modification part. The first four figures from left to right represent that the interruptible continuation part in the online modification part is loaded after the control program is executed, and stops when the control program starts to execute in the next control cycle. When the control program is executed, the interruptible continuation part is loaded again, and the loading is completed in batches. In the last figure, after the interruptible continuation part is loaded, the blocking part is loaded before the control program starts. The loading time of this part is shorter. The black part is the actual execution time of the target program after the modification is completed, and a part of the white rectangle is used to represent the remaining time, indicating that the total time of modifying the control program by loading the interruptible blocking part and the actual execution time of the modified program does not exceed the control cycle.

[0108] It should be noted that, in this embodiment, executing step S10 first and then executing step S20 is only an embodiment. The order of executing step S10 and step S20 is not limited in the present invention. In another embodiment, step S20 may be executed first and then step S10.

[0109] The programmable logic controller control method proposed in the present invention divides the online modification part required by the control program into an interruptible continuation part and a blocking part, so that the interruptible continuation part is loaded in batches in the non-disturbance time slice between the completion of the control program execution and the start of the next control cycle, but the download of these interruptible continuation parts will not be submitted to the control program that is running in the control cycle. Subsequently, it is only necessary to complete the data submission of the blocking part before the next control cycle control program starts to execute, and the online modification of the control program can be completed. Since only the last submission requires the actual blocking of the control program, and the last blocking part data is very small compared to all the online modification parts, the execution time required for the modification is very short, which can ensure that the program is modified during the operation of the control program, and does not cause excessive jitter to the control cycle as a whole, so that the goal of non-disturbance downloading can be achieved, ensuring the normal and stable operation of the online equipment, and providing convenience for debugging such as production line upgrades and process parameter adjustments, without the need to frequently start and stop the production line to cause losses.

[0110] Furthermore, based on the first embodiment of the programmable logic controller control method of the present invention, a second embodiment of the programmable logic controller control method of the present invention is proposed.

[0111] Reference Figure 5 A flow chart of a second embodiment of a programmable logic controller control method of the present invention. In the second embodiment, after step S40, the method further includes:

[0112] Step S41, obtaining the modified target program and executing the target program;

[0113] In one embodiment, after modifying the control program, a modified target program is obtained and the target program is executed. It can be understood that the ultimate purpose of modifying the program is to adjust the production line according to the modified target program, so the target program is executed after the modification is completed.

[0114] Step S42, releasing the resources occupied by the part of the control program replaced by the online modification part.

[0115] In one embodiment, after obtaining the target program, the modified portion of the original control program does not need to be stored, and thus the resources occupied by this portion are released.

[0116] In this embodiment, after the modification of the control program is completed, the modified target program is obtained, and the target program is executed, and at the same time, the memory occupied by the part replaced by the online modification part is released. Specifically, after the blocking part is loaded, the entire online modification part is loaded, that is, the modification of the control program is completed, and the modified target program is obtained. At this time, the target program is executed, and the unnecessary replaced data residing in the memory is released from the memory, so as to improve the utilization rate of memory resources and thus improve the performance of the programmable logic controller.

[0117] Furthermore, based on the first and second embodiments of the programmable logic controller control method of the present invention, a third embodiment of the programmable logic controller control method of the present invention is proposed.

[0118] The third embodiment of the programmable logic controller control method is different from the first and second embodiments of the programmable logic controller control method in that the step of obtaining the actual execution time period of the control program and calculating the non-disturbance time period based on the control cycle and the actual execution time period includes:

[0119] Step a, tracking and counting a preset number of the control programs in the second actual execution time period of the historical control cycle, and calculating the historical remaining time period;

[0120] Step b: selecting a minimum remaining time period from the historical remaining time periods as the non-disturbance time period.

[0121] This embodiment differs from the previous embodiment in the method of obtaining the actual execution time period of the control program and calculating the disturbance-free time period based on the control cycle and the actual execution time period. This embodiment obtains the minimum remaining time period in the historical remaining time period and uses the minimum remaining time period as a fixed disturbance-free time period to reduce the burden of the programmable logic controller to recalculate the disturbance-free time period in each control cycle, thereby making control simpler.

[0122] The following is a detailed description of each step:

[0123] Step a, tracking and counting a preset number of the control programs in the second actual execution time period of the historical control cycle, and calculating the historical remaining time period;

[0124] In one embodiment, the programmable logic controller tracks and counts the second actual execution time period of a preset number of control programs in the historical control cycle, and calculates the historical remaining time period. It can be understood that since the interruptible continuation part needs to be loaded multiple times, in one embodiment, the non-disturbance time slice used each time is a time of uncertain length, that is, the remaining time period is of uncertain length. The programmable logic controller needs to use the scheduler to recalculate how much remaining time the interruptible continuation part can use in each cycle. This places relatively high requirements on the design of the scheduler, and is relatively complex, and there is a problem of scheduling difficulty. Therefore, the preset number of historical remaining time periods can be obtained by subtracting the total time of the preset number of control cycles from the second actual execution time period corresponding to the control cycle.

[0125] Among them, the second actual execution time period is the actual execution time period of the control program history. In the step of tracking and counting the second actual execution time period of the preset number of control programs in the historical control cycle, the optimal choice of the historical control cycle is the historical control cycle of the control program executed recently. Due to the delay of hardware actions and other factors that affect the actual execution time, the historical remaining time period calculated by the second actual execution time period of the most recent control program execution has a smaller error. It should be noted that the preset number can be set according to the actual situation, for example, it can be 10 second actual execution time periods corresponding to the most recent 10 control program executions.

[0126] Step b: selecting a minimum remaining time period from the historical remaining time periods as the non-disturbance time period.

[0127] In one embodiment, the programmable logic controller selects the minimum remaining time period from a preset number of historical remaining time periods as the non-disturbance time period for the interruptible continuation part to be loaded. Because the loading of the interruptible continuation part cannot affect the operation of the original control program, a second actual execution time period required for the execution of the control program is obtained through statistics, and the corresponding historical remaining time period is calculated, and the minimum remaining time is selected as the non-disturbance time period, that is, the actual execution time required for the control program is the longest second actual execution time counted, and the corresponding non-disturbance time period is the minimum remaining time period.

[0128] It is understandable that if the preset number is larger, the minimum remaining time period will usually be smaller, then the number of control cycles required for the interruptible continuation part will also be more, and the total online modification time will also be longer. The results of multiple tracking statistics and implementations can be stored to obtain the optimal preset number to guide subsequent online modifications.

[0129] For ease of understanding, in one embodiment, the above example is used. Figure 6 , Figure 6 This is a schematic diagram of an online modification process for selecting the minimum remaining time slice as the interruptible and continuing partial loading time in the third embodiment of the present invention.

[0130] like Figure 6 As shown in the figure, according to the statistical results of the most recent control cycle, the minimum remaining time period is selected as the fixed time occupied by the online modification function. The gray part in the first four figures from left to right represents the minimum remaining time period, and the size is consistent. The interruptible continuation part is loaded in the minimum remaining time period, and the online modification part is not loaded in the remaining time after the actual execution time.

[0131] This embodiment tracks and statistics the minimum remaining time period corresponding to the control program in the most recent control cycles, and uses the minimum remaining time period as the non-disturbance time period fixedly occupied by the interruptible continuation part loading, and appropriately lengthens the total time of the interruptible continuation part loading to solve the scheduling difficulty problem caused by the unequal length of each non-disturbance time period.

[0132] Furthermore, based on the previous embodiments of the programmable logic controller control method of the present invention, a fourth embodiment of the programmable logic controller control method of the present invention is proposed.

[0133] The fourth embodiment of the programmable logic controller control method is different from the previous embodiment of the programmable logic controller control method in that, when the control program is executed, the corresponding online modification part is obtained, and the online modification part includes an interruptible continuation part and a blocking part. Before the step of setting the control program with a corresponding control cycle, the method further includes:

[0134] Step c, confirming the part of the online modification part that affects the operation of the control program, and dividing the online modification part;

[0135] Step d, dividing the part of the online modification part that affects the operation into a blocking part;

[0136] Step e: dividing the part of the online modification part that does not affect the operation into an interruptible and continuable part.

[0137] This embodiment divides the online modification part into two parts by confirming the part that affects the operation of the control program in the online modification part. The part that affects the operation of the current control program in the online modification part is divided into a blocking part, and the part that does not affect the operation of the current control program in the online modification part is divided into an interruptible and continuing part. It should be noted that we actually modify the running control program through these two parts, so after the control program is updated, these two parts will eventually affect the operation of the control program. The online modification part of this embodiment is divided according to whether it affects the operation of the current control program. The interruptible and continuing part is only the part that does not affect the operation of the current control program, but the control program is eventually changed, affecting the operation of the control program.

[0138] The following is a detailed description of each step:

[0139] Step c, confirming the part of the online modification part that affects the operation of the control program, and dividing the online modification part;

[0140] In one embodiment, before the programmable logic controller obtains the online modification part, the part of the online modification part that affects the operation of the control program is confirmed, and the online modification part is divided. It can be understood that this embodiment is based on the purpose of minimizing the impact on the operation of the control program within the control cycle. Therefore, the part of the online modification part that affects the operation of the control program is confirmed, and the part that does not affect the operation of the control program is also obtained.

[0141] Step d, dividing the part of the online modification part that affects the operation into a blocking part;

[0142] In one embodiment, the part of the online modification part that affects the operation of the control program is treated as a blocking part. Specifically, the part that affects the operation of the control program, that is, the part that needs to terminate the operation of the control program, is treated as the online loading part and loaded last. The loading of the blocking part requires blocking the original control program, and the loading or operation of the blocking part needs to be completed at one time and cannot be interrupted.

[0143] Step e: dividing the part of the online modification part that does not affect the operation into an interruptible and continuable part.

[0144] In one embodiment, after the part of the online modification part that affects the operation of the control program is divided into a blocking part, the remaining part that does not affect the operation of the control program is the interruptible and continuable part. The loading of this part can be interrupted and continued at any time without affecting the operation of the control program. This part of the data includes where the blocking part needs to be executed, the program content to be replaced, etc.

[0145] For ease of understanding, in one embodiment, refer to Figure 7 , Figure 7 It is a schematic diagram of the replacement implementation method of the online modification part of the present invention, explaining the whole process of control program modification.

[0146] exist Figure 7 In the example, the control program contains two functions: F1 and F2. Function F1 has a calling relationship with F2. The user modifies the implementation of function F2 and needs to complete the logic replacement through online modification, replacing F2 with F2'. The replacement steps are explained according to the figure above. The replacement is divided into two steps:

[0147] The first step is to use the remaining time of each control cycle to slowly load the F2' function. During this process, the part that has no impact on the control program is loaded, that is, the interruptible and continuing part. In the figure, F2' (30%) is used to represent the loading progress of the interruptible and continuing part in F2'. It should be noted that this process may require multiple control cycles to complete. This figure does not limit the number of control cycles required and the loading progress of the interruptible and continuing part in each control cycle.

[0148] The second step is, after the interruptible continuation part is loaded, that is, F2' (100%), before the next control cycle starts, the function link relationship is replaced, that is, F1 is linked to F2'. At this time, since the content that needs to be modified is only the association relationship between functions, the impact on the overall time is very small. This part is the blocking part that will affect the normal operation of the control program.

[0149] Therefore, the division of the continued part and the blocked part can be interrupted according to whether it will affect the normal operation of the control program, so as to ensure that the loading of most of the data in the online modification part is completed while the control program is running.

[0150] Further, in one embodiment, the step of dividing the part of the online modification part that affects the operation into a blocking part comprises:

[0151] Step f, taking the part of the online modification part that affects the operation as the initial blocking part;

[0152] In one embodiment, if a part of the online modification part that has an impact on the execution of the control program is confirmed, then this part is used as the initial blocking part. Instead of directly using the divided part that has an impact on the control program as the blocking part, it is first used as the initial uninterruptible part, and then it is further confirmed whether the initial uninterruptible part can be used as the blocking part.

[0153] Step g, obtaining a third actual execution time of the history of the control program, and calculating an estimated loading time of the initial blocking part;

[0154] In one embodiment, the third actual time of the history of the control program is obtained, and the estimated loading time of the blocking part is calculated. Specifically, the third actual time corresponding to the historical execution of the control program is obtained. Since the online modification part is usually obtained based on the control program, and in the same control cycle, the execution time required for the modified program is roughly the same as the actual execution required for the control program, the third actual execution time of the history of the control program is obtained as a reference for the actual execution time of the program after the online modification. Furthermore, the estimated loading time of the initial blocking part is calculated based on the loading time required for the historical loading of the initial blocking part. It can be understood that in order to ensure that the target program can be executed within the control cycle after the blocking part is loaded, it is necessary to obtain the estimated loading time of the initial blocking part and the actual execution time required for the online modified program.

[0155] Step h, confirming whether the estimated loading time of the initial blocking part meets the execution condition based on the third actual running time and the control period;

[0156] In one embodiment, whether the estimated execution time of the initial blocking part meets the execution condition is determined based on the third actual running time and the control cycle. Specifically, after obtaining the third actual execution time of the control program for multiple times under the same control cycle, the third actual execution time is processed by taking the average value, the median, etc. to obtain a statistical value, and then the estimated loading time is added to compare with the total duration of the control cycle. If it exceeds the total duration of the control cycle, or the difference with the total duration is less than a preset threshold, it is judged that the execution condition is not met. The size of the preset threshold can be set according to the actual situation.

[0157] Step i: if the estimated loading time does not meet the execution condition, the size of the initial blocking part is compressed to obtain the blocking part.

[0158] In one embodiment, if the initial blocking part does not meet the execution condition, the size of the initial blocking part is compressed to finally obtain the blocking part. It can be understood that if the estimated loading time of the initial non-blockable part plus the actual execution time required for the modified program exceeds the control cycle or the difference with the length of the control cycle is less than a preset threshold, that is, the execution condition is not met, then loading the initial blocking part will cause a large cycle jitter. Therefore, it is necessary to compress the initial blocking part to shorten its estimated loading time, and then use the compressed initial blocking part as the blocking part for online modification of the control program to reduce the jitter of the control cycle.

[0159] This embodiment reduces the impact of online modification on the operation of the control program in the control cycle by dividing the online modification part into an interruptible continuation part that can be loaded without affecting the operation of the control program and a blocking part that needs to briefly block the operation of the control program. When dividing the blocking part, the required loading time is confirmed to ensure that the blocking part meets the execution conditions, further avoiding excessive jitter in the control cycle due to blocking the operation of the program, thereby achieving relatively smooth online modification.

[0160] The present invention also provides a programmable logic controller control device. Figure 3 As shown, Figure 3 It is a schematic diagram of a programmable logic controller control device of the present invention.

[0161] The programmable logic controller control device of the present invention comprises:

[0162] An acquisition module 10, used for acquiring a corresponding online modification part when the control program is executed, the online modification part including an interruptible continuation part and a blocking part, and the control program is provided with a corresponding control cycle;

[0163] A calculation module 20, configured to obtain an actual execution time period of the control program, and calculate a non-disturbance time period based on the control cycle and the actual execution time period;

[0164] A scheduling module 30, used for scheduling the interruptible continuation part to be loaded during the non-disturbance time period;

[0165] The data refresh module 40 is used to block the execution of the control program in the next control cycle when it is detected that the interruptible continuation part is fully loaded, and load the blocked part at the beginning of the next control cycle to complete the modification of the control program.

[0166] Optionally, the calculation module is further used for:

[0167] Acquire a first actual execution time period of the control program in a current control cycle;

[0168] The current remaining time period of the current control cycle is calculated and used as the non-disturbance time period.

[0169] Optionally, the calculation module is further used for:

[0170] Tracking and counting a preset number of the control programs in the second actual execution time period of the historical control cycle, and calculating the historical remaining time period;

[0171] A minimum remaining time period is selected from the historical remaining time periods as the non-disturbance time period.

[0172] Optionally, the scheduling module is further used to:

[0173] Scheduling the interruptible and continuing part to be loaded during the non-disturbance time period, and confirming whether the interruptible and continuing part has been completely loaded;

[0174] If loading is not completed, obtain the undisturbed time period corresponding to the next control cycle, and cyclically execute the steps of scheduling the interruptible continuation part to be loaded during the undisturbed time period, and confirming whether the interruptible continuation part has been fully loaded, until the interruptible continuation part has been fully loaded.

[0175] Optionally, the acquisition module is further used to:

[0176] confirming a part of the online modification part that affects the operation of the control program, and dividing the online modification part;

[0177] dividing the part of the online modification part that affects the operation into a blocking part;

[0178] The portion of the online modification portion that does not affect the operation is divided into an interruptible and continuable portion.

[0179] Optionally, the acquisition module is further used to:

[0180] taking the part of the online modification part that affects the operation as the initial blocking part;

[0181] Obtaining a third actual execution time of the history of the control program, and calculating an estimated loading time of the initial blocking portion;

[0182] confirming whether the estimated loading time of the initial blocking portion meets the execution condition based on the third actual running time and the control period;

[0183] If the estimated loading time does not satisfy the execution condition, the size of the initial blocking part is compressed to obtain the blocking part.

[0184] Optionally, the data refreshing module is further used for:

[0185] Obtaining the modified target program and executing the target program;

[0186] The resources occupied by the portion of the control program replaced by the online modification portion are released.

[0187] The invention also provides a readable storage medium.

[0188] The readable storage medium of the present invention stores a programmable logic controller control program, and when the programmable logic controller control program is executed by a processor, the steps of the programmable logic controller control method described above are implemented.

[0189] Among them, the method implemented when the programmable logic controller control program running on the processor is executed can refer to the various embodiments of the programmable logic controller control method of the present invention, and will not be repeated here.

[0190] It should be noted that, in this article, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or system including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or system. In the absence of further restrictions, an element defined by the sentence "comprises a ..." does not exclude the existence of other identical elements in the process, method, article or system including the element.

[0191] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0192] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes a number of instructions for a terminal device (which can be a mobile phone, a computer, a server, or a network device, etc.) to execute the methods described in each embodiment of the present invention.

[0193] The above are only preferred embodiments of the present invention, and are not intended to limit the patent scope of the present invention. Any equivalent structure or equivalent process transformation made using the contents of the present invention specification and drawings, or directly or indirectly applied in other related technical fields, are also included in the patent protection scope of the present invention.

Claims

1. A programmable logic controller control method, It is characterized in that The programmable logic controller control method comprises the following steps: When the control program is executed, a corresponding online modification part is obtained, wherein the online modification part includes an interruptible continuation part and a blocking part, and the control program is provided with a corresponding control cycle; Acquire an actual execution time period of the control program, and calculate a non-disturbance time period based on the control cycle and the actual execution time period; Scheduling the interruptible continuation portion to be loaded during the disturbance-free time period; When it is detected that all the interruptible continuation parts have been loaded, the execution of the control program in the next control cycle is blocked, and the blocked part is loaded at the beginning of the next control cycle to complete the modification of the control program.

2. The programmable logic controller control method according to claim 1, It is characterized in that The step of obtaining the actual execution time period of the control program and calculating the disturbance-free time period based on the control cycle and the actual execution time period comprises: Acquire a first actual execution time period of the control program in a current control cycle; The current remaining time period of the current control cycle is calculated and used as the non-disturbance time period.

3. The programmable logic controller control method according to claim 1, It is characterized in that The step of obtaining the actual execution time period of the control program and calculating the disturbance-free time period based on the control cycle and the actual execution time period comprises: Tracking and counting a preset number of the control programs in the second actual execution time period of the historical control cycle, and calculating the historical remaining time period; A minimum remaining time period is selected from the historical remaining time periods as the non-disturbance time period.

4. The programmable logic controller control method according to claim 1, It is characterized in that The step of scheduling the interruptible continuation part to be loaded during the disturbance-free time period comprises: Scheduling the interruptible and continuing part to be loaded during the non-disturbance time period, and confirming whether the interruptible and continuing part has been completely loaded; If loading is not completed, obtain the undisturbed time period corresponding to the next control cycle, and cyclically execute the steps of scheduling the interruptible continuation part to be loaded during the undisturbed time period, and confirming whether the interruptible continuation part has been fully loaded, until the interruptible continuation part has been fully loaded.

5. The programmable logic controller control method according to claim 1, It is characterized in that When the control program is executed, the corresponding online modification part is obtained, and the online modification part includes an interruptible continuation part and a blocking part. Before the step of setting the control program with a corresponding control cycle, the method further includes: confirming a portion of the online modification portion that affects the current operation of the control program, and dividing the online modification portion; Dividing the part of the online modification part that affects the current operation into a blocking part; The part of the online modification part that does not affect the current operation is divided into an interruptible and continuable part.

6. The programmable logic controller control method according to claim 5, It is characterized in that The step of dividing the part of the online modification part that affects the operation into a blocking part comprises: taking the part of the online modification part that affects the operation as the initial blocking part; Obtaining a third actual execution time of the history of the control program, obtaining a corresponding statistical result, and calculating an estimated loading time of the initial blocking part; Based on the statistical results and the estimated loading time, confirming whether the initial blocking part can be completed within the control period; If the initial blocking part cannot be completed within the control period, the size of the initial blocking part is compressed to obtain the blocking part.

7. The programmable logic controller control method according to any one of claims 1 to 6, It is characterized in that After the step of blocking the execution of the control program in the next control cycle after detecting that all the interruptible continuation parts have been loaded, and loading the blocked part at the beginning of the next control cycle to complete the modification of the control program, the method further includes: Obtaining the modified target program and executing the target program; The resources occupied by the portion of the control program replaced by the online modification portion are released.

8. A programmable logic controller control device, It is characterized in that The device comprises: An acquisition module, used for acquiring a corresponding online modification part when the control program is executed, wherein the online modification part includes an interruptible continuation part and a blocking part, and the control program is provided with a corresponding control cycle; A calculation module, used for obtaining an actual execution time period of the control program, and calculating a non-disturbance time period based on the control cycle and the actual execution time period; A scheduling module, used for scheduling the interruptible continuation part to be loaded during the non-disturbance time period; The data refresh module is used to block the execution of the control program in the next control cycle when it is detected that the interruptible continuation part is fully loaded, and load the blocked part at the beginning of the next control cycle to complete the modification of the control program.

9. A programmable logic controller control device, It is characterized in that The device comprises: a memory, a processor, and a programmable logic controller control program stored in the memory and executable on the processor, wherein the programmable logic controller control program is configured to implement the steps of the programmable logic controller control method according to any one of claims 1 to 7.

10. A readable storage medium, It is characterized in that The readable storage medium stores a programmable logic controller control program, and when the programmable logic controller control program is executed by the processor, the steps of the programmable logic controller control method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Method for amending logic algorithm routine of control system in online mode

    CN103529743A

  • Control method and device of programmable logic controller and medium

    CN109613885A

  • Control system and method therefor

    US20030158615A1

  • System for modifying a PLC program

    WO2013113320A1