Logic switching method of programmable controller, electronic equipment and storage medium

By using differential jump patching and differential logic patching, the logic switching of the programmable controller can be realized without stopping the machine, which solves the production interruption problem caused by downtime in traditional solutions and improves the adaptability and efficiency of industrial control scenarios.

CN121411301APending Publication Date: 2026-01-27SUZHOU GAOCHUANG MOTION CONTROL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410968931.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2026-01-27

AI Technical Summary

Technical Problem

Traditional programmable logic controller (PLC) logic switching schemes require system downtime for downloading, which can cause production process interruptions in some industrial control scenarios and has poor adaptability.

Method used

By employing differential jump patching and differential logic patching, differential jump patching and differential logic patching are downloaded from the host computer to non-volatile memory while the programmable controller is executing the original logic. When the task is idle, they are downloaded to the running memory address, and logic switching is achieved using jump instructions.

Benefits of technology

It enables logic switching of programmable controllers without stopping the machine, improves the adaptability of industrial control scenarios, reduces data transmission volume and download time, and ensures the continuity of the production process.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121411301A_ABST
    Figure CN121411301A_ABST
Patent Text Reader

Abstract

The invention discloses a logic switching method of a programmable controller, electronic equipment and a storage medium, and relates to the technical field of programmable controllers, and the logic switching method of the programmable controller applied to the programmable controller comprises the following steps: in a state of executing original logic, switching the original logic into a logic state; a differential jump patch and a differential logic patch are downloaded from the upper computer to the nonvolatile memory, the differential logic patch comprises a differential logic block between the update logic and the original logic and a jump instruction for jumping back to the original logic, and the differential jump patch comprises a jump instruction for controlling switching from the original logic to the differential logic block; downloading the differential logic patch to a running memory address; when the task is in an idle state, downloading the differential jump patch to a running memory address; and executing updating logic based on the differential jump patch and the differential logic patch on the running memory address. According to the technical scheme, the technical problem that the scene adaptability of a traditional programmable controller shutdown downloading scheme is poor is solved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of programmable controller technology, and in particular to a logic switching method for a programmable controller, an electronic device, and a computer-readable storage medium. Background Technology

[0002] Currently, the logic of a programmable logic controller (PLC) can be freely edited according to customer needs. When it is necessary to update the logic in the PLC, the PLC is usually stopped, and the new logic is downloaded from the host computer to the PLC's non-volatile memory. After the PLC is restarted, the new logic in the non-volatile memory is read and downloaded to the running memory for execution.

[0003] However, in some industrial control applications, the shutdown of the production process can have significant negative impacts, such as reduced production efficiency and increased costs. Traditional programmable controller shutdown download solutions require the execution of the logic before the update to be stopped before the logic can be switched, thus making them less adaptable to different scenarios. Summary of the Invention

[0004] The main purpose of this application is to provide a logic switching method for a programmable controller, an electronic device, and a computer-readable storage medium, aiming to solve the technical problem of poor scenario adaptability of traditional programmable controller shutdown download schemes.

[0005] To achieve the above objectives, this application provides a logic switching method for a programmable controller, applied to a programmable controller, the logic switching method for the programmable controller comprising:

[0006] While executing the original logic, a differential jump patch and a differential logic patch are downloaded from the host computer to non-volatile memory. The differential logic patch includes a differential logic block between the update logic and the original logic, as well as a jump back instruction to the original logic. The differential jump patch includes a jump instruction, which is used to control the programmable controller to switch from the original logic to the differential logic block.

[0007] The differential logic patch is downloaded to the runtime memory address of the programmable controller;

[0008] When the programmable controller is in a task idle state, the differential jump patch is downloaded to the running memory address;

[0009] The update logic is executed based on the differential jump patch and differential logic patch at the running memory address.

[0010] In one embodiment, the logic switching method of the programmable controller further includes:

[0011] While executing the original logic, a differential data patch is downloaded from the host computer to the non-volatile memory, wherein the differential data patch includes a newly added data segment;

[0012] The differential data patch is downloaded to the runtime memory address of the programmable controller;

[0013] The update logic is executed based on the differential jump patch, differential logic patch, and differential data patch at the aforementioned memory address.

[0014] In one embodiment, after the step of downloading the differential jump patch to the runtime memory address, the method further includes:

