PLC-based fault diagnosis method and device
By obtaining, converting and storing sensor data in PLC, calculating feature values and using decision tree models for troubleshooting, the shortcomings of the PLC system in equipment fault diagnosis are solved, and efficient and accurate fault identification and prediction are achieved.
Patent Information
- Application Number
- CN202510351785.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-24
- Publication Date
- 2025-07-04
AI Technical Summary
PLC systems lack in-depth utilization of real-time data in industrial equipment, and cannot effectively diagnose equipment failure types, resulting in limited diagnostic capabilities.
The sensor data is obtained through PLC, physical quantity type conversion and storage, the characteristic value is calculated, and a pre-trained decision tree fault recognition model is input, and the fault recognition results and trigger alarms are output.
It improves the accuracy and real-time nature of equipment fault diagnosis, reduces noise interference, makes full use of data value, and improves the intelligence level and maintenance efficiency of the equipment.
Smart Images

Figure CN120255470A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of industrial automation control technology, and particularly to a method and device for fault diagnosis based on PLC. Background Art
[0002] Currently, with the advancement of Industry 4.0 and intelligent manufacturing, industrial equipment is developing towards high automation and intelligence. The PLC (Programmable Logic Controller) system, as the core device of industrial automation control, is widely used in various industrial scenarios and is responsible for key tasks such as data acquisition and control logic execution.
[0003] During the operation of industrial equipment, sensors continuously collect numerical values of various physical quantities such as temperature, vibration, and pressure. These data are important bases for equipment fault diagnosis. However, the PLC system only stays at the level of data acquisition and basic control, does not deeply utilize the collected real-time data, lacks the ability to classify and diagnose equipment fault types using these data, and has limited diagnostic capabilities for equipment faults. Summary of the Invention
[0004] Based on this, it is necessary to provide a method and device for fault diagnosis based on PLC for the above technical problems.
[0005] In a first aspect, a method for fault diagnosis based on PLC is provided. The method is applied to a fault diagnosis system, and the system includes a terminal and a Programmable Logic Controller (PLC). The method includes:
[0006] The PLC obtains data of a target device collected by a corresponding connected sensor through at least one data acquisition point;
[0007] According to a preset conversion method, the PLC determines the data as physical quantity values of corresponding physical quantity types and stores the physical quantity values in a circular buffer with a preset time window length;
[0008] Based on the data acquisition point, the PLC determines multiple characteristic values of the physical quantity values in the circular buffer according to a preset duration to determine a period;
[0009] The PLC inputs the multiple characteristic values into a pre-trained decision tree fault recognition model and outputs a fault recognition result of the target device;
[0010] According to the target fault type label of the fault recognition result, the PLC triggers an alarm signal and records a fault log of the target device.
[0011] As an optional implementation manner, the method further includes:
[0012] The PLC obtains data sequences collected by corresponding connected sensors through multiple data acquisition points, and receives fault type labels corresponding to the data in the data sequences sent by the upper computer.
[0013] According to a preset conversion method, the PLC determines the data in the data sequences as physical quantity values of corresponding physical quantity types, and stores the physical quantity values in a circular buffer with a preset time window length.
[0014] Determining a period according to a preset duration, based on the data acquisition points, the PLC determines multiple characteristic values of the physical quantity values in the circular buffer, and stores the multiple characteristic values and the corresponding fault type labels in a table form according to the timestamps of collecting the data sequences.
[0015] The terminal preprocesses the exported table data stored in the PLC, deletes data records containing missing values, and based on the fault type labels when a fault occurs in the data sequences, removes data records within a preset duration threshold before and after the fault type labels, to obtain a data training library for a decision tree fault recognition model.
[0016] As an optional implementation manner, the method further includes:
[0017] The terminal obtains the data training library with a first preset proportional coefficient to obtain a training sample set, where the training sample set includes multiple training samples and sample fault recognition results corresponding to each training sample, the training samples are characteristic values, and the sample fault recognition results are fault type labels corresponding to the characteristic values;
[0018] Based on each training sample and the sample fault recognition result corresponding to each training sample, the terminal constructs an initial decision tree fault recognition model, and optimizes the model depth of the initial decision tree fault recognition model through a pruning technique to obtain the constructed decision tree fault recognition model;
[0019] The terminal converts the constructed decision tree fault recognition model into a rule set and embeds it into the PLC. The PLC converts the rule set into a JSON format configuration file, dynamically loads and parses it through the PLC's script engine, and realizes real-time matching of characteristic values and the rule set in the PLC program.
[0020] As an alternative implementation, based on each of the training samples and the sample fault recognition results corresponding to each of the training samples, the terminal constructs an initial decision tree fault recognition model and optimizes the model depth of the initial decision tree fault recognition model through pruning technology to obtain the constructed decision tree fault recognition model, including:
[0021] (1) Decision tree node initialization: The terminal uses the training sample set as the root node, and the root node contains the feature values of all training samples and their corresponding fault type labels;
[0022] (2) Recursive feature selection and node splitting: The terminal determines the splitting gain values of all features for the data set of the current node to be split, and selects the feature with the largest splitting gain value as the splitting condition; the data set is inherited from the data generated after the parent node is split and contains the feature values and corresponding fault type labels in the parent node data that meet the current splitting condition;
[0023] The terminal divides the data set into a left child node and a right child node according to the splitting condition, and each child node corresponds to a subset of the training sample set;
[0024] (3) Recursive termination condition determination: If the current node to be split meets any of the following conditions, the terminal marks it as a leaf node and outputs the fault type label:
[0025] The proportion of the target fault type in the leaf node is greater than or equal to the preset proportion threshold;
[0026] The number of samples contained in the leaf node is less than or equal to the preset minimum number of samples in the leaf node;
[0027] The current node depth reaches the preset maximum number of layers;
[0028] (4) Pruning optimization: The terminal uses the cost complexity pruning algorithm to calculate the total cost complexity of each subtree according to the pre-stored pruning coefficient, and iteratively removes the subtree with the minimum total cost complexity to obtain the constructed decision tree fault recognition model.
[0029] As an alternative implementation, the method further includes:
[0030] The terminal obtains the data training library with the second preset proportional coefficient to obtain a test sample set, which includes a plurality of test samples and the test fault recognition results corresponding to each of the test samples. The test samples are feature values, and the test fault recognition results are the fault type labels corresponding to the feature values;
[0031] The terminal inputs each of the test samples into the decision tree fault recognition model and outputs a second fault recognition result;
[0032] Based on the test fault identification result and the second fault identification result, the terminal determines the second identification accuracy rate and recall rate of the decision tree fault identification model;
[0033] If the second identification accuracy rate is greater than the preset accuracy rate threshold and the recall rate is greater than the preset recall rate threshold, the terminal determines that the decision tree fault identification model meets the preset construction requirements; otherwise, it determines that the decision tree fault identification model does not meet the preset construction requirements and adjusts the model parameters of the decision tree fault identification model.
[0034] As an optional implementation manner, the eigenvalue includes the mean and median representing the central tendency feature, the variance and standard deviation representing the dispersion degree feature, the skewness and kurtosis representing the distribution form feature, the trend slope representing the change trend feature, and the eigenvalue representing the frequency domain feature obtained by extracting the frequency domain energy distribution through Fourier transform.
[0035] In a second aspect, a device for PLC-based fault diagnosis is provided. The device is applied to a fault diagnosis system, and the system includes a terminal and a programmable logic controller (PLC). The device includes:
[0036] A first acquisition module, configured to enable the PLC to acquire data of a target device collected by a corresponding connected sensor through at least one data acquisition point;
[0037] A first determination module, configured to enable the PLC to determine the data as physical quantity values of corresponding physical quantity types according to a preset conversion method, and store the physical quantity values in a circular buffer with a preset time window length;
[0038] A second determination module, configured to determine a period according to a preset duration, and based on the data acquisition point, enable the PLC to determine multiple eigenvalues of the physical quantity values in the circular buffer;
[0039] A first identification module, configured to enable the PLC to input multiple eigenvalues into a pre-trained decision tree fault identification model and output a fault identification result of the target device;
[0040] A trigger module, configured to enable the PLC to trigger an alarm signal according to the target fault type label of the fault identification result and record a fault log of the target device.
[0041] As an optional implementation manner, the device further includes:
[0042] A second acquisition module, configured to enable the PLC to acquire a data sequence collected by a corresponding connected sensor through multiple data acquisition points and receive a fault type label corresponding to the data in the data sequence sent by a host computer;
[0043] A third determination module, configured to determine, according to a preset conversion method, that the PLC determines the data in the data sequence as physical quantity values of corresponding physical quantity types, and stores the physical quantity values in a circular buffer with a preset time window length;
[0044] A fourth determination module, configured to determine a period according to a preset duration, and based on the data acquisition points, the PLC determines multiple characteristic values of the physical quantity values in the circular buffer, and stores the multiple characteristic values and the corresponding fault type labels in a table form according to the time stamps of collecting the data sequence;
[0045] A preprocessing module, configured to preprocess the table data stored by the PLC exported by the terminal, delete data records containing missing values, and based on the fault type labels when a fault occurs in the data sequence, remove data records within a preset duration threshold before and after the fault type labels, to obtain a data training library for a decision tree fault recognition model.
[0046] As an optional implementation manner, the device further includes:
[0047] A third acquisition module, configured to the terminal acquires the data training library with a first preset proportional coefficient to obtain a training sample set, where the training sample set includes multiple training samples and sample fault recognition results corresponding to each training sample, the training samples are characteristic values, and the sample fault recognition results are fault type labels corresponding to the characteristic values;
[0048] A construction module, configured to based on each training sample and the sample fault recognition result corresponding to each training sample, the terminal constructs an initial decision tree fault recognition model, and optimizes the model depth of the initial decision tree fault recognition model through a pruning technique to obtain the constructed decision tree fault recognition model;
[0049] A conversion module, configured to the terminal converts the constructed decision tree fault recognition model into a rule set and embeds it into the PLC, and the PLC converts the rule set into a JSON format configuration file, which is dynamically loaded and parsed through the script engine of the PLC, and realizes real-time matching of characteristic values and the rule set in the PLC program.
[0050] As an optional implementation manner, the construction module is specifically configured to:
[0051] (1) Initialization of decision tree nodes: The terminal uses the training sample set as the root node, and the root node includes the characteristic values of all training samples and their corresponding fault type labels;
[0052] (2) Recursive Feature Selection and Node Splitting: The terminal determines the splitting gain values of all features for the dataset of the current node to be split, and selects the feature with the largest splitting gain value as the splitting condition; the dataset is inherited from the data generated after the parent node is split and contains the feature values that meet the current splitting condition in the parent node data and the corresponding fault type labels.
[0053] The terminal divides the dataset into a left child node and a right child node according to the splitting condition, and each child node corresponds to a subset of the training sample set.
[0054] (3) Recursive Termination Condition Judgment: If the current node to be split meets any of the following conditions, the terminal marks it as a leaf node and outputs the fault type label:
[0055] The proportion of the target fault type in the leaf node is greater than or equal to the preset proportion threshold.
[0056] The number of samples contained in the leaf node is less than or equal to the preset minimum number of samples in the leaf node.
[0057] The depth of the current node reaches the preset maximum number of layers.
[0058] (4) Pruning Optimization: The terminal adopts the cost complexity pruning algorithm, calculates the total cost complexity of each subtree according to the pre-stored pruning coefficient, and iteratively removes the subtree with the minimum total cost complexity to obtain the constructed decision tree fault recognition model.
[0059] As an optional implementation, the device further includes:
[0060] A fourth acquisition module, configured to enable the terminal to acquire the data training library with a second preset proportional coefficient to obtain a test sample set, where the test sample set includes multiple test samples and the corresponding test fault recognition results for each test sample, the test sample is a feature value, and the test fault recognition result is the fault type label corresponding to the feature value.
[0061] A second recognition module, configured to enable the terminal to input each test sample into the decision tree fault recognition model and output a second fault recognition result.
[0062] A fifth determination module, configured to enable the terminal to determine the second recognition accuracy rate and recall rate of the decision tree fault recognition model according to the test fault recognition result and the second fault recognition result.
[0063] An adjustment module is configured to determine that the decision tree fault identification model meets the preset construction requirements if the second recognition accuracy rate is greater than the preset accuracy rate threshold and the recall rate is greater than the preset recall rate threshold; otherwise, it is determined that the decision tree fault identification model does not meet the preset construction requirements, and the model parameters of the decision tree fault identification model are adjusted.
[0064] As an alternative implementation, the eigenvalue includes the mean and median representing the central tendency features, the variance and standard deviation representing the dispersion degree features, the skewness and kurtosis representing the distribution form features, the trend slope representing the change trend features, and the eigenvalue representing the frequency domain features obtained by extracting the frequency domain energy distribution through Fourier transform.
[0065] In a third aspect, a PLC-based fault diagnosis system is provided. The PLC-based fault diagnosis system includes: the PLC-based fault diagnosis method as described in the first aspect and the PLC-based fault diagnosis device as described in the second aspect.
[0066] The present application provides a PLC-based fault diagnosis method. The technical solutions provided by the embodiments of the present application at least bring the following beneficial effects: The data statistical feature extraction method based on a time window effectively reduces the data volume and noise interference. By calculating various statistical eigenvalues, key information is mined from the data, improving the data processing efficiency and diagnosis accuracy. Combining with the PLC to implement a machine learning model (decision tree fault identification model) improves the intelligence and real-time performance of fault classification diagnosis and prediction. It improves the intelligent level of industrial equipment operation. It fully explores and utilizes the value of sensor data collected by the PLC, solves problems such as large data volume, noise interference, and lack of intelligent diagnosis, provides a reliable fault diagnosis and prediction solution for industrial equipment, and improves equipment maintenance efficiency and production stability.
[0067] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0068] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0069] Figure 1 It is a schematic structural diagram of a PLC-based fault diagnosis system provided by an embodiment of the present application;
[0070] Figure 2Flowchart of a method for PLC-based fault diagnosis provided by an embodiment of the present application;
[0071] Figure 3 Schematic structural diagram of a device for PLC-based fault diagnosis provided by an embodiment of the present application. Detailed implementation manners
[0072] In order to make the objectives, technical solutions and advantages of the present application clearer and more understandable, the present application will be further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0073] The method for PLC-based fault diagnosis provided by the embodiment of the present application can be applied to a system for PLC-based fault diagnosis. As Figure 1 shown, the system for PLC-based fault diagnosis includes a PLC 101, a sensor 102, and a target device 103. The sensor 102 is respectively connected to the PLC 101 and the target device 103.
[0074] The PLC 101 is configured to obtain data of the target device 103 collected by the correspondingly connected sensor 102 through at least one data acquisition point. According to a preset conversion method, the PLC 101 determines the data as physical quantity values of corresponding physical quantity types and stores the physical quantity values in a circular buffer with a preset time window length. According to a preset time period to determine a cycle, based on the data acquisition point, the PLC 101 determines multiple characteristic values of the physical quantity values in the circular buffer. The PLC 101 inputs the multiple characteristic values into a pre-trained decision tree fault recognition model and outputs a fault recognition result of the target device 103. According to the target fault type label of the fault recognition result, the PLC 101 triggers an alarm signal and records a fault log of the target device 103.
[0075] The sensor 102 is configured to collect data during the operation of the target device 103 and send the data to the PLC 101.
[0076] Next, a method for PLC-based fault diagnosis provided by the embodiment of the present application will be described in detail in conjunction with the specific implementation manners. Figure 2 Flowchart of a method for PLC-based fault diagnosis provided by an embodiment of the present application, as Figure 2 shown, the specific steps are as follows:
[0077] Step 201, the PLC obtains data of the target device collected by the correspondingly connected sensor through at least one data acquisition point.
[0078] In implementation, the existing PLC systems mainly focus on real-time data acquisition and the execution of control logic, without making in-depth use of the real-time sensor data collected. They lack the ability to classify and diagnose equipment fault types using these data. For example, for a large amount of data such as temperature and vibration collected, due to the high data acquisition frequency and large data volume, effective storage and subsequent utilization are not carried out, and there is no mature method for feature extraction and analysis, making it impossible to accurately determine whether there is a fault in the equipment and the fault type based on the data characteristics. Therefore, fault diagnosis and analysis can be performed on the target equipment according to the data of the target equipment to determine whether a fault has occurred and the corresponding type of the fault that has occurred, so as to notify the technical personnel to repair the target equipment. Then, it is necessary to first obtain the data of the target equipment at the beginning. The PLC obtains the data of the target equipment collected by the corresponding connected sensors through at least one data acquisition point. Among them, there can be multiple data acquisition points, and the data acquisition points include analog input points AI and pulse input points PI. The analog input point AI can be connected to sensors with analog quantity output such as 4 - 20mA, 0 - 20mA, 0 - 5V, 0 - 10V, etc., and the pulse input point PI can be connected to pulse output type sensors. A sampling period can also be set. The data acquisition point can obtain the data of the target equipment collected by the sensor through the sampling period or can also obtain the data of the target equipment collected by the sensor in real time. Among them, the sampling period can be 100ms.
[0079] Step 202, according to the preset conversion method, the PLC determines the physical quantity value corresponding to the physical quantity type of the data and stores the physical quantity value in a circular buffer with a preset time window length.
[0080] In implementation, after obtaining the current or voltage corresponding to the data of the target equipment through the data acquisition point, it is necessary to determine the physical quantity value corresponding to the physical quantity type of the sensor according to the current or voltage corresponding to the data. The PLC can determine the physical quantity value corresponding to the physical quantity type of the data according to the preset conversion method. Among them, the preset conversion method is the physical quantity value calculation method preset in the PLC, which converts the collected current value or voltage value into the actual physical quantity value. For example, for a temperature sensor with 4 - 20mA output, the current value is converted into the actual temperature value through the built-in algorithm. After obtaining the physical quantity value, it is also necessary to save the physical quantity value, and the physical quantity value can be stored in a circular buffer with a preset time window length. The circular buffer is a circular storage area with a fixed size. Data is written in sequence and wraps around to the beginning to continue storage after reaching the end, ensuring the continuity and timeliness of the data. Among them, the preset time window length can be 30S.
[0081] Step 203, determine the period according to the preset duration. Based on the data acquisition point, the PLC determines multiple characteristic values of the physical quantity values in the circular buffer.
[0082] In implementation, after storing the physical quantity values in the circular buffer, fault diagnosis and analysis can be performed on the target device according to the physical quantity values of the target device to determine whether a fault has occurred and the corresponding fault type of the occurred fault, so that technicians can be notified to repair the target device. By determining the characteristic values of the physical quantity values, the characteristic values of the physical quantity values can reflect whether the target device has a fault. Therefore, it is necessary to first calculate multiple characteristic values of the physical quantity values, and then the occurrence of a fault in the target device can be determined according to the multiple characteristic values. Among them, the characteristic values include the mean and median representing the characteristics of central tendency, the variance and standard deviation representing the characteristics of dispersion degree, the skewness and kurtosis representing the characteristics of distribution form, the trend slope representing the characteristics of change trend, and the characteristic values representing the frequency domain characteristics obtained by extracting the frequency domain energy distribution through Fourier transform. Different target devices have different corresponding characteristic values for the occurrence of faults, so different characteristic values need to be determined. Multiple characteristic values that need to be calculated can be correspondingly set for different data acquisition points. Then, according to the target device to be judged, the corresponding data acquisition point is selected to determine multiple characteristic values of the physical quantity values in the circular buffer. The data in the circular buffer will be overwritten after the preset time window length, so it is necessary to determine the period according to the preset duration. Based on the data acquisition point, the PLC determines multiple characteristic values of the physical quantity values in the circular buffer. Among them, the period duration of determining the period according to the preset duration is less than the preset time window length, so as to ensure that the data of the target device collected will not be wasted and the data will not be missing. For example, the period duration of determining the period according to the preset duration can be 20S, and the ratio of the period duration of determining the period according to the preset duration to the preset time window length can be between 1 / 3 - 1 / 10, so that both the data can be ensured not to be overwritten and the characteristic values can be determined in a relatively short time.
[0083] Furthermore, some real-time data can also be combined during data storage, and this part of real-time data is also used to participate in the training of the algorithm model, which can realize the prediction of time series data. For example, in the form of a sliding window, the latest part of real-time data is incorporated into the training sample set, and the decision tree fault recognition model is continuously updated to adapt to the dynamic changes of the device operation state and improve the accuracy and timeliness of fault prediction.
[0084] Step 204, the PLC inputs multiple characteristic values into the pre-trained decision tree fault recognition model and outputs the fault recognition result of the target device.
[0085] In implementation, after determining multiple characteristic values of the target device, the PLC inputs the multiple characteristic values into a pre-trained decision tree fault identification model to output a fault identification result of the target device. When the target device has no fault, the fault identification result is a label of no fault; when the target device has a fault, the fault identification result is a target fault type label of the target fault type of the target device. During the training process of the decision tree fault identification model, when the selected characteristic value cannot reflect whether the device has a fault, other characteristic values can be selected for testing.
[0086] Furthermore, the decision tree fault identification model can also be replaced by a neural network model or an SVM (support vector machines) model. For example, the neural network model is a BP neural network, a convolutional neural network, etc. The neural network model can also be used for fault classification diagnosis. The neural network has a powerful non-linear mapping ability and can learn more complex fault patterns. However, the training computational complexity of the neural network is relatively large, and reasonable selection and optimization need to be carried out according to the computing resources of the PLC. For example, lightweight neural network architectures or model compression techniques can be adopted. The SVM model is also a feasible alternative. The SVM model has good performance in dealing with small sample and non-linear problems. By constructing an appropriate kernel function, the fault data can be classified. However, the parameter selection and optimization of the SVM model are relatively complex and require certain experience and skills. An automated parameter adjustment tool can be used to improve the efficiency.
[0087] Step 205: According to the target fault type label of the fault identification result, the PLC triggers an alarm signal and records the fault log of the target device.
[0088] In implementation, after obtaining the fault identification result, it is judged whether the target device has a fault according to the fault identification result. If the target device has a fault, then according to the target fault type label in the fault identification result, the PLC triggers an alarm signal and records the fault log of the target device. Among them, the fault log includes a timestamp, the target fault type, and the corresponding fault description information.
[0089] As an example, a case of bearing fault diagnosis for an industrial fan. The industrial fan is a key device in the production system, and the operating state of its bearings is directly related to the reliability of the device and production efficiency. To achieve real-time monitoring and fault classification diagnosis of the bearings, data is collected through vibration and temperature sensors, and eigenvalue determination and embedded inference of the decision tree fault recognition model are performed through time windows to achieve efficient diagnosis of the bearing state. (1) Data collection by sensors: Vibration sensors and temperature sensors are required. The vibration sensor has a range of 0 - 5g and outputs a 4 - 20mA signal. The temperature sensor has a range of 0 - 100 °C and outputs a 4 - 20mA signal. The signals of both sensors are connected to the analog input channels of the PLC, that is, the AI points. (2) Sampling period and buffer configuration: The sampling period is set to 100 ms to ensure the collection of high-frequency data. A circular buffer is configured to store data for a 30-second time window, corresponding to 300 data points. The buffer uses a circular storage structure, and the latest collected data overwrites the oldest data. Sampling data examples: Vibration (g): 0.5, 0.6, 0.65, 0.7, 0.8, 0.9, 1.0, 1.1, 1.15, 1.2, 1.25, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.85, 1.9, 2.0.... etc.; Temperature (°C): 45.0, 45.5, 46.0, 46.2, 46.5, 47.0, 47.5, 48.0, 48.5, 49.0, 49.5, 50.0, 51.0, 52.0, 53.0, 54.0, 55.0, 55.5, 56.0, 57.0.... etc. (3) Feature calculation: The preset duration for feature calculation is determined as 20 seconds for each cycle, and the eigenvalues are calculated for the data in the circular buffer once. The results are used for model inference. The calculated eigenvalues are set as follows: the mean value of the vibration feature, the maximum value of the temperature feature, and the trend slope. The calculated eigenvalues are: vibration mean 0.85g, temperature maximum 70.0 °C, and temperature trend slope 2.5 °C / s. The PLC calculates the eigenvalues every 20 seconds and inputs the calculated eigenvalues into the decision tree fault recognition model to output the fault recognition result, achieving real-time fault diagnosis. Among them, the fault type labels include 0 - normal, 1 - bearing wear, 2 - insufficient lubrication, and 3 - bearing looseness. When the target fault type label in the fault recognition result is 1, 2, or 3, the PLC triggers an alarm signal and records the fault log of the target device. The fault log is |timestamp|fault label|fault description information|, |2024-01-01 00:00:20|1|bearing wear|. In this way, the data collection and feature calculation periods are short, the fault diagnosis delay is less than 30 seconds, and it has real-time performance. The decision tree fault recognition model is based on the determined eigenvalues, the noise interference is significantly reduced, and the misjudgment rate is less than 5%, having accuracy. There is no need to add hardware devices, the algorithm is directly embedded in the PLC, with low deployment cost and convenience.Through this method, the fault classification diagnosis of industrial fan bearings realizes integrated and automated processing from raw data acquisition to fault category output, providing reliable support for the intelligent maintenance of industrial equipment.
[0090] Furthermore, according to the fault identification result, it is judged whether the target device has a fault. If the target device has no fault, the label in the fault identification result is no fault.
[0091] Furthermore, before constructing the decision tree fault identification model, it is necessary to first obtain the data training library of the decision tree fault identification model, and then the decision tree fault identification model can be constructed and tested according to the data training library. The specific process is as follows:
[0092] Step 1, the PLC obtains the data sequence collected by the corresponding connected sensors through multiple data acquisition points, and receives the fault type labels corresponding to the data in the data sequence sent by the upper computer.
[0093] In implementation, when obtaining the data training library of the decision tree fault identification model, the PLC obtains the data sequence collected by the corresponding connected sensors through multiple data acquisition points. The data acquisition points include analog input points AI and pulse input points PI. The analog input point AI can access sensors with analog quantity output such as 4 - 20mA, 0 - 20mA, 0 - 5V, 0 - 10V, etc., and the pulse input point PI can access sensors with pulse output. There can be multiple data acquisition points. When on-site personnel identify the corresponding fault type, the fault type label is sent to the PLC by the upper computer, and the PLC receives the fault type label corresponding to the data in the data sequence sent by the upper computer. Among them, the default type is no fault at the beginning.
[0094] Step 2, according to the preset conversion method, the PLC determines the data in the data sequence as the physical quantity values of the corresponding physical quantity types, and stores the physical quantity values in a circular buffer with a preset time window length.
[0095] In implementation, after the PLC receives the data sequence of the target device, it determines the data in the data sequence as the physical quantity values of the corresponding physical quantity types according to the preset conversion method. Among them, the preset conversion method is the physical quantity value calculation method preset in the PLC, which converts the collected current value or voltage value into the actual physical quantity value. For example, for a temperature sensor with 4 - 20mA output, the current value is converted into the actual temperature value through the built-in algorithm. After obtaining the physical quantity value, it is also necessary to save the physical quantity value. The physical quantity value can be stored in a circular buffer with a preset time window length. The circular buffer is a circular storage area with a fixed size. Data is written in sequence, and after reaching the end, it wraps around to the beginning and continues to be stored to ensure the continuity and timeliness of the data. Among them, the preset time window length can be 30S.
[0096] Step 3: Determine the period according to the preset duration. Based on the data acquisition points, the PLC determines multiple characteristic values of the physical quantity values in the cyclic buffer, and stores the multiple characteristic values and the corresponding fault type labels in tabular form according to the timestamps of the acquired data sequence.
[0097] In implementation, determine the period according to the preset duration. Based on the data acquisition points, the PLC determines multiple characteristic values of the physical quantity values in the cyclic buffer. Store the multiple characteristic values and the corresponding fault type labels in tabular form according to the timestamps of the acquired data sequence. Among them, the period determined by the preset duration can be 20S. The physical quantity type, characteristic values, fault type labels, and timestamps can also be stored in the FLASH memory uniformly, so as to achieve persistent storage. The timestamp accurately records the data generation moment, which is convenient for subsequent timing analysis and data screening.
[0098] For example, one row of the table refers to a complete data record, that is, a storage item corresponding to a timestamp. The column data are the characteristic values of each physical quantity value and the fault type, such as [temperature mean, temperature standard deviation] or [humidity maximum, humidity mean, humidity median] or fault type labels [no fault, short circuit fault, overheat fault], etc. For example: | Timestamp | Temperature Mean | Temperature Standard Deviation | Humidity Maximum | Humidity Mean | Humidity Median | No Fault | Short Circuit Fault | Overheat Fault |, | 2024-01-01 00:00:00 | 25.0 | 2.0 | 60.0 | 50.0 | 48.0 | 1 | 0 | 0 |, | 2024-01-01 01:00:00 | 26.0 | 1.5 | 62.0 | 52.0 | 50.0 | 0 | 1 | 0 |. Organizing data in this way is conducive to data processing using the python library at the terminal. For example, in the decision tree fault identification model, the characteristic value variables and the target fault type need to be separated. Among them, the terminal can be a computer terminal. Assuming the data has been stored in the data DataFrame, the python code can separate the target variable and the characteristics as follows: features = data[["Temperature Mean", "Temperature Standard Deviation", "Humidity Maximum", "Humidity Mean", "Humidity Median"]], target = data[["No Fault", "Short Circuit Fault", "Overheat Fault"]].
[0099] Step 4: The terminal preprocesses the tabular data stored in the exported PLC, deletes the data records containing missing values, and based on the fault type labels when a fault occurs in the data sequence, removes the data records within the preset duration threshold before and after the fault type labels, to obtain the data training library for the decision tree fault identification model.
[0100] In implementation, after storing multiple eigenvalue and corresponding fault type labels in tabular form, before constructing a decision tree fault recognition model, it is also necessary to preprocess the physical quantity values and delete the data records containing physical quantity values with missing values. Among them, the data records with missing values can be deleted by using the pandas library of the python language or manually. Since, when the target device changes from normal and fault-free to faulty, and from faulty to normal and fault-free, some of the intermediate transition physical quantity values are normal and some are fault data, which cannot be clearly separated and cannot be used to construct a decision tree fault recognition model. Therefore, it is also necessary to delete the data records when the target device changes from normal and fault-free to faulty, and from faulty to normal and fault-free. So, based on the fault type labels when a fault occurs in the data sequence, the data records within the preset time threshold before and after the fault type labels are removed. Among them, the range of the preset time threshold can be from 5 minutes to 10 minutes. In this way, the data training library for the decision tree fault recognition model is obtained.
[0101] Furthermore, the specific steps in the process of constructing the decision tree fault recognition model are as follows:
[0102] Step A, the terminal obtains a data training library with a first preset proportional coefficient to get a training sample set. The training sample set includes multiple training samples and the corresponding sample fault recognition results for each training sample. The training samples are eigenvalues, and the sample fault recognition results are the fault type labels corresponding to the eigenvalues.
[0103] In implementation, the terminal obtains a data training library with a first preset proportional coefficient to get the training sample set of the decision tree fault recognition model. The value range of the first preset proportional coefficient can be from 70% to 80%. The training sample set includes multiple training samples and the corresponding sample fault recognition results for each training sample. The training samples are eigenvalues, and the sample fault recognition results are the fault type labels corresponding to the eigenvalues.
[0104] Step B, based on each training sample and the corresponding sample fault recognition result for each training sample, the terminal constructs an initial decision tree fault recognition model and optimizes the model depth of the initial decision tree fault recognition model through pruning technology to obtain the constructed decision tree fault recognition model.
[0105] In the implementation, based on each training sample and the sample fault recognition result corresponding to each training sample, the terminal constructs an initial decision tree fault recognition model. The initial decision tree fault recognition model can be constructed based on each training sample and the sample fault recognition result corresponding to each training sample by a decision tree algorithm, wherein the decision tree algorithm can be a scikit-learn library or an XGBoost library of Python. Then, the model depth of the initial decision tree fault recognition model is optimized by pruning technology to obtain a constructed decision tree fault recognition model, so that the depth overfitting of the initial decision tree fault recognition model can be prevented.
[0106] Specifically, the specific process of executing step B is as follows:
[0107] (1) Decision tree node initialization: The terminal takes the training sample set as the root node, which contains the feature values of all training samples and their corresponding fault type labels.
[0108] In implementation, when constructing the initial decision tree fault identification model, the nodes of the decision tree need to be initialized first, starting from the root node. The terminal uses the training sample set as the root node, and the root node contains the feature values of all training samples and their corresponding fault type labels.
[0109] (2) Recursive feature selection and node splitting: The terminal determines the splitting gain values of all features in the data set of the current node to be split, and selects the feature with the largest splitting gain value as the splitting condition; the data set is inherited from the parent node after the split, and contains the feature values and corresponding fault type labels in the parent node data that meet the current splitting condition.
[0110] The terminal divides the data set into left child nodes and right child nodes according to the splitting condition, and each child node corresponds to a subset of the training sample set.
[0111] In the implementation, the decision tree is split from the root node. The terminal determines the splitting gain values of all features in the training sample set of the root node, and compares the splitting gain values of all features to determine the feature with the largest splitting gain value as the splitting condition. According to the splitting condition, all training samples in the training sample set are divided into two subsets, namely the left child node and the right child node, and each child node corresponds to a subset of the training sample set. Then, according to the left child node and the right child node, the decision tree continues to split. The terminal is executed in a loop to determine the splitting gain values of all features of the data set of the current node to be split, and selects the feature with the largest splitting gain value as the splitting condition. The terminal divides the data set into the left child node and the right child node according to the splitting condition. Among them, the data set is inherited from the parent node after the splitting, and contains the feature values and corresponding fault type labels in the parent node data that meet the current splitting conditions. Until the current node to be split meets the recursive termination condition, the construction of the fault identification model representing the initial decision tree is completed.
[0112] (3) Determination of recursive termination condition: If the current node to be split meets any of the following conditions, the terminal is marked as a leaf node and the fault type label is output:
[0113] The proportion of the target fault type in the leaf node is greater than or equal to the preset proportion threshold;
[0114] The number of samples contained in the leaf node is less than or equal to the preset minimum number of samples in a leaf node;
[0115] The depth of the current node reaches the preset maximum number of layers.
[0116] In implementation, based on the training sample set, recursive feature selection and node splitting start from the root node. The root node divides the training samples in the training sample set into a left child node and a right child node, and then continues with node splitting. Determine the splitting gain value of the next splitting node, select the feature with the largest splitting gain value in the data set as the splitting condition, and continue to divide the data set into a left child node and a right child node. Repeat node splitting until the decision tree is constructed. The leaf nodes of the decision tree are determined, and the leaf nodes represent the final fault type classification. If the current node to be split meets any of the following recursive termination conditions, it means the initial decision tree construction is completed. The terminal is marked as a leaf node and the fault type label is output: The proportion of the target fault type in the leaf node is greater than or equal to the preset proportion threshold; The number of samples contained in the leaf node is less than or equal to the preset minimum number of samples in a leaf node; The depth of the current node reaches the preset maximum number of layers. Among them, the preset proportion threshold can be 95%, the range of the preset minimum number of samples in a leaf node can be from 10 to 50, and the range of the preset maximum number of layers can be from 5 to 10.
[0117] (4) Pruning optimization: The terminal adopts the cost complexity pruning algorithm, calculates the total cost complexity of each subtree according to the pre-stored pruning coefficient, and iteratively removes the subtree with the minimum total cost complexity to obtain the constructed decision tree fault recognition model.
[0118] In implementation, after the initial decision tree fault recognition model is constructed, pruning technology can prevent the decision tree from overfitting and improve the generalization ability of the model. The terminal adopts the cost complexity pruning algorithm, calculates the total cost complexity of each subtree according to the pre-stored pruning coefficient, and iteratively removes the subtree with the minimum total cost complexity to obtain the constructed decision tree fault recognition model. Among them, the range of the pre-stored pruning coefficient can be between 0.01 and 0.1. In this way, the branches that contribute nothing to the generalization performance of the initial decision tree fault recognition model are removed through pruning technology, and the constructed decision tree fault recognition model is obtained.
[0119] A decision tree is a classification model based on a tree structure. By gradually dividing the features of the training sample set, a decision tree structure is constructed. In the present invention, a decision tree is constructed according to the characteristic values of sensor data, such as the maximum temperature, vibration mean value and other features. Each node in the decision tree represents a feature judgment condition, the branches represent different judgment results, and the leaf nodes represent the final classified fault types. The advantages of the decision tree algorithm are easy to understand and interpret, relatively low computational complexity, and suitable for industrial scenarios with high real-time requirements. At the same time, pruning techniques can be used to prevent the decision tree from overfitting and improve the generalization ability of the model. Pruning operations include pre-pruning and post-pruning. Pre-pruning is to stop growing in advance during the construction of the decision tree. Post-pruning is to prune the decision tree after construction is completed. Whether to prune is determined by evaluating indicators such as the purity of nodes and the number of samples to optimize the model structure and improve diagnostic accuracy.
[0120] Step C, the terminal converts the constructed decision tree fault recognition model into a rule set and embeds it into the PLC. The PLC converts the rule set into a JSON format configuration file, which is dynamically loaded and parsed through the PLC's script engine to achieve real-time matching of feature values and the rule set in the PLC program.
[0121] In implementation, after the decision tree fault recognition model is constructed, it needs to be deployed to the PLC. The terminal extracts the decision tree fault recognition model as a rule set, and the PLC converts the rule set into a JSON format configuration file. In the PLC program, the decision tree fault recognition model structure is directly converted according to if-else or dynamically loaded, that is, dynamically parsed through the JSON data set to achieve real-time matching of feature values and the rule set in the PLC program.
[0122] For example, the if-else logic code converted to C code is as follows:
[0123] if (maximum temperature > 65.0) { if (vibration mean value > 0.9) return 1; / / Bearing wear else return 2; / / Lubrication shortage} else { if (temperature trend slope > 2.0) return 3; / / Bearing vibration else return 0; / / Normal.
[0124] Furthermore, after the model is constructed, the model needs to be tested to determine whether the model is constructed successfully. The specific steps are as follows:
[0125] Step D, the terminal obtains a data training library with a second preset proportional coefficient to obtain a test sample set. The test sample set includes multiple test samples and the corresponding test fault recognition results for each test sample. The test samples are feature values, and the test fault recognition results are the fault type labels corresponding to the feature values.
[0126] In implementation, the terminal obtains a data training library with a second preset proportional coefficient to obtain a test sample set for the decision tree fault identification model. The value range of the second preset proportional coefficient can be from 20% to 30%. The test sample set includes multiple test samples and the corresponding test fault identification results. The test samples are eigenvalue, and the test fault identification results are the fault type labels corresponding to the eigenvalues. In the subsequent steps, the constructed decision tree fault identification model is tested using the test sample set to determine whether the decision tree fault identification model is constructed successfully.
[0127] Step E, the terminal inputs each test sample into the decision tree fault identification model and outputs a second fault identification result.
[0128] In implementation, the terminal inputs each test sample into the decision tree fault identification model and outputs a second fault identification result. Subsequently, it can be determined whether the decision tree fault identification model accurately identifies based on the second fault identification result.
[0129] Step F, based on the test fault identification results and the second fault identification results, the terminal determines the second identification accuracy rate and recall rate of the decision tree fault identification model.
[0130] In implementation, based on the test fault identification results and the second fault identification results, the terminal determines the second identification accuracy rate and recall rate of the decision tree fault identification model. Among them, the second identification accuracy rate is the ratio of the number of correctly identified samples to the total number of test samples, and the recall rate is the ratio of the number of correctly identified fault samples to the number of actual fault samples. Subsequently, it can be determined whether the decision tree fault identification model is constructed successfully based on the second identification accuracy rate and recall rate.
[0131] Step G, if the second identification accuracy rate is greater than the preset accuracy rate threshold and the recall rate is greater than the preset recall rate threshold, then the terminal determines that the decision tree fault identification model meets the preset construction requirements; otherwise, it determines that the decision tree fault identification model does not meet the preset construction requirements and adjusts the model parameters of the decision tree fault identification model.
[0132] In implementation, the second identification accuracy rate is compared with the preset accuracy rate threshold, and the recall rate is compared with the preset recall rate threshold. If the second identification accuracy rate is greater than the preset accuracy rate threshold and the recall rate is greater than the preset recall rate threshold, then the terminal determines that the decision tree fault identification model meets the preset construction requirements. Among them, the preset accuracy rate threshold can be 95%, and the preset recall rate threshold can be 90%. If either the second identification accuracy rate or the recall rate fails to meet the standard, it is determined that the decision tree fault identification model does not meet the preset construction requirements, and the model parameters of the decision tree fault identification model are adjusted. Among them, the model parameters can be the tree depth or the number of the training sample set. It is also possible to readjust the eigenvalue selection strategy or optimize the data preprocessing process and then train again.
[0133] In the prior art, there is a lack of in-depth mining and utilization of data: existing PLCs only use the collected data to execute control logic, without fully utilizing the precious data accumulated in the production scenario, and no valuable information is mined from the massive data. Large data volume and complex processing: In the prior art, the data is not further utilized. Because the PLC has a high acquisition frequency, the amount of sensor data collected is huge. Directly transmitting and real-time analyzing this data will impose a heavy computational burden on the system, reduce the response speed, and affect the real-time performance of the system. Data noise interference: Sensor data is vulnerable to noise, resulting in a relatively high misjudgment rate of the fault classification and diagnosis model. Lack of intelligent diagnosis: Existing PLCs rely on simple threshold judgments or manually set logical rules, making it difficult to handle complex and diverse equipment fault states, unable to automatically learn and identify new fault modes, and having poor flexibility and accuracy.
[0134] The embodiment of the present application provides a method for fault diagnosis based on PLC, including: efficient data processing and utilization: reducing the data processing burden, replacing the original data input by calculating eigenvalues, significantly reducing the data volume and computational complexity, improving the system processing efficiency and response speed, and at the same time not reducing the feature information reflected by the data, fully utilizing the data value. Accurate fault diagnosis: improving the diagnosis accuracy, the eigenvalues based on the time-window data can effectively smooth the noise interference, enabling the decision tree fault identification model to more accurately identify or predict the equipment fault type, reducing the misjudgment rate, and providing a reliable basis for equipment maintenance. Powerful real-time diagnosis ability: strong real-time performance, relying on the embedded computing ability of the PLC, performing feature extraction and fault diagnosis in real time during the data acquisition process, timely outputting the diagnosis result, realizing efficient real-time fault diagnosis and prediction, being able to quickly respond to equipment faults, and reducing production losses. Convenient deployment and application: easy to deploy, without additional hardware devices, directly deploying the algorithm model in the existing PLC system, fully utilizing the PLC resources, reducing costs, being easy to promote and apply in the industrial environment, and facilitating the intelligent upgrade and transformation of enterprise equipment. The present invention effectively solves the problems of large data volume, serious noise interference, and poor real-time performance of fault identification by implementing time-window statistical feature extraction and fault diagnosis in the PLC, providing an efficient, accurate, and easy-to-deploy fault diagnosis and prediction solution for industrial equipment.
[0135] It should be understood that although Figure 2 the steps in the flowchart of Figure 2At least a part of the steps therein may include multiple steps or multiple stages. These steps or stages are not necessarily executed and completed at the same moment, but can be executed at different moments. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turns with at least a part of other steps or steps or stages in other steps.
[0136] It can be understood that for the same / similar parts among the various embodiments of the above methods in this specification, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. For the relevant parts, reference can be made to the descriptions of other method embodiments.
[0137] The embodiment of the present application also provides a device for PLC-based fault diagnosis, as Figure 3 shown. The device includes:
[0138] A first acquisition module 301, configured to enable the PLC to acquire data of a target device collected by a corresponding connected sensor through at least one data acquisition point;
[0139] A first determination module 302, configured to enable the PLC to determine the data as a physical quantity value of a corresponding physical quantity type according to a preset conversion method, and store the physical quantity value in a circular buffer with a preset time window length;
[0140] A second determination module 303, configured to determine a period according to a preset duration, and based on the data acquisition point, enable the PLC to determine multiple characteristic values of the physical quantity values in the circular buffer;
[0141] A first identification module 304, configured to enable the PLC to input multiple characteristic values into a pre-trained decision tree fault identification model, and output a fault identification result of the target device;
[0142] A trigger module 305, configured to enable the PLC to trigger an alarm signal according to a target fault type label of the fault identification result, and record a fault log of the target device.
[0143] As an optional implementation manner, the device further includes:
[0144] A second acquisition module, configured to enable the PLC to acquire a data sequence collected by a corresponding connected sensor through multiple data acquisition points, and receive a fault type label corresponding to the data in the data sequence sent by a host computer;
[0145] A third determination module, configured to enable the PLC to determine the data in the data sequence as a physical quantity value of a corresponding physical quantity type according to a preset conversion method, and store the physical quantity value in a circular buffer with a preset time window length;
[0146] A fourth determination module, configured to determine a period according to a preset duration, and based on the data acquisition points, the PLC determines multiple characteristic values of the physical quantity values in the cyclic buffer, and stores the multiple characteristic values and the corresponding fault type labels in a table form according to the timestamps of the collected data sequence;
[0147] A preprocessing module, configured to preprocess the table data stored in the PLC exported by the terminal, delete data records containing missing values, and based on the fault type labels when a fault occurs in the data sequence, remove data records within a preset duration threshold before and after the fault type labels, to obtain a data training library for a decision tree fault recognition model.
[0148] As an optional implementation manner, the device further includes:
[0149] A third acquisition module, configured to enable the terminal to acquire the data training library with a first preset proportional coefficient to obtain a training sample set, where the training sample set includes multiple training samples and the corresponding sample fault recognition results for each training sample, the training samples are characteristic values, and the sample fault recognition results are the fault type labels corresponding to the characteristic values;
[0150] A construction module, configured to enable the terminal to construct an initial decision tree fault recognition model based on each training sample and the corresponding sample fault recognition result for each training sample, and optimize the model depth of the initial decision tree fault recognition model through pruning technology to obtain the constructed decision tree fault recognition model;
[0151] A conversion module, configured to enable the terminal to convert the constructed decision tree fault recognition model into a rule set and embed it into the PLC, and the PLC converts the rule set into a JSON format configuration file, which is dynamically loaded and parsed through the script engine of the PLC, and realizes real-time matching of characteristic values and the rule set in the PLC program.
[0152] As an optional implementation manner, the construction module is specifically configured to:
[0153] (1) Decision tree node initialization: The terminal uses the training sample set as the root node, and the root node contains the characteristic values of all training samples and their corresponding fault type labels;
[0154] (2) Recursive feature selection and node splitting: The terminal determines the splitting gain values of all features for the data set of the currently to-be-split node, and selects the feature with the largest splitting gain value as the splitting condition; the data set is inherited from the data of the parent node after splitting and contains the characteristic values and corresponding fault type labels in the parent node data that meet the current splitting condition;
[0155] The terminal divides the data set into a left child node and a right child node according to the splitting condition, and each child node corresponds to a subset of the training sample set;
[0156] (3) Determination of recursive termination condition: If the currently to-be-split node meets any of the following conditions, the terminal marks it as a leaf node and outputs a fault type label:
[0157] The proportion of the target fault type in the leaf node is greater than or equal to a preset proportion threshold;
[0158] The number of samples included in the leaf node is less than or equal to a preset minimum number of samples in the leaf node;
[0159] The depth of the current node reaches a preset maximum number of layers;
[0160] (4) Pruning optimization: The terminal adopts a cost complexity pruning algorithm, calculates the total cost complexity of each subtree according to the pre-stored pruning coefficient, and iteratively removes the subtree with the minimum total cost complexity to obtain a constructed decision tree fault recognition model.
[0161] As an optional implementation manner, the device further includes:
[0162] A fourth acquisition module, configured to enable the terminal to acquire the data training library with a second preset proportional coefficient to obtain a test sample set, where the test sample set includes a plurality of test samples and corresponding test fault recognition results for each test sample, the test sample is a feature value, and the test fault recognition result is a fault type label corresponding to the feature value;
[0163] A second recognition module, configured to enable the terminal to input each test sample into the decision tree fault recognition model and output a second fault recognition result;
[0164] A fifth determination module, configured to enable the terminal to determine the second recognition accuracy rate and recall rate of the decision tree fault recognition model according to the test fault recognition result and the second fault recognition result;
[0165] An adjustment module, configured to determine that the decision tree fault recognition model meets the preset construction requirements if the second recognition accuracy rate is greater than a preset accuracy rate threshold and the recall rate is greater than a preset recall rate threshold, otherwise, determine that the decision tree fault recognition model does not meet the preset construction requirements and adjust the model parameters of the decision tree fault recognition model.
[0166] As an alternative embodiment, the eigenvalue includes the mean and median representing the central tendency characteristics, the variance and standard deviation representing the dispersion degree characteristics, the skewness and kurtosis representing the distribution form characteristics, the trend slope representing the change trend characteristics, and the eigenvalue representing the frequency domain characteristics obtained by extracting the frequency domain energy distribution through Fourier transform.
[0167] The embodiment of the present application provides a device for fault diagnosis based on PLC, with efficient data processing and utilization: reducing the data processing burden, replacing the original data input by calculating eigenvalues, significantly reducing the data volume and computational complexity, improving the system processing efficiency and response speed, and at the same time not reducing the characteristic information reflected by the data, making full use of the data value. Accurate fault diagnosis: improving the diagnosis accuracy, the eigenvalues based on the time window data can effectively smooth the noise interference, enabling the decision tree fault recognition model to more accurately identify or predict the equipment fault type, reducing the misjudgment rate, and providing a reliable basis for equipment maintenance. Powerful real-time diagnosis ability: strong real-time performance, relying on the embedded computing power of PLC, performing feature extraction and fault diagnosis in real time during the data acquisition process, timely outputting the diagnosis results, realizing efficient real-time fault diagnosis and prediction, being able to quickly respond to equipment faults, and reducing production losses. Convenient deployment and application: easy to deploy, without additional hardware devices, directly deploying the algorithm model in the existing PLC system, making full use of the PLC resources, reducing costs, being easy to popularize and apply in the industrial environment, and facilitating the intelligent upgrade and transformation of enterprise equipment. The present invention effectively solves the problems of large data volume, serious noise interference and poor real-time fault recognition by implementing time window statistical feature extraction and fault diagnosis in PLC, and provides an efficient, accurate and easy-to-deploy fault diagnosis and prediction solution for industrial equipment.
[0168] The above embodiments only represent several implementation manners of the present application, and the description thereof is relatively specific and detailed, but it should not be construed as a limitation on the scope of the invention patent. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the appended claims.
Claims
1. A method for fault diagnosis based on PLC, characterized in that, The method is applied to a fault diagnosis system, which includes a terminal and a programmable logic controller (PLC). The method includes: The PLC obtains data of a target device collected by sensors connected thereto through at least one data acquisition point; According to a preset conversion method, the PLC determines the data as a physical quantity value of a corresponding physical quantity type and stores the physical quantity value in a circular buffer with a preset time window length; According to a preset time period, based on the data acquisition point, the PLC determines multiple characteristic values of the physical quantity value in the circular buffer; The PLC inputs the multiple characteristic values into a pre-trained decision tree fault recognition model and outputs a fault recognition result of the target device; According to the target fault type label of the fault recognition result, the PLC triggers an alarm signal and records a fault log of the target device.
2. The method according to claim 1, wherein The method further includes: The PLC obtains a data sequence collected by sensors connected thereto through multiple data acquisition points and receives a fault type label corresponding to the data in the data sequence sent by a host computer; According to a preset conversion method, the PLC determines the data in the data sequence as a physical quantity value of a corresponding physical quantity type and stores the physical quantity value in a circular buffer with a preset time window length; According to a preset time period, based on the data acquisition point, the PLC determines multiple characteristic values of the physical quantity value in the circular buffer and stores the multiple characteristic values and the corresponding fault type labels in a table form according to the time stamp of the data sequence acquisition; The terminal preprocesses the exported table data stored in the PLC, deletes data records containing missing values, and removes data records within a preset time threshold before and after the fault type label when a fault occurs in the data sequence, to obtain a data training library for the decision tree fault recognition model.
3. The method according to claim 2, wherein The method further includes: The terminal obtains the data training library with a first preset proportional coefficient to obtain a training sample set, which includes multiple training samples and a sample fault recognition result corresponding to each training sample. The training sample is a characteristic value, and the sample fault recognition result is the fault type label corresponding to the characteristic value; Based on each training sample and the sample fault recognition result corresponding to each training sample, the terminal constructs an initial decision tree fault recognition model and optimizes the model depth of the initial decision tree fault recognition model through a pruning technique to obtain the constructed decision tree fault recognition model; The terminal converts the constructed decision tree fault recognition model into a rule set and embeds it into the PLC. The PLC converts the rule set into a JSON format configuration file, dynamically loads and parses it through the PLC's script engine, and realizes real-time matching of characteristic values and the rule set in the PLC program.
4. The method according to claim 3, wherein Based on each of the training samples and the corresponding sample fault identification results, the terminal constructs an initial decision tree fault identification model and optimizes the model depth of the initial decision tree fault identification model through pruning techniques to obtain the constructed decision tree fault identification model, including: (1) Decision tree node initialization: The terminal uses the training sample set as the root node, and the root node contains the feature values of all training samples and their corresponding fault type labels; (2) Recursive feature selection and node splitting: The terminal determines the splitting gain values of all features for the data set of the current node to be split, and selects the feature with the largest splitting gain value as the splitting condition; the data set is inherited from the data generated after the parent node is split and contains the feature values and corresponding fault type labels in the parent node data that meet the current splitting condition; The terminal divides the data set into a left child node and a right child node according to the splitting condition, and each child node corresponds to a subset of the training sample set; (3) Recursive termination condition determination: If the current node to be split meets any of the following conditions, the terminal marks it as a leaf node and outputs the fault type label: The proportion of the target fault type in the leaf node is greater than or equal to the preset proportion threshold; The number of samples contained in the leaf node is less than or equal to the preset minimum number of samples in the leaf node; The current node depth reaches the preset maximum number of layers; (4) Pruning optimization: The terminal adopts a cost complexity pruning algorithm, calculates the total cost complexity of each subtree according to the pre-stored pruning coefficient, and iteratively removes the subtree with the minimum total cost complexity to obtain the constructed decision tree fault identification model.
5. The method according to claim 3, wherein The method further includes: The terminal obtains the data training library with a second preset proportional coefficient to obtain a test sample set, which includes multiple test samples and the corresponding test fault identification results for each test sample. The test sample is a feature value, and the test fault identification result is the fault type label corresponding to the feature value; The terminal inputs each of the test samples into the decision tree fault identification model and outputs a second fault identification result; Based on the test fault identification result and the second fault identification result, the terminal determines the second identification accuracy rate and recall rate of the decision tree fault identification model; If the second identification accuracy rate is greater than the preset accuracy rate threshold and the recall rate is greater than the preset recall rate threshold, the terminal determines that the decision tree fault identification model meets the preset construction requirements; otherwise, it determines that the decision tree fault identification model does not meet the preset construction requirements and adjusts the model parameters of the decision tree fault identification model.
6. The method according to claim 1, characterized in that The feature value includes the mean and median representing the central tendency feature, the variance and standard deviation representing the dispersion degree feature, the skewness and kurtosis representing the distribution form feature, the trend slope representing the change trend feature, and the feature value representing the frequency domain feature obtained by extracting the frequency domain energy distribution through Fourier transform.
7. A device for fault diagnosis based on PLC, characterized in that, The device is applied to a fault diagnosis system, and the system includes a terminal and a programmable logic controller PLC. The device includes: The first acquisition module is used for the PLC to acquire the data of the target device collected by the corresponding connected sensors through at least one data acquisition point; The first determination module is used for the PLC to determine the data as the physical quantity values of the corresponding physical quantity types according to a preset conversion method, and store the physical quantity values in a circular buffer with a preset time window length; The second determination module is used for the PLC to determine a period according to a preset duration, and based on the data acquisition point, determine multiple characteristic values of the physical quantity values in the circular buffer; The identification module is used for the PLC to input multiple characteristic values into a pre-trained decision tree fault identification model, and output the fault identification result of the target device; The trigger module is used for the PLC to trigger an alarm signal according to the target fault type label of the fault identification result, and record the fault log of the target device.
8. The device according to claim 7, characterized in that, The device further includes: The second acquisition module is used for the PLC to acquire a data sequence collected by the corresponding connected sensors through multiple data acquisition points, and receive the fault type label corresponding to the data in the data sequence sent by the upper computer; The third determination module is used for the PLC to determine the data in the data sequence as the physical quantity values of the corresponding physical quantity types according to a preset conversion method, and store the physical quantity values in a circular buffer with a preset time window length; The fourth determination module is used for the PLC to determine a period according to a preset duration, and based on the data acquisition point, determine multiple characteristic values of the physical quantity values in the circular buffer, and store the multiple characteristic values and the corresponding fault type labels in a table form according to the time stamp of the data sequence acquisition; The preprocessing module is used for the terminal to preprocess the exported table data stored in the PLC, delete the data records containing missing values, and based on the fault type label when a fault occurs in the data sequence, remove the data records within a preset duration threshold before and after the fault type label to obtain a data training library for the decision tree fault identification model.
9. The device according to claim 8, characterized in that, The device further includes: The third acquisition module is used for the terminal to acquire a data training library with a first preset proportional coefficient to obtain a training sample set, where the training sample set includes multiple training samples and the sample fault identification results corresponding to each training sample, the training sample is a characteristic value, and the sample fault identification result is the fault type label corresponding to the characteristic value; The construction module is used for the terminal to construct an initial decision tree fault identification model based on each training sample and the sample fault identification result corresponding to each training sample, and optimize the model depth of the initial decision tree fault identification model through pruning technology to obtain the constructed decision tree fault identification model; The conversion module is used for the terminal to convert the constructed decision tree fault identification model into a rule set and embed it into the PLC. The PLC converts the rule set into a JSON format configuration file, dynamically loads and parses it through the PLC's script engine, and realizes the real-time matching of the characteristic values and the rule set in the PLC program.
10. The device according to claim 9, characterized in that, The construction module is specifically used for: (1) Initializing the decision tree node: The terminal uses the training sample set as the root node, and the root node contains the feature values of all training samples and their corresponding fault type labels; (2) Recursive feature selection and node splitting: The terminal determines the splitting gain values of all features for the data set of the current node to be split, and selects the feature with the largest splitting gain value as the splitting condition; The data set is inherited from the data generated after the parent node is split and contains the feature values and corresponding fault type labels in the parent node data that meet the current splitting condition; The terminal divides the data set into a left child node and a right child node according to the splitting condition, and each child node corresponds to a subset of the training sample set; (3) Determining the recursive termination condition: If the current node to be split meets any of the following conditions, the terminal marks it as a leaf node and outputs the fault type label: The proportion of the target fault type in the leaf node is greater than or equal to the preset proportion threshold; The number of samples contained in the leaf node is less than or equal to the preset minimum number of samples in the leaf node; The depth of the current node reaches the preset maximum number of layers; (4) Pruning optimization: The terminal adopts the cost complexity pruning algorithm, calculates the total cost complexity of each subtree according to the pre-stored pruning coefficient, and iteratively removes the subtree with the minimum total cost complexity to obtain the constructed decision tree fault recognition model.
Citation Information
Cited By
Fault diagnosis method, system and equipment based on first-in first-out strategy and medium
CN121234210A
Fault diagnosis method, system, device and medium based on first-in-first-out strategy
CN121234210B
Refrigerator fault remote diagnosis method and system
CN121479550A