Periodic synchronization method and device and periodic task execution method
By monitoring and compensating the waiting time of the backup PLC in the soft redundant PLC system, the problem of staggered main and backup PLC cycles is solved, the stability and security of the system are improved, and the continuous operation of the system is ensured.
Patent Information
- Application Number
- CN202411282920.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-13
- Publication Date
- 2025-01-10
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
In soft redundant PLC systems, due to problems such as network transmission delay and system clock drift, the main PLC and the backup PLC may have periodic staggering, resulting in system instability or even failure.
By monitoring the waiting time of the backup PLC, when the waiting time exceeds the preset value, calculate the compensation value and update the current cycle time to ensure high-precision synchronization between the main PLC and the backup PLC.
It effectively avoids the problem of periodic out-of-synchronization, improves the stability and security of the system, and ensures seamless connection of the main and backup PLCs and continuous operation of the system.
Smart Images

Figure CN119292031A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of industrial automation control technology, and in particular to a periodic synchronization method and device, and a periodic task execution method. Background Art
[0002] Programmable Logic Controller (PLC) is widely used in the field of industrial automation control to realize complex logic control, data acquisition and processing, equipment monitoring and other functions. In order to improve the reliability and stability of the PLC system, the PLC system usually adopts a redundant design. In a redundant PLC system, the main PLC and the backup PLC operate independently, and data synchronization is generally performed through interfaces such as Ethernet. When the main PLC fails, the backup PLC can seamlessly take over the system tasks, thereby ensuring the continuous operation of the system.
[0003] In a redundant PLC system, hard redundancy or soft redundancy can generally be used. Hard redundancy is usually achieved through hardware devices, such as redundant power supplies, redundant processors, and redundant network interfaces. Soft redundancy, on the other hand, uses software to achieve redundant control of the primary and standby PLCs, and then uses the communication network to synchronize the data of the two. Generally, soft redundancy does not require additional hardware devices, which can reduce system costs, and soft redundancy can flexibly configure redundancy solutions according to specific needs, which is convenient for system expansion and upgrading, making the system more flexible. However, the synchronization accuracy and precision of soft redundancy largely depends on the programming level and algorithm design.
[0004] When the software redundant system is running for a long time, due to problems such as network transmission delay and system clock drift, the main PLC and the backup PLC are very likely to have cycle misalignment as the running time accumulates. If the cycle synchronization error is too large, it may cause system instability or even failure. Summary of the invention
[0005] In view of the above problems in the prior art, the present application provides a periodic synchronization method and device, as well as a periodic task execution method, which can achieve high-precision synchronization of the periods of the main PLC and the backup PLC by dynamically adjusting the periods of the two, thereby improving the stability and reliability of the system.
[0006] To achieve the above-mentioned purpose, the first aspect of the present application provides a cycle synchronization method, which is applied to a soft redundant PLC system, wherein the system includes a main PLC and a standby PLC, and the method includes: obtaining a first waiting time of the standby PLC; the first waiting time is used to represent the time elapsed from a first moment to a second moment, the first moment being the moment when the standby PLC enters preparation to execute a task corresponding to the current cycle, and the second moment is the moment when the standby PLC receives a first instruction sent by the main PLC to start executing a task corresponding to the current cycle; when the first waiting time reaches a preset maximum waiting time, determining a compensation value for the current cycle time according to the first waiting time; determining an actual value of the current cycle time according to the compensation value, and controlling the current cycle time of the standby PLC to be the actual value.
[0007] From the above, this aspect monitors the waiting time of the backup PLC before each periodic task starts to execute, and compensates for the waiting time when the waiting time exceeds a preset value, thereby avoiding the problem of period asynchrony between the main PLC and the backup PLC caused by network transmission delays or internal clock drift of the system, thereby improving the stability and security of the system.
[0008] As an implementation method of this aspect, determining the actual value of the current cycle length based on the compensation value includes: summing the reference value of the current cycle length and the compensation value of the current cycle length to obtain the actual value of the current cycle length; wherein the reference value of the current cycle length is the cycle length value pre-set in the initialization phase.
[0009] From the above, when the waiting time exceeds the preset value, the period reference time is updated by the compensation value, thereby achieving high-precision synchronization between the main PLC and the standby PLC.
[0010] As an implementation manner of this aspect, determining the compensation value of the current cycle duration according to the first waiting duration includes: using the first waiting duration as the compensation value of the current cycle duration.
[0011] From the above, when the waiting time exceeds the preset value, the actual waiting time (i.e., the first waiting time) is used as the cycle time compensation value, which can eliminate the transmission delay caused by network problems, thereby keeping the main PLC and the standby PLC synchronized in cycle.
[0012] As an implementation method of this aspect, it also includes: restoring the cycle duration of the next cycle to a reference value of the cycle duration, where the reference value of the cycle duration is a cycle duration value pre-set in an initialization phase.
[0013] From the above, the cycle synchronization of the present application is executed separately for each cycle. Therefore, after executing the current cycle, the duration of the next cycle must first be restored to the baseline value, and then the relationship between the actual waiting time in the corresponding cycle and the maximum waiting time allowed for the corresponding cycle is judged to determine the actual value of the cycle duration.
[0014] As an implementation method of this aspect, it also includes: determining the time corresponding to the standby PLC entering the next cycle to prepare for executing the periodic task according to the actual value of the current cycle duration and the first moment of the current cycle.
[0015] From the above, the preparation time for the standby PLC to enter the next cycle can be accurately calculated.
[0016] The second aspect of the present application provides a periodic task execution method, which is applied to a soft redundant PLC system, the system including a main PLC and a standby PLC, and the method including: when the first waiting time of the standby PLC reaches a preset maximum waiting time: updating the actual value of the current cycle time of the standby PLC through the cycle synchronization method described in any one of the first aspects above, and executing the task corresponding to the current cycle after updating the cycle time; when the first waiting time of the standby PLC does not reach the preset maximum waiting time: when the standby PLC receives a first instruction sent by the main PLC, it feeds back a first signal to the main PLC and starts to execute the task corresponding to the current cycle; wherein, the first instruction is used to indicate that the task corresponding to the current cycle starts to be executed; the first signal is used to notify the main PLC that it has received the first instruction.
[0017] As an implementation method of this aspect, it also includes: the backup PLC receives the second instruction sent by the main PLC and feeds back a second signal to the main PLC; wherein the second instruction is used to indicate that the corresponding task of the current cycle has been executed; and the second signal is used to notify the PLC that it has received the second instruction.
[0018] The beneficial effects of this aspect can also be found in the description of the beneficial effects of each part of the first aspect above.
[0019] The third aspect of the present application provides a cycle synchronization device, which is applied to a soft redundant PLC system, the system includes a main PLC and a standby PLC, and the device includes: an acquisition module, used to acquire a first waiting time of the standby PLC; the first waiting time is used to represent the time elapsed from a first moment to a second moment, the first moment is the moment when the standby PLC enters the preparation to execute the task corresponding to the current cycle, and the second moment is the moment when the standby PLC receives the first instruction sent by the main PLC to start executing the task corresponding to the current cycle; a first determination module, used to determine the compensation value of the current cycle duration according to the first waiting time when the first waiting time reaches a preset maximum waiting time; a second determination module, used to determine the actual value of the current cycle duration according to the compensation value, and control the current cycle duration of the standby PLC to be the actual value.
[0020] The beneficial effects of this aspect can also be found in the description of the beneficial effects of each part of the first aspect above.
[0021] The fourth aspect of the present application provides a computing device, comprising: at least one processor; and at least one memory, which is connected to the processor and stores program instructions, and when the program instructions are executed by the at least one processor, the at least one processor executes the periodic synchronization method described in any one of the first aspect above, or executes the periodic task execution method described in any one of the second aspect above.
[0022] The beneficial effects of this aspect can also be found in the description of the beneficial effects of each part of the first aspect above.
[0023] The fifth aspect of the present application provides a computer-readable storage medium having program instructions stored thereon. When the program instructions are executed by a computer, the computer performs the periodic synchronization method described in any one of the first aspects above, or performs the periodic task execution method described in any one of the second aspects above.
[0024] The beneficial effects of this aspect can also be found in the description of the beneficial effects of each part of the first aspect above. BRIEF DESCRIPTION OF THE DRAWINGS
[0025] The various technical features of the present application and the relationship between them are further explained below with reference to the accompanying drawings. The accompanying drawings are exemplary, and some technical features are not shown in actual proportion. In addition, some drawings may omit technical features that are commonly used in the technical field to which the present application belongs and are not essential for understanding and implementing the present application, or additional technical features that are not essential for understanding and implementing the present application may be shown. In other words, the combination of the various technical features shown in the accompanying drawings is not used to limit the present application. In addition, throughout the present application, the same figure numbers refer to the same content. The specific description of the drawings is as follows:
[0026] Figure 1 A flowchart of a periodic synchronization method provided in an embodiment of the present application;
[0027] Figure 2 A schematic diagram of a PLC cycle synchronization mechanism provided in an embodiment of the present application;
[0028] Figure 3 A schematic diagram of the interaction between the main PLC and the standby PLC under the periodic synchronization mechanism provided in an embodiment of the present application;
[0029] Figure 4 A flow chart of periodic error correction provided in an embodiment of the present application;
[0030] Figure 5 A schematic diagram of periodic error correction under an example provided in an embodiment of the present application;
[0031] Figure 6 A schematic diagram of the structure of a periodic synchronization device provided in an embodiment of the present application;
[0032] Figure 7 A structural schematic diagram of a computing device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The technical solution provided by the present application is further described below with reference to the accompanying drawings and examples. It should be understood that the system structure and business scenarios provided in the examples of the present application are mainly to illustrate the possible implementation methods of the technical solution of the present application and should not be interpreted as the only limitation on the technical solution of the present application. It is known to those of ordinary skill in the art that with the evolution of the system structure and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems.
[0034] It should be understood that the embodiments of the present application provide a periodic synchronization solution and a periodic task execution solution. Since the principles of solving the problems in these technical solutions are the same or similar, some repetitions may not be repeated in the following specific embodiments, but it should be regarded as that these specific embodiments have been referenced to each other and can be combined with each other.
[0035] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art of the present application. In case of any inconsistency, the meaning described in this specification or the meaning derived from the contents recorded in this specification shall prevail. In addition, the terms used herein are only for the purpose of describing the embodiments of the present application and are not intended to limit the present application.
[0036] First, the application scenarios of the periodic synchronization solution provided in the embodiments of the present application are introduced.
[0037] The cycle synchronization scheme provided by the present application can keep the cycles of the main PLC and the backup PLC synchronized with high precision in the soft redundant PLC system, so it is particularly suitable for use in scenarios with high requirements for system stability. For example, the scheme can be applied to industrial automation control. The cycle synchronization method of the present application can keep the cycles of the main PLC and the backup PLC synchronized, thereby ensuring the effectiveness efficiency and product quality. For another example, the scheme can also be applied to the field of intelligent transportation, such as the control of traffic lights, the control of the operation of subways and other trains, etc., thereby ensuring the orderly operation and safety of transportation. For another example, the scheme can also be applied to the medical field, such as life support systems (such as ventilators, electrocardiogram monitors, etc.), surgical robot systems, etc. The cycle synchronization technology provided by the present application can ensure the accuracy and stability of the above-mentioned systems during operation, thereby ensuring the safety of patients.
[0038] It should be understood that the above application scenarios are exemplary descriptions and are not intended to limit the scope of this application.
[0039] Referring to the accompanying drawings below, a cycle synchronization method provided by an embodiment of the present application is described in detail. In this embodiment, the cycle synchronization method is applied to a soft redundant PLC system, which includes a main PLC and a standby PLC, wherein the main PLC is the subject used to perform system tasks during the normal operation of the system, and the standby PLC is the subject used to replace the main PLC to perform system tasks when the main PLC fails. Therefore, it is necessary to ensure that the working cycles of the main PLC and the standby PLC are consistent during operation, so as to facilitate the seamless takeover of the standby PLC, and will not cause control interruptions or errors due to differences in working cycles.
[0040] like Figure 1 As shown, the cycle synchronization method includes steps S110-S130:
[0041] S110: Obtain the first waiting time of the standby PLC.
[0042] like Figure 2 As shown, before this step, a step of setting a first synchronization point CycleStart before each cycle task of the main PLC and the standby PLC is executed, and setting a second synchronization point CycleEnd after each cycle task is executed may be included. The first synchronization point CycleStart is used to ensure that the main PLC and the standby PLC enter the execution logic of the current cycle task at the same time, and the second synchronization point CycleEnd is used to ensure that the main PLC and the standby PLC exit the execution logic of the current cycle task at the same time.
[0043] In this embodiment, the first waiting time of the standby PLC is monitored at the first synchronization point CycleStart of the standby PLC, so as to obtain the first waiting time. The first waiting time represents the time elapsed from the first moment when the standby PLC enters the preparation to execute the task corresponding to the current cycle (i.e., the standby PLC completes the task of the previous cycle) to the second moment when the standby PLC receives the first instruction sent by the main PLC to start executing the task corresponding to the current cycle (i.e., the instruction sent by the main PLC to enter the current cycle).
[0044] Next, with the help of Figure 3 The first waiting time is explained in detail. Since the main PLC is the PLC when the system is operating normally, the main PLC controls the start time of the periodic task, that is, Figure 3 As shown, after the standby PLC enters the state of preparing to execute the current cycle task, it waits for the main PLC to send the first instruction. After the standby PLC receives the first instruction, it feeds back the first signal to the main PLC to inform the main PLC that it has received the first instruction and starts to execute the current cycle-related tasks. After receiving the first signal sent by the standby PLC, the main PLC can know that the standby PLC is ready, and then the main PLC also starts to execute the current cycle-related tasks, thereby ensuring that the main PLC and the slave PLC can execute the current cycle tasks at the same time. However, due to network delays or system internal clock drift and other problems, the main PLC may be delayed or missed when sending the first instruction to the standby PLC. In order to cope with this situation, this embodiment monitors and obtains the first waiting time of the standby PLC at the first synchronization point CycleStart (i.e., entering the waiting state of the current cycle and before receiving the first instruction).
[0045] S120: When the first waiting time reaches the preset maximum waiting time, a compensation value of the current cycle time is determined according to the first waiting time.
[0046] As an implementation manner, this embodiment may directly use the first waiting time as the compensation value of the current cycle time.
[0047] S130: Determine the actual value of the current cycle duration according to the compensation value, and control the current cycle duration of the standby PLC to be the actual value.
[0048] In this embodiment, the duration value of the current cycle can be obtained by summing a preset reference value of the duration of the current cycle and a compensation value of the duration of the current cycle, thereby updating the duration of the current cycle.
[0049] It should be understood that Figure 3As shown, after the execution of the periodic task is completed, the main PLC sends a second instruction to the standby PLC to end the current periodic task. After receiving the second instruction, the standby PLC ends the task of the current cycle and feeds back a second signal to the main PLC to inform the main PLC that it has received the second instruction. At this time, the main PLC exits the current cycle, so that the main PLC and the standby PLC exit the periodic task at the same time.
[0050] In this embodiment, when the task of the current cycle is completed, that is, when entering the next cycle, the cycle length of the next cycle is restored to the reference value of the original cycle.
[0051] Based on the cycle synchronization method provided in this embodiment, the cycles of the main PLC and the standby PLC in the soft redundant PLC system can be unaffected by network delays or system clock drift, thereby ensuring high-precision synchronization of the cycles.
[0052] Another embodiment of the present application provides a periodic synchronization method, which includes two parts: a periodic synchronization mechanism and an error correction mechanism.
[0053] First, the periodic synchronization mechanism provided by this embodiment is introduced.
[0054] like Figure 2 As shown, in order to synchronize the execution of the periodic tasks of the main PLC and the backup PLC, this embodiment sets a first synchronization point CycleStart before the execution of the periodic task logic of each PLC, and sets a second synchronization point CycleEnd after the execution of the periodic task logic of each PLC. The first synchronization point CycleStart is used to enable the main PLC and the backup PLC to simultaneously enter the execution logic of the current periodic task, and the second synchronization point CycleEnd is used to enable the main PLC and the backup PLC to simultaneously exit the execution logic of the current periodic task.
[0055] like Figure 3 As shown, before each periodic task is executed, the standby PLC needs to wait for the main PLC to send a first instruction to indicate the start of the current periodic task. After the standby PLC receives the first instruction, the standby PLC starts to execute the current periodic task and feeds back a first signal to the main PLC to notify the main PLC that it has received the first instruction. After the main PLC receives the first signal, the main PLC starts to execute the current periodic task. The above settings can achieve synchronization of the start time of the main PLC and standby PLC periodic tasks.
[0056] Also, please see Figure 3After each periodic task is executed, the internal PLC waits for the main PLC to send a second instruction to indicate the end of the execution of the current periodic task. After the standby PLC receives the second instruction, the standby PLC ends the execution of the current periodic task and feeds back a second signal to the main PLC to notify the main PLC that it has received the second instruction. After the main PLC receives the second signal, the main PLC ends the execution of the current periodic task. The above settings can achieve synchronization of the end time points of the periodic tasks of the main PLC and the standby PLC.
[0057] The above scheme realizes the synchronization of the main PLC and standby PLC cycles.
[0058] Next, the error correction method provided by this embodiment is introduced.
[0059] As the main PLC and the backup PLC run for a long time, due to network transmission delays or system clock drift, the backup PLC may time out while waiting for the main PLC to send the first instruction before starting to execute a task in a certain cycle (since the main PLC needs to wait for the backup PLC to send the second signal at the end of the task, the only possibility is that the backup PLC enters the waiting stage of the next cycle before the main PLC). In this case, the present application considers compensating the cycle of the backup PLC through an error correction method.
[0060] In this embodiment, if Figure 4 As shown, the error correction method includes steps S210-S240, specifically:
[0061] S210: Initialize the parameters of the PLC task cycle duration, the base value BaseInterval and the maximum waiting time MaxWaitTime.
[0062] As an implementation method, in a task, the base value BaseInterval of each cycle duration is the same, and the maximum waiting duration MaxWaitTime is also the same.
[0063] As another implementation manner, different reference values BaseInterval for different cycle durations may be preset according to task requirements, and different maximum waiting durations MaxWaitTime allowed for different cycles may also be set.
[0064] S220: When the actual waiting time of the standby PLC reaches the maximum waiting time, clock compensation is performed to obtain a compensation value.
[0065] In this step, before each PLC cycle starts, the waiting time of the standby PLC is monitored at the first synchronization point to see if it reaches the maximum waiting time corresponding to the current cycle in the initialization phase. When the waiting time reaches the maximum waiting time, clock compensation is required for the current cycle standby PLC.
[0066] Specifically: compensation value CompensationValue = actual waiting time WaitTime.
[0067] S230: updating the actual duration of the current cycle according to the compensation value, and setting the duration of the current cycle as the actual duration.
[0068] Specifically: Update the actual duration of the current cycle NewInterval = the base value of the current cycle duration BaseInterval + compensation value CompensationValue
[0069] S240: The duration of restoring the PLC periodic task in the next cycle is a reference value BaseInterval of the duration in the corresponding cycle.
[0070] From the above, the error correction of the standby PLC cycle is completed.
[0071] See next Figure 5 An example is used to illustrate the error correction process.
[0072] In this example, it is assumed that the maximum waiting time MaxWaitTime of the current cycle initialized in step S210 is 10 ms, and the reference value BaseInterval of the duration of the PLC task of the current cycle is 100 ms.
[0073] In a certain cycle n, assuming that the time when the cycle starts to execute the task is CycleStartTime, due to the delay of network transmission, when the standby PLC is waiting for the first instruction, the first waiting time reaches 10ms, then the clock compensation mechanism of step S220 will be triggered.
[0074] At this time, the standby PLC obtains its actual waiting time WaitTime, which is assumed to be 11ms. It has exceeded the maximum waiting time of 10ms in this cycle. At this time, the compensation value CompensationValue=actual waiting time WaitTime=11ms needs to be calculated.
[0075] Next, the actual duration of the current cycle is calculated based on the compensation value = the reference value of the current cycle duration + the compensation value = 100ms + 11ms = 111ms, and the duration of the current cycle is set to the calculated actual duration, i.e. 111ms. Thus, the error correction of the current cycle is completed.
[0076] After completing the error correction of the current cycle, the standby PLC will also calculate the start time of the next cycle based on the actual cycle duration after compensation: the start time of the next cycle NextCycleSartTime = the start time of the current cycle CycleStartTime + the actual duration of the current cycle NewInterval. Through this calculation, the main PLC and the standby PLC can be restored to the previous synchronization stage in the next cycle.
[0077] Based on the periodic error correction mechanism provided by the above embodiment, it can be ensured that in the event of network delay or system internal clock drift, the main PLC and the standby PLC can still maintain synchronous execution of periodic tasks.
[0078] Another embodiment of the present application provides a periodic task execution method. Similarly, the method is applied to a soft redundant PLC system.
[0079] In this embodiment, when the waiting time of the standby PLC reaches the preset maximum waiting time, the cycle time is updated by the cycle synchronization or error correction method provided in the above embodiment, and the periodic task is executed after the update, which will not be described again here.
[0080] In this embodiment, when the waiting time of the standby PLC does not reach the maximum waiting time, the periodic synchronization mechanism (i.e. Figure 2 The interaction between the main PLC and the standby PLC shown in the figure) is used to achieve periodic synchronization and execute periodic tasks, which will not be described in detail here.
[0081] Another embodiment of the present application provides a cycle synchronization device 30. It should be understood that: Figure 6 This is only a schematic diagram of a structure of a cycle synchronization device 30, and the present application does not limit the division of functional modules in the cycle synchronization device. Figure 6 As shown, the apparatus 30 can be logically divided into multiple modules, each module can have different functions, and the functions of each module can be implemented by a processor in a computing device reading and executing instructions in a memory. Exemplarily, the apparatus 30 includes an acquisition module 310, a first determination module 320, and a second determination module 330. In one implementation, the cycle synchronization apparatus 30 is used to execute Figure 1 or Figure 4 The content shown.
[0082] Specifically: the acquisition module 310 is used to acquire the first waiting time of the backup PLC; the first waiting time is used to represent the time elapsed from the first moment to the second moment, the first moment is the moment when the backup PLC enters the preparation to execute the task corresponding to the current cycle, and the second moment is the moment when the backup PLC receives the first instruction sent by the main PLC to start executing the task corresponding to the current cycle. The first determination module 320 is used to determine the compensation value of the current cycle duration according to the first waiting time when the first waiting time reaches the preset maximum waiting time. The second determination module 330 is used to determine the actual value of the current cycle duration according to the compensation value, and control the current cycle duration of the backup PLC to be the actual value.
[0083] The specific implementation of each functional module in this embodiment can refer to the introduction of the above embodiments, and this embodiment will not describe it in detail.
[0084] Figure 7 900 is a schematic structural diagram of a computing device 900 provided in an embodiment of the present application. The computing device can execute the optional embodiments of the above-mentioned periodic synchronization method or periodic task execution method. The computing device can be a terminal or a chip or chip system inside the terminal. Figure 7 As shown, the computing device 900 includes: a processor 910 , a memory 920 , and a communication interface 930 .
[0085] It should be understood that Figure 7 The communication interface 930 in the computing device 900 shown may be used to communicate with other devices, and may specifically include one or more transceiver circuits or interface circuits.
[0086] The processor 910 may be connected to a memory 920. The memory 920 may be used to store the program code and data. Therefore, the memory 920 may be a storage unit inside the processor 910, or an external storage unit independent of the processor 910, or a component including a storage unit inside the processor 910 and an external storage unit independent of the processor 910.
[0087] Optionally, the computing device 900 may further include a bus. The memory 920 and the communication interface 930 may be connected to the processor 910 via the bus. The bus may be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus. The bus may be divided into an address bus, a data bus, a control bus, etc. For ease of representation, Figure 7A line without an arrow is used to represent the bus, but this does not mean that there is only one bus or one type of bus.
[0088] It should be understood that in the embodiment of the present application, the processor 910 may adopt a central processing unit (CPU). The processor may also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc. Alternatively, the processor 910 may adopt one or more integrated circuits to execute relevant programs to implement the technical solutions provided in the embodiment of the present application.
[0089] The memory 920 may include a read-only memory and a random access memory, and provides instructions and data to the processor 910. A portion of the processor 910 may also include a nonvolatile random access memory. For example, the processor 910 may also store information on the device type.
[0090] When the computing device 900 is running, the processor 910 executes the computer-executable instructions in the memory 920 to perform any operation step of the above method and any optional embodiment thereof.
[0091] It should be understood that the computing device 900 according to the embodiment of the present application can correspond to the corresponding subjects in the methods according to the embodiments of the present application, and the above-mentioned and other operations and / or functions of each module in the computing device 900 are respectively for implementing the corresponding processes of each method of the present embodiment. For the sake of brevity, they will not be repeated here.
[0092] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0093] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0094] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0095] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0096] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0097] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the methods described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0098] An embodiment of the present application also provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, it is used to execute the above method, which includes at least one of the solutions described in the above embodiments.
[0099] The computer storage medium of the embodiment of the present application can adopt any combination of one or more computer-readable media. Computer-readable media can be computer-readable signal media or computer-readable storage media. Computer-readable storage media can be, for example, but not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices or devices, or any combination of the above. More specific examples (non-exhaustive lists) of computer-readable storage media include: electrical connections with one or more wires, portable computer disks, hard disks, random access memories (RAM), read-only memories (ROM), erasable programmable read-only memories (EPROM or flash memory), optical fibers, portable compact disk read-only memories (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this document, computer-readable storage media can be any tangible medium containing or storing programs, which can be used by instruction execution systems, devices or devices or used in combination with them.
[0100] Computer-readable signal media may include data signals propagated in baseband or as part of a carrier wave, which carry computer-readable program code. Such propagated data signals may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. Computer-readable signal media may also be any computer-readable medium other than a computer-readable storage medium, which may send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device.
[0101] The program code embodied on the computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, RF, etc., or any suitable combination of the foregoing.
[0102] Computer program code for performing the operation of the present application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages, such as Java, Smalltalk, C++, and conventional procedural programming languages, such as "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 an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through 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., using an Internet service provider to connect through the Internet).
[0103] In addition, the words "first, second, third, etc." or module A, module B, module C and other similar terms in the specification and claims are only used to distinguish similar objects and do not represent a specific ordering of the objects. It can be understood that the specific order or sequence can be interchanged where permitted so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.
[0104] In the above description, the numbers representing the steps, such as S110, S120, etc., do not necessarily mean that the steps will be executed in this manner. If permitted, the order of the steps can be interchanged or they can be executed simultaneously.
[0105] The term "comprising" as used in the description and claims should not be interpreted as being limited to what is listed thereafter; it does not exclude other elements or steps. Therefore, it should be interpreted as specifying the presence of the features, integers, steps or components mentioned, but does not exclude the presence or addition of one or more other features, integers, steps or components and groups thereof. Therefore, the expression "a device comprising means A and B" should not be limited to a device consisting of components A and B only.
[0106] References to "one embodiment" or "an embodiment" in this specification mean that a particular feature, structure, or characteristic described in conjunction with the embodiment is included in at least one embodiment of the present application. Therefore, the phrases "in one embodiment" or "in an embodiment" appearing in various places in this specification do not necessarily refer to the same embodiment, but may refer to the same embodiment. In addition, in one or more embodiments, the particular features, structures, or characteristics can be combined in any appropriate manner, as would be apparent to one of ordinary skill in the art from this disclosure.
[0107] Note that the above are only preferred embodiments of the present application and the technical principles used. Those skilled in the art will understand that the present application is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present application. Therefore, although the present application is described in more detail through the above embodiments, the present application is not limited to the above embodiments, and may also include more other equivalent embodiments without departing from the concept of the present application, all of which belong to the scope of protection of the present application.
Claims
1. A periodic synchronization method, characterized in that: Applied in a soft redundant PLC system, the system includes a main PLC and a standby PLC, the method includes: Obtaining a first waiting time of the standby PLC; the first waiting time is used to represent the time elapsed from a first moment to a second moment, the first moment being the moment when the standby PLC enters preparation to execute a task corresponding to the current cycle, and the second moment being the moment when the standby PLC receives a first instruction sent by the main PLC to start executing a task corresponding to the current cycle; When the first waiting time reaches a preset maximum waiting time, determining a compensation value of the current cycle time according to the first waiting time; The actual value of the current cycle duration is determined according to the compensation value, and the current cycle duration of the standby PLC is controlled to be the actual value.
2. The method according to claim 1, characterized in that The determining the actual value of the current cycle duration according to the compensation value includes: The reference value of the current cycle duration and the compensation value of the current cycle duration are summed to obtain the actual value of the current cycle duration; wherein the reference value of the current cycle duration is the cycle duration value preset in the initialization phase.
3. The method according to claim 1, characterized in that The determining the compensation value of the current cycle duration according to the first waiting duration includes: The first waiting time is used as a compensation value for the current cycle time.
4. The method according to claim 1, characterized in that: Also includes: The cycle duration of the next cycle is restored to a reference value of the cycle duration, where the reference value of the cycle duration is a cycle duration value preset in an initialization phase.
5. The method according to claim 1, characterized in that Also includes: The time corresponding to when the standby PLC enters the next cycle and prepares to execute the periodic task is determined according to the actual value of the current cycle duration and the first time of the current cycle.
6. A periodic task execution method, characterized in that: Applied in a soft redundant PLC system, the system includes a main PLC and a standby PLC, the method includes: When the first waiting time of the standby PLC reaches the preset maximum waiting time: updating the actual value of the current cycle time of the standby PLC by the cycle synchronization method according to any one of claims 1 to 5, and executing the task corresponding to the current cycle after updating the cycle time; When the first waiting time of the backup PLC does not reach the preset maximum waiting time: when the backup PLC receives the first instruction sent by the main PLC, it feeds back a first signal to the main PLC and starts executing the task corresponding to the current cycle; wherein, the first instruction is used to indicate that the task corresponding to the current cycle has started to be executed; the first signal is used to notify the main PLC that it has received the first instruction.
7. The method according to claim 6, characterized in that Also includes: The standby PLC receives the second instruction sent by the main PLC and feeds back a second signal to the main PLC; wherein the second instruction is used to indicate that the task corresponding to the current cycle has been executed; and the second signal is used to notify the PLC that it has received the second instruction.
8. A periodic synchronization device, characterized in that: Applicable to a soft redundant PLC system, the system includes a main PLC and a standby PLC, and the device includes: An acquisition module, used for acquiring a first waiting time of the standby PLC; the first waiting time is used to represent the time elapsed from a first moment to a second moment, the first moment being the moment when the standby PLC enters preparation to execute the task corresponding to the current cycle, and the second moment is the moment when the standby PLC receives a first instruction sent by the main PLC to start executing the task corresponding to the current cycle; A first determining module, configured to determine a compensation value of the current cycle duration according to the first waiting duration when the first waiting duration reaches a preset maximum waiting duration; The second determination module is used to determine the actual value of the current cycle duration according to the compensation value, and control the current cycle duration of the standby PLC to be the actual value.
9. A computing device, characterized in that include: at least one processor; And at least one memory, which is connected to the processing and stores program instructions, and when the program instructions are executed by the at least one processor, the at least one processor executes the periodic synchronization method described in any one of claims 1-5, or executes the periodic task execution method described in any one of claims 6-7.
10. A computer-readable storage medium, characterized in that: Program instructions are stored thereon, and when the program instructions are executed by a computer, the computer performs the periodic synchronization method described in any one of claims 1-5, or performs the periodic task execution method described in any one of claims 6-7.
Citation Information
Patent Citations
Bus period synchronization method and system
CN112115079A
Multi-PLC instruction output high-precision synchronization method based on soft timer
CN116184920A
Medical system, time sequence synchronization device thereof, storage medium and program product
CN116881875A
Multi-driver control method and apparatus thereof
US20140114446A1