Optimize Machine Lifecycle and Reduce Downtime with Predictive Maintenance
This example shows you how to predict the maintenance requirement of a machine and generate a maintenance alert.
Predictive maintenance enables you to estimate the time to failure of a machine. Being able to predict the time of failure helps you find the optimum time to schedule maintenance for your equipment. This example uses the mean and RMS voltage as condition indicators to predict the maintenance requirement of a rotor. You can obtain these values using an accelerometer sensor mounted on the rotor under test.
Train Model with SVM Classifier
Load the trainingData.mat
data set, which includes the mean and RMS voltage of a rotor.
load('trainingData.mat');
Train a two-class support vector machine (SVM) classifier with the data set using the fitcsvm
(Statistics and Machine Learning Toolbox) function.
X = trainingData(:,1:end-1); y = trainingData(:,end); SVMModel = fitcsvm(X, y); classOrder = SVMModel.ClassNames
classOrder = 2×1
0
1
Analyze Maintenance Requirement
Plot a scatter diagram of the processed data and circle the support vectors.
plotScatterDiagram(SVMModel, X, y)
Plot decision boundary and margin lines for the processed data.
plotDBandML(SVMModel, X, y)
Predict Maintenance Requirement and Generate Alert
Create a DataAcquisition
object using the daq
function. Add an analog input channel using the addinput
function. Set the scan rate as 1000 scans per second using the Rate property of the DataAcquisition
object.
dq = daq("ni"); addinput(dq, "Dev1", "ai0", "Voltage"); dq.Rate = 1000;
Use the classifyData
function provided with this example to extract condition indicators, deploy the trained model, and generate a maintenance alert. This example executes the prediction algorithm every time the number acquired scans reaches 1000. You can modify these execution settings using the ScansAvailableFcn and ScansAvailableFcnCount properties of the DataAcquisition
object.
dq.ScansAvailableFcn = @(src, event) classifyData(src, event, SVMModel); dq.ScansAvailableFcnCount = 1000;
Acquire data for prediction by initiating background acquisition of data using the start
function. You can acquire data for a finite span of time by setting the span argument in the function to the required time span. This example acquires data for a duration of 5 seconds.
start(dq, "Duration", seconds(5));