[0015] If the running memory address includes a historical differential jump patch corresponding to the last logical update, then delete the historical differential jump patch.

[0016] Furthermore, to achieve the above objectives, this application also provides a logic switching method for a programmable controller, applied to a host computer, wherein the logic switching method for the programmable controller includes:

[0017] Obtain the update logic, and determine the corresponding differential logic block based on the original logic and the update logic;

[0018] A jump instruction is generated based on the difference hole in the original logic, and a differential jump patch is generated based on the jump instruction. The difference hole is a logic block in the original logic that is replaced by the differential logic block. The jump instruction is used to be downloaded in the task idle state of the programmable controller and to control the programmable controller to switch from the original logic to the differential logic block.

[0019] A jump-back instruction is added to the end of the differential logic block, and a differential logic patch is generated based on the differential logic block and the jump-back instruction. The differential logic patch is used to be downloaded while the programmable controller is executing the original logic, and the jump-back instruction is used to control the programmable controller to switch from the differential logic block to the original logic.

[0020] In one embodiment, the step of determining the corresponding differential logic block based on the original logic and the updated logic includes:

[0021] By comparing the original logic with the updated logic, the differences are obtained;

[0022] The differences are compiled to obtain differential logic blocks.

[0023] In one embodiment, the logic switching method of the programmable controller further includes:

[0024] Compare the original data segment and the modified data segment to determine the newly added data segment;

[0025] Generate corresponding differential data patches based on the newly added data segments.

[0026] In one embodiment, the step of generating a differential logic patch based on the differential logic block and the jump-back instruction includes:

[0027] If the differential logic block is a new logic block added by the update logic relative to the original logic, then obtain the adjacent logic block in the original logic that is located before the new logic block;

[0028] The corresponding differential logic patch is generated based on the adjacent logic block, the newly added logic block, and the jumpback instruction.

[0029] In one embodiment, when the differential logic block is a newly added logic block of the updated logic relative to the original logic, the jump instruction is used to control the programmable logic controller to switch from the previous logic block in the original logic to the adjacent logic block in the differential logic patch, wherein the previous logic block is the logic block in the original logic that is located before and adjacent to the adjacent logic block.

[0030] In addition, to achieve the above objectives, this application also provides an electronic device, which is a physical device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the steps of the logic switching method of the programmable controller as described above.

[0031] In addition, to achieve the above objectives, this application also provides a readable storage medium, which is a computer-readable storage medium, on which a program implementing a logic switching method of a programmable controller is stored. The program implementing the logic switching method of the programmable controller is executed by a processor to implement the steps of the logic switching method of the programmable controller as described above.

[0032] In addition, to achieve the above objectives, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the logic switching method of the programmable controller as described above.

[0033] This application provides a logic switching method for a programmable logic controller (PLC). First, while executing the original logic, a differential jump patch and a differential logic patch are downloaded from a host computer to a non-volatile memory. The differential logic patch includes a differential logic block between the update logic and the original logic, and a jump instruction to return to the original logic. The differential jump patch includes a jump instruction used to control the PLC to switch from the original logic to the differential logic block. Then, the differential logic patch is downloaded to the PLC's runtime memory address. When the PLC is in a task idle state, the differential jump patch is downloaded to the runtime memory address. Based on the differential jump patch and differential logic patch at the runtime memory address, the update logic is executed. In this application's technical solution, the differential jump patch and differential logic patch can be downloaded while the original logic is being executed, without stopping the programmable controller (PLC). The differential jump patch only includes jump instructions, has a small data volume, and a short download time. Because the differential jump patch download time is short, it can be downloaded into memory during a brief idle state while the PLC is executing the original logic. After the differential jump patch download is complete, the PLC can be switched from the original logic to the updated logic based on the differential jump patch and differential logic patch in memory. This achieves logic switching of the PLC without stopping it, adapting to industrial control scenarios where the production process cannot be stopped. Compared with the traditional PLC shutdown download scheme, this effectively improves scenario adaptability. Attached Figure Description

[0034] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0035] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0036] Figure 1 This is a flowchart illustrating an embodiment of a logic switching method for a programmable controller applied to a programmable controller in this application.

[0037] Figure 2 This is a flowchart illustrating an embodiment of the logic switching method for a programmable controller applied to a host computer in this application.

