A method and system for diagnosing a PLC program off-machine failure
By monitoring and extracting features from multi-dimensional runtime sequence data of PLC programs, the problem of delayed fault diagnosis response in existing technologies has been solved, enabling early anomaly identification and fault source location, and improving the accuracy of fault tracing and predictive maintenance capabilities.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU POLYTECHNIC
- Filing Date
- 2026-04-21
- Publication Date
- 2026-07-21
Smart Images

Figure CN122431928A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of PLC program diagnostic technology, and more specifically, to a method and system for diagnosing PLC program shutdown faults. Background Technology
[0002] A PLC program is a sequence of industrial control instructions written for a programmable logic controller. It processes input signals and drives output devices according to preset logic rules. It is written in standardized languages such as ladder diagrams and structured text, and realizes real-time and reliable control of automated production processes. It is the core software carrier for the operation of industrial equipment.
[0003] Current technologies for PLC program fault diagnosis generally suffer from limitations in detection mechanisms and delayed responses. Their core flaw lies in their over-reliance on passive alarms triggered by single thresholds or simple statistical indicators such as watchdog timeouts. This mechanism is essentially a reactive, retrospective diagnostic approach. When early, subtle abnormal signs appear in program operation (e.g., gradual shifts in specified variable values, minor fluctuations in critical loop cycles, or occasional disruptions in the control logic sequence), current technologies are unable to identify these weak signals through multi-dimensional feature correlation, nor can they effectively distinguish them from normal program fluctuations. This results in the system only triggering alarms after a serious error or complete program crash, missing the critical opportunity for early warning and intervention in the early stages of fault evolution. This leaves maintenance work in a perpetually reactive state, hindering the transition from fault repair to predictive maintenance. Therefore, achieving confident localization of PLC program crashes, thereby improving the accuracy of PLC program fault tracing, has become a challenging problem for the industry. Summary of the Invention
[0004] This application provides a method and system for diagnosing PLC program shutdown faults, which can realize the confident location of PLC program shutdown faults, thereby improving the accuracy of PLC program fault tracing.
[0005] Firstly, this application provides a method for diagnosing PLC program crashes, including: During the execution of the target PLC program, the program execution process is dynamically monitored, and multi-dimensional runtime sequence data reflecting the health status of the program is collected. Extract time-series-based node distribution features and logical association-based pattern association features from the multi-dimensional runtime sequence data, and then evaluate the state of the target PLC program based on the node distribution features and the pattern association features to obtain the anomaly confidence level of the target PLC program. When the anomaly confidence level is greater than the standard anomaly threshold of the PLC program, the anomaly control parameters in the program execution process are fused according to the feature contribution of each anomaly feature node in the target PLC program to obtain the diagnostic feature vector of parameter and state association in the target PLC program. When the target PLC program crashes, the complete diagnostic feature vector of the target PLC program before the crash is correlated with the final state information at the time of the crash to locate the confidence fault source that caused the target PLC program to crash.
[0006] In some embodiments, extracting time-series-based node distribution features and logical association-based pattern association features from the multi-dimensional runtime sequence data specifically includes: Based on the program structure of the target PLC program, multiple execution nodes are determined, and the timing data of each execution node is obtained from the multi-dimensional runtime timing data. Extract the temporal statistical features of each execution node from each time series data, and then determine the node distribution features based on the time series. The conditional probability of execution order and mutual information of execution intervals between execution nodes are calculated to determine the pattern association features based on logical association.
[0007] In some embodiments, the state evaluation of the target PLC program based on the node distribution characteristics and the pattern association characteristics to obtain the anomaly confidence level of the target PLC program's operation specifically includes: During the normal operation phase of the PLC program, node distribution characteristics and pattern association characteristics are collected, and a benchmark model describing the health status of the program is constructed using a Gaussian mixture model or an autoencoder. Input the node distribution characteristics and pattern association characteristics of each current execution node into the baseline model, and calculate the feature deviation between it and the health status distribution; The anomaly confidence level of the target PLC program execution is determined based on all characteristic deviations.
[0008] In some embodiments, the abnormal control parameters during program execution are fused based on the feature contribution of each abnormal feature node in the target PLC program to obtain a diagnostic feature vector relating parameters and states in the target PLC program. Specifically, this includes: Determine the feature contribution of each abnormal feature node in the target PLC program; Starting with the abnormal feature node with the highest feature contribution, trace its direct association with input / output parameters, intermediate variables, and device states in the program control logic to obtain the parameter-state association graph; Extract diagnostic feature vectors of parameter and state associations from the parameter-state association diagram in the target PLC program.
[0009] In some embodiments, the complete diagnostic feature vector of the target PLC program before the shutdown is abnormally correlated with the final state information at the time of the shutdown, thereby locating the credible fault source that caused the shutdown of the target PLC program, specifically includes: Record the final state information of the program at the moment of crash, and obtain a snapshot before and after the failure; Starting from the abnormal parameters and states recorded in the diagnostic feature vector, and ending with the final state information in the snapshots before and after the fault, trace back in reverse in the control logic diagram of the PLC program to find the minimum causal path that can connect the starting abnormality and the ending fault state. The confidence source of the PLC program that caused this crash was determined by identifying all links in the least causal path.
[0010] In some embodiments, a non-intrusive online monitoring agent module is used to dynamically monitor the program execution process.
[0011] In some embodiments, the target PLC program is a structured text based on the IEC 61131-3 standard.
[0012] Secondly, this application provides a PLC program shutdown fault diagnosis system, comprising: The data acquisition module is used to dynamically monitor the program execution process during the operation of the target PLC program and collect multi-dimensional runtime sequence data that reflects the health status of the program. The processing module is used to extract time-series-based node distribution features and logical association-based pattern association features from the multi-dimensional runtime sequence data, and then perform state evaluation on the target PLC program based on the node distribution features and the pattern association features to obtain the abnormal confidence level of the target PLC program. The processing module is also used to perform contribution fusion of abnormal control parameters in the program execution process according to the feature contribution of each abnormal feature node in the target PLC program when the abnormal confidence level is greater than the standard abnormal threshold of the PLC program, so as to obtain a diagnostic feature vector of parameter and state association in the target PLC program. The execution module is used to perform abnormal evolution correlation between the complete diagnostic feature vector of the target PLC program before the crash and the final state information at the time of the crash when the target PLC program crashes, thereby locating the confidence fault source that caused the target PLC program to crash.
[0013] Thirdly, this application provides a computer device, the computer device including a memory and a processor, the memory for storing a computer program, and the processor for calling and running the computer program from the memory, so that the computer device executes the above-described PLC program shutdown fault diagnosis method.
[0014] Fourthly, this application provides a computer-readable storage medium storing instructions or code that, when executed on a computer, cause the computer to implement the aforementioned PLC program shutdown fault diagnosis method.
[0015] The technical solutions provided by the embodiments disclosed in this application have the following beneficial effects: This application provides a PLC program shutdown fault diagnosis method and system. During the operation of the target PLC program, the program execution process is dynamically monitored, and multi-dimensional runtime sequence data reflecting the program's health status is collected. Node distribution features based on time series and pattern association features based on logical association are extracted from the multi-dimensional runtime sequence data. The state of the target PLC program is then evaluated based on the node distribution features and the pattern association features to obtain the anomaly confidence level of the target PLC program. When the anomaly confidence level is greater than the standard anomaly threshold of the PLC program, the contribution of the abnormal control parameters during program execution is fused according to the feature contribution of each abnormal feature node in the target PLC program to obtain a diagnostic feature vector of parameter and state association in the target PLC program. When the target PLC program shuts down, the complete diagnostic feature vector of the target PLC program before the shutdown is abnormally evolved and associated with the final state information at the time of the shutdown, thereby locating the confidence fault source that caused the target PLC program to shut down.
[0016] Therefore, in this application, when the target PLC program crashes, the complete diagnostic feature vector of the target PLC program before the crash is correlated with the final state information at the time of the crash through abnormal evolution, thereby locating the source of the confidence fault that caused the crash. First, determining the anomaly confidence level yields a quantitative risk assessment index for the program's running state, thus establishing a mapping relationship from system appearance to internal hidden dangers. This index, by integrating multi-dimensional temporal features and pattern correlation features, transforms the originally scattered program behavior information into a scalar value that dynamically reflects the overall health, enabling the system to identify early, weak, and complex abnormal patterns before the program completely collapses. Continuous calculation of the anomaly confidence level provides a time window for fault early warning, allowing maintenance personnel to take intervention measures before the program experiences unrecoverable errors. It provides triggering criteria and data screening standards, ensuring that the diagnostic process is only initiated when necessary, avoiding resource waste. Then, determining the diagnostic feature vector allows the construction of a standardized data structure covering the evolution process of abnormal parameters, thus providing a complete spatiotemporal evidence chain for fault root cause analysis. This vector extracts and fuses the parameter correlation network of high-contribution anomaly nodes, transforming discrete anomaly signals into a feature set with clear causal relationships. It not only preserves the complete temporal trajectory of the anomaly occurrence but also clarifies the logical dependencies between various anomaly factors through a parameter-state correlation diagram. The diagnostic feature vector acts as a fault black box record when the program crashes, completely preserving key state transition information from the anomaly's inception to system collapse. When correlated with the final fault state, this vector provides a traceable anomaly evolution path, thus overcoming the limitations of the final error manifestation and accurately locating the causal node that triggers the chain reaction. In summary, based on the above scheme, confident localization of PLC program crash faults can be achieved, thereby improving the accuracy of PLC program fault tracing. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is an exemplary flowchart of a PLC program shutdown fault diagnosis method according to some embodiments of this application; Figure 2 This is a flowchart illustrating the process of determining diagnostic feature vectors according to some embodiments of this application; Figure 3 This is a schematic diagram of the structure of a PLC program shutdown fault diagnosis system according to some embodiments of this application; Figure 4 This is a schematic diagram of the structure of a computer device that implements a PLC program crash fault diagnosis method according to some embodiments of this application. Detailed Implementation
[0019] To better understand the technical solution of this application, the technical solution of this application will be described in detail below with reference to the accompanying drawings and specific embodiments.
[0020] refer to Figure 1 The figure is an exemplary flowchart of a PLC program shutdown fault diagnosis method according to some embodiments of this application. The PLC program shutdown fault diagnosis method mainly includes the following steps: In step 101, during the execution of the target PLC program, the program execution process is dynamically monitored, and multi-dimensional runtime sequence data reflecting the health status of the program is collected.
[0021] It should be noted that in this application, dynamic monitoring is a non-intrusive monitoring mechanism used to capture changes in the internal state of the program in real time; multi-dimensional runtime sequence data is a set of parameters used to characterize the comprehensive behavior of the program in the time dimension; a non-intrusive online monitoring agent module is used to dynamically monitor the program execution process; the target PLC program is a structured text based on the IEC 61131-3 standard.
[0022] In practice, dynamic monitoring is achieved by deploying a dedicated monitoring agent module within the programmable logic controller (PLC). This module automatically inserts observation hooks at key execution points (e.g., the start and end points of program loops, the entry point of conditional jump instructions, and the moment of read / write operations on external input / output modules) without interfering with the normal scanning and execution of the original program. These hooks synchronously record the instantaneous values of predefined key variables, the timestamp of the execution point, and the duration of the current scan cycle within each PLC scan cycle. The collected raw data is packaged in real time and precisely time-stamped, forming a raw data stream with a unified time base. Finally, the system uses this data stream, containing variable value sequences, timestamp sequences, and periodic time sequences, as multi-dimensional runtime sequence data for subsequent analysis.
[0023] In step 102, node distribution features based on time series and pattern association features based on logical association are extracted from the multi-dimensional runtime sequence data. Then, the target PLC program is evaluated based on the node distribution features and the pattern association features to obtain the abnormal confidence level of the target PLC program.
[0024] In some embodiments, extracting time-series-based node distribution features and logical association-based pattern association features from the multi-dimensional runtime sequence data can be achieved through the following steps: Based on the program structure of the target PLC program, multiple execution nodes are determined, and the timing data of each execution node is obtained from the multi-dimensional runtime timing data. Extract the temporal statistical features of each execution node from each time series data, and then determine the node distribution features based on the time series. The conditional probability of execution order and mutual information of execution intervals between execution nodes are calculated to determine the pattern association features based on logical association.
[0025] It should be noted that, in this application, the program structure is a logical framework used to define the organization and execution flow of a PLC program; the execution node is a logical location identifier used to mark key control points or functional units of the program; the timing data is a time series set used to record the state changes of a specified execution node at consecutive time points; the timing statistical features are mathematical indicators used to quantify the fluctuation patterns and central tendency of a single data sequence; the node distribution features are feature vectors used to comprehensively characterize the stability of the behavior of a single execution node; the conditional probability is a probability value used to measure the likelihood of the execution of the next node given the execution of the previous node; the mutual information is an information metric used to quantify the degree of reduction in the uncertainty of the execution time interval between two nodes; and the pattern association features are a set of association strengths used to characterize the stable timing relationships between different execution nodes.
[0026] In practical implementation, firstly, multiple execution nodes are determined based on the program structure of the target PLC program. The timing data of each execution node can be obtained from the multi-dimensional runtime timing data in the following way: the source code or compiled intermediate code of the target PLC program is parsed to identify specific control structures in the program, including the start and end positions of loop structures, conditional branch judgment points, subroutine or function call entry and return points, and key instruction positions for reading and writing operations to external input / output modules. Using these key positions of control structures as a benchmark, corresponding marker points are created in the program logic flow diagram, and these marker points are identified as multiple execution nodes to be monitored. During program execution, when the execution flow passes through any marked execution node, the monitoring system synchronously collects three types of data for that node: the node's unique identifier number, the precise timestamp of passing through the node, and the instantaneous value of relevant variables at that node. The system categorizes and aggregates all collected raw data according to node identifiers, using data point sequences belonging to the same node and arranged in chronological order as the time-series data for that execution node. Then, it extracts the temporal statistical characteristics of each execution node from these time-series data. The determination of node distribution characteristics based on time series can be achieved in the following way: For each execution node's aggregated time-series data, statistical analysis is performed on the periodic time series and key variable numerical series. For periodic time series, the arithmetic mean and standard deviation are calculated within a fixed-length analysis window to describe the central level and fluctuation of the node's execution time. For key variable numerical series, the skewness and kurtosis are calculated within the analysis window. Skewness measures the direction and degree of asymmetry in the data distribution, while kurtosis measures the sharpness or flatness of the data distribution.The system combines all calculated statistical indicators such as mean, standard deviation, skewness, and kurtosis into a multidimensional array in a predetermined order, and uses this multidimensional array as the node distribution characteristic of the execution node. Finally, it calculates the conditional probability of the execution order and the mutual information of the execution interval between each execution node, and then determines the pattern association characteristics based on logical association. This can be achieved in the following way: First, analyze the occurrence order of each execution node on the time axis, and count the frequency of node B executing in the same or next scan cycle after node A executes in a large number of scan cycles. Divide this frequency by the total frequency of node A's execution, and the resulting ratio is... The conditional probability of the execution order from node A to node B is calculated. The time interval sequence of the execution times of any two nodes is analyzed. By calculating the relationship between the joint probability distribution of the two interval sequences and the product of their respective marginal probability distributions, the amount of information provided by the known execution interval of one node for predicting the execution interval of another node is measured. This amount of information is the mutual information between the two nodes. Node pairs with conditional probabilities higher than a set threshold or mutual information values significantly greater than zero are selected. The identifiers of these node pairs, as well as their corresponding conditional probability values and mutual information values, are recorded. The list of these records is used as a pattern association feature describing the inherent execution logic of the program.
[0027] In some embodiments, the state evaluation of the target PLC program based on the node distribution characteristics and the pattern association characteristics, to obtain the anomaly confidence level of the target PLC program's operation, can be achieved through the following steps: During the normal operation phase of the PLC program, node distribution characteristics and pattern association characteristics are collected, and a benchmark model describing the health status of the program is constructed using a Gaussian mixture model or an autoencoder. Input the node distribution characteristics and pattern association characteristics of each current execution node into the baseline model, and calculate the feature deviation between it and the health status distribution; The anomaly confidence level of the target PLC program execution is determined based on all characteristic deviations.
[0028] It should be noted that, in this application, the anomaly confidence level is a normalized score used to comprehensively assess the probability of an anomaly in the current operating state of the program; the baseline model is a mathematical model used to characterize the normal distribution pattern of all features of the PLC program in a healthy state; and the feature deviation is a scalar value used to quantify the magnitude of the difference between the current program features and the healthy baseline model.
[0029] In specific implementation, firstly, during the normal operation phase of the PLC program, the node distribution characteristics and pattern association characteristics are collected. A benchmark model describing the program's health status is constructed using a Gaussian mixture model or an autoencoder. This can be achieved in the following way: First, a model training phase is conducted, ensuring the target PLC program is in a known normal and stable operating state and runs continuously in this state for a sufficient period. During this period, the monitoring system continuously operates, periodically extracting the program's node distribution characteristics and pattern association characteristics according to the aforementioned method, and storing these characteristics in chronological order to form a health feature sample library. An unsupervised learning algorithm is then used to model this sample library. If a Gaussian mixture model is used, the algorithm automatically divides the high-dimensional feature space into multiple Gaussian distributed sub-regions defined by different means and covariance matrices. The linear combination of these sub-regions constitutes the benchmark model, which describes the probability distribution of health characteristics in multidimensional space. If an autoencoder is used, a neural network consisting of an encoder and a decoder is trained to compress and reconstruct the input health features with minimal reconstruction error. After training, the network's ability to reconstruct health features constitutes the baseline model. The parameters of the trained Gaussian mixture model or the weights of the autoencoder network are used as the baseline model for subsequent state evaluation. Then, the node distribution features and pattern association features of each current execution node are input into the baseline model, and the feature deviation between it and the health state distribution is calculated. This can be achieved as follows: During the real-time monitoring phase, after the system completes feature extraction for a monitoring cycle and obtains the node distribution features and pattern association features of all execution nodes at the current moment, these features are combined into a complete real-time feature vector. This real-time feature vector is input into the constructed baseline model for comparison and analysis. If the baseline model is a Gaussian mixture model, the probability (i.e., likelihood value) that the real-time feature vector belongs to this mixture model is calculated. The lower the probability value, the less likely the feature vector is to appear in the health feature distribution, and the greater the deviation. Therefore, the negative logarithm of the likelihood value is usually used as the feature deviation.If the baseline model is an autoencoder, the real-time feature vector is input into the autoencoder to obtain its reconstructed output. Then, the Euclidean distance or mean square error between the original input feature vector and the reconstructed output feature vector is calculated. The larger the error value, the more difficult it is for the autoencoder to accurately reconstruct the feature, that is, the greater the difference between the feature and the healthy features seen during training. This error value is used as the feature deviation. The calculated negative logarithm of the probability and the reconstruction error value are used as the overall feature deviation at the current moment. Finally, the abnormal confidence level of the target PLC program operation can be determined based on all feature deviations. This can be achieved in the following way: In order to obtain an easy-to-understand and uniformly judged index, the calculated feature deviation, which may be a single value or a set of deviations of multiple sub-features, needs to be transformed into a standardized score. First, a normalization interval is set, such as 0 to 1. During the model training phase, in addition to establishing the baseline model, the feature deviation of a batch of healthy feature samples is calculated, and the maximum value of these deviations is counted, or a high percentile (e.g., 99th percentile) is set as a reference benchmark based on its statistical distribution. During real-time evaluation, the currently calculated real-time feature deviation is compared with this reference baseline. A specific transformation method could be to divide the real-time deviation by the reference baseline value and then map it using a sigmoid-type function, ensuring the output value is limited to between 0 and 1. Another more direct method is to directly use the probability value of the feature output from the baseline model (e.g., a Gaussian mixture model) belonging to a healthy distribution as the anomaly confidence level; in this case, the lower the probability value, the higher the confidence level. The system outputs a value between 0 and 1, which is used as the anomaly confidence level characterizing the probability of an abnormal state in the current program execution.
[0030] In step 103, when the anomaly confidence level is greater than the standard anomaly threshold of the PLC program, the anomaly control parameters in the program execution process are fused according to the feature contribution of each anomaly feature node in the target PLC program to obtain the diagnostic feature vector of parameter and state association in the target PLC program.
[0031] In some embodiments, the contribution of abnormal control parameters during program execution is fused based on the feature contribution of each abnormal feature node in the target PLC program to obtain a diagnostic feature vector relating parameters and states in the target PLC program, with reference to... Figure 2 The diagram is a flowchart illustrating the process of determining diagnostic feature vectors in some embodiments of this application. In this embodiment, the determination of diagnostic feature vectors can be achieved using the following steps: In step 1031, the feature contribution of each abnormal feature node in the target PLC program is determined; In step 1032, the abnormal feature node with the highest feature contribution is taken as the starting node, and its input and output parameters, intermediate variables and device states directly associated with it in the program control logic are traced to obtain the parameter-state association diagram. In step 1033, diagnostic feature vectors relating parameters and states in the target PLC program are extracted from the parameter-state association diagram.
[0032] It should be noted that, in this application, the diagnostic feature vector is a structured data object used to encapsulate the historical sequence of key parameters highly correlated with the current anomaly and their state change markers; the feature contribution is a weight value used to quantify the degree of influence of each anomaly feature node on the final anomaly confidence value; and the parameter-state association graph is a directed network structure used to visualize the causal relationships and dependencies between the core anomaly node and related program variables and external states.
[0033] In practical implementation, the contribution of each abnormal feature node in the target PLC program can be determined as follows: after calculating the anomaly confidence level exceeding the threshold, it is necessary to backtrack and analyze the specific source leading to the high confidence level. The system implements this through an attribution analysis method. This method is based on a core idea: attempting to remove a specific feature node (e.g., the average periodic time of a specified execution node) sequentially from the current complete feature set, and then recalculating the anomaly confidence level after removing the feature. Comparing the original complete anomaly confidence level with the anomaly confidence level after removing the feature, the difference approximately reflects the "contribution" of the feature node to the final result. The system performs this operation for each feature node marked as "abnormal" (whose data value deviates significantly from the healthy baseline), calculating its respective difference. Finally, all differences are normalized so that their sum is 1. The proportional value corresponding to each abnormal feature node obtained after normalization is determined as the feature contribution of that node. Then, taking the abnormal feature node with the highest feature contribution as the starting node, the input and output parameters, intermediate variables, and device states directly associated with it in the program control logic are traced to obtain the parameter-state association diagram. This can be achieved in the following way: First, identify one or several abnormal feature nodes with the highest feature contribution. Using these nodes as the starting point of analysis, trace along both the data flow and control flow directions by parsing the PLC program source code or control logic diagram. In the data flow direction, find the read source and write target of the program variable (e.g., current value of a timer, accumulated value of a counter) corresponding to the abnormal feature node. This includes tracing back to the direct input signal (e.g., Boolean input of a sensor), the intermediate variables affecting the calculation of the variable (e.g., temporary storage data involved in arithmetic operations), and the output signal directly or indirectly controlled by the variable (e.g., coil state of a relay) and the associated device state (e.g., motor start, valve opening). In the control flow direction, analyze whether the execution of the node is affected by specified condition judgments. All traced parameters (inputs, outputs, intermediate variables) and states (device actions, flags) are treated as vertices of a graph, and the read / write, control, and mapping relationships between them are treated as directed edges. The network structure formed by the resulting set of vertices and directed edges serves as a parameter-state association graph describing the potential impact range and logical links of the current anomaly. Finally, the diagnostic feature vectors of parameter and state associations in the target PLC program can be extracted from the parameter-state association graph in the following way: data extraction is performed based on the constructed parameter-state association graph. For each vertex in the graph (i.e., a related parameter or state), the system extracts all historical data within a fixed-length backtracking window before the anomaly occurred from its corresponding runtime sequence database.For continuous variables (e.g., temperature, pressure values), their numerical sequences over time are extracted. For Boolean variables or state variables (e.g., fault flags, mode switches), the time points and directions of state transitions are recorded. Simultaneously, the system records the "depth" of each vertex in the association graph (i.e., its logical distance from the initial fault node) and the type of edges it connects to (data dependency or control dependency). Then, the extracted data is weighted and sorted according to the importance of the vertices (usually determined by feature contribution and logical distance). The weighted numerical sequences, state transition sequences, and related metadata (e.g., vertex identifiers, logical distances) are concatenated and encoded according to a predefined format. The resulting multidimensional array is used as a diagnostic feature vector for subsequent in-depth fault analysis.
[0034] In step 104, when the target PLC program crashes, the complete diagnostic feature vector of the target PLC program before the crash is abnormally evolved and correlated with the final state information at the time of the crash, thereby locating the confidence fault source that caused the target PLC program to crash.
[0035] In some embodiments, the following steps can be used to abnormally evolve and correlate the complete diagnostic feature vector of the target PLC program before the shutdown with the final state information at the time of the shutdown, thereby locating the credible fault source that caused the target PLC program to shut down: Record the final state information of the program at the moment of crash, and obtain a snapshot before and after the failure; Starting from the abnormal parameters and states recorded in the diagnostic feature vector, and ending with the final state information in the snapshots before and after the fault, trace back in reverse in the control logic diagram of the PLC program to find the minimum causal path that can connect the starting abnormality and the ending fault state. The confidence source of the PLC program that caused this crash was determined by identifying all links in the least causal path.
[0036] It should be noted that, in this application, the confidence fault source is the program or hardware component that has been analyzed and determined to be the most likely root cause of the program crash chain reaction; the final state information is snapshot data used to record the critical operating state at the moment of program crash; the snapshots before and after the fault are paired state records used to correlate the abnormal development process with the final fault result; the control logic diagram is a program structure model used to represent the relationship between program instructions, data flow and control flow; and the minimum causal path is an explanatory link with the fewest logical components used to connect the initial abnormal manifestation and the final fault phenomenon.
[0037] In practical implementation, firstly, the final state information at the moment of program crash is recorded to obtain a snapshot before and after the fault. This can be achieved as follows: when the monitoring system detects that the target PLC program has unexpectedly stopped running or the controller has entered a fault state, the crash scene recording process is immediately initiated. The system reads and saves the following key information from the PLC's fault register, system status word, and program execution stack: the identifier of the last executed program organization block or function block when the program stopped, the current value of the main process data register, unprocessed hardware interrupt event code, watchdog timeout flag, and the final latch state of the input / output modules. This information together constitutes the final state information recording the state at the moment of program crash. At the same time, the system retrieves the diagnostic feature vector generated in the last complete monitoring cycle before the crash occurred from the cache. The diagnostic feature vector and final state information are aligned and encapsulated according to a unified time base to form a complete data record containing "features at the end of the abnormal development" and "state at the moment of collapse." This paired data record serves as a snapshot before and after the fault for subsequent root cause analysis. Then, starting from the abnormal parameters and states recorded in the diagnostic feature vector and ending with the final state information in the snapshot before and after the fault, the control logic diagram of the PLC program is traced backward to find the minimum causal path connecting the starting abnormality and the ending fault state. This can be achieved as follows: First, load the control logic diagram of the target PLC program. This diagram uses nodes to represent program instructions or variable operations and directed edges to represent data dependencies or execution order relationships. The analysis process starts from the diagnostic feature vector in the snapshot before and after the fault, extracting all recorded abnormal parameters (e.g., a continuously exceeding temperature value) and abnormal states (e.g., a set alarm flag) as the initial node set for path tracing. Simultaneously, the final state information (e.g., a "main loop timeout" error code) is used as the endpoint target that the path must reach. Subsequently, a reverse breadth-first search is performed in the control logic diagram: starting from each initial abnormal node, the system traces back layer by layer along the reverse direction of the data flow or control flow (i.e., finding the upstream node that affects the current node's value) to identify its direct cause node. During the tracing process, it is determined whether the currently traced node or state can logically explain the occurrence of the final fault state. The system searches for all possible paths that can start from the initial abnormal node, pass through a series of direct causal relationships, and ultimately reach the fault endpoint node, selecting the path with the fewest nodes and the most direct logical relationships. This selected path is taken as the minimal causal path explaining the current crash event. Finally, the system determines the confident fault source that caused the target PLC program to crash by examining all links on the minimal causal path. This can be achieved by: after finding the minimal causal path, the system performs an in-depth analysis of the path. Each link on the path is a possible fault point.The analysis process comprehensively considers the following dimensions: First, it examines the feature contribution of the link in the diagnostic feature vector or the anomalous significance of its associated parameters; second, it analyzes the temporal position of the link on the path, with links closer to the starting point generally being more likely to be the cause; third, it assesses whether the failure of this link can logically and completely explain the anomalies of all subsequent links and the final shutdown state. The system calculates a comprehensive suspicion score for each link on the path, which integrates contribution weight, temporal coefficient, and logical explanatory power. For example, a link located at the starting point of the path, with a high feature contribution, and whose failure (e.g., "input module stuck, causing the signal to remain at a constant high level") can directly cause anomalies in multiple downstream nodes and ultimately trigger a watchdog timeout, will receive a very high comprehensive score; the system identifies the link with the highest comprehensive suspicion score as the credible fault source causing this shutdown and outputs the type of the link (e.g., "specific input channel hardware failure," "a certain program logic defect") and its specific location identifier.
[0038] In another aspect, in some embodiments, this application provides a PLC program shutdown fault diagnosis system, see reference. Figure 3 The figure is a schematic diagram of the structure of a PLC program shutdown fault diagnosis system according to some embodiments of this application. The PLC program shutdown fault diagnosis system includes: a data acquisition module 201, a processing module 202, and an execution module 203, which are described below: The data acquisition module 201 in this application is mainly used to dynamically monitor the program execution process during the operation of the target PLC program and collect multi-dimensional runtime sequence data reflecting the health status of the program. Processing module 202, in this application, is used to extract time-series-based node distribution features and logical association-based pattern association features from the multi-dimensional runtime sequence data, and then perform state evaluation on the target PLC program based on the node distribution features and the pattern association features to obtain the abnormal confidence level of the target PLC program operation. It should be noted that the processing module 202 is also used to perform contribution fusion on the abnormal control parameters in the program execution process according to the feature contribution of each abnormal feature node in the target PLC program when the abnormal confidence is greater than the standard abnormal threshold of the PLC program, so as to obtain the diagnostic feature vector of parameter and state association in the target PLC program. The execution module 203 in this application is mainly used to perform abnormal evolution correlation between the complete diagnostic feature vector of the target PLC program before the crash and the final state information at the time of the crash when the target PLC program crashes, so as to locate the confidence fault source that caused the target PLC program to crash.
[0039] The foregoing has detailed examples of the PLC program shutdown fault diagnosis method and system provided in the embodiments of this application. It is understood that the corresponding device, in order to achieve the above functions, includes hardware structures and / or software modules corresponding to the execution of each function. Those skilled in the art should readily recognize that, in conjunction with the units and algorithm steps of the various examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed by hardware or by computer software driving hardware depends on the specified application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specified application, but such implementation should not be considered beyond the scope of this application.
[0040] In some embodiments, this application also provides a computer device, the computer device including a memory and a processor, the memory for storing a computer program, and the processor for calling and running the computer program from the memory, so that the computer device executes the above-described PLC program shutdown fault diagnosis method.
[0041] In some embodiments, reference Figure 4 The dashed lines in the figure indicate that the unit or module is optional. This figure is a structural schematic diagram of a computer device for implementing a PLC program crash fault diagnosis method according to an embodiment of this application. The PLC program crash fault diagnosis method described in the above embodiments can... Figure 4 The computer device shown is used to implement this, and the computer device includes at least one processor 301, a memory 302 and at least one communication unit 305. The computer device may be a terminal device, a server or a chip.
[0042] Processor 301 can be a general-purpose processor or a special-purpose processor. For example, processor 301 can be a central processing unit (CPU), which can be used to control computer devices, execute software programs, and process data from software programs. The computer device may also include a communication unit 305 for inputting (receiving) and outputting (transmitting) signals.
[0043] For example, the computer device may be a chip, and the communication unit 305 may be the input and / or output circuit of the chip, or the communication unit 305 may be the communication interface of the chip, which may be a component of a terminal device, network device or other device.
[0044] For example, the computer device may be a terminal device or a server, and the communication unit 305 may be a transceiver of the terminal device or the server, or the communication unit 305 may be a transceiver circuit of the terminal device or the server.
[0045] The computer device may include one or more memories 302 storing a program 304. The program 304 can be executed by a processor 301 to generate instructions 303, causing the processor 301 to execute the method described in the above method embodiments according to the instructions 303. Optionally, the memory 302 may also store data (such as a target audit model). Optionally, the processor 301 may also read data stored in the memory 302, which may be stored at the same storage address as the program 304, or it may be stored at a different storage address than the program 304.
[0046] The processor 301 and memory 302 can be configured separately or integrated together, for example, integrated on the system on chip (SOC) of the terminal device.
[0047] It should be understood that each step of the above method embodiment can be completed by hardware logic circuits or software instructions in the processor 301. The processor 301 can be a CPU, a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA), or other programmable logic devices, such as discrete gates, transistor logic devices, or discrete hardware components.
[0048] Those skilled in the art will understand that embodiments of this application can be provided as methods, systems, or computer program products. Therefore, this application can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, this application can take the form of a computer program product embodied on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0049] For example, in some embodiments, this application also provides a computer-readable storage medium storing instructions or code that, when executed on a computer, cause the computer to implement the above-described PLC program shutdown fault diagnosis method.
[0050] Although preferred embodiments of this application have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of this application.
[0051] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. A method for diagnosing PLC program crash faults, characterized in that, Includes the following steps: During the execution of the target PLC program, the program execution process is dynamically monitored, and multi-dimensional runtime sequence data reflecting the health status of the program is collected. Extract time-series-based node distribution features and logical association-based pattern association features from the multi-dimensional runtime sequence data, and then evaluate the state of the target PLC program based on the node distribution features and the pattern association features to obtain the anomaly confidence level of the target PLC program. When the anomaly confidence level is greater than the standard anomaly threshold of the PLC program, the anomaly control parameters in the program execution process are fused according to the feature contribution of each anomaly feature node in the target PLC program to obtain the diagnostic feature vector of parameter and state association in the target PLC program. When the target PLC program crashes, the complete diagnostic feature vector of the target PLC program before the crash is correlated with the final state information at the time of the crash to locate the confidence fault source that caused the target PLC program to crash.
2. The method as described in claim 1, characterized in that, Extracting time-series-based node distribution features and logical association-based pattern association features from the multi-dimensional runtime sequence data specifically includes: Based on the program structure of the target PLC program, multiple execution nodes are determined, and the timing data of each execution node is obtained from the multi-dimensional runtime timing data. Extract the temporal statistical features of each execution node from each time series data, and then determine the node distribution features based on the time series. The conditional probability of execution order and mutual information of execution intervals between execution nodes are calculated to determine the pattern association features based on logical association.
3. The method as described in claim 1, characterized in that, Based on the node distribution characteristics and the pattern association characteristics, the state of the target PLC program is evaluated to obtain the anomaly confidence level of the target PLC program's operation, specifically including: During the normal operation phase of the PLC program, node distribution characteristics and pattern association characteristics are collected, and a benchmark model describing the health status of the program is constructed using a Gaussian mixture model or an autoencoder. Input the node distribution characteristics and pattern association characteristics of each current execution node into the baseline model, and calculate the feature deviation between it and the health status distribution; The anomaly confidence level of the target PLC program execution is determined based on all characteristic deviations.
4. The method as described in claim 1, characterized in that, Based on the feature contribution of each abnormal feature node in the target PLC program, the contribution of abnormal control parameters during program execution is fused to obtain the diagnostic feature vector of parameter and state correlation in the target PLC program, which specifically includes: Determine the feature contribution of each abnormal feature node in the target PLC program; Starting with the abnormal feature node with the highest feature contribution, trace its direct association with input / output parameters, intermediate variables, and device states in the program control logic to obtain the parameter-state association graph; Extract diagnostic feature vectors of parameter and state associations from the parameter-state association diagram in the target PLC program.
5. The method as described in claim 1, characterized in that, By abnormally correlated between the complete diagnostic feature vector of the target PLC program before the shutdown and the final state information at the time of the shutdown, the specific confident fault sources that caused the target PLC program to shut down include: Record the final state information of the program at the moment of crash, and obtain a snapshot before and after the failure; Starting from the abnormal parameters and states recorded in the diagnostic feature vector, and ending with the final state information in the snapshots before and after the fault, trace back in reverse in the control logic diagram of the PLC program to find the minimum causal path that can connect the starting abnormality and the ending fault state. The confidence source of the PLC program that caused this crash was determined by identifying all links in the least causal path.
6. The method as described in claim 1, characterized in that, A non-intrusive online monitoring agent module is used to dynamically monitor the program execution process.
7. The method as described in claim 1, characterized in that, The target PLC program is a structured text based on the IEC 61131-3 standard.
8. A PLC program crash fault diagnosis system, characterized in that, include: The data acquisition module is used to dynamically monitor the program execution process during the operation of the target PLC program and collect multi-dimensional runtime sequence data that reflects the health status of the program. The processing module is used to extract time-series-based node distribution features and logical association-based pattern association features from the multi-dimensional runtime sequence data, and then perform state evaluation on the target PLC program based on the node distribution features and the pattern association features to obtain the abnormal confidence level of the target PLC program. The processing module is also used to perform contribution fusion of abnormal control parameters in the program execution process according to the feature contribution of each abnormal feature node in the target PLC program when the abnormal confidence level is greater than the standard abnormal threshold of the PLC program, so as to obtain a diagnostic feature vector of parameter and state association in the target PLC program. The execution module is used to perform abnormal evolution correlation between the complete diagnostic feature vector of the target PLC program before the crash and the final state information at the time of the crash when the target PLC program crashes, thereby locating the confidence fault source that caused the target PLC program to crash.
9. A computer device, characterized in that, The computer device includes a memory and a processor. The memory is used to store computer programs, and the processor is used to call and run the computer programs from the memory, so that the computer device performs the PLC program shutdown fault diagnosis method according to any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores instructions or code that, when executed on a computer, cause the computer to implement the PLC program shutdown fault diagnosis method as described in any one of claims 1 to 7.