Programmable logic controller (PLC) and data recovery method, device and storage medium thereof
By restoring the data in the DW memory address to the MW memory address when the PLC is powered on and initialized, the problem of clearing PLC device information is solved, the device status is quickly restored, and the equipment maintenance efficiency is improved.
Patent Information
- Application Number
- CN202111486960.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-07
- Publication Date
- 2024-10-01
- Estimated Expiration
- 2041-12-07
AI Technical Summary
After the PLC is powered on again, the device information is cleared, which increases spare parts replacement and troubleshooting time, and reduces production efficiency.
Execute the data recovery program in the first scan cycle after PLC initialization, import the data in the DW memory address to the MW memory address to avoid zero calibration; starting from the Nth scan cycle, perform data saving in each scan cycle The program copies the data in the MW memory address to the DW memory address and saves the device information in real time.
It avoids the tedious and time-consuming steps of zero calibration, achieves rapid recovery of PLC equipment status, and significantly improves equipment maintenance efficiency and fault handling speed.
Smart Images

Figure CN114428477B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of industrial control technology, and in particular to a programmable logic controller (PLC) and a data recovery method, device and storage medium thereof. Background Art
[0002] Programmable Logic Controller (PLC) is widely used in industrial automatic control. PLC stores instructions for executing logical operations, sequential control, timing, counting and arithmetic operations, and controls various types of industrial equipment or production processes through digital or analog input and output. When the equipment is maintained and the spare parts of PLC-related modules are replaced, the PLC needs to be powered off. When powered on again, the PLC application will be initialized, and the important equipment information such as the device location and device status stored in the PLC memory address will be cleared. After clearing, each device controlled by the PLC needs to be re-calibrated to zero. Zero calibration is time-consuming and cumbersome, which seriously affects the time for spare parts replacement and troubleshooting. Summary of the invention
[0003] The present invention provides a programmable logic controller (PLC) and a data recovery method, device and storage medium thereof, so as to solve or partially solve the technical problem that after the PLC controller is powered on again, the device information is reset, resulting in an increase in PLC spare parts replacement and failure time, and a decrease in production efficiency.
[0004] To solve the above technical problem, according to an optional embodiment of the present invention, a data recovery method for a programmable logic controller (PLC) is provided, comprising:
[0005] In the first scanning cycle after the PLC is initialized, a data recovery program is executed;
[0006] Starting from the Nth scanning cycle after the PLC is initialized, a data saving program is executed in each scanning cycle, where N is ≥ 2 and is an integer;
[0007] Among them, the data recovery program is used to: import the data written in the DW address of the target device into the clearing program corresponding to the MW address written in the target memory; the data saving program is used to: copy the data written in the MW address of the target device to the DW address written in the target memory.
[0008] Optionally, the value of N is 3.
[0009] Optionally, in the first scanning cycle after the PLC is initialized, executing a data recovery program includes:
[0010] In the first scanning cycle, a pulse signal is generated;
[0011] The data recovery procedure is executed according to the pulse signal.
[0012] Optionally, the PLC memory stores M processing programs, where M ≥ 1 and is an integer;
[0013] In each scanning cycle, the data saving procedure is executed, including:
[0014] After executing the M processing programs, the data saving program is executed.
[0015] According to another optional embodiment of the present invention, there is provided a data recovery device for a programmable logic controller (PLC), comprising:
[0016] A data recovery module, used to execute a data recovery program in the first scanning cycle after the PLC is initialized;
[0017] A data saving module, used to execute a data saving program in each scanning cycle starting from the Nth scanning cycle after the PLC is initialized, where N is greater than or equal to 2 and is an integer;
[0018] Among them, the data recovery program is used to: import the data written in the DW address of the target device into the clearing program corresponding to the MW address written in the target memory; the data saving program is used to: copy the data written in the MW address of the target device to the DW address written in the target memory.
[0019] Optionally, the value of N is 3.
[0020] Optionally, the data recovery module is used to:
[0021] In the first scanning cycle, a pulse signal is generated;
[0022] The data recovery procedure is executed according to the pulse signal.
[0023] Optionally, the PLC memory stores M processing programs, where M ≥ 1 and is an integer;
[0024] The data saving module is used to execute the data saving program after executing the M processing programs.
[0025] According to another optional embodiment of the present invention, a programmable logic controller (PLC) is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the data recovery method described in any one of the aforementioned technical solutions when executing the computer program.
[0026] According to another optional embodiment of the present invention, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the data recovery method described in any one of the aforementioned technical solutions is implemented.
[0027] Through one or more technical solutions of the present invention, the present invention has the following beneficial effects or advantages:
[0028] The invention provides a data recovery method for a programmable logic controller (PLC). The method utilizes the principle that data in a DW memory address will not be cleared when the PLC is powered on and initialized. By performing data recovery in the first scanning cycle of the PLC power-on and initialization, key device information stored in the DW memory address before power-on is imported into a clearing program of a device corresponding to an MW address. In this way, the clearing program can directly recover the key device information of the PLC before power failure or restart in the MW memory address, and it is no longer necessary to re-calibrate the zero position of the device controlled by the PLC, thereby solving the problem that the zero position calibration is time-consuming and has complicated steps. Then, in each subsequent scanning cycle, the data in the MW memory address is continuously saved to the DW memory address, thereby saving or backing up the latest key device information in real time, so as to ensure that after the next PLC power failure or program restart, the key device information stored in the DW memory address can be restored to the MW memory address in the next round of PLC power-on and initialization. In general, by saving key equipment information before the PLC is powered off or the program is restarted, and then automatically restoring the previously saved data after the PLC is powered on and initialized, the tedious work of equipment zero position calibration after initialization is avoided, the equipment status can be quickly restored, and the equipment maintenance efficiency is significantly improved.
[0029] The above description is only an overview of the technical solution of the present invention. In order to more clearly understand the technical means of the present invention, it can be implemented according to the contents of the specification. In order to make the above and other purposes, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] Various other advantages and benefits will become apparent to those of ordinary skill in the art by reading the detailed description of the preferred embodiments below. The accompanying drawings are only for the purpose of illustrating the preferred embodiments and are not to be considered as limiting the present invention. Moreover, the same reference symbols are used throughout the accompanying drawings to represent the same components. In the accompanying drawings:
[0031] Figure 1 A schematic diagram of a PLC data recovery method flow chart according to an embodiment of the present invention is shown;
[0032] Figure 2A logical timing diagram of a PLC built-in program according to an embodiment of the present invention is shown;
[0033] Figure 3 A detailed logic diagram of a PLC main program according to an embodiment of the present invention is shown;
[0034] Figure 4 A schematic diagram of a control flow of PLC executing data recovery and data preservation according to an embodiment of the present invention is shown;
[0035] Figure 5 A logical diagram of a data recovery program according to an embodiment of the present invention is shown;
[0036] Figure 6 A logical diagram of a data storage program according to an embodiment of the present invention is shown;
[0037] Figure 7 A schematic diagram of a PLC data recovery device according to another embodiment of the present invention is shown;
[0038] Figure 8 A schematic diagram of an electronic device according to an embodiment of the present invention is shown;
[0039] Fig. 9 A schematic diagram of a computer-readable storage medium according to another embodiment of the present invention is shown. DETAILED DESCRIPTION
[0040] In order to make the technical personnel in the technical field to which the present application belongs more clearly understand the present application, the technical solution of the present application is described in detail by specific embodiments in conjunction with the accompanying drawings. Throughout the specification, unless otherwise specified, the terms used herein should be understood as the meanings commonly used in the art. Therefore, unless otherwise defined, all technical and scientific terms used herein have the same meanings as the general understanding of the technical personnel in the field to which the present invention belongs. If there is a contradiction, this specification takes precedence. Unless otherwise specified, the various equipment used in the present invention, etc., can be purchased from the market or can be prepared by existing methods.
[0041] Research shows that the memory addresses of PLC are divided into DW (Device Write) memory addresses and MW (Memory Write) memory addresses. The MW address will be cleared when the PLC application is initialized, while the DW address will not be cleared when the PLC application is initialized. Based on this, in order to solve the technical problem that when the PLC is powered on and initialized again, the important device information is cleared to affect the efficiency of spare parts replacement and fault handling, the present invention proposes a data recovery method for a programmable logic controller PLC, and its overall idea is as follows:
[0042] In the first scanning cycle after the PLC is initialized, a data recovery program is executed; starting from the Nth scanning cycle after the PLC is initialized, a data preservation program is executed in each scanning cycle, where N≥2 and is an integer; wherein the data recovery program is used to: import the data written in the DW address of the target device into the clearing program corresponding to the MW address written in the target memory; the data preservation program is used to: copy the data written in the MW address of the target device to the DW address written in the target memory.
[0043] In general, the above method utilizes the principle that the data in the DW memory address will not be cleared when the PLC is powered on and initialized. By performing data recovery in the first scanning cycle of the PLC power-on initialization, the key device information stored in the DW memory address before power-on is imported into the zeroing program of the device corresponding to the MW memory address. In this way, the zeroing program can directly restore the key device information before the PLC power is off or restarted in the MW memory address, and there is no need to re-calibrate the zero position of the device controlled by the PLC, thereby solving the problem of time-consuming and cumbersome steps of zero position calibration; then in each subsequent scanning cycle, the data in the MW memory address is continuously saved to the DW memory address, so as to save or back up the latest key device information in real time, so as to ensure that after the next PLC power failure or program restart, the key device information stored in the DW memory address can be restored to the MW memory address in the next round of PLC power-on initialization. In general, by saving key equipment information before the PLC is powered off or the program is restarted, and then automatically restoring the previously saved data after the PLC is powered on and initialized, the tedious work of equipment zero position calibration after initialization is avoided, the equipment status can be quickly restored, and the equipment maintenance efficiency is significantly improved.
[0044] In the following content, the above solution is further explained in combination with specific implementation methods:
[0045] In an optional embodiment, if Figure 1 As shown, the PLC data recovery method provided includes:
[0046] S1: In the first scanning cycle after the PLC is initialized, a data recovery program is executed.
[0047] Specifically, the working process of PLC is a cyclic scanning process. When PLC is in RUN working mode, the time required to perform a scanning operation is a scanning cycle. The scanning cycle is related to the length of the user program, the type of instruction and the speed at which the CPU executes instructions.
[0048] Specifically, after the PLC is restarted, the system is initialized and the data recovery program is executed. When the data recovery program is executed, the corresponding data saved in the DW memory address before power failure or restart is imported into the device reset program corresponding to the MW memory address. At the same time, the initialization reset program is executed to restore the data before power failure or restart to the MW address. Optionally, the data here includes the device zero position information and device status information of the device object controlled by the PLC.
[0049] Since the data recovery program is executed only once, it is completed in the first scanning cycle of the PLC to avoid erroneous clearing of data. Therefore, the execution signal of the data recovery program must be a pulse signal generated by the processor, and the data recovery program is called after the pulse signal comes. Therefore, optionally, the data recovery program is executed in the first scanning cycle after the PLC is initialized, including: generating a pulse signal in the first scanning cycle; and executing the data recovery program according to the pulse signal.
[0050] S2: Starting from the Nth scanning cycle after the PLC is initialized, a data saving program is executed in each scanning cycle, where N≥2 and is an integer.
[0051] After the first scan cycle, starting from the Nth scan cycle, the data saving program requires real-time execution. In each scan cycle, the data in the corresponding MW memory address will be stored in the DW memory address. Real-time storage ensures the accuracy and real-time nature of the data saved in the DW memory address, and prevents the system from not saving the latest data due to a sudden power outage.
[0052] Since the PLC program is executed from front to back, the execution order of the data saving program should be placed at the end of all programs, and the execution order of the data recovery program should be placed before the data saving program. Therefore, optionally, the PLC memory stores M processing programs, M≥1 and is an integer; in the first scanning cycle, after executing the M processing programs, the data recovery program is executed; in each scanning cycle starting from the Nth scanning cycle, after executing the M processing programs, the data saving program is executed.
[0053] Optionally, N can be 3, 4, or 5, preferably 3, indicating that the data saving procedure is executed from the third scanning cycle. The reason why the data saving procedure is executed at least one scanning cycle after the first scanning cycle is to avoid saving before the data is fully recovered and saving incorrect data.
[0054] Next, we will take N=3 as an example. The PLC memory stores multiple execution programs. The control logic timing diagram is as follows: Figure 2Among them, CALL DATA LOAD is the data recovery program, and CALL DATA SAVE is the data recovery program. Figure 2 The black block in the figure indicates that the signal state is 1, and no fill indicates that the signal state is 0. Since the program is executed from left to right and from top to bottom in PLC, Figure 2 , the detailed logic diagram of PLC when executing the program is as follows Figure 3 shown.
[0055] Only for data recovery program (DATA LOAD) and data saving program (DATA SAVE), combined Figure 2 , and its execution process is:
[0056] The first scanning cycle: execute the DATA LOAD program;
[0057] The second scanning cycle: a blank scanning cycle is not executed;
[0058] The third scanning cycle: execute the DATA SAVE program;
[0059] From the 4th scan cycle onwards: the DATA SAVE program is always executed.
[0060] The process diagram of PLC executing data recovery program and data saving program is as follows Figure 4 shown.
[0061] For the DATA LOAD program, the data recovery logic is as follows: Figure 5 shown.
[0062] For the DATA SAVE program, its data saving logic is as follows Figure 6 shown.
[0063] In general, the PLC data recovery method provided in this embodiment has the following advantages:
[0064] (1) Automatic data saving and recovery can avoid the loss of important data in the MW address in the program (such as device zero position, etc.), and avoid data omissions and errors caused by manual data saving.
[0065] (2) Starting from the Nth scanning cycle, all data that needs to be saved are automatically saved in real time in each scanning cycle, thereby ensuring the real-time nature of the data and preventing the situation in which the data is not stored in time due to sudden power failure of the equipment;
[0066] (3) Automatically restore data within the first scan cycle of PLC restart or power-on initialization to reduce errors caused by manual backup and recovery of data, thereby significantly reducing troubleshooting and module replacement time.
[0067] The data recovery method provided in this embodiment is applicable to PLC products provided by major PLC suppliers, and is particularly applicable to Hitachi's PLC system.
[0068] Based on the same inventive concept as the above embodiment, in another optional embodiment, as Figure 7 As shown, a data recovery device for a programmable logic controller (PLC) is provided, comprising:
[0069] The data recovery module 701 is used to execute a data recovery program in the first scanning cycle after the PLC is initialized;
[0070] The data saving module 702 is used to execute a data saving program in each scanning cycle starting from the Nth scanning cycle after the PLC is initialized, where N is greater than or equal to 2 and is an integer;
[0071] Among them, the data recovery program is used to: import the data written in the DW address of the target device into the clearing program corresponding to the MW address written in the target memory; the data saving program is used to: copy the data written in the MW address of the target device to the DW address written in the target memory.
[0072] Optionally, the data recovery module 701 is used to:
[0073] In the first scanning cycle, a pulse signal is generated;
[0074] The data recovery procedure is executed according to the pulse signal.
[0075] Optionally, M processing programs are stored in the memory of the PLC; the data saving module 702 is used to execute the data saving program after executing the M processing programs.
[0076] Based on the same inventive concept as the above embodiment, in another optional embodiment, as Figure 8 As shown, a programmable logic controller PLC800 is provided, including a memory 810, a processor 820, and a computer program 811 stored in the memory 810 and executable on the processor 820, and when the processor 820 executes the computer program 811, the steps of the data recovery method as described in any one of the aforementioned technical solutions are implemented.
[0077] Based on the same inventive concept as the above embodiment, in another optional embodiment, as Fig. 9 As shown, a computer-readable storage medium 900 is provided, on which a computer program 911 is stored. When the computer program 911 is executed by a processor, the data recovery method described in any one of the aforementioned embodiments is implemented.
[0078] Through one or more embodiments of the present invention, the present invention has the following beneficial effects or advantages:
[0079] The present invention provides a programmable logic controller (PLC) and a data recovery method, device and storage medium thereof. The principle that data in a DW memory address will not be cleared when the PLC is powered on and initialized is utilized. Data recovery is performed in the first scanning cycle of the PLC power-on and initialization, and key device information stored in the DW memory address before power-on is imported into a clearing program of a device corresponding to an MW address. In this way, the clearing program can directly restore the key device information of the PLC before power failure or restart in the MW memory address, and it is no longer necessary to re-calibrate the zero position of the device controlled by the PLC, thereby solving the problem that the zero position calibration is time-consuming and has complicated steps. Then, in each subsequent scanning cycle, the data in the MW memory address is continuously saved to the DW memory address, so as to save or back up the latest key device information in real time, so as to ensure that after the next PLC power failure or program restart, the key device information stored in the DW memory address can be restored to the MW memory address in the next round of PLC power-on and initialization. In general, by saving key equipment information before the PLC is powered off or the program is restarted, and then automatically restoring the previously saved data after the PLC is powered on and initialized, the tedious work of equipment zero position calibration after initialization is avoided, the equipment status can be quickly restored, and the equipment maintenance efficiency is significantly improved.
[0080] Although the preferred embodiments of the present application have been described, those skilled in the art may make additional changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present application.
[0081] Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.
Claims
1. A data recovery method for a programmable logic controller (PLC), characterized in that: The method is used to recover the device zero position information and device status information of the target device controlled by the PLC; the data recovery method comprises: The PLC memory stores M processing programs, where M≥1 and is an integer; In each scanning cycle before the data of the PLC is restored, a data saving procedure is executed, including: After executing the M processing programs, executing the data saving program; The data saving program is used to store the device zero position information and device status information of the target device to its DW memory address before the PLC is powered on for the next round; In the first scanning cycle of the next round of power-on initialization of the PLC, a data recovery program is executed, including: In the first scanning cycle, a pulse signal is generated; Executing the data recovery program according to the pulse signal; Starting from the Nth scanning cycle after the PLC is initialized, a data saving program is executed in each scanning cycle, where N is ≥ 2 and is an integer; Among them, the data recovery program is used to: import the data written in the DW address of the target device into the clearing program corresponding to the MW address written in the target memory; the data saving program is used to: copy the data written in the MW address of the target device to the DW address written in the target memory; so that the target device will not be repeatedly calibrated to zero position during the next round of power-on initialization, and can be directly restored to the device state before power-off.
2. The data recovery method according to claim 1, characterized in that: The value of N is 3.
3. A data recovery device for a programmable logic controller (PLC), characterized in that: The device is a device corresponding to the data recovery method according to any one of claims 1 to 2, and the data recovery device includes: A data recovery module, used to execute a data recovery program in the first scanning cycle after the PLC is initialized; A data saving module, used to execute a data saving program in each scanning cycle starting from the Nth scanning cycle after the PLC is initialized, where N is greater than or equal to 2 and is an integer; Among them, the data recovery program is used to: import the data written in the DW address of the target device into the clearing program corresponding to the MW address written in the target memory; the data saving program is used to: copy the data written in the MW address of the target device to the DW address written in the target memory.
4. The data recovery device according to claim 3, characterized in that: The value of N is 3.
5. A programmable logic controller (PLC), comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the data recovery method according to any one of claims 1 to 2 are implemented.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the data recovery method according to any one of claims 1 to 2 is implemented.
