Configuration file synchronization method and system for double-CPU redundant PLC in nuclear power industry
By combining TCP protocol and FPGA heartbeat line monitoring, the configuration file synchronization in the dual-CPU redundant PLC system of the nuclear power industry is realized, which solves the problem of consistency between master and slave PLC configuration files and improves the reliability and security of the system.
Patent Information
- Application Number
- CN202511489131.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-10-17
- Publication Date
- 2026-01-09
Smart Images

Figure CN121301097A_ABST
Abstract
Description
[0001] Configuration file synchronization method and system for dual-CPU redundant PLCs in the nuclear power industry Technical Field This invention belongs to the field of nuclear power system technology, and in particular relates to a method and system for synchronizing configuration files of dual-CPU redundant PLCs for the nuclear power industry. Background Technology
[0002] In the nuclear power industry, programmable logic controllers (PLCs) are used as controllers for related non-safety equipment. However, even these non-safety equipment in nuclear power plants require high reliability and safety. In this system, redundancy is typically used to improve safety. If one PLC fails, another can immediately take over as master and control the entire system without disruption. The PLC can operate normally and connect to various modules. The configuration file is crucial; the PLC uses the configuration file to set relevant parameters and connect to various modules. To ensure seamless switching between master and slave PLCs, the consistency of the configuration file must be guaranteed. A common method is to download the configuration file to both the master and slave PLCs, but manual operation introduces uncertainties. Summary of the Invention
[0003] To address the problems in the prior art, this invention aims to provide a method and system for synchronizing configuration files of dual-CPU redundant PLCs for the nuclear power industry, which can better ensure the consistency of configuration files between master and slave PLCs.
[0004] To achieve the above objectives, this invention provides a method for synchronizing configuration files of a dual-CPU redundant PLC for the nuclear power industry, comprising the following steps: S1: Set one CPU to master CPU mode and the other CPU to slave CPU mode; each CPU includes a configuration file; S2: The CPU in slave CPU mode downloads and synchronizes the configuration file from the CPU in master CPU mode; S3: When the CPU mentioned above restarts, update the master-slave status and synchronize the configuration file according to the preset rules.
[0005] As one implementation, step S1 is preceded by the following step: When the system is powered on, each of the two CPUs creates a TCP server.
[0006] As one implementation, step S2 further includes: S21: The process of creating a TCP client from the CPU in CPU mode and connecting to the TCP server of the CPU in main CPU mode through the TCP client; S22: The CPU in slave CPU mode downloads the configuration file from the TCP server of the CPU in master CPU mode via the TCP client; S23: The CPU in CPU mode caches the downloaded configuration file and obtains the configuration cache file.
[0007] S24: The CPU in slave CPU mode verifies the configuration cache file; if the verification passes, the configuration cache file is replaced with the new configuration file of the CPU in slave CPU mode; if the verification fails, the current configuration file of the CPU in slave CPU mode remains unchanged.
[0008] As one implementation, step S3 further includes the following steps: S31: One CPU that has not restarted detects that the other CPU has restarted via the heartbeat line between the FPGA modules of the two CPUs; S32: The CPU that has not been restarted determines its master-slave status. When the master-slave status is in master CPU mode, it updates the master-slave status and synchronization configuration file according to the first preset rule. When the master-slave status is in slave CPU mode, it updates the master-slave status and synchronization configuration file according to the second preset rule.
[0009] As one implementation method, the first preset rule is: The master-slave state of the CPU that has not been restarted remains in master CPU mode; The restarted CPU determines and sets its master-slave status to slave CPU mode; The CPU in slave CPU mode downloads and synchronizes the configuration file from the CPU in master CPU mode through the TCP client and the TCP server.
[0010] As one implementation method, the second preset rule is: Change the master-slave state of the CPU that has not been restarted to master CPU mode; The restarted CPU determines and sets its master-slave status to slave CPU mode; The CPU in slave CPU mode downloads and synchronizes the configuration file from the CPU in master CPU mode through the TCP client and the TCP server.
[0011] As one implementation, step S2 is followed by the following step: S4: Modify the CPU's configuration file via the host computer.
[0012] As one implementation, step S4 further includes the following steps: S41: The host computer is connected to the CPU in the main CPU mode; S42: The host computer sends a target configuration file and a synchronization instruction to the CPU in the main CPU mode; S43: After the CPU in the master CPU mode updates its own configuration file to the target configuration file, it sends the target configuration file to the CPU in the slave CPU mode according to the synchronization instruction; S44: The CPU in CPU mode updates its own configuration file to the target configuration file; S45: The CPU in the main CPU mode sends a synchronization completion feedback signal to the host computer.
[0013] As one implementation, step S45 is followed by the following step: S46: The host computer sends a master-slave restart command to the CPU in the master CPU mode; S47: The CPU in the master CPU mode forwards the master-slave restart command to the CPU in the slave CPU mode; S48: The CPU in slave CPU mode restarts, and the CPU in master CPU mode detects that the CPU in slave CPU mode has restarted through the heartbeat line; S49: The CPU in the main CPU mode restarts.
[0014] The present invention provides a configuration file synchronization system based on the configuration file synchronization method for dual-CPU redundant PLCs used in the nuclear power industry described in this invention, characterized in that it includes: A mode configuration unit is used to set one CPU to master CPU mode and another CPU to slave CPU mode; each of the two CPUs includes a configuration file; An initial synchronization configuration unit is used for the CPU in slave CPU mode to download and synchronize the configuration file from the CPU in master CPU mode; The restart synchronization configuration unit is used to update the master-slave status and synchronize the configuration file according to preset rules when one of the CPUs restarts.
[0015] Because the present invention adopts the above technical solution, it has the following beneficial effects: In this invention, the two CPUs synchronize their configuration files via a network. When a CPU restarts, powers on / off, or performs command operations, it will perform a process where the slave CPU synchronizes the master CPU's configuration file via TCP. By synchronizing the configuration file from the slave to the master, the consistency of the master and slave CPU configuration files can be better and more stably guaranteed. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0017] Figure 1 This is a schematic diagram of the system structure of the configuration file synchronization method for a dual-CPU redundant PLC used in the nuclear power industry, according to an embodiment of this application. Figure 2 This is a flowchart illustrating a configuration file synchronization method for a dual-CPU redundant PLC used in the nuclear power industry, as described in an embodiment of this application. Detailed Implementation
[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0019] Please see Figure 1 An embodiment of the present invention provides a method for synchronizing configuration files of a dual-CPU redundant PLC for the nuclear power industry, comprising the following steps: When the system is powered on, each of the two CPUs creates a TCP server.
[0020] TCP is a connection-oriented, reliable transport layer protocol that provides packet ordering, flow control, congestion control, error detection, and retransmission mechanisms. Compared to connectionless protocols such as UDP, TCP ensures that data arrives at its destination intact, without packet loss, and in order. This is crucial for applications requiring data accuracy, such as industrial control, file transfer, and remote monitoring. It offers advantages such as reliable data transmission, reduced packet loss and errors, and improved communication quality.
[0021] S1: Set one CPU to master CPU mode and the other CPU to slave CPU mode; each CPU includes a configuration file; S2: The CPU in slave CPU mode downloads and synchronizes the configuration file from the CPU in master CPU mode; Step S2 further includes: S21: The process of creating a TCP client from the CPU in CPU mode and connecting to the TCP server of the CPU in main CPU mode through the TCP client; S22: The CPU in slave CPU mode downloads the configuration file from the TCP server of the CPU in master CPU mode via the TCP client; S23: The CPU in CPU mode caches the downloaded configuration file and obtains the configuration cache file.
[0022] S24: The CPU in slave CPU mode verifies the configuration cache file; if the verification passes, the configuration cache file is replaced with the new configuration file of the CPU in slave CPU mode; if the verification fails, the current configuration file of the CPU in slave CPU mode remains unchanged.
[0023] The method of verifying before replacing configuration file updates ensures the correctness and integrity of the data in the configuration files. Configuration files typically contain critical system parameters, such as communication parameters, device addresses, operating modes, and security keys. If the configuration file is corrupted, tampered with, or partially lost during transmission, storage, or download, directly replacing the original configuration file may lead to problems such as system startup failure, device malfunction, communication failure, and security vulnerabilities. By validating the configuration cache file using methods such as CRC, MD5, SHA checksums, or more complex format / semantic checks, it can be ensured that the configuration content is complete, undisturbed, and conforms to the expected format. Only verified and trusted configurations are applied, avoiding system risks caused by incorrect configurations from the outset.
[0024] In this embodiment, the system includes a first CPU 11 and a second CPU 21. The first CPU 11 and the second CPU 21 interact with each other via a network. The first CPU 11 and the second CPU 21 can determine whether the other is in place through the heartbeat lines on their respective first FPGA module 12 and second FPGA module 22. The host computer 3 communicates with the first CPU 11 and the second CPU 21 via network cables, respectively, through the first network port 13 connected to the first CPU 11 and the second network port 23 connected to the second CPU 21.
[0025] In this embodiment, after the system starts, it is assumed that the first CPU 11 is determined to be the master and the second CPU 21 is the slave. Then, the second CPU 21 will create a TCP client and connect to the server of the first CPU 11. After that, it will request the configuration file. The second CPU 21 will cache the received data to the file. After all the data has been received and passed the verification, the original configuration file will be deleted and the received cached file will be renamed as the configuration file.
[0026] S3: When the CPU mentioned above restarts, update the master-slave status and synchronize the configuration file according to preset rules; Step S3 further includes the following steps: S31: One CPU that has not restarted detects that the other CPU has restarted via the heartbeat line between the FPGA modules of the two CPUs; A heartbeat line is a simple communication line used to periodically transmit signals between two modules, such as two CPUs, a CPU and an FPGA, or a primary and backup system. It is usually one or more GPIO lines that transmit status information through level signals, pulse signals, or fixed-period signals.
[0027] The FPGA is responsible for real-time monitoring of the heartbeat signal to detect whether it appears at the expected frequency and format. If the signal is abnormal, such as not receiving a heartbeat for a long time or signal interruption, the FPGA can determine that there may be a problem with the CPU on the other end.
[0028] FPGAs are hardware logic circuits with response times ranging from nanoseconds to microseconds, enabling real-time detection of heartbeat signal changes. Compared to software polling, they are faster and more accurate. Furthermore, they are independent of the operating system or CPU's software state; even if the target CPU is completely frozen, deadlocked, or enters an abnormal state, the FPGA can still accurately determine whether its heartbeat has stopped.
[0029] S32: The CPU that has not been restarted determines its master-slave status. When the master-slave status is in master CPU mode, it updates the master-slave status and synchronization configuration file according to the first preset rule. When the master-slave status is in slave CPU mode, it updates the master-slave status and synchronization configuration file according to the second preset rule.
[0030] The first preset rule is: The master-slave state of the CPU that has not been restarted remains in master CPU mode; The restarted CPU determines and sets its master-slave status to slave CPU mode; The CPU in slave CPU mode downloads and synchronizes the configuration file from the CPU in master CPU mode through the TCP client and the TCP server.
[0031] The second preset rule is: Change the master-slave state of the CPU that has not been restarted to master CPU mode; The restarted CPU determines and sets its master-slave status to slave CPU mode; The CPU in slave CPU mode downloads and synchronizes the configuration file from the CPU in master CPU mode through the TCP client and the TCP server.
[0032] For example: During system operation, the first CPU11 in master CPU mode restarts, and the second CPU21 in slave CPU mode is promoted to master CPU mode. When the first CPU11 restarts and initializes, it determines that it is in slave CPU mode. The first CPU11 will synchronize the configuration file of the second CPU21 through TCP to ensure the consistency of the master and slave CPU configuration files. During system operation, the second CPU 21 in CPU mode restarts, while the first CPU 11 in CPU mode continues to run as the master. When the second CPU 21 restarts and initializes, it determines that it is in slave CPU mode. The second CPU 21 will synchronize the configuration file of the first CPU 11 via TCP to ensure the consistency of the master and slave CPU configuration files.
[0033] Additionally, during system operation after a reboot, if the first CPU 11, previously in master CPU mode, has already rebooted, then the first CPU 11 is now in slave CPU mode, and the second CPU 21 is in master CPU mode; its configuration is as follows: When the first CPU11 restarts from CPU mode, the second CPU12, which is in master CPU mode, still runs as master. When the first CPU11 restarts and initializes, it determines that it is in slave CPU mode. The first CPU11 will synchronize the configuration file of the second CPU21 via TCP to ensure the consistency of the master and slave CPU configuration files.
[0034] When the second CPU 21 in master CPU mode restarts, the first CPU 11 in slave CPU mode is promoted to master CPU mode. When the second CPU 21 restarts and initializes, it determines that it is in slave CPU mode. The second CPU 21 will synchronize the configuration file of the first CPU 11 via TCP to ensure the consistency of the master and slave CPU configuration files.
[0035] In this embodiment, step S2 is followed by the following step: S4: Modify the configuration file of the CPU via the host computer 3.
[0036] Step S4 shown further includes the following steps: S41: The host computer 3 is connected to the CPU in the main CPU mode; S42: The host computer 3 sends a target configuration file and a synchronization instruction to the CPU in the main CPU mode; S43: After the CPU in the master CPU mode updates its own configuration file to the target configuration file, it sends the target configuration file to the CPU in the slave CPU mode according to the synchronization instruction; S44: The CPU in CPU mode updates its own configuration file to the target configuration file; S45: The CPU in the main CPU mode sends a synchronization completion feedback signal to the host computer 3.
[0037] During system operation, the configuration file can be modified via host computer 3. Then, host computer 3 connects to the CPU in master CPU mode, sends the configuration file to the CPU in master CPU mode via FTP, and tells the CPU in master CPU mode to send it to the CPU in slave CPU mode via TCP. After successful synchronization, the CPU in master CPU mode sends a feedback signal to host computer 3 to let the user know that the synchronization was successful.
[0038] The step S45 is followed by the following step: S46: The host computer 3 sends a master-slave restart command to the CPU in the master CPU mode; S47: The CPU in the master CPU mode forwards the master-slave restart command to the CPU in the slave CPU mode; S48: The CPU in slave CPU mode restarts, and the CPU in master CPU mode detects that the CPU in slave CPU mode has restarted through the heartbeat line; S49: The CPU in the main CPU mode restarts.
[0039] Configuration files sometimes require a CPU restart to take effect. The host computer 3 can connect to the CPU in master CPU mode and issue master and slave CPU restart commands. The master CPU mode CPU tells the slave CPU mode CPU to restart via TCP and detects the heartbeat signal via the heartbeat line. If there is no heartbeat signal, the slave CPU restarts successfully, and then the master CPU restarts.
[0040] In traditional methods, if the master and slave CPUs restart simultaneously, the entire system may become completely unavailable for a short period of time, or even lead to problems such as dual-master conflicts, data inconsistencies, and service interruptions. By restarting the slave CPU first, followed by the master CPU, it is ensured that at least one CPU is in a controllable state or has completed the restart process at any given time. This guarantees higher overall system availability, ensures the effectiveness of master and slave CPU restarts, and effectively prevents logical conflicts or data corruption that may result from simultaneous restarts.
[0041] An embodiment of the present invention provides a configuration file synchronization system based on the configuration file synchronization method for dual-CPU redundant PLCs in the nuclear power industry described in this invention, comprising: A mode configuration unit is used to set one CPU to master CPU mode and another CPU to slave CPU mode; each of the two CPUs includes a configuration file; An initial synchronization configuration unit is used for the CPU in slave CPU mode to download and synchronize the configuration file from the CPU in master CPU mode; The restart synchronization configuration unit is used to update the master-slave status and synchronize the configuration file according to preset rules when one of the CPUs restarts.
[0042] The initial synchronization configuration unit is further configured to perform the following steps: S21: The process of creating a TCP client from the CPU in CPU mode and connecting to the TCP server of the CPU in main CPU mode through the TCP client; S22: The CPU in slave CPU mode downloads the configuration file from the TCP server of the CPU in master CPU mode via the TCP client; S23: The CPU in CPU mode caches the downloaded configuration file and obtains the configuration cache file.
[0043] S24: The CPU in slave CPU mode verifies the configuration cache file; if the verification passes, the configuration cache file is replaced with the new configuration file of the CPU in slave CPU mode; if the verification fails, the current configuration file of the CPU in slave CPU mode remains unchanged.
[0044] The restart synchronization configuration unit is further used to perform the following steps: S31: One CPU that has not restarted detects that the other CPU has restarted via the heartbeat line between the FPGA modules of the two CPUs; S32: The CPU that has not been restarted determines its master-slave status. When the master-slave status is in master CPU mode, it updates the master-slave status and synchronization configuration file according to the first preset rule. When the master-slave status is in slave CPU mode, it updates the master-slave status and synchronization configuration file according to the second preset rule.
[0045] The first preset rule is: The master-slave state of the CPU that has not been restarted remains in master CPU mode; The restarted CPU determines and sets its master-slave status to slave CPU mode; The CPU in slave CPU mode downloads and synchronizes the configuration file from the CPU in master CPU mode through the TCP client and the TCP server.
[0046] The second preset rule is: Change the master-slave state of the CPU that has not been restarted to master CPU mode; The restarted CPU determines and sets its master-slave status to slave CPU mode; The CPU in slave CPU mode downloads and synchronizes the configuration file from the CPU in master CPU mode through the TCP client and the TCP server.
[0047] In this embodiment, it also includes: a host computer 3 configuration module, used to modify the configuration file of the CPU through the host computer 3.
[0048] The host computer 3 configuration module shown is further used to execute the following steps: S41: The host computer is connected to the CPU in the main CPU mode; S42: The host computer sends a target configuration file and a synchronization instruction to the CPU in the main CPU mode; S43: After the CPU in the master CPU mode updates its own configuration file to the target configuration file, it sends the target configuration file to the CPU in the slave CPU mode according to the synchronization instruction; S44: The CPU in CPU mode updates its own configuration file to the target configuration file; S45: The CPU in the main CPU mode sends a synchronization completion feedback signal to the host computer; S46: The host computer sends a master-slave restart command to the CPU in the master CPU mode; S47: The CPU in the master CPU mode forwards the master-slave restart command to the CPU in the slave CPU mode; S48: The CPU in slave CPU mode restarts, and the CPU in master CPU mode detects that the CPU in slave CPU mode has restarted through the heartbeat line; S49: The CPU in the main CPU mode restarts.
[0049] In this invention, the two CPUs synchronize their configuration files via a network. When a CPU restarts, powers on / off, or performs command operations, it will perform a process where the slave CPU synchronizes the master CPU's configuration file via TCP. By synchronizing the configuration file from the slave to the master, the consistency of the master and slave CPU configuration files can be better and more stably guaranteed.
[0050] It should be noted that while the preferred embodiments of the present invention are provided in the specification and accompanying drawings, the present invention can be implemented in many different forms and is not limited to the embodiments described herein. These embodiments are not intended to impose additional limitations on the content of the present invention; their purpose is to provide a more thorough and comprehensive understanding of the disclosure of the present invention. Furthermore, the above-described technical features can be combined with each other to form various embodiments not listed above, all of which are considered to be within the scope of the present invention specification. Moreover, those skilled in the art can make improvements or modifications based on the above description, and all such improvements and modifications should fall within the protection scope of the appended claims.
[0051] The present invention has been described in detail above with reference to the accompanying drawings and embodiments. Those skilled in the art can make various modifications to the present invention based on the above description. Therefore, certain details in the embodiments should not be construed as limiting the present invention, and the scope of protection of the present invention shall be defined by the appended claims.
Claims
1. A method for synchronizing configuration files of a dual-CPU redundant PLC for the nuclear power industry, comprising the following steps: S1: Set one CPU to master CPU mode and the other CPU to slave CPU mode; each CPU includes a configuration file; S2: The CPU in slave CPU mode downloads and synchronizes the configuration file from the CPU in master CPU mode; S3: When the CPU mentioned above restarts, update the master-slave status and synchronize the configuration file according to the preset rules.
2. The configuration file synchronization method for dual-CPU redundant PLCs in the nuclear power industry according to claim 1, characterized in that, The step S1 is preceded by the following step: When the system is powered on, each of the two CPUs creates a TCP server.
3. The configuration file synchronization method for dual-CPU redundant PLCs in the nuclear power industry according to claim 2, characterized in that, Step S2 further includes: S21: The process of creating a TCP client from the CPU in CPU mode and connecting to the TCP server of the CPU in main CPU mode through the TCP client; S22: The CPU in slave CPU mode downloads the configuration file from the TCP server of the CPU in master CPU mode via the TCP client; S23: The CPU in CPU mode caches the downloaded configuration file and obtains the configuration cache file. S24: The CPU in slave CPU mode verifies the configuration cache file; if the verification passes, the configuration cache file is replaced with the new configuration file of the CPU in slave CPU mode; if the verification fails, the current configuration file of the CPU in slave CPU mode remains unchanged.
4. The configuration file synchronization method for a dual-CPU redundant PLC in the nuclear power industry according to claim 3, characterized in that, Step S3 further includes the following steps: S31: One CPU that has not restarted detects that the other CPU has restarted via the heartbeat line between the FPGA modules of the two CPUs; S32: The CPU that has not been restarted determines its master-slave status. When the master-slave status is in master CPU mode, it updates the master-slave status and synchronization configuration file according to the first preset rule. When the master-slave status is in slave CPU mode, it updates the master-slave status and synchronization configuration file according to the second preset rule.
5. The configuration file synchronization method for dual-CPU redundant PLCs in the nuclear power industry according to claim 4, characterized in that, The first preset rule is: The master-slave state of the CPU that has not been restarted remains in master CPU mode; The restarted CPU determines and sets its master-slave status to slave CPU mode; The CPU in slave CPU mode downloads and synchronizes the configuration file from the CPU in master CPU mode through the TCP client and the TCP server.
6. The configuration file synchronization method for a dual-CPU redundant PLC in the nuclear power industry according to claim 5, characterized in that, The second preset rule is: Change the master-slave state of the CPU that has not been restarted to master CPU mode; The restarted CPU determines and sets its master-slave status to slave CPU mode; The CPU in slave CPU mode downloads and synchronizes the configuration file from the CPU in master CPU mode through the TCP client and the TCP server.
7. The configuration file synchronization method for a dual-CPU redundant PLC in the nuclear power industry according to claim 6, characterized in that, The step S2 is followed by the following step: S4: Modify the CPU's configuration file via the host computer.
8. The configuration file synchronization method for a dual-CPU redundant PLC in the nuclear power industry according to claim 7, characterized in that, Step S4 shown further includes the following steps: S41: The host computer is connected to the CPU in the main CPU mode; S42: The host computer sends a target configuration file and a synchronization instruction to the CPU in the main CPU mode; S43: After the CPU in the master CPU mode updates its own configuration file to the target configuration file, it sends the target configuration file to the CPU in the slave CPU mode according to the synchronization instruction; S44: The CPU in CPU mode updates its own configuration file to the target configuration file; S45: The CPU in the main CPU mode sends a synchronization completion feedback signal to the host computer.
9. The configuration file synchronization method for a dual-CPU redundant PLC in the nuclear power industry according to claim 8, characterized in that, The step S45 is followed by the following step: S46: The host computer sends a master-slave restart command to the CPU in the master CPU mode; S47: The CPU in the master CPU mode forwards the master-slave restart command to the CPU in the slave CPU mode; S48: The CPU in slave CPU mode restarts, and the CPU in master CPU mode detects that the CPU in slave CPU mode has restarted through the heartbeat line; S49: The CPU in the main CPU mode restarts.
10. A configuration file synchronization system based on the configuration file synchronization method for dual-CPU redundant PLCs in the nuclear power industry as described in any one of claims 1 to 9 of the present invention, characterized in that, include: A mode configuration unit is used to set one CPU to master CPU mode and another CPU to slave CPU mode; each of the two CPUs includes a configuration file; An initial synchronization configuration unit is used for the CPU in slave CPU mode to download and synchronize the configuration file from the CPU in master CPU mode; The restart synchronization configuration unit is used to update the master-slave status and synchronize the configuration file according to preset rules when one of the CPUs restarts.