An online downloading method and related device

By acquiring and comparing the PLC's memory description information, generating data copy functions and description information generation code, the problems of data corruption and jitter during PLC online download are solved, realizing a more flexible and stable online download method.

CN119758864BActive Publication Date: 2025-12-12SHENZHEN LEAD CNC SYST +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411948896.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-27
Publication Date
2025-12-12
Estimated Expiration
2044-12-27

AI Technical Summary

Technical Problem

In the current PLC online download process, the comparison of compiled data is not flexible enough, resulting in data corruption and jitter, which affects real-time control.

Method used

By obtaining the PLC's memory description information, comparing the locally stored memory description information with the PLC's memory description information, generating a data copy function and description information generation code, and updating the storage address of the compiled data, data consistency and stability are ensured.

Benefits of technology

This improves the system's flexibility and real-time performance, reduces data jitter and errors, and ensures the stability and reliability of the online download process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119758864B_ABST
    Figure CN119758864B_ABST
Patent Text Reader

Abstract

Embodiments of the present application provide an online downloading method and related device, which are used for utilizing memory description data to reduce the data jitter and confusion caused by compiling data replacement. The method comprises the following steps: after receiving an engineering downloading instruction of a programmable logic controller (PLC) from a user, obtaining memory description information of the PLC; comparing whether the memory description information of the PLC is same as the locally stored memory description information; if there is a difference between the memory description information of the PLC and the locally stored memory description information, generating a data copy function and description information generation code according to the locally stored memory description information, and obtaining modified compiling data; when the PLC loads the modified compiling data to a memory storage space, and a current scheduling task of the PLC for the compiling data is completed, calling the data copy function, updating a current storage address pointed by the current scheduling task of the PLC, loading the description information generation code, and completing the downloading of the PLC engineering.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present application relate to the field of programmable logic controller, and particularly relate to an online downloading method and related device. BACKGROUND

[0002] In the current programmable logic controller (PLC) scheme, a user project can be edited by using the programming software of the PLC, so that the compiled data is generated after the editing. Then the compiled data is downloaded to the PLC, and the PLC runs, and the PLC loads and executes the logic. When online downloading, the PLC can continue to run, and the logic execution of the user project is not stopped, the programming software downloads new compiled data at the same time, and the new compiled data is loaded synchronously when the PLC runs, and the running logic is replaced, so as to achieve the purpose of online downloading.

[0003] However, in this online downloading case, the comparison of the compiled data is not flexible enough, and after multiple modifications, the data is prone to disorder and limits the downloading. At the same time, when the compiled data is replaced, it is easy to cause jitter, and jitter is not allowed in real-time control. SUMMARY

[0004] Embodiments of the present application provide an online downloading method and related device, which are used to utilize memory description data to reduce the problem of data jitter and disorder caused by replacement of compiled data.

[0005] The first aspect of embodiments of the present application provides an online downloading method applied to a programming program platform, and the method comprises:

[0006] After receiving a project downloading instruction of a user to a programmable logic controller (PLC), memory description information of the PLC is obtained; wherein the memory description information is used to represent address distribution information of the compiled data when the PLC runs the PLC project;

[0007] The local stored memory description information is compared with the memory description information of the PLC to determine whether they are the same;

[0008] If there is a difference between the local stored memory description information and the memory description information of the PLC, a data copy function and description information generation code are compiled according to the local stored memory description information, and modified compiled data is generated;

[0009] When the PLC loads the modified compiled data to the memory storage space, and the PLC completes the current scheduling task for the compiled data, the data copy function is called, and the current memory address pointed by the current scheduling task of the PLC is updated, so that the PLC loads the description information generation code, and completes the download of the PLC project.

[0010] Optionally, the comparison of whether the locally stored memory description information and the memory description information of the PLC are same includes:

[0011] The memory description information of the PLC is analyzed to obtain data type information of the compiled data and a memory storage address of the memory storage space; wherein the memory storage address is used to point to a memory address position of any variable in the compiled data;

[0012] The address position of the any variable pointed by the local storage address in the locally stored memory description information is compared with the memory address position;

[0013] And / or, the data type information of the locally stored memory description information is compared with the data type information of the memory description information of the PLC.

[0014] If not same, the step of generating the data copy function and the description information generation code according to the locally stored memory description information and obtaining the modified compiled data is executed.

[0015] Optionally, the generation of the data copy function and the description information generation code according to the memory description information of the PLC includes:

[0016] The memory storage address and the data type information in the memory description information of the PLC are compiled in combination with the locally stored memory description information to generate the description information generation code; wherein the description information generation code is used to represent the program code for the address distribution information in the compiled data.

[0017] The data copy function is compiled according to the description information generation code.

[0018] Optionally, the obtaining of the modified compiled data includes:

