Method and system for controlling and optimizing program downloading process of upper computer of PLC (Programmable Logic Controller)
By comparing the differences between the PLC device and the host computer program, inspection data is generated to accurately determine the impact of downloading. Single-module downloading is supported, which solves the problem of low efficiency in existing technologies and achieves efficient and safe PLC program downloading.
Patent Information
- Application Number
- CN202511275479.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-08
- Publication Date
- 2026-01-20
AI Technical Summary
Existing PLC program download technology is inefficient in frequently changing scenarios, lacks accuracy in incremental judgment, and is inaccurate in stop judgment, resulting in invalid downloads and unnecessary production interruptions. Furthermore, it cannot support single-module downloads.
By comparing the differences between the host computer program and the current program of the PLC device, inspection data is generated to accurately determine the impact of the download on the operation of the PLC device. It supports single module download or download with shutdown, provides user interaction to obtain permission instructions, and rolls back the download operation when necessary.
Incremental downloading is implemented, reducing data transfer volume and download time, improving production efficiency, reducing unnecessary downtime, and supporting efficient single-module downloading.
Smart Images

Figure CN121364677A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of industrial control, in particular, to a host computer program download process control optimization method and system of a programmable logic controller (PLC). BACKGROUND
[0002] In the field of industrial automation, programmable logic controllers (PLC) as core control devices are widely used in manufacturing processes, through receiving sensor data, executing preset logic programs, to achieve control of actuators. The running program of PLC needs to be written by engineers through the host computer, and downloaded to the device with the help of special software. Although the existing mainstream tools such as Siemens TIA Portal, CodeSys, etc. integrate programming, communication protocol and download functions, they can meet the basic download needs, but in the industrial scene where the program changes frequently, there are still obvious technical pain points, which are difficult to adapt to efficient production needs.
[0003] Although the existing technology supports incremental download (only download the changed program), the incremental determination accuracy is insufficient, and its determination logic depends on the timestamp rather than the actual program content. For example, TIA Portal will mistakenly judge the program with different timestamps but the same code content as having changes, which not only increases invalid download operations, but also is not conducive to users understanding the actual role of the incremental function. At the same time, although the existing technology supports runtime download in some scenarios, the determination of whether to stop is too general, often mistakenly judging scenes that can not stop as having to stop, resulting in unnecessary production interruption; and the technical solutions generally do not provide stop reason prompts, so users cannot know the necessity of stopping. In addition, the existing download technology is mostly consistent download, that is, even if only a single program module is modified, the complete program package still needs to be downloaded; although some tools have incremental mode, compared to directly downloading a single module, there is still redundant data transmission, and in the scene of high-frequency modification and debugging of a single module, the problem of low efficiency is particularly prominent.
[0004] Through the search of patent documents, it is found that the patent for invention with publication number CN117193152A discloses a PLC programming method, device, electronic equipment and computer program product. The method includes: obtaining user voice content, identifying the voice content as a graphical programming node according to a preset rule, connecting the graphical programming node based on user voice programming instructions, generating a graphical user program; performing syntax checking on the user program according to a preset rule, and compiling the user program based on a compilation protocol to generate a binary file; downloading the binary file to a programmable logic controller for debugging and running, obtaining state and variable information in the debugging process and adjusting the user program according to the state and variable information. The core of this patent focuses on voice programming and compilation debugging, and does not optimize the program download process: there is no incremental determination mechanism, no accurate stop determination, and no single module download support, which is low in efficiency when frequently debugging a single module.
[0005] The application patent with the publication number CN116233207A discloses a program downloading method, system and storage medium, and relates to the technical field of controllers. The program downloading method comprises the following steps: receiving a downloading instruction of an upper computer to enter a downloading mode, and receiving a data frame sent by the upper computer, wherein the data frame comprises a program file segment and a corresponding frame serial number; reading the data frame into a preset buffer area according to the frame serial number, wherein the buffer area is arranged in a RAM storage unit of a PLC; reading a next data frame into the buffer area when the idle space of the current buffer area meets a preset condition; forming a data block according to the program file segment in the data frame, and writing the data block from the buffer area of the RAM storage unit to a Flash storage unit of the PLC; obtaining the program file segment according to the data block written into the Flash storage unit, and obtaining a program file according to the program file segment. The patent only optimizes the receiving and storage of the data frame, has no splitting and context control in the downloading stage, and has poor process flexibility; has no incremental comparison, and needs to process the program segment in full amount; has no accurate judgment and user interaction prompt in the stopping field, and unnecessary production interruption is easily caused.
[0006] In view of the problems of the prior art, the present application provides a program downloading process control optimization method and system for an upper computer of a programmable logic controller (PLC). SUMMARY
[0007] In view of the defects in the prior art, the present application provides a program downloading process control optimization method and system for an upper computer of a programmable logic controller (PLC).
[0008] The program downloading process control optimization method for an upper computer of a programmable logic controller provided by the present application comprises the following steps: Step S1, connecting and locking the PLC device by the upper computer; Step S2, checking the correctness of the program of the upper computer, and checking the current state of the PLC device; if the PLC device is in a downloadable state, then comparing the program of the upper computer with the current program of the PLC device to obtain program difference information, judging the influence of the downloading operation on the operation of the PLC device based on the program difference information, and generating checking data; if the PLC device is not in a downloadable state, then converting the PLC device into a downloadable state; if the conversion fails, then terminating the process and prompting the user; Step S3, displaying the checking data to the user, and waiting for the user to issue a downloading permission instruction; after receiving the downloading permission instruction, controlling the PLC device to stop running or keep running according to the influence judgment result in the checking data; Step S4, downloading the program of the upper computer into the PLC device; if an error occurs in the downloading process, then rolling back the downloading operation, and displaying the error information to the user; Step S5, the lock of the PLC device is released, and the program resources occupied by the downloading process are released.
[0009] Preferably, in step S1, if the PLC device is not connected, the PLC device of the same type in the local area network is scanned, and the connection is established after a PLC device is selected by the user; the PLC device is locked after the connection is successful; if the PLC device is connected before, the PLC device connected last time is tried to connect.
[0010] Preferably, step S2 includes the following sub-steps: Step S2.1, the program source code of the host computer program is compiled to obtain a compilation product, and the compilation product includes multiple fingerprint information; Step S2.2, the difference between the host computer program and the current program in the PLC device is compared according to the fingerprint information to obtain program difference information, and the minimum changed program element is determined to judge the minimum download range; Step S2.3, the influence of the downloading operation on the running of the PLC device is judged based on the program difference information to generate check data.
[0011] Preferably, step S2.3 includes the following sub-steps: Step S2.3.1, whether the change of the program only exists in a single module and the changed part is not dependent on other modules is judged based on the program difference information, if yes, the single module downloading is supported, otherwise, the single module downloading is not supported; Step S2.3.2, whether the change of the program needs to be stopped for downloading is judged based on the program difference information; if the difference part of the program only involves software and does not depend on the program hardware configuration, the stop is not needed; if the difference part of the program involves a special software object that needs to be stopped, the stop is needed.
[0012] Preferably, in step S2, the check data includes the comparison results of the program content to be deleted, the program content to be changed, the program content to be added, and the influence judgment result of the downloading operation on the running of the PLC device.
[0013] Preferably, in step S5, after the downloading is completed, operation options are provided to the user, and the operation options include asking the user whether to start the PLC device to run the newly downloaded program immediately.
[0014] The application also provides a host computer program downloading flow control system of a programmable logic controller, which includes a flow control module, a PLC communication module, a comparison module, a check module and a user interaction module. The flow control module is used for generating a downloading context data set and controlling the execution of each module; The PLC communication module is used for establishing a connection with the PLC device and obtaining a locking mechanism in response to the instruction of the flow control module. The comparison module is configured to compare the host program with the current program in the PLC device in response to a call from the flow control module, obtain program difference information, and store the program difference information in the download context data set; The checking module is configured to read the program difference information in response to a call from the flow control module, determine the influence of the download operation on the operation of the PLC device, obtain an influence determination result, and store the influence determination result in the download context data set; The user interaction module is configured to obtain the program difference information and the influence determination result from the download context data set and display them to the user, and receive a download permission instruction issued by the user and transmit the download permission instruction to the flow control module.
[0015] Preferably, the flow control module is further configured to: according to the influence determination result in the download context data set, instruct the PLC communication module to control the PLC device to stop running when shutdown is required, and instruct the PLC communication module to directly perform program download when running can be maintained.
[0016] Preferably, the PLC communication module controls the PLC device to stop running or maintain running according to the instruction, and downloads the host program into the PLC device; if an error occurs during the download process, the download operation is rolled back.
[0017] Preferably, the checking module determines the influence of the download operation on the operation of the PLC device, including determining whether single-module download is supported without affecting the normal operation of the PLC device; the influence determination result indicates that single-module download is supported or shutdown download is required.
[0018] Compared with the prior art, the present application has the following advantages: 1. The present application realizes incremental download by accurately comparing the program content difference, reduces the amount of data to be transmitted, and thus reduces the download time overhead and the error risk caused by long-time transmission.
[0019] 2. The present application reduces unnecessary shutdown and improves production efficiency by intelligently determining the influence of the download on the running system.
[0020] 3. The method supports single-module download under safe conditions, greatly meeting the needs of efficient download during the development and debugging stage. BRIEF DESCRIPTION OF DRAWINGS
[0021] Other features, objects and advantages of the present application will become more apparent from the following detailed description of non-limiting embodiments with reference to the attached drawings: Figure 1 FIG. 1 is a schematic diagram of a host program download flow control optimization system for a programmable logic controller (PLC) in an embodiment of the present application. DETAILED DESCRIPTION
[0022] The application will be described in detail below with reference to specific embodiments. The following embodiments will help those skilled in the art to further understand the application, but do not limit the application in any form. It should be pointed out that those skilled in the art can make several changes and improvements without departing from the concept of the application. These are within the scope of protection of the application.
[0023] The application discloses a kind of programmable logic controller (PLC) host computer program download process control optimization method and system, wherein method includes step S1, host computer is connected and locks PLC device;Step S2, the correctness of the host computer program is checked, after confirming that PLC device is in downloadable state, the difference between host computer program and the current program in PLC device is compared, program difference information is obtained, the influence of download operation on PLC device running is judged, and inspection data is generated;Step S3, the inspection data is shown to user, and waits for user to issue download permission instruction;After receiving the download permission instruction, according to the influence judgment result in inspection data, PLC device is controlled to stop running or keep running;Step S4, host computer program is downloaded into PLC device;If error occurs during downloading, then roll back download operation, and error information is displayed to user;Step S5, the lock of PLC device is released, and the program resource occupied by download process is released.
[0024] Embodiment 1: The embodiment of the application provides a host computer program download process control optimization method of programmable logic controller, comprising the following steps: Step S1, host computer is connected and locks PLC device.
[0025] Specifically, in step S1, if PLC device is not connected, scan the PLC device of the same type in local area network, select one PLC device by user, and then establish connection; lock the PLC device after successful connection; if the PLC device has been connected before, try to connect the PLC device connected last time.
[0026] Step S2, the correctness of the host computer program is checked, and the current state of PLC device is checked; if PLC device is in downloadable state, then the difference between host computer program and the current program in PLC device is compared, program difference information is obtained, the influence of download operation on PLC device running is judged based on program difference information, and inspection data is generated; if PLC device is not in downloadable state, convert PLC device into downloadable state; if it cannot be converted, terminate the process and prompt user.
[0027] Specifically, step S2 includes the following substeps: Step S2.1, compile the program source code of the host computer program to obtain a compilation product, the compilation product including a plurality of fingerprint information. These fingerprints cover different levels of source code information from broad to specific.
[0028] Step S2.2, compare the host computer program with the current program in the PLC device according to the fingerprint information to obtain program difference information and determine the minimum changed program element to determine the minimum download range. Step S2.3, determine the influence of the download operation on the operation of the PLC device based on the program difference information, specifically including determining whether single-module download is supported, whether the normal operation of the PLC device is affected, etc., and generating check data.
[0029] Further, step S2.3 includes the following sub-steps: Step S2.3.1, based on the program difference information, determine whether the change of the program only exists in a single module and the changed part is not dependent on other modules, if yes, support single-module download, otherwise, do not support single-module download. Step S2.3.2, based on the program difference information, determine whether the change of the program needs to be stopped before downloading; if the difference part of the program only involves software and does not depend on the hardware configuration of the program, it is not necessary to stop; if the difference part of the program involves special software objects that need to be stopped, it needs to be stopped.
[0030] Specifically, there are several extensible checkpoints to meet the shutdown requirement of special software object download. If all the checkpoints pass the check, the download can be performed without stopping, otherwise, the download needs to be completed after stopping.
[0031] In this embodiment, the check data includes the comparison results of the program content to be deleted, the program content to be changed, and the program content to be added, and the influence judgment result of the download operation on the operation of the PLC device.
[0032] Step S3, display the check data to the user and wait for the user to issue a download permission instruction; after receiving the download permission instruction, control the PLC device to stop running or keep running according to the influence judgment result in the check data; Step S4, download the host computer program to the PLC device; if an error occurs during the download process, roll back the download operation, the program will be reset to the state before the download, and the error information will be displayed to the user; Step S5, unlock the PLC device and release the program resources occupied by the download process. In this embodiment, after the download is completed, operation options are provided to the user, including asking the user whether to start the PLC device to run the newly downloaded program immediately.
[0033] Embodiment 2: The application further provides a host computer program download flow control system of a programmable logic controller.
[0034] Figure 1 Figure 1 is a schematic diagram of a host computer program download flow control optimization system of a programmable logic controller (PLC) according to an embodiment of the application.
[0035] As shown in Figure 1 The host computer program download flow control system of the programmable logic controller comprises a flow control module, a PLC communication module, a comparison module, a checking module and a user interaction module.
[0036] The flow control module is configured to generate a download context data set and control the execution of each module.
[0037] The PLC communication module is configured to establish a connection with the PLC device and obtain a locking mechanism in response to the instructions of the flow control module. Specifically, the flow control module is further configured to instruct the PLC communication module to stop the operation of the PLC device when a shutdown is required according to the influence judgment result in the download context data set, and to directly perform program download when the operation can be maintained.
[0038] Further, the PLC communication module controls the PLC device to stop or maintain operation according to the instructions, and downloads the host computer program into the PLC device; if an error occurs during the download process, the download operation is rolled back. The PLC communication module releases the locking mechanism in the post-download phase or when a download error occurs.
[0039] The comparison module is configured to compare the differences between the host computer program and the current program in the PLC device in response to the call of the flow control module, obtain program difference information, and store the program difference information in the download context data set. Specifically, the comparison module comprises: Module M2.1, which compiles the program source code of the host computer program to obtain a compilation product, the compilation product comprising a plurality of fingerprint information; Module M2.2, which compares the differences between the host computer program and the current program in the PLC device according to the fingerprint information, obtains program difference information, and determines the smallest changed program element to judge the smallest download range.
[0040] The checking module is configured to read the program difference information in response to a call from the flow control module, determine the influence of the downloading operation on the running of the PLC device, obtain an influence determination result, and store the influence determination result in the downloading context data set. The checking module determines the influence of the downloading operation on the running of the PLC device, including determining whether single-module downloading is supported without affecting the normal running of the PLC device; and the influence determination result indicates that single-module downloading is supported or downloading needs to be stopped.
[0041] Specifically, the checking module includes: Module M2.3.1, which determines, based on the program difference information, whether the change of the program only exists in a single module and the changed part is not dependent on other modules, and if so, single-module downloading is supported, otherwise, single-module downloading is not supported; Module M2.3.2, which determines, based on the program difference information, whether the change of the program needs to be stopped for downloading; if the difference part of the program only involves software and is not dependent on the hardware configuration of the program, stopping is not needed; if the difference part of the program involves a special software object that needs to be stopped, stopping is needed.
[0042] Specifically, there are several extensible checkpoints to cope with the stopping requirement of the downloading of the special software object. If all the checkpoints are passed, downloading can be performed without stopping, otherwise, downloading needs to be stopped.
[0043] The user interaction module is configured to obtain the program difference information and the influence determination result from the downloading context data set and display them to the user, and receive a downloading permission instruction issued by the user and transmit the downloading permission instruction to the flow control module.
[0044] Specifically, the user interaction module is further configured to provide an operation option to the user after the downloading is completed, and the operation option includes asking the user whether to immediately start the PLC device to run the newly downloaded program.
[0045] The present application divides the downloading process into multiple stages, and the steps in each stage are executed in sequence. A downloading context is generated at the beginning, which determines the execution mode and result of each step; the execution of the steps can update or expand the context content, thereby affecting the execution of subsequent steps. By using an accurate incremental comparison mechanism, the present application reduces the amount of data that needs to be actually downloaded, thereby reducing the downloading time and risk and improving the downloading efficiency; by accurately determining the influence of the downloading operation on the running, the scenarios that must be stopped are reduced, and the system reliability and safety are enhanced; single-module downloading is supported when the conditions are met, which provides efficient downloading support for program modules that need to be modified frequently and debugged quickly.
[0046] Those skilled in the art know that, in addition to implementing the system provided by the present application and each device, module and unit thereof in the form of pure computer readable program code, the system provided by the present application and each device, module and unit thereof can also be implemented in the form of logic gates, switches, application specific integrated circuits, programmable logic controllers and embedded microcontrollers, etc. by logically programming the method steps to achieve the same functions. Therefore, the system provided by the present application and each device, module and unit thereof can be considered as a hardware component, and the devices, modules and units included therein for achieving various functions can also be considered as structures within the hardware component; the devices, modules and units for achieving various functions can also be considered as both software modules implementing methods and structures within hardware components.
[0047] The specific embodiments of the present application are described above. It needs to be understood that the present application is not limited to the specific embodiments described above, and various changes or modifications can be made by those skilled in the art within the scope of the claims, which does not affect the essential content of the present application. The embodiments of the present application and the features in the embodiments can be combined with each other in any manner without conflict.
Claims
1. A method for optimizing the flow control of a host program download of a PLC, characterized in that, The method comprises the following steps: Step S1, the host computer connects and locks the PLC device; Step S2, the correctness of the host computer program is checked, and the current state of the PLC device is checked. If the PLC device is in a downloadable state, the differences between the host computer program and the current program in the PLC device are compared to obtain program difference information. Based on the program difference information, the influence of the download operation on the operation of the PLC device is judged, and check data is generated; If the PLC device is not in a downloadable state, the PLC device is converted to a downloadable state; If it cannot be converted, the process is terminated and the user is prompted; Step S3, the check data is displayed to the user, and the user is waited for to issue a download permission instruction. After receiving the download permission instruction, the PLC device is controlled to stop running or keep running according to the influence judgment result in the check data; Step S4, the host computer program is downloaded into the PLC device; If an error occurs during the download process, the download operation is rolled back, and the error information is displayed to the user; Step S5, the lock on the PLC device is released, and the program resources occupied by the download process are released.
2. The PLC host computer program download flow control optimization method of claim 1, wherein, In step S1, if the PLC device has not been connected, the PLC device of the same type in the local area network is scanned, and a PLC device is selected by the user to establish a connection. After the connection is successful, the PLC device is locked. If the PLC device has been connected before, the last connected PLC device is tried to be connected.
3. The PLC host computer program download flow control optimization method of claim 2, wherein, The step S2 comprises the following sub-steps: Step S2.1, the program source code of the host computer program is compiled to obtain a compilation product, and the compilation product comprises a plurality of fingerprint information; Step S2.2, the differences between the host computer program and the current program in the PLC device are compared according to the fingerprint information to obtain the program difference information, and the smallest changed program element is determined to judge the smallest download range; Step S2.3, based on the program difference information, the influence of the download operation on the operation of the PLC device is judged, and check data is generated.
4. The PLC host computer program download flow control optimization method of claim 3, wherein, The step S2.3 comprises the following sub-steps: Step S2.3.1, based on the program difference information, it is judged whether the program change exists only in a single module and the changed part is not dependent on other modules. If yes, single module download is supported, otherwise, single module download is not supported; Step S2.3.2, based on the program difference information, it is judged whether the program change needs to be stopped to be downloaded. If the difference part of the program only involves software and does not depend on the hardware configuration of the program, it is not necessary to stop. If the difference part of the program involves special software objects that need to be stopped, it needs to be stopped.
5. The PLC host program download flow control optimization method of claim 4, wherein, In step S2, the check data comprises the comparison results of the program content to be deleted, the program content to be changed, and the program content to be added, and the influence judgment result of the download operation on the operation of the PLC device.
6. The PLC host program download flow control optimization method of claim 1, wherein, In step S5, after the download is completed, operation options are provided to the user, and the operation options comprise asking the user whether to start the PLC device to run the newly downloaded program immediately.
7. A host computer program download flow control system for a PLC, characterized by, The method for optimizing the flow control of the host program download process for implementing the PLC of any one of claims 1-6, comprising a flow control module, a PLC communication module, a comparison module, a check module, and a user interaction module; The flow control module is configured to generate a download context data set and control the PLC communication module, the comparison module, the check module, and the user interaction module to execute; The PLC communication module is configured to establish a connection with a PLC device and acquire a locking mechanism in response to an instruction from the flow control module; The comparison module is configured to compare the host program with the current program in the PLC device to obtain program difference information and store the program difference information in the download context data set in response to a call from the flow control module; The check module is configured to read the program difference information, determine the impact of the download operation on the operation of the PLC device, obtain an impact determination result, and store the impact determination result in the download context data set in response to a call from the flow control module; The user interaction module is configured to obtain the program difference information and the impact determination result from the download context data set and display them to a user, and receive a download permission instruction from the user and pass it to the flow control module.
8. The PLC host program download flow control optimization system of claim 7, wherein, The flow control module is further configured to instruct the PLC communication module to control the PLC device to stop running when a shutdown is needed and to directly perform program download when the operation can be maintained, according to the impact determination result in the download context data set.
9. The PLC host program download flow control optimization system of claim 8, wherein, The PLC communication module controls the PLC device to stop running or maintain running and downloads the host program into the PLC device according to the instruction, and rolls back the download operation if an error occurs during the download process.
10. The PLC host program download flow control optimization system of claim 9, wherein, The check module determines the impact of the download operation on the operation of the PLC device by determining whether single-module download is supported without affecting the normal operation of the PLC device, and the impact determination result indicates whether single-module download is supported or a shutdown is needed.
Citation Information
Patent Citations
Program downloading method and system and storage medium
CN116233207A
Equipment remote debugging method based on cloud gateway in remote operation and maintenance system
CN110365521A
Automated system and method for updating firmware on industrial devices
CN112088340A
Method and engineering system for the modification of a program of an industrial automation component
CN113874796A
PLC programming method and device, electronic equipment and computer program product
CN117193152A