A method and apparatus for updating a PLC program
By comparing and fragmenting the old and new versions of PLC variable tables, ensuring consistent byte alignment, and allocating addresses on the final variable table, the problem of memory fragmentation in PLC program updates is solved, memory utilization and update efficiency are improved, and the user experience is optimized.
Patent Information
- Application Number
- CN202311411550.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-10-27
- Publication Date
- 2026-11-06
- Estimated Expiration
- 2043-10-27
AI Technical Summary
During existing PLC program updates, the failure to reallocate PLC variables leads to increased memory fragmentation, resulting in insufficient memory and impacting update efficiency and user experience.
By comparing the old and new versions of the variable table, the data is segmented to ensure that the byte alignment of the new sub-variable table is consistent with that of the old version. Address allocation is then performed on the final variable table to update the PLC program.
It avoids memory fragmentation, improves PLC memory utilization and program update efficiency, and optimizes the user experience.
Smart Images

Figure CN117331587B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a method and apparatus for updating PLC programs. Background Technology
[0002] When updating existing PLC (programmable logic controller) programs, the built-in PLC variables are not reallocated. This results in many unusable fragmented memory items being generated during the PLC program update process. After multiple updates to the PLC program, the number of unusable fragmented memory items increases, leading to less and less available memory in the PLC, and even insufficient memory. This affects the update efficiency of the PLC program and the user experience. Summary of the Invention
[0003] The technical problem to be solved by the present invention is: to provide a method and apparatus for updating PLC programs, thereby improving the efficiency of PLC program updates and optimizing the user experience.
[0004] To solve the above-mentioned technical problems, the technical solution adopted by the present invention is as follows: In a first aspect, the present invention provides a method for updating a PLC program, comprising: Obtain the old version variable table of the old project and the new version variable table of the new project, compare the old version variable table with the new version variable table, and obtain all the differences. The new version of the variable table is divided into N new version sub-variable tables based on each of the difference variables, wherein the variable byte alignment in each new version sub-variable table is consistent with the variable byte alignment in the old version of the variable table. Construct a final variable table, assign addresses to each of the new version sub-variable tables on the final variable table, initialize the final variable table, obtain the initialized final variable table, and update the PLC program based on the initialized final variable table.
[0005] The beneficial effects of this invention are as follows: By segmenting the new version of the variable table, the byte alignment of the new variables in each new sub-variable table is made consistent with the byte alignment of the old variables in the old variable table. Thus, address allocation is performed on each new sub-variable table in the final variable table to obtain the initialized final variable table. The PLC program is updated based on the initialized final variable table, avoiding the generation of unusable fragmented memory during the PLC program update process. This improves the utilization rate of PLC memory, increases the efficiency of PLC program updates, and optimizes the user experience.
[0006] Optionally, comparing the old version of the variable table with the new version of the variable table to obtain all the differences include: Obtain the old variable name, old variable type, and old variable structure from the old variable table; obtain the new variable name, new variable type, and new variable structure from the new variable table. The old version variable names, old version variable types, and old version variable structures are compared with the new version variable names, new version variable types, and new version variable structures to obtain all the differences.
[0007] As described above, when comparing the old version of the variable table with the new version of the variable table, not only are the variable names in the old version compared with the variable names in the new version, but also the variable types and structures in the old version are compared with the variable types and structures in the new version, so as to ensure the completeness and comprehensiveness of the differences obtained.
[0008] Optionally, the step of segmenting the new version variable table according to each of the difference variables to obtain N new version sub-variable tables, wherein the byte alignment of the new version variables in each of the new version sub-variable tables is consistent with the byte alignment of the old version variables in the old version variable table, includes: Obtain the difference position of each difference variable in the new version variable table, and divide the new version variable table into N new version sub-variable tables according to the difference position. The byte alignment of the new version variables in each new version sub-variable table is consistent with the byte alignment of the old version variables in the old version variable table.
[0009] As described above, when performing segmentation on the new version of the variable table, the segmentation is based on the position of the difference between each difference variable in the new version of the variable table, ensuring the rationality of the segmentation process.
[0010] Optionally, the byte alignment of the new variables in each of the new sub-variable tables being consistent with the byte alignment of the old variables in the old variable table includes: Calculate the address of the new variable occupied by the new variable in each new sub-variable table, and compare the address of the new variable with the address of the old variable occupied by the old variable in the old variable table. If the address of the new variable is inconsistent with the address of the old variable, the corresponding new sub-variable table is further divided into sub-tables until the address of the new variable occupied by the new variable in each new sub-variable table is consistent with the address of the old variable occupied by the old variable in the old variable table.
[0011] As described above, when the addresses of new variables in the new version sub-variable table are inconsistent with the addresses of old variables in the old version variable table, the inconsistent new version sub-variable table will be fragmented again. This ensures that the addresses of new variables in each fragment of the new version sub-variable table are consistent with the addresses of old variables in the old version variable table, thus guaranteeing that the byte alignment of new variables in each fragment of the new version sub-variable table is consistent with the byte alignment of old variables in the old version variable table.
[0012] Optionally, the step of allocating addresses for each of the new sub-variable tables on the final variable table to initialize the final variable table includes: Based on the order and size of the processing of each new version sub-variable table, an address is allocated for each new version sub-variable table on the final variable table, and the new data of the new version variables in each new version sub-variable table is copied to the final variable table to initialize the final variable table.
[0013] As described above, when allocating addresses for each new version of the sub-variable table on the final variable table, the allocation is based on the order and size of the segmentation process for each new version of the sub-variable table. This initializes the final variable table, and the PLC program is updated based on the initialized final variable table. This avoids generating unusable fragmented memory during the PLC program update process, improves the utilization rate of PLC memory, increases the efficiency of PLC program updates, and optimizes the user experience.
[0014] Secondly, the present invention provides a device for updating a PLC program, comprising: The comparison module is used to obtain the old version variable table of the old version project and the new version variable table of the new version project, compare the old version variable table with the new version variable table, and obtain all the difference variables. The sharding module is used to shard the new version variable table according to each of the difference variables to obtain N new version sub-variable tables, wherein the byte alignment of the new version variables in each new version sub-variable table is consistent with the byte alignment of the old version variables in the old version variable table; The update module is used to construct the final variable table, allocate addresses to each new version of the sub-variable table on the final variable table, initialize the final variable table, obtain the initialized final variable table, and update the PLC program based on the initialized final variable table.
[0015] The beneficial effects of this invention are as follows: By segmenting the new version of the variable table, the byte alignment of the new variables in each new sub-variable table is made consistent with the byte alignment of the old variables in the old variable table. Thus, address allocation is performed on each new sub-variable table in the final variable table to obtain the initialized final variable table. The PLC program is updated based on the initialized final variable table, avoiding the generation of unusable fragmented memory during the PLC program update process. This improves the utilization rate of PLC memory, increases the efficiency of PLC program updates, and optimizes the user experience.
[0016] Optionally, the comparison module is specifically used for: Obtain the old variable name, old variable type, and old variable structure from the old variable table; obtain the new variable name, new variable type, and new variable structure from the new variable table. The old version variable names, old version variable types, and old version variable structures are compared with the new version variable names, new version variable types, and new version variable structures to obtain all the differences.
[0017] As described above, when comparing the old version of the variable table with the new version of the variable table, not only are the variable names in the old version compared with the variable names in the new version, but also the variable types and structures in the old version are compared with the variable types and structures in the new version, so as to ensure the completeness and comprehensiveness of the differences obtained.
[0018] Optionally, the sharding module is specifically used for: Obtain the difference position of each difference variable in the new version variable table, and divide the new version variable table into N new version sub-variable tables according to the difference position. The byte alignment of the new version variables in each new version sub-variable table is consistent with the byte alignment of the old version variables in the old version variable table.
[0019] As described above, when performing segmentation on the new version of the variable table, the segmentation is based on the position of the difference between each difference variable in the new version of the variable table, ensuring the rationality of the segmentation process.
[0020] Optionally, the sharding module includes: The byte alignment module is used to calculate the address of the new variable occupied by the new variable in each new sub-variable table, compare the address of the new variable with the address of the old variable occupied by the old variable in the old variable table, and if the address of the new variable is inconsistent with the address of the old variable, the corresponding new sub-variable table is further fragmented until the address of the new variable occupied by the new variable in each new sub-variable table is consistent with the address of the old variable occupied by the old variable in the old variable table.
[0021] As described above, when the addresses of new variables in the new version sub-variable table are inconsistent with the addresses of old variables in the old version variable table, the inconsistent new version sub-variable table will be fragmented again. This ensures that the addresses of new variables in each fragment of the new version sub-variable table are consistent with the addresses of old variables in the old version variable table, thus guaranteeing that the byte alignment of new variables in each fragment of the new version sub-variable table is consistent with the byte alignment of old variables in the old version variable table.
[0022] Optionally, the update module includes: The initialization module is used to allocate addresses for each new version sub-variable table on the final variable table according to the order and size of the segment processing of each new version sub-variable table, and copy the new data of the new version variables in each new version sub-variable table to the final variable table, thereby realizing the initialization of the final variable table.
[0023] As described above, when allocating addresses for each new version of the sub-variable table on the final variable table, the allocation is based on the order and size of the segmentation process for each new version of the sub-variable table. This initializes the final variable table, and the PLC program is updated based on the initialized final variable table. This avoids generating unusable fragmented memory during the PLC program update process, improves the utilization rate of PLC memory, increases the efficiency of PLC program updates, and optimizes the user experience. Attached Figure Description
[0024] Figure 1 A flowchart illustrating a PLC program update method provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the overall process of a PLC program update method provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of a PLC program update device provided in an embodiment of the present invention.
[0025] [Explanation of Labels in the Attached Image] 1. A device for updating PLC programs; 2. Comparison module; 3. Fragmentation module; 31. Byte alignment module; 4. Update module; 41. Initialize module. Detailed Implementation
[0026] To better understand the above technical solutions, exemplary embodiments of the present invention will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present invention are shown in the drawings, it should be understood that the present invention can be implemented in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that the present invention can be understood more clearly and thoroughly, and that the scope of the present invention can be fully conveyed to those skilled in the art.
[0027] Example 1 Please refer to Figures 1 to 2 This invention provides a method for updating a PLC program, comprising the following steps: S1. Obtain the old version variable table of the old version project and the new version variable table of the new version project, compare the old version variable table with the new version variable table, and obtain all the difference variables; In this embodiment, the old version variable table of the old project is encrypted and stored in the PLC. Therefore, the old version variable table of the old project is obtained from the PLC and decrypted to obtain the decrypted old version variable table of the old project. This decrypted old version variable table is then compared with the new version variable table of the new project to find all the different variables, i.e., all the inconsistent variables.
[0028] At this point, the comparison between the old version of the variable table and the new version of the variable table in step S1 yields all the difference variables, including: S11. Obtain the old variable name, old variable type and old variable structure from the old variable table, and obtain the new variable name, new variable type and new variable structure from the new variable table; S12. Compare the old version variable name, old version variable type, and old version variable structure with the new version variable name, new version variable type, and new version variable structure to obtain all the differences.
[0029] In this embodiment, as Figure 2 As shown, since both the old and new versions of the variable table store information such as variable name, variable type, and variable structure (i.e., the old version of the variable table contains the old version of variable name, variable type, and variable structure, and the new version of the variable table contains the new version of variable name, variable type, and variable structure), we need to compare them one by one to find the variables that are different or inconsistent.
[0030] S2. The new version of the variable table is segmented according to each of the difference variables to obtain N new version sub-variable tables, wherein the byte alignment of the new version variables in each new version sub-variable table is consistent with the byte alignment of the old version variables in the old version variable table; At this point, step S2, which involves segmenting the new variable table according to each difference variable to obtain N new sub-variable tables, wherein the byte alignment of the new variables in each new sub-variable table is consistent with the byte alignment of the old variables in the old variable table, includes: S21. Obtain the difference position of each difference variable in the new version variable table, and perform segmentation processing on the new version variable table according to the difference position to obtain N new version sub-variable tables, wherein the byte alignment of the new version variables in each new version sub-variable table is consistent with the byte alignment of the old version variables in the old version variable table.
[0031] In this embodiment, as Figure 2 As shown, when segmenting the new version of the variable table, the segmentation is based on the position of each difference variable in the new version of the variable table. For example, Table 1 is the old version of the variable table, Table 2 is the new version of the variable table, and the difference variable is a8. Therefore, based on the position of the difference variable a8 in the new version of the variable table, the new version of the variable table is divided into two new version sub-variable tables. For example, Table 3 is the first new version sub-variable table, and Table 4 is the second new version sub-variable table. Here, BOOL represents Boolean type, and INT represents integer type.
[0032] Table 1. Old version of variable table
[0033] Table 2. New Variable Table
[0034] Table 3. Subvariable Table of the First New Version
[0035] Table 4. Subvariable Table of the Second Version
[0036] At this point, the byte alignment of the new variables in each of the new sub-variable tables in step S21 being consistent with the byte alignment of the old variables in the old variable table includes: S211. Calculate the address of the new variable occupied by the new variable in each new sub-variable table, and compare the address of the new variable with the address of the old variable occupied by the old variable in the old variable table. If the address of the new variable is inconsistent with the address of the old variable, then the corresponding new sub-variable table is further divided into sub-tables until the address of the new variable occupied by the new variable in each new sub-variable table is consistent with the address of the old variable occupied by the old variable in the old variable table.
[0037] In this embodiment, as Figure 2As shown, calculate whether the addresses of the new variables in each new version sub-variable table are consistent with the addresses of the old variables in the old version variable table. BOOL type variables occupy 1 byte (byte alignment value 1), and INT type variables occupy 4 bytes (byte alignment value 4). Table 5 is the address table of the old variables in the old version variable table, Table 6 is the address table of the new variables in the first new version sub-variable table, and Table 7 is the address table of the new variables in the second new version sub-variable table.
[0038] Table 5. Old version variable address table of the old version variable table
[0039] Table 6. New Variable Address Table for the First New Version of Sub-Variable Table
[0040] Table 7. New Variable Address Table for the Second New Version of Sub-Variable Table
[0041] First, compare the addresses of the new variables in the first new version sub-variable table (Table 6) with the addresses of the old variables in the old version variable table (Table 5). The addresses of a1 and a2 are consistent, meaning the byte alignment of the new variables in the first new sub-variable table is consistent with the byte alignment of the old variables in the old variable table. Therefore, it is not necessary to further fragment the first new sub-variable table. In the second new sub-variable table, as shown in Table 7, there are two empty address bits: 11 and 12 between a4 and a5, while there are no empty address bits between a4 and a5 in Table 1. Therefore, the old addresses occupied by the old variables in the second new sub-variable table are inconsistent with those in the old variable table. That is, the byte alignment of the new variables in the first new sub-variable table is inconsistent with the byte alignment of the old variables in the old variable table. Therefore, the second new sub-variable table is further fragmented, with a3 and a4 divided into a separate table, and the remaining variables forming a new new sub-variable table. Table 8 is the third new sub-variable table, Table 9 is the fourth new sub-variable table, and Table 10 is the fifth new sub-variable table.
[0042] Table 8. Subvariable Table of the Third Version
[0043] Table 9. Subvariable Table for the Fourth Version
[0044] Table 10. Subvariable Table of the Fifth Version
[0045] At this point, the new variable addresses of the third new version sub-variable table are shown in Table 11, the new variable addresses of the fourth new version sub-variable table are shown in Table 12, and the new variable addresses of the fifth new version sub-variable table are shown in Table 13. Table 11. New Variable Address Table for the Third New Version of Sub-Variable Table
[0046] Table 12. New Variable Address Table for the Fourth New Version of Sub-Variable Table
[0047] Table 13. New Variable Address Table for the Fourth New Version of Sub-Variable Table
[0048] In Table 11, the addresses of the new variables in the third new sub-variable table (Table 6) are consistent with the addresses of the old variables in the old variable table. In Table 12, the addresses of the new variables in the fourth new sub-variable table (Table 6) are consistent with the addresses of the old variables in the old variable table. In Table 13, the addresses of the new variables in the third new sub-variable table (Table 6) are consistent with the addresses of the old variables in the old variable table. That is, the byte alignment of the new variables in each new sub-variable table is consistent with the byte alignment of the old variables in the old variable table. Therefore, the fragmentation process is completed, and the final N new sub-variable tables are obtained.
[0049] S3. Construct the final variable table, allocate addresses to each of the new version sub-variable tables on the final variable table, initialize the final variable table, obtain the initialized final variable table, and update the PLC program based on the initialized final variable table.
[0050] In this embodiment, as Figure 2 As shown, a new variable table, namely the final variable table, is reconstructed. Addresses are assigned to each new version of the sub-variable in the final variable table, thereby completing the initialization of the final variable table. The PLC program is then updated based on the initialized final variable table.
[0051] At this point, step S3, which involves allocating addresses for each new sub-variable table in the final variable table to initialize the final variable table, includes: S31. Based on the order and size of the sharding process of each new version sub-variable table, allocate addresses for each new version sub-variable table on the final variable table, and copy the new data of the new version variables in each new version sub-variable table to the final variable table to initialize the final variable table.
[0052] In this embodiment, as Figure 2 As shown, when allocating addresses for each new version of the sub-variable table on the final variable table, the address allocation is based on the order of the fragmentation processing of each new version of the sub-variable table and the size of the fragmentation processing. Here, the size of the fragmentation processing refers to the address of the new version variable occupied by the new version variable. The new data of the new version variable is then copied to the final variable table to complete the initialization of the final variable table.
[0053] Example 2 Please refer to Figure 3 The present invention provides a PLC program update device 1, which specifically includes: a comparison module 2, an allocation module 3, a byte alignment module 31, an update module 4, and an initialization module 41.
[0054] Among them, comparison module 2 is used to obtain the old version variable table of the old version project and the new version variable table of the new version project, compare the old version variable table with the new version variable table, and obtain all the difference variables; The sharding module 3 is used to shard the new version variable table according to each of the difference variables to obtain N new version sub-variable tables, wherein the byte alignment of the new version variables in each new version sub-variable table is consistent with the byte alignment of the old version variables in the old version variable table; Update module 4 is used to construct the final variable table, allocate addresses to each of the new version sub-variable tables on the final variable table, initialize the final variable table, obtain the initialized final variable table, and update the PLC program based on the initialized final variable table.
[0055] Specifically, comparison module 2 is used for: Obtain the old variable name, old variable type, and old variable structure from the old variable table; obtain the new variable name, new variable type, and new variable structure from the new variable table. The old version variable names, old version variable types, and old version variable structures are compared with the new version variable names, new version variable types, and new version variable structures to obtain all the differences.
[0056] Specifically, the sharding module 3 is used for: Obtain the difference position of each difference variable in the new version variable table, and divide the new version variable table into N new version sub-variable tables according to the difference position. The byte alignment of the new version variables in each new version sub-variable table is consistent with the byte alignment of the old version variables in the old version variable table.
[0057] Specifically, the sharding module 3 includes: The byte alignment module 31 is used to calculate the address of the new variable occupied by the new variable in each new sub-variable table, compare the address of the new variable with the address of the old variable occupied by the old variable in the old variable table, and if the address of the new variable is inconsistent with the address of the old variable, the corresponding new sub-variable table is further divided into segments until the address of the new variable occupied by the new variable in each new sub-variable table is consistent with the address of the old variable occupied by the old variable in the old variable table.
[0058] Specifically, update module 4 includes: The initialization module 41 is used to allocate addresses for each new version sub-variable table on the final variable table according to the order and size of the segmentation processing of each new version sub-variable table, and copy the new data of the new version variables in each new version sub-variable table to the final variable table, thereby realizing the initialization of the final variable table.
[0059] Since the systems / devices described in the above embodiments of the present invention are systems / devices used to implement the methods of the above embodiments of the present invention, those skilled in the art can understand the specific structure and modifications of the systems / devices based on the methods described in the above embodiments of the present invention, and therefore will not be repeated here. All systems / devices used in the methods of the above embodiments of the present invention fall within the scope of protection of the present invention.
[0060] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0061] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions.
[0062] It should be noted that any reference numerals placed between parentheses in the claims should not be construed as limiting the claims. The word "comprising" does not exclude the presence of components or steps not listed in the claims. The word "a" or "an" preceding a component does not exclude the presence of a plurality of such components. The invention can be implemented by means of hardware comprising several different components and by means of a suitably programmed computer. In claims that enumerate several means, several of these means may be embodied by the same hardware. The use of the terms first, second, third, etc., is merely for convenience of expression and does not indicate any order. These terms can be understood as part of the component names.
[0063] Furthermore, it should be noted that in the description of this specification, the terms "one embodiment," "some embodiments," "embodiment," "example," "specific example," or "some examples," etc., refer to specific features, structures, materials, or characteristics described in connection with that embodiment or example, which are included in at least one embodiment or example of the present invention. In this specification, the illustrative expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described may be combined in any suitable manner in one or more embodiments or examples. Furthermore, without contradiction, those skilled in the art can combine and integrate the different embodiments or examples described in this specification, as well as the features of different embodiments or examples.
[0064] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the claims should be interpreted to include both the preferred embodiments and all changes and modifications falling within the scope of the invention.
[0065] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, then this invention should also include these modifications and variations.
Claims
1. A method for updating a PLC program, characterized in that, include: Obtain the old version variable table of the old project and the new version variable table of the new project, compare the old version variable table with the new version variable table, and obtain all the differences. The new version of the variable table is divided into N new version sub-variable tables based on each difference variable. The byte alignment of the new version variables in each new version sub-variable table is consistent with the byte alignment of the old version variables in the old version variable table. The byte alignment is the size of the number of bytes occupied by the variable. Construct a final variable table, assign addresses to each of the new version sub-variable tables on the final variable table, initialize the final variable table, obtain the initialized final variable table, and update the PLC program based on the initialized final variable table; The step of segmenting the new version variable table according to each of the difference variables to obtain N new version sub-variable tables, wherein the byte alignment of the new version variables in each of the new version sub-variable tables is consistent with the byte alignment of the old version variables in the old version variable table includes: Obtain the difference position of each difference variable in the new version variable table, and divide the new version variable table into N new version sub-variable tables according to the difference position. The byte alignment of the new version variables in each new version sub-variable table is consistent with the byte alignment of the old version variables in the old version variable table. The byte alignment of the new variables in each of the new sub-variable tables being consistent with the byte alignment of the old variables in the old variable table includes: Calculate the address of the new variable occupied by the new variable in each new sub-variable table, and compare the address of the new variable with the address of the old variable occupied by the old variable in the old variable table. If the address of the new variable is inconsistent with the address of the old variable, the corresponding new sub-variable table is further divided into sub-tables until the address of the new variable occupied by the new variable in each new sub-variable table is consistent with the address of the old variable occupied by the old variable in the old variable table.
2. The method for updating a PLC program as described in claim 1, characterized in that, The comparison between the old version of the variable table and the new version of the variable table yields all the differences, including: Obtain the old variable name, old variable type, and old variable structure from the old variable table; obtain the new variable name, new variable type, and new variable structure from the new variable table. The old version variable names, old version variable types, and old version variable structures are compared with the new version variable names, new version variable types, and new version variable structures to obtain all the differences.
3. The method for updating a PLC program as described in claim 1, characterized in that, The step of allocating addresses for each of the new sub-variable tables on the final variable table to initialize the final variable table includes: Based on the order and size of the processing of each new version sub-variable table, an address is allocated for each new version sub-variable table on the final variable table, and the new data of the new version variables in each new version sub-variable table is copied to the final variable table to initialize the final variable table.
4. A device for updating a PLC program, characterized in that, include: The comparison module is used to obtain the old version variable table of the old version project and the new version variable table of the new version project, compare the old version variable table with the new version variable table, and obtain all the difference variables. The sharding module is used to shard the new version variable table according to each of the difference variables to obtain N new version sub-variable tables, wherein the byte alignment of the new version variables in each new version sub-variable table is consistent with the byte alignment of the old version variables in the old version variable table, and the byte alignment is the size of the bytes occupied by the variable; The update module is used to construct the final variable table, allocate addresses to each new version of the sub-variable table on the final variable table, initialize the final variable table, obtain the initialized final variable table, and update the PLC program based on the initialized final variable table. The sharding module is specifically used for: Obtain the difference position of each difference variable in the new version variable table, and divide the new version variable table into N new version sub-variable tables according to the difference position. The byte alignment of the new version variables in each new version sub-variable table is consistent with the byte alignment of the old version variables in the old version variable table. The sharding module includes: The byte alignment module is used to calculate the address of the new variable occupied by the new variable in each new sub-variable table, compare the address of the new variable with the address of the old variable occupied by the old variable in the old variable table, and if the address of the new variable is inconsistent with the address of the old variable, the corresponding new sub-variable table is further fragmented until the address of the new variable occupied by the new variable in each new sub-variable table is consistent with the address of the old variable occupied by the old variable in the old variable table.
5. The PLC program update device as described in claim 4, characterized in that, The comparison module is specifically used for: Obtain the old variable name, old variable type, and old variable structure from the old variable table; obtain the new variable name, new variable type, and new variable structure from the new variable table. The old version variable names, old version variable types, and old version variable structures are compared with the new version variable names, new version variable types, and new version variable structures to obtain all the differences.
6. The PLC program update device as described in claim 4, characterized in that, The update module includes: The initialization module is used to allocate addresses for each new version sub-variable table on the final variable table according to the order and size of the segment processing of each new version sub-variable table, and copy the new data of the new version variables in each new version sub-variable table to the final variable table, thereby realizing the initialization of the final variable table.
Citation Information
Patent Citations
Energy efficient method for communication in wireless sensor network of industrial control system
CN102845100A
Variable address allocation system and method for programmable controller
CN110471862A