[0019] The memory description information of the PLC in the compiled data is parsed based on the locally stored memory description information, and the parsed compiled data is modified according to the description information generation code to generate the modified compiled data.

[0020] Optionally, before the calling of the data copy function, the method further includes:

[0021] issuing an engineering update instruction based on the current scheduling task to control the PLC to enter an update state;

[0022] When the PLC enters the update state and the scheduling task of the PLC executing the compiled data of the PLC engineering is completed, marking the task state of the current scheduling task as an idle state;

[0023] When the task states of all current scheduling tasks are the idle state, entering a replacement state and executing the step of calling the data copy function.

[0024] Optionally, the calling of the data copy function and the updating of the current storage address pointed to by the current scheduling task of the PLC according to the address distribution information in the locally stored memory description information to load the description information generation code to complete the downloading of the PLC engineering, comprises:

[0025] calling the data copy function to adjust the memory data of the PLC according to the modified memory description information of the PLC; wherein the memory data is used to describe the running data of the modified compiled data in the PLC runtime;

[0026] replacing the current storage address pointed to by the current scheduling task of the PLC with the code address of the description information generation code in the memory storage space to load the description information generation code.

[0027] Optionally, after the loading of the description information generation code, the method further comprises:

[0028] When all description information generation codes and all locally stored memory description information are replaced in the PLC, exiting the update state and aborting the downloading of the PLC engineering.

[0029] The second aspect of the embodiments of the present application provides an online downloading system, comprising:

[0030] an acquisition unit, configured to acquire memory description information of a programmable logic controller (PLC) after receiving an engineering downloading instruction of the PLC; wherein the memory description information is used to represent address distribution information of compiled data when the PLC runs the PLC engineering;

[0031] a comparison unit, configured to compare whether the locally stored memory description information and the memory description information of the PLC are the same;

[0032] The generating unit is configured to compile a data copy function and description information generation code according to the locally stored memory description information and generate modified compiled data when the locally stored memory description information is different from the memory description information of the PLC.

[0033] The calling unit is configured to call the data copy function and update a current memory address pointed to by a current scheduling task of the PLC after the PLC loads the modified compiled data into a memory storage space and the current scheduling task of the PLC is completed, so that the PLC loads the description information generation code and completes downloading of the PLC project.

[0034] The second aspect of the embodiment of the present application provides an online downloading system for executing the online downloading method of the first aspect.

[0035] The third aspect of the embodiment of the present application provides an online downloading device, which comprises:

[0036] The central processor, the memory, the input and output interface, the wired or wireless network interface and the power supply;

[0037] The memory is a transient storage memory or a persistent storage memory;

[0038] The central processor is configured to communicate with the memory and execute instruction operation in the memory to execute the online downloading method of the first aspect.

[0039] The fourth aspect of the embodiment of the present application provides a computer readable storage medium, which comprises instructions, and when the instructions are run on a computer, the computer executes the online downloading method of the first aspect.

[0040] The fifth aspect of the embodiment of the present application provides a computer program product, which comprises instructions, and when the instructions are run on a computer, the computer executes the online downloading method of the first aspect.

[0041] As can be seen from the above technical solutions, the online downloading method disclosed by the embodiment of the present application separates the memory description data from the compiled data, thereby improving the flexibility of the system. In addition, by comparing the memory description data, only the differences between the modification before and the final modification are compared, and the intermediate modifications are ignored. At the same time, the code can also be updated in real time when downloading the compiled data without being affected. BRIEF DESCRIPTION OF DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings needed to be used in the embodiments description will be briefly introduced. Obviously, the drawings in the following description only represent some embodiments described in the present application, and other drawings can also be obtained by those skilled in the art based on these drawings.

[0043] Figure 1 A logic diagram of an online download disclosed by the embodiments of the present application;

[0044] Figure 2 A flow diagram of an online download method disclosed by the embodiments of the present application;

[0045] Figure 3 A flow diagram of another online download method disclosed by the embodiments of the present application;

[0046] Figure 4 A flow diagram of another online download method disclosed by the embodiments of the present application;

[0047] Figure 5 A flow diagram of another online download method disclosed by the embodiments of the present application;

[0048] Figure 6 A structure diagram of an online download system disclosed by the embodiments of the present application;

[0049] Figure 7 A structure diagram of an online download device disclosed by the embodiments of the present application. DETAILED DESCRIPTION

[0050] The technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments only represent some embodiments of the present application, rather than all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the present application.

[0051] As shown in the above background art, the prior art mainly has the problems of not flexible enough in comparing the compiled data, and after multiple modifications, the data is easy to be disordered and limit the download. In addition, the replacement is easy to cause jitter. In order to solve the above technical problems, please refer to Figure 1 , Figure 1 A logic diagram of an online download disclosed by the embodiments of the present application.

[0052] By Figure 1As shown, the user can compile the user project running on the PLC on the programming software (installed on the programming program platform), and then can generate the compiled data and the memory description data belonging to a part of the compiled data on the compiling software. Then, the compiling software transmits the compiled data to the PLC device through the communication connection, and the PLC device can translate the compiled data into the project data (the data of the user project of the PLC, which can be stored and synchronized in real time on the PLC device) during the running, and then runs based on the project data. At the same time, during the running of the PLC, the running data in the actual running process, i.e., various signals generated by the running of the PLC, can also be obtained, which is not limited here.

[0053] Specifically, in the technical scheme of the present application, the compiling software can be a Leadsys software, which is a programming software for writing and debugging the PLC program, and is installed in the upper computer. The PLC device is a digital electronic device with a microprocessor, which is a digital logic controller for automatic control, and can load the control instructions into the memory for storage and execution at any time, and is installed in the lower computer. The programmable controller is modularized and combined by the internal CPU, instruction and data memory, input and output unit, power module, digital analog unit, etc. In the technical scheme of the present application, the Leadsys software and the PLC program realize the communication connection. In other words, the local project file service is set in the Leadsys software, which specifically refers to an implementation means for file reading, writing, checking or saving, and will not be described hereinafter for the convenience of description. In addition, when there is no compiled information file corresponding to the PLC device saved on the local device.

[0054] To realize Figure 1 The logic diagram shown, please refer to Figure 2 , Figure 2 The flowchart of the online downloading method disclosed by the embodiment of the present application. It includes steps 201-204.

[0055] 201, after receiving the project downloading instruction of the user on the programmable logic controller PLC, the memory description information of the PLC is obtained.

[0056] In this embodiment, after the programming program platform receives the project downloading instruction uploaded by the user on the PLC device, the programming program platform can obtain the memory description information of the PLC stored on the PLC device. It should be noted that the memory description information is used to represent the address distribution information of the compiled data when the PLC runs the PLC project.

[0057] In one specific embodiment, after the user successfully logs in the PLC, the user can subsequently need to modify the relevant PLC project. Then, when the user opens the project file on the programming software (the file is opened and saved by the programming software after modification), the user can send a relevant project download command to the PLC, so that the PLC generates a relevant project download instruction according to the project download command, and thus starts the project download service. It should be noted that in this embodiment, the project download command is a command for instructing the PLC to perform a project download operation. The PLC can download the project data of the currently running PLC project and upload it to the programming program platform (which can be viewed or compiled on the programming software). The compilation software can monitor the running status and data of the current PLC in real time.

[0058] Further, in combination with the above Figure 1 As shown in the figure, the project data further includes memory description information of the PLC. The memory description information can compare the memory data distribution of the user project before and after modification, and calculate the arrangement mode of the new data by algorithm. In one realizable technical solution, the memory description data includes data type definition, address position of each variable, and other information, which is not limited here.

[0059] 202. Compare whether the locally stored memory description information and the memory description information of the PLC are the same.

[0060] Then, the locally stored memory description information and the memory description information of the PLC in the programming program platform can be compared.

[0061] In one specific embodiment, the memory description information can use a string form to describe the variable and type information. Then, the difference between the variable and type information can be used as a comparison between the locally stored memory description information and the memory description information of the PLC. For details, please refer to the embodiment shown in Figure 3

[0062] 203. If the locally stored memory description information and the memory description information of the PLC are different, generate a data copy function and description information generation code according to the locally stored memory description information, and generate modified compilation data.

[0063] Therefore, when the locally stored memory description information and the memory description information of the PLC are different, a data copy function and description information generation code can be generated according to the locally stored memory description information, and modified compilation data can be generated.

[0064] ​In one specific embodiment, in the process of comparing the locally stored memory description information with the memory description information of the PLC, if a difference is found in the description of the variable or type information, it can be determined that there is a difference between the locally stored memory description information and the memory description information of the PLC. Therefore, if the complete compilation data (which can also be understood as engineering data, because the data is ultimately run in the PLC engineering) is to be compiled, the difference between the locally stored memory description information and the memory description information of the PLC needs to be compiled. The compilation data is composed of multiple data segments, such as code segments, text segments, program segments, configuration segments, or data segments describing objects, etc. However, for the memory description information, it mainly represents the variable or type information of the compilation data, and therefore, the content of the memory description information is mainly located in the code segment. Thus, the difference in the memory description information can be compiled to generate description information generation code and a data copy function corresponding to the generated code.

[0065] Further, in other implementable technical solutions, the method for obtaining the modified compilation data can refer to the embodiments shown in Figure 4 , and specific details are not repeated here.

[0066] 204、When the PLC loads the modified compilation data into the memory storage space, and the current scheduling task of the PLC with respect to the compilation data is completed, the data copy function is called, and the current storage address pointed to by the current scheduling task of the PLC is updated, so that the PLC loads the description information generation code and completes the download of the PLC engineering.

[0067] Further, when the PLC loads the modified compilation data into the memory storage space, and the current scheduling task of the PLC with respect to the compilation data is completed, the PLC can call the data copy function in the compilation data, update the current storage address pointed to by the current scheduling task of the PLC, and then make the PLC load the description information generation code to complete the download of the PLC engineering. The current storage address pointed to by the current scheduling task is the memory code segment of the PLC after modification, and the code segment belongs to a part of the description information generation code.

[0068] In one specific embodiment, after the PLC receives the modified compilation data issued by the programming platform, the modified compilation data is stored in the memory storage space of the PLC. Then, the programming platform can prepare an International Electrotechnical Commission (IEC) task, which in this embodiment can be understood as a scheduling task. In this embodiment, the IEC task needs to load a new code segment. The code segment belongs to a part of the description information generation code. Specifically, when the PLC downloads the new compilation data, because the original PLC project can still be running on the original IEC task, the new IEC task can first process the loading of the code. Thus, after the original IEC task is scheduled to be completed, the data copying function issued by the programming platform can be scheduled to update the pointer of the programming organization unit (POU) of the new IEC task, and then update or modify the related function address, so that the PLC loads the difference between the locally stored memory description information and the memory description information of the PLC, that is, the description information generation code (further, it can be understood as loading the modified compilation data, one is incremental download, and one is full download). It should be noted that the pointer of the POU refers to the function address, which is also the address of the execution code. One POU corresponds to one function, and each function has an address (pointer).

[0069] Through the online downloading method disclosed in this embodiment, the memory description data and the compilation data are independent, which improves the flexibility of the system. Moreover, by comparing the memory description data, only the difference between the modification before and the final modification needs to be compared, and the intermediate modification is ignored. At the same time, the code can be updated in real time when downloading the compilation data without being affected.

[0070] Further, because the memory description information is added in this embodiment, the memory data distribution of the PLC project before and after the modification needs to be compared additionally. Please refer to Figure 3 , Figure 3 This is a flowchart of another online downloading method disclosed in this embodiment. It includes steps 301-304.

[0071] 301, analyze the memory description information of the PLC to obtain the data type information of the compilation data and the memory storage address of the memory storage space.

[0072] In combination with the above Figure 2As shown, the memory description information of the PLC can be analyzed to obtain the data type information of the compiled data and the memory storage address of the memory storage space. It should be noted that the memory storage address is used to point to the memory address position of any variable in the compiled data.

[0073] In one specific embodiment, the memory description data is analyzed separately, and specifically, the data type information contained in the memory description information and the memory storage address of the memory storage space pointed to by the memory description information are analyzed. The memory storage address points to the address information of each variable.

[0074] 302. Compare whether the address position of any variable pointed to by the local storage address in the locally stored memory description information is the same as the memory address position.

[0075] Further, in combination with step 301, in one implementable technical solution, the address position of any variable pointed to by the local storage address in the locally stored memory description information can be compared with the memory address position.

[0076] In one specific embodiment, the address position of the variable pointed to by the local storage address can be analyzed to determine whether it is the same as the address position of the variable pointed to by the memory storage address (PLC). Further, if there is a difference, step 304 is performed. If they are the same, the memory description information at this time does not need to be modified.

[0077] Specifically, by analyzing the address position information of the variable address of the locally stored memory description information in the programming program platform and the memory storage memory description information in the PLC, it is determined whether there is a difference between the two.

[0078] In addition, since the memory description information is a text-based description format, not just address information, there can be other description information content, and thus the intermediate modification can be ignored, and only the difference between the modification before and the final modification needs to be compared. Further, the description file can also be replaced by JSON or XML, which is not limited here.

[0079] 303. Compare whether the data type information of the locally stored memory description information is the same as the data type information of the memory description information of the PLC.

[0080] In contrast to step 302, the data type information of the locally stored memory description information can also be compared with the data type information of the memory description information of the PLC.

[0081] In one specific embodiment, by analyzing the object description data of the program object in the memory description information of the PLC project, or the logic description data of the logic function and logic object, etc., the data type of the described object, and the format type of the description format of the text segment of the program code, etc., are also analyzed. Details are not described here. Further, when the data type information in the locally stored memory description information and the memory description information of the PLC is different, it can be determined that one or more of the text segment, program segment, configuration segment or data segment of the described object in the compiled data are different, and then step 304 is performed.

[0082] Further, if they are the same, there is no need to modify the memory description information at this time.

[0083] 304, combine the locally stored memory description information, compile the memory storage address and data type information in the memory description information of the PLC, generate description information generation code, and compile the data copy function according to the description information generation code.