[0038] Figure 3 This is a schematic diagram illustrating the principle of replacing the difference gaps in the original logic with differential logic in the embodiments of this application;

[0039] Figure 4 This is a schematic diagram illustrating the principle of adding a new logic block to the original logic in an embodiment of this application;

[0040] Figure 5 This is a schematic diagram of the device structure of the hardware operating environment involved in the logic switching method of the programmable controller in the embodiments of this application.

[0041] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0042] To make the above-mentioned objectives, features, and advantages of this application more apparent and understandable, the technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are merely some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0043] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0044] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0045] Currently, the logic of programmable logic controllers (PLCs) can be freely edited according to customer needs. In industrial applications, some production processes cannot be stopped due to process requirements or cost constraints. In such cases, a non-stop download solution is urgently needed. Non-stop download refers to updating the original logic while the PLC is executing it, ensuring that the executing customer logic does not stop, allowing the PLC to seamlessly transition from the original logic to the updated logic.

[0046] To achieve the above objectives, embodiments of this application provide a logic switching method for a programmable controller, referring to... Figure 1 , Figure 1 This is a flowchart illustrating an embodiment of the logic switching method for a programmable controller according to this application. The logic switching method for the programmable controller specifically includes:

[0047] Step S10: While executing the original logic, download the differential jump patch and differential logic patch from the host computer to the non-volatile memory. The differential logic patch includes a differential logic block between the update logic and the original logic, as well as a jump back instruction for jumping back to the original logic. The differential jump patch includes a jump instruction for controlling the programmable controller to switch from the original logic to the differential logic block.

[0048] The execution entity in this embodiment is a programmable logic controller (PLC). When the PLC needs to update its logic, it first downloads a differential jump patch and a differential logic patch from a host computer with which it has established a communication connection, and stores them in its own non-volatile memory. It should be noted that the above download process can be performed at any time without system downtime. Since the differential jump patch and differential logic patch are stored in non-volatile memory rather than RAM, they do not affect the current production process of the PLC. Furthermore, the host computer has pre-generated the differential jump patch and differential logic patch based on the user-inputted update logic for the PLC to download. Compared to the traditional approach of downloading all files corresponding to the update logic, this embodiment only downloads the differential jump patch and differential logic patch. This is equivalent to downloading only the parts of the update logic that have changed compared to the original logic; the unchanged parts of the original logic can still be used. This reduces the amount of data downloaded by the PLC and improves the logic update efficiency.

[0049] Additionally, it should be noted that the differential logic patch includes differential logic blocks corresponding to the newly added logic in the update logic relative to the original logic. If there is logic to be deleted in the original logic, the newly added logic replaces the deleted logic; if there is no logic to be deleted in the original logic, the update logic adds a new logic block to the original logic, and this new logic is inserted into a certain position in the original logic. Furthermore, the jump back instruction in the differential logic patch is used to control the programmable controller to jump back to the original logic after executing the logic corresponding to the differential logic block, and continue subsequent execution steps. The differential logic patch is used to control the programmable controller to jump to the differential logic block of the differential logic patch at a specified position during the execution of the original logic, thereby enabling the programmable controller to switch from the original logic to the update logic, completing the download without stopping and the switching between the old and new logic.

[0050] For example, referring to Table 1 below, the storage format of the files corresponding to the differential logic patch and the differential jump patch may include physical address, code length, and code segment.

[0051] physical address Code length code snippet physical address Code length code snippet physical address Code length code snippet

[0052] Table 1

[0053] Step S20: Download the differential logic patch to the programmable controller's running memory address;

[0054] After the differential logic patch is stored in non-volatile memory, it can be downloaded to the programmable controller's running memory address. Since the differential logic patch does not contain jump instructions, although the differential logic patch exists at the programmable controller's running memory address, it will not be triggered and will not affect the current programmable controller's execution of the original logic process. Therefore, step S20 can also be executed without stopping the system.

[0055] Step S30: When the programmable controller is in a task idle state, download the differential jump patch to the running memory address;

[0056] Since the differential jump patch includes a jump instruction that enables the programmable controller (PLC) to switch from the original logic to the differential logic block of the differential logic patch, step S30 requires downloading the differential jump patch while the PLC is in a task idle state to avoid affecting the normally executing original logic. The task idle state means that all tasks on the PLC are not in execution. The differential jump patch contains only one jump instruction, resulting in short code, small data size, and short download time. Because the differential jump patch download time is short, it can be downloaded into memory during the brief task space state of the PLC without affecting the execution of the original logic.