[0084] Further, the memory storage address and data type information in the memory description information of the PLC can be compiled in combination with the locally stored memory description information, so as to generate the description information generation code. At the same time, the data copy function can also be compiled according to the description information generation code. It should be noted that the description information generation code is used to represent the program code of the address distribution information in the compiled data.

[0085] In one specific embodiment, the locally stored memory description information can be combined, and then compiled by the difference part between the memory description information of the PLC and the locally stored memory description information. Specifically, the locally stored memory description information can be combined, and then the memory storage address in the memory description information of the PLC and the data type information that are different between them are combined for compilation, and then the description information generation code is compiled.

[0086] Further, the address of the generation code is determined by the description information generation code, and the storage address of the related compiled data is pointed to, and then the data copy function is generated.

[0087] In other implementable technical solutions, the address pointed to by the compiled data may not be changed, so the data copy function can also be generated based on the memory description information (original memory description data) of the PLC.

[0088] The online downloading method disclosed in the embodiment can use string form to describe variable and type information as comparison between front and back states, meanwhile, the description file can also use JSON or XML instead, and the memory description data is separated, which improves the flexibility of the system, and the description format is based on text instead of address information only, the intermediate modification can be ignored, and only the difference between the modification before and the final modification needs to be compared, which improves the realizability of the scheme.

[0089] In combination with the above Figure 2 and Figure 3 Since the memory description data is also in the compiling data, the generation manner of the compiling data is changed, please refer to Figure 4 , Figure 4 The flowchart of another online downloading method disclosed in the embodiment is shown. The method comprises the following steps.

[0090] 401. Based on the memory description information stored locally, the memory description information of the PLC in the compiling data is parsed, and the parsed compiling data is modified according to the description information generation code to generate the modified compiling data.

[0091] It should be noted that the modified compiling data in the embodiment can be obtained by modifying the compiling data, the description information generation code and the memory description information stored locally by the programming program platform.

[0092] In one specific embodiment, the memory description information of the PLC in the original compiling data is parsed based on the memory description information stored locally. Then, the address of the PLC project pointed by the parsed compiling data is modified according to the description information generation code, so as to obtain the modified compiling data.

[0093] Further, in the embodiment, the generation manner of the compiling data is similar to the conventional one, and details are not described herein. Since the memory description information belongs to the compiling data, the obtained compiling data (from the PLC) can be modified according to the difference between the memory description information stored locally and the memory description information of the PLC, and the address positions of various functions or variables can be adjusted. In addition, since the memory description information can compare the memory data distribution of the PLC project, the new data arrangement manner can be calculated by an algorithm, the latest arrangement manner is used to generate the description information generation code, so as to modify or replace the original compiling data, thereby obtaining the modified compiling data.

[0094] In other implementable technical solutions, when the original compiled data is modified or replaced, the local memory description information can also be sequentially adjusted according to the memory description information of the PLC. For example, the memory description information of the PLC includes variable objects A, B and C and their order, while the order of the variable objects in the local memory description information is B, A and C. Then, the variable objects B, A and C in the local memory description information are sequentially adjusted to A, B and C.

[0095] Through the online downloading method disclosed in this embodiment, the compiled data after the memory description data is added can be obtained, and the original compiled data is replaced, thereby improving the implementability of the scheme.

[0096] Furthermore, in combination with the above Figure 2 , Figure 3 and Figure 4 , in the downloading process of the new compiled data, the Figure 5 , Figure 5 is another flowchart of the online downloading method disclosed in the embodiments of the present application. It includes steps 501-504.

[0097] 501. The engineering update instruction is issued based on the current scheduling task to control the PLC to enter the update state.

[0098] It should be noted that in this embodiment, steps 501-504 are performed after the PLC receives the modified compiled data. Specifically, the programming program platform issues the engineering update instruction based on the current scheduling task to control the PLC to enter the update state.

[0099] In one specific embodiment, the programming program platform can first set the scheduling task of the PLC, and then determine the subsequent loading data of the compiled data and the running order of the corresponding PLC project (when the PLC runs the compiled data, the compiled data can also be referred to as project data) through the scheduling task.

[0100] Further, the programming program platform can prepare the IEC task, that is, prepare to load the new code segment (the content of the compiled code segment). The new code segment is the modified compiled data. Since the PLC mainly runs in binary code during running, the compiled data needs to be translated into a binary code, and the specific translation process is not described here.

[0101] 502. When the PLC enters the update state and the scheduling task of the PLC project is completed, the task state of the current scheduling task is marked as an idle state.

[0102] Further, after the IEC task is prepared, the PLC enters the updating state. At this time, the PLC executes the original scheduling task of the PLC project, specifically, the compiled data that has not been loaded before is loaded, that is, the original PLC project (real-time task) is executed. Further, after the PLC completes the original PLC project, each real-time task will mark the tail of the newly set IEC task, that is, the task state marker, as the idle state after the scheduling is completed.

[0103] It should be noted that the real-time task does not need to be stopped during the execution of the switching code, that is, each real-time task can mark the task state of the IEC task associated with the real-time task as the idle state after the scheduling is completed. For example, tasks such as motion control, bus communication, and the like that require high real-time, the IEC task also needs to set the corresponding execution flow. Further, in the real-time task of the original PLC project, a certain motion control execution is completed, at this time, the task state corresponding to the motion control in the IEC task can be marked as the idle state.

[0104] 503、When the task states of all current scheduling tasks are idle, enter the replacement state, call the data copy function, adjust the memory data of the PLC according to the modified memory description information of the PLC, and replace the current storage address pointed to by the current scheduling task of the PLC with the code address of the description information generation code in the memory storage space to load the description information generation code.

[0105] Further, when the task states of all current scheduling tasks are idle, the replacement state can be entered, at this time, the data copy function is called, the memory data of the PLC is adjusted according to the modified memory description information of the PLC, and the current storage address pointed to by the current scheduling task of the PLC is replaced with the code address of the description information generation code in the memory storage space, so as to load the description information generation code. It should be noted that the memory data is used to describe the running data of the modified compiled data during the running of the PLC. That is, the memory data is the real-time running data in the PLC.

[0106] In one specific embodiment, after the task states of all current scheduling tasks in the PLC are idle, the replacement state can be entered. Specifically, the data copy function can be called, and then the code address of the description information generation code pointing to the new code segment in the memory storage space is determined, so as to replace the code address of the code segment pointed to in the pre-set IEC task with the code address of the new code segment, so as to make the PLC load the description generation code, that is, run the new PLC project.

[0107] Specifically, it can be understood that by calling the data copy function, the memory data of the PLC is copied to the correct memory data according to the modified memory description information (in the PLC). Among them, the engineering data (compiled data) is the data required by the PLC at runtime, which is static on the disk. The memory data is initialized by the engineering data and stored in the memory, which is the data that will change with the running of the PLC. In combination with the above changes, the real-time task can receive the jitter caused by data copying. It can also be understood that in the process of replacing all real-time tasks, since the data needs space address for running or storage, the POU pointer of the IEC task is updated, so that only the data address of the data required for reference needs to be replaced in the data replacement process, and the data replacement can be completed. In this embodiment, the data with high real-time requirement can be arranged in a fixed position, and when the data with low real-time requirement is used in other tasks with low real-time requirement, the reference method is used, which not only can quickly copy data, but also can ensure data security.

[0108] 504、When all the description information generation codes and all the locally stored memory description information are replaced in the PLC, the update state is exited, and the download of the PLC project is terminated.

[0109] Further, when all the description information generation codes and all the locally stored memory description information are replaced in the PLC, the update state is exited, and the download of the PLC project is terminated.

[0110] In one specific embodiment, when all the current scheduled tasks are completed, that is, when all the description information generation codes and all the locally stored memory description information are replaced in the PLC, the update state can be exited, and the download of the PLC project is terminated.

[0111] Further, in other implementable technical solutions, the update state can also be exited and the download of the PLC project is terminated when the replacement process times out, which will not be described in detail here.

[0112] By using the global replacement, the online download method disclosed in this embodiment can reduce the running logic error problem caused by the data inconsistency caused by data copying. At the same time, the memory reference method is used to solve the memory copying problem of real-time tasks, that is, this part of data does not need to be copied. Without stopping the real-time task, the real-time requirement can be guaranteed, and the realizability of the scheme is improved.

[0113] It should be understood that although the steps in the flowcharts involved in the embodiments described above are shown in sequence according to the arrows, the steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified herein, the execution of the steps is not strictly limited in sequence, and the steps can be executed in other orders. Moreover, at least some of the steps in the flowcharts involved in the embodiments described above can include multiple steps or multiple stages, which are not necessarily executed at the same time, but can be executed at different times, and the execution order of the steps or stages is not necessarily sequential, but can be alternately or alternately executed with at least part of other steps or steps or stages in other steps.

[0114] Referring to Figure 6 , Figure 6 A structure schematic diagram of an online download system disclosed by the embodiments of the present application is shown in FIG. 1.

[0115] The acquisition unit 601 is configured to acquire memory description information of the PLC after receiving the engineering download instruction of the programmable logic controller (PLC) of the user; wherein the memory description information is used to represent address distribution information of the compiled data of the PLC running the PLC engineering.

[0116] The comparison unit 602 is configured to compare whether the locally stored memory description information and the memory description information of the PLC are the same.

[0117] The generation unit 603 is configured to, when the locally stored memory description information and the memory description information of the PLC are different, compile and generate a data copy function and description information generation code according to the locally stored memory description information, and generate modified compiled data.

[0118] The calling unit 604 is configured to, when the PLC loads the modified compiled data to the memory storage space, and the current scheduling task of the PLC for the compiled data is completed, call the data copy function, and update the current storage address pointed by the current scheduling task of the PLC, so that the PLC loads the description information generation code and completes the download of the PLC engineering.

[0119] Exemplarily, the system further includes an analysis unit 605 and an execution unit 606.

[0120] The analysis unit 605 is configured to analyze the memory description information of the PLC to obtain data type information of the compiled data and a memory storage address of the memory storage space; wherein the memory storage address is used to point to a memory address position of any variable in the compiled data.

[0121] The comparison unit 602 is specifically configured to compare whether the address position of any variable pointed to by the local storage address in the locally stored memory description information is the same as the memory address position.

[0122] And / or, the comparison unit 602 is further configured to compare whether the data type information of the locally stored memory description information is the same as the data type information of the memory description information of the PLC.

[0123] If not, the execution unit 606 is configured to perform the step of generating a data copy function and description information generation code according to the locally stored memory description information, and obtaining modified compilation data.

[0124] Exemplarily, the system further includes a compilation unit 607.

[0125] The compilation unit 607 is configured to compile the memory storage address and data type information in the memory description information of the PLC in combination with the locally stored memory description information, to generate description information generation code; wherein the description information generation code is used to represent the program code for the address distribution information in the compilation data.

[0126] The compilation unit 607 is further configured to compile the data copy function according to the description information generation code.

[0127] Exemplarily, the system further includes a parsing unit 608.

[0128] The parsing unit 608 is configured to parse the memory description information of the PLC in the compilation data based on the locally stored memory description information, and modify the parsed compilation data according to the description information generation code, to generate modified compilation data.

[0129] Exemplarily, the system further includes a control unit 609 and a marking unit 610.

[0130] The control unit 609 is configured to issue an engineering update instruction based on a current scheduling task, to control the PLC to enter an update state.

[0131] The marking unit 610 is configured to, when the PLC enters the update state and the scheduling task of the PLC to execute the compilation data of the PLC engineering is completed, mark the task state of the current scheduling task as an idle state.

[0132] The execution unit 606 is further configured to, when the task states of all current scheduling tasks are idle states, enter a replacement state, and perform the step of calling the data copy function.

[0133] Exemplarily, the system includes:

[0134] The calling unit 604 is specifically configured to call the data copying function, and adjust the memory data of the PLC according to the modified memory description information of the PLC; wherein the memory data is used to describe the running data of the modified compilation data in the PLC runtime.

[0135] The generating unit 603 is specifically configured to replace the current storage address pointed to by the current scheduling task of the PLC with a code address of the description information generation code in the memory storage space, so as to load the description information generation code.

[0136] Exemplarily, the system further comprises:

[0137] The executing unit 606 is further configured to exit the update state and abort the download of the PLC project when the replacement of all the description information generation code and all the locally stored memory description information in the PLC is completed.

[0138] Please refer to Figure 7 The structure diagram of the online downloading device disclosed in the embodiments of the present application comprises:

[0139] The central processing unit 701, the memory 705, the input and output interface 704, the wired or wireless network interface 703 and the power supply 702;

[0140] The memory 705 is a transitory storage memory or a persistent storage memory;

[0141] The central processing unit 701 is configured to communicate with the memory 705, and execute the instruction operation in the memory 705 to perform the online downloading method in any of the foregoing embodiments. Figures 2 to 5 The online downloading method in any of the foregoing embodiments.

[0142] The embodiments of the present application further provide a chip system, which comprises at least one processor and a communication interface, the communication interface and the at least one processor are interconnected through a line, and the at least one processor is used to run a computer program or an instruction to execute the online downloading method in any of the foregoing embodiments. Figures 2 to 5 The online downloading method in any of the foregoing embodiments.

[0143] The embodiments of the present application further provide a computer readable storage medium, which comprises an instruction, when the instruction is run on a computer, the computer executes the online downloading method in any of the foregoing embodiments. Figures 2 to 5 The online downloading method in any of the foregoing embodiments.

[0144] The embodiments of the present application further provide a computer program product comprising an instruction, when the computer program product is run on a computer, the computer executes the online downloading method in any of the foregoing embodiments. Figures 2 to 5 The online downloading method in any of the foregoing embodiments.

[0145] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the foregoing method embodiments, which will not be repeated here.

[0146] In several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic, for example, the division of the units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units shown or discussed can be indirect coupling or communication connection through some interface, device or unit, and can be electrical, mechanical or other forms.

[0147] The units described as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on a plurality of network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.

[0148] In addition, each functional unit in each embodiment of the present application can be integrated in one processing unit, or each unit can exist physically, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0149] The integrated unit, if realized in the form of a software functional unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part of the prior art that makes a contribution or the whole or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM, read-only memory), a random access memory (RAM, random access memory), a magnetic disk or an optical disk, and various program code storage media.

Claims

1. An online download method, characterized in that, Applied to a programming platform, the method includes: Upon receiving a project download instruction from the user on the programmable logic controller (PLC), the system obtains the PLC's memory description information; wherein, the memory description information is used to characterize the address distribution information of the compilation data when the PLC runs the PLC project; Compare whether the memory description information stored locally is the same as the memory description information of the PLC; If the memory description information stored locally differs from the memory description information of the PLC, a data copy function and description information generation code are compiled and generated based on the memory description information stored locally, and modified compiled data is generated. When the PLC loads the modified compilation data into the memory storage space, and the PLC completes the current scheduling task for the compilation data, it calls the data copy function and updates the current storage address pointed to by the current scheduling task of the PLC, so that the PLC loads the description information to generate code and completes the download of the PLC project.

2. The online download method according to claim 1, characterized in that, The comparison of whether the locally stored memory description information is the same as the PLC's memory description information includes: Analyze the memory description information of the PLC to obtain the data type information of the compiled data and the memory storage address of the memory storage space; wherein, the memory storage address is used to point to the memory address location of any variable in the compiled data; Compare whether the address location of any variable pointed to by the local storage address in the locally stored memory description information is the same as the memory address location; And / or, compare the data type information of the locally stored memory description information to see if it is the same as the data type information of the PLC's memory description information; If they are different, execute the steps of compiling and generating a data copy function and generating code based on the locally stored memory description information, and obtaining the modified compiled data.

3. The online download method according to claim 2, characterized in that, The step of compiling and generating a data copy function and description information generation code based on the PLC's memory description information includes: Combining the memory description information stored locally, the memory storage address and data type information in the PLC's memory description information are compiled to generate the description information generation code; wherein, the description information generation code is used to characterize the program code for address distribution information in the compiled data; Code is generated based on the description information, and the data copy function is compiled.

4. The online download method according to claim 1, characterized in that, The process of obtaining the modified compilation data includes: Based on the memory description information stored locally, the memory description information of the PLC in the compilation data is parsed, and code is generated according to the description information to modify the parsed compilation data, thereby generating the modified compilation data.

5. The online download method according to claim 1, characterized in that, Before calling the data copy function, the method further includes: Based on the current scheduling task, an engineering update instruction is issued to control the PLC to enter the update state; When the PLC enters the update state and the PLC completes the scheduling task of executing the compilation data of the PLC project, the task status of the current scheduling task is marked as idle. When all currently scheduled tasks are in the idle state, the process enters the replacement state and executes the step of calling the data copy function.

6. The online download method according to claim 5, characterized in that, The step of calling the data copy function and updating the current storage address pointed to by the current scheduled task of the PLC according to the address distribution information in the locally stored memory description information, in order to load the description information to generate code and complete the download of the PLC project, includes: The data copy function is called to adjust the PLC's memory data according to the modified PLC memory description information; wherein, the memory data is used to describe the running data of the modified compilation data when the PLC is running; Replace the current storage address pointed to by the current scheduled task of the PLC with the code address of the description information generation code in the memory storage space, so as to load the description information generation code.

7. The online download method according to claim 6, characterized in that, After loading the description information to generate the code, the method further includes: When all description information generation code and all locally stored memory description information have been replaced in the PLC, the update state is exited and the download of the PLC project is stopped.

8. An online download system, characterized in that, The system, applied to a programming platform, includes: The acquisition unit is used to acquire the memory description information of the PLC after receiving a project download instruction from the user on the programmable logic controller (PLC); wherein the memory description information is used to characterize the address distribution information of the compilation data when the PLC runs the PLC project; The comparison unit is used to compare whether the memory description information stored locally is the same as the memory description information of the PLC. The generation unit is used to compile and generate a data copy function and description information generation code based on the locally stored memory description information when there is a difference between the memory description information stored locally and the memory description information of the PLC, and to generate modified compiled data. The calling unit is used to call the data copy function when the PLC loads the modified compilation data into the memory storage space and the PLC completes the current scheduling task for the compilation data, and to update the current storage address pointed to by the current scheduling task of the PLC, so that the PLC loads the description information to generate code and completes the download of the PLC project.

9. An online downloading device, characterized in that, The device includes: Central processing unit, memory, input / output interfaces, wired or wireless network interfaces, and power supply; The memory is either a short-term storage memory or a persistent storage memory; The central processing unit is configured to communicate with the memory and execute instructions in the memory to perform the online download method according to any one of claims 1 to 7.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium includes instructions that, when executed on a computer, cause the computer to perform the online download method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Method and device for compiling PLC (Programmable Logic Controller) program code into WebAssembly code

    CN114661300A

  • PLC program compiling method and device based on array mapping memory address

    CN117806607A