[0057] Step S40: Based on the differential jump patch and differential logic patch on the running memory address, execute the update logic.

[0058] After both the differential jump patch and the differential logic patch are downloaded to the runtime memory address, the differential jump patch can take effect. When the programmable controller (PLC) executes to the original logic location corresponding to the jump instruction of the differential jump patch, it jumps to the differential logic block corresponding to the differential logic patch according to the jump instruction, executes the new logic, and then jumps back to the original logic according to the jump back instruction in the differential logic patch after the differential logic block has finished executing. Therefore, in this embodiment, when switching the logic of the PLC, only the newly added differential logic block is downloaded, and the switching between the original logic and the differential logic block is completed by combining the jump instruction and the jump back instruction. There is no need to stop the system to download and update all the files corresponding to the logic, which reduces the amount of data transmission and ensures the continuity of the PLC production process.

[0059] This application provides a logic switching method for a programmable logic controller (PLC). First, while executing the original logic, a differential jump patch and a differential logic patch are downloaded from a host computer to a non-volatile memory. The differential logic patch includes a differential logic block between the update logic and the original logic, as well as a jump instruction to return to the original logic. The differential jump patch includes a jump instruction for controlling the PLC to switch from the original logic to the differential logic block. Then, the differential logic patch is downloaded to the PLC's running memory address. When the PLC is in a task idle state, the differential jump patch is downloaded to the running memory address. Based on the differential jump patch and differential logic patch at the running memory address, the update logic is executed. In the technical solution of this application embodiment, the differential jump patch and differential logic patch can be downloaded while the original logic is being executed, without stopping the programmable controller. The differential jump patch only includes jump instructions, with a small data volume and short download time. Because the differential jump patch download time is short, it can be downloaded into memory when the programmable controller is in a brief task idle state during the execution of the original logic. After the differential jump patch download is complete, the programmable controller can be switched from the original logic to the updated logic based on the differential jump patch and differential logic patch in memory. This realizes logic switching of the programmable controller without stopping it, which can adapt to industrial control scenarios where the production process cannot be stopped. Compared with the traditional programmable controller shutdown download scheme, it effectively improves scenario adaptability.

[0060] In another feasible embodiment, the logic switching method of the programmable controller further includes:

[0061] Step A10: While executing the original logic, download the differential data patch from the host computer to the non-volatile memory, wherein the differential data patch includes newly added data segments;

[0062] Step A20: Download the differential data patch to the programmable controller's running memory address;

[0063] Step A30: Based on the differential jump patch, differential logic patch, and differential data patch at the running memory address, execute the update logic.

[0064] Understandably, when updating or switching the logic of a programmable logic controller (PLC), in addition to updating the execution logic itself, there may be situations where it's necessary to add new data segments to the original data segments. When adding a new data segment to the PLC, the differential data patch corresponding to the new data segment is downloaded from the host computer. This differential data patch is first downloaded and stored in non-volatile memory, and then, if the runtime memory address space allows, it is downloaded directly to the runtime memory address. Because the new data segment corresponds to and works in conjunction with the updated logic, the differential data patch itself will not affect the execution of the original logic by the controllable programmer if the differential jump patch has not yet been downloaded to the runtime memory address.

[0065] For example, the storage format of the differential data patch is shown in Table 2 below, including data type, physical address, length, and initial value (i.e., default value).

[0066] Data types physical address length initial value Data types physical address length initial value Data types physical address length initial value

[0067] Table 2

[0068] Furthermore, after downloading the new data segment to the programmable controller, the data segment to be replaced does not need to be processed; simply add the new data segment to the end of the original data segment. For data segments with specified addresses, they are called according to their addresses. When the update logic calls the new data segment, its value is the default initial value. When variables in a data segment change relative to the address of the replaced data segment, the new address is used.

[0069] Finally, after the differential jump patch, differential logic patch, and differential data patch at the running memory address have all been downloaded, the update logic can be executed according to the method described in step S40, and the data in the newly added data segment can be called as needed.

[0070] In one feasible embodiment, after the step of downloading the differential jump patch to the runtime memory address, the logic switching method of the programmable controller further includes:

[0071] Step S21: If the running memory address includes the historical differential jump patch corresponding to the last logical update, then delete the historical differential jump patch.

[0072] In the technical solution of this application embodiment, each time the original logic needs to be updated, the new logic is executed in the form of differential jump patch and differential logic patch. Moreover, each update is based on the original logic of the original version compiled for the first time to determine the corresponding patch file (including differential jump patch, differential logic patch and differential data patch, etc.).

[0073] For example, after the programmable controller has performed N updates to the original logic, the differential jump patch and differential logic patch in the N+1th update are still obtained by comparing the new logic with the original logic in the first update, and are unrelated to the other differential jump patches and differential logic patches in these N updates. Therefore, after the first update, the historical differential jump patch corresponding to the previous logic update will exist in the non-volatile memory and the running memory. Before the update logic corresponding to the N+1th update is executed, it is necessary to ensure the normal operation of the update logic corresponding to the Nth update. Therefore, before the differential jump patch is downloaded to the running memory address, the historical differential jump patch in the running memory address is retained. After the differential jump patch is downloaded to the running memory address, the historical differential jump patch in the running memory address can be deleted. For other historical differential logic patches or historical differential data patches, they can also be deleted together after the historical differential jump patch is deleted. For the historical patch file in the non-volatile memory, it is also deleted after the update logic corresponding to the N+1th update is executed.

[0074] It should be noted that if this is the N+1th compilation, the binary file of the Nth compilation (including the differential jump patch, differential logic patch, and differential data patch) needs to be retained. This is because the Nth update logic needs to be able to run normally before the N+1th update logic runs. Therefore, the memory of the patch file used in the Nth compilation should not overlap with that of the Nth compilation.

[0075] Furthermore, embodiments of this application also provide a logic switching method for a programmable controller applied to a host computer, referring to... Figure 2 The specific steps include:

[0076] Step B10: Obtain the update logic and determine the corresponding differential logic block based on the original logic and the update logic;

[0077] It should be noted that this application embodiment provides a method for generating differential jump patches and differential logic patches by a host computer based on user-input update logic, for download and use by a programmable controller.

[0078] First, the host computer can compare the differences between the original logic and the updated logic in the programmable controller at the IEC (an IEC-compliant programming language) level, and compile them to obtain the corresponding differential logic blocks. The updated logic can be a file in the form of code entered by the operator on the host computer. In this case, it can be assumed that there are several difference gaps between the original client logic and the updated logic, and these difference gaps in the programmable controller are still filled with the original logic.

[0079] Furthermore, the steps for determining the corresponding differential logic block based on the original logic and the updated logic include:

[0080] Step B11: Compare the original logic with the updated logic to obtain the differences.

[0081] Step B12: Compile the difference content to obtain the differential logic block.

[0082] The host computer can compare the differences between each line of IEC language code in the original logic and the updated logic, and compile the differences as POUs (Programming Organisation Units) to generate the corresponding differential logic blocks.

[0083] It should be noted that the host computer software of the programmable controller must retain the original client logic. Only when the original client logic exists can the normal differential compilation process be performed.

[0084] Step B20: Generate a jump instruction based on the difference hole in the original logic, and generate a differential jump patch based on the jump instruction. The difference hole is the logic block in the original logic that has been replaced by the differential logic block. The jump instruction is used to be downloaded in the idle state of the programmable controller and to control the programmable controller to switch from the original logic to the differential logic block.

[0085] After identifying the differential gaps in the original logic, jump instructions are added at these gaps. These jump instructions control the programmable controller to switch from the original logic to the differential logic block execution when the programmable controller reaches the location corresponding to the jump instruction. The differential jump patch is a binary file generated based on the jump instructions, and its data size is relatively small.

[0086] Furthermore, the specific implementation methods for downloading jump instructions and differential jump patches to the programmable controller are consistent with the logic switching methods applied to the programmable controller in the aforementioned embodiments, and can be referred to the foregoing content, so they will not be repeated here. Since the code for the jump instruction is short, the differential jump patch can be downloaded to the running memory during a brief period of task idle state of the programmable controller, without affecting the execution process of the original logic, thereby achieving non-stop downloading of the programmable controller.

[0087] Step B30: Add a jump-back instruction to the end of the differential logic block, and generate a differential logic patch based on the differential logic block and the jump-back instruction. The differential logic patch is used to be downloaded while the programmable controller is executing the original logic, and the jump-back instruction is used to control the programmable controller to switch from the differential logic block to the original logic.

[0088] A jump-back instruction is added to the end of the differential logic block to jump back to the original logic after the differential logic block has been executed. The differential logic block and the jump-back instruction are then combined to form a differential logic patch in binary file form. This differential logic patch will only take effect if the differential jump patch is active. Therefore, it can be downloaded to the running memory synchronously while the programmable controller is executing the original logic, without affecting the programmable controller's execution of the original logic.

[0089] Additionally, it should be noted that when the host computer software compiles and generates the differential logic patch, it is important to ensure that the beginning and end of the patch maintain the values ​​of the processor's general-purpose registers. This is because the patch is not a normal function call, but rather a jump instruction, and the processor's general-purpose registers are not automatically pushed onto the stack.

[0090] For example, refer to Figure 3 The original logic includes original logic 1 to 4. The original logic 3 (i.e., the differential hole) to be replaced is the differential logic block including differential logic 1, differential logic 2, etc. First, the jump instruction in the differential jump patch controls the programmable controller to switch to the differential logic block corresponding to the differential logic patch after the original logic 2, and executes differential logic 1, differential logic 2, etc. Then, according to the jump back instruction in the differential logic patch, the programmable controller is controlled to switch back to the original logic 4. Thus, the entire execution process of one update logic is completed.

[0091] In another feasible embodiment, the logic switching method of the programmable controller further includes:

[0092] Step C10: Compare the original data segment and the modified data segment to determine the newly added data segment;

[0093] Step C20: Generate the corresponding differential data patch based on the newly added data segment.

[0094] When a data segment needs to be updated, the difference between the original data segment and the modified data segment can be compared with that of the host computer to obtain the newly added data segment. In particular, if the original data segment does not need to be deleted during the data segment update process (i.e., the original data segment is not modified), and only a new data segment is added, then the newly added data segment can be obtained directly.

[0095] Similarly, after acquiring the new data segment, it is converted into a binary differential data patch for the programmable controller to download and use.

[0096] In another feasible embodiment, the step of generating a differential logic patch based on the differential logic block and the jump-back instruction includes:

[0097] Step B31: If the differential logic block is a new logic block added to the update logic relative to the original logic, then obtain the adjacent logic block in the original logic that is located before the new logic block.

[0098] Step B32: Generate the corresponding differential logic patch based on adjacent logic blocks, newly added logic blocks, and jump back instructions.

[0099] It should be noted that a differential logic block, which is a newly added logic block relative to the original logic, means that during the update of the original logic, it is not necessary to delete any part of the original logic; only a new logic block needs to be inserted. In this case, there are no differential gaps in the original logic, and the method of directly replacing part of the original logic with the new logic block cannot be used. Therefore, in this embodiment, a differential gap is identified by cutting out a segment of logic at the location where the new logic block is added (i.e., the adjacent logic block before the new logic block). Then, the cut adjacent logic block is combined with the new logic block and the jump back instruction to generate the corresponding differential logic patch.

[0100] For example, refer to Figure 4 The original logic includes original logic 1 to 4, and there is no original logic that needs to be replaced or deleted. The new logic (differential logic 1, differential logic 2, etc.) is inserted between original logic 3 and original logic 4. At this time, the differential logic patch consists of original logic 3, differential logic 1, differential logic 2, etc. arranged in sequence, as well as a jump instruction. When executing the update logic, the programmable controller is first controlled to switch to the differential logic block corresponding to the differential logic patch after original logic 2 through the jump instruction in the differential jump patch, and original logic 3, differential logic 1, differential logic 2, etc. are executed. Then, according to the jump instruction in the differential logic patch, the programmable controller is controlled to switch back to original logic 4. Thus, the entire execution process of one update logic is completed.

[0101] Furthermore, in a feasible embodiment, when the differential logic block is a newly added logic block relative to the original logic, the jump instruction is used to control the programmable logic controller to switch from the previous logic block in the original logic to the adjacent logic block in the differential logic patch, wherein the previous logic block is the logic block in the original logic that is located before and adjacent to the adjacent logic block.

[0102] Here, the preceding logical block refers to the logical block preceding the adjacent logical block that appears sequentially before the newly added logical block during execution. For example, such as... Figure 4 As shown, the newly added logic blocks include differential logic 1, differential logic 2, etc. The adjacent logic block is the original logic 3, and the previous logic block is the original logic 2. The jump instruction is used to control the programmable logic controller to switch from the original logic 2 to the original logic 3 in the differential logic patch.

[0103] The logic switching method for a programmable controller (PCC) applied to a host computer provided in this application, employing the PCC logic switching methods described in the above embodiments, can solve the technical problem of poor scenario adaptability of traditional PCC shutdown download schemes. Compared with the prior art, the beneficial effects of the PCC logic switching device provided in this application are the same as the beneficial effects of the PCC logic switching method applied to the above-described PCC, and other technical features in the PCC logic switching method are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0104] This application also provides an electronic device, which includes at least: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the logic switching method of the programmable controller in the first embodiment described above.

[0105] The following is for reference. Figure 5 It shows a schematic diagram of the structure of an electronic device suitable for implementing the embodiments of the present disclosure. Figure 5 The electronic device shown is merely an example and should not be construed as limiting the functionality and scope of the embodiments disclosed herein.

[0106] like Figure 5As shown, the electronic device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the electronic device. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to the I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows electronic devices to communicate wirelessly or wiredly with other devices to exchange data. While electronic devices with various systems are shown in the figures, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.

[0107] In particular, according to embodiments of this disclosure, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this disclosure include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of embodiments of this disclosure.

[0108] The electronic device provided in this application, employing the logic switching method of the programmable controller in the above embodiments, can solve the technical problem of poor scenario adaptability of traditional programmable controller shutdown download schemes. Compared with the prior art, the beneficial effects of the electronic device provided in this application are the same as those of the logic switching method of the programmable controller provided in the above embodiments, and other technical features of this electronic device are the same as those disclosed in the method of the previous embodiment, and will not be repeated here.

[0109] It should be understood that various parts of this disclosure can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics may be combined in any suitable manner in one or more embodiments or examples.

[0110] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0111] This application also provides a computer-readable storage medium having computer-readable program instructions stored thereon, the computer-readable program instructions being used to execute the logic switching method of the programmable controller in the first embodiment described above.

[0112] The computer-readable storage medium provided in this application embodiment may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0113] The aforementioned computer-readable storage medium may be included in an electronic device or may exist independently without being assembled into an electronic device.

[0114] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by an electronic device (e.g., a programmable controller), the electronic device performs the following: While executing the original logic, downloading a differential jump patch and a differential logic patch from a host computer to non-volatile memory, wherein the differential logic patch includes a differential logic block between the update logic and the original logic, and a jump back instruction to the original logic; the differential jump patch includes a jump instruction used to control the programmable controller to switch from the original logic to the differential logic block; downloading the differential logic patch to the runtime memory address of the programmable controller; when the programmable controller is in a task idle state, downloading the differential jump patch to the runtime memory address; and executing the update logic based on the differential jump patch and differential logic patch at the runtime memory address.

[0115] Additionally, when one or more of the above programs are executed by an electronic device (e.g., a host computer), the electronic device performs the following: obtaining update logic; determining the corresponding differential logic block based on the original logic and the update logic; generating a jump instruction based on the difference gap in the original logic; and generating a differential jump patch based on the jump instruction, wherein the difference gap is a logic block in the original logic that has been replaced by the differential logic block, and the jump instruction is used to be downloaded in the programmable controller's idle state and to control the programmable controller to switch from the original logic to the differential logic block; adding a jump back instruction to the end of the differential logic block; and generating a differential logic patch based on the differential logic block and the jump back instruction, wherein the differential logic patch is used to be downloaded while the programmable controller is executing the original logic, and the jump back instruction is used to control the programmable controller to switch from the differential logic block to the original logic.

[0116] Computer program code for performing the operations of this disclosure can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, and conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0117] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0118] The modules described in the embodiments of this disclosure can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0119] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions for executing the logic switching method of the programmable controller described above. This solves the technical problem of poor scenario adaptability in traditional programmable controller shutdown and download schemes. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the logic switching method of the programmable controller provided in Embodiment 1 above, and will not be repeated here.

[0120] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the logic switching method for a programmable controller as described above.

[0121] The computer program product provided in this application can solve the technical problem of poor scenario adaptability of traditional programmable controller shutdown download schemes. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the logic switching method of the programmable controller provided in Embodiment 1 above, and will not be repeated here.

[0122] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent scope of this application.

Claims

1. A logic switching method for a programmable controller, characterized in that, Applied to a programmable logic controller (PLC), the logic switching method of the PLC includes: While executing the original logic, a differential jump patch and a differential logic patch are downloaded from the host computer to non-volatile memory. The differential logic patch includes a differential logic block between the update logic and the original logic, as well as a jump back instruction to the original logic. The differential jump patch includes a jump instruction, which is used to control the programmable controller to switch from the original logic to the differential logic block. The differential logic patch is downloaded to the runtime memory address of the programmable controller; When the programmable controller is in a task idle state, the differential jump patch is downloaded to the running memory address; The update logic is executed based on the differential jump patch and differential logic patch at the running memory address.

2. The logic switching method for a programmable controller as described in claim 1, characterized in that, The logic switching method of the programmable controller further includes: While executing the original logic, a differential data patch is downloaded from the host computer to the non-volatile memory, wherein the differential data patch includes a newly added data segment; The differential data patch is downloaded to the runtime memory address of the programmable controller; The update logic is executed based on the differential jump patch, differential logic patch, and differential data patch at the aforementioned memory address.

3. The logic switching method for a programmable controller as described in claim 1, characterized in that, After the step of downloading the differential jump patch to the runtime memory address, the method further includes: If the running memory address includes a historical differential jump patch corresponding to the last logical update, then delete the historical differential jump patch.

4. A logic switching method for a programmable controller, characterized in that, When applied to a host computer, the logic switching method of the programmable controller includes: Obtain the update logic, and determine the corresponding differential logic block based on the original logic and the update logic; A jump instruction is generated based on the difference hole in the original logic, and a differential jump patch is generated based on the jump instruction. The difference hole is a logic block in the original logic that is replaced by the differential logic block. The jump instruction is used to be downloaded in the task idle state of the programmable controller and to control the programmable controller to switch from the original logic to the differential logic block. A jump-back instruction is added to the end of the differential logic block, and a differential logic patch is generated based on the differential logic block and the jump-back instruction. The differential logic patch is used to be downloaded while the programmable controller is executing the original logic, and the jump-back instruction is used to control the programmable controller to switch from the differential logic block to the original logic.

5. The logic switching method for a programmable controller as described in claim 4, characterized in that, The step of determining the corresponding differential logic block based on the original logic and the updated logic includes: By comparing the original logic with the updated logic, the differences are obtained; The differences are compiled to obtain differential logic blocks.

6. The logic switching method for a programmable controller as described in claim 4, characterized in that, The logic switching method of the programmable controller further includes: Compare the original data segment and the modified data segment to determine the newly added data segment; Generate corresponding differential data patches based on the newly added data segments.

7. The logic switching method for a programmable controller as described in claim 4, characterized in that, The step of generating a differential logic patch based on the differential logic block and the jumpback instruction includes: If the differential logic block is a new logic block added by the update logic relative to the original logic, then obtain the adjacent logic block in the original logic that is located before the new logic block; The corresponding differential logic patch is generated based on the adjacent logic block, the newly added logic block, and the jumpback instruction.

8. The logic switching method for a programmable controller as described in claim 7, characterized in that, When the differential logic block is a newly added logic block of the updated logic relative to the original logic, the jump instruction is used to control the programmable logic controller to switch from the previous logic block in the original logic to the adjacent logic block in the differential logic patch, wherein the previous logic block is the logic block in the original logic that is located before and adjacent to the adjacent logic block.

9. An electronic device, characterized in that, The electronic device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the logic switching method of the programmable controller as claimed in any one of claims 1 to 3 or 4 to 8.

10. A readable storage medium, characterized in that, The readable storage medium is a computer-readable storage medium, on which a program implementing a logic switching method of a programmable controller is stored. The program implementing the logic switching method of a programmable controller is executed by a processor to implement the steps of the logic switching method of a programmable controller as described in any one of claims 1 to 3 or 4 to 8.