Predicting Mechanical Failure: Vibration Anomaly Detection with TinyML
Predicting Mechanical Failure: Vibration Anomaly Detection with TinyML
In industrial manufacturing, rotating machinery—pumps, compressors, CNC spindles, and gearboxes—gives clear warning signs long before catastrophic failure. These warnings manifest as subtle shifts in acoustic emissions, harmonic resonance, and multi-axis vibration patterns. Traditionally, identifying these defects required expensive external vibration analyzers or periodic manual technician inspections.
Today, TinyML-powered condition monitoring enables continuous, low-cost predictive maintenance. By embedding unsupervised anomaly detection models directly onto microcontrollers connected to industrial accelerometers, machines can diagnose their own wear patterns in real time while drawing milliwatts of power.
The Engineering Bottleneck: Raw Time-Series vs. Spectral Features
Industrial accelerometers (such as the ADXL345 or high-bandwidth piezoelectric sensors) sample vibration across 3 axes at frequencies between 1.6 kHz and 20 kHz. Feeding raw time-domain waveforms directly into a neural network creates two critical issues:
- Memory Overload: A 1-second 3-axis buffer sampled at 10 kHz contains 30,000 floating-point values—demanding 120 KB of RAM per sample just for input buffers.
- Phase Sensitivity: Raw time-series signals shift with minor starting-phase discrepancies, requiring deep, parameter-heavy neural networks to learn invariant features.
The solution is not deeper neural networks; it is classical Digital Signal Processing (DSP) executed before neural inference.
The TinyML Anomaly Pipeline
[ 3-Axis Accelerometer ] ──➔ [ Fast Fourier Transform (FFT) ] ──➔ [ Spectral Feature Vector ] ──➔ [ Autoencoder / GMM ]
(MEMS / Piezo) (CMSIS-DSP / DSP Lib) (Peak Harmonics & Power) (Anomaly Scoring)
1. Spectral Decomposition via FFT
Transforming raw vibration data from the time domain into the frequency domain converts a massive stream of positional data into discrete harmonic peaks:
By extracting energy across key mechanical frequency bands, bearing defects, shaft misalignment, and mechanical looseness appear as distinct, stationary spectral signatures.
2. Feature Compression
Instead of passing raw FFT bins, we extract a lean feature vector containing:
- Root Mean Square (RMS): Quantifies total vibrational energy.
- Kurtosis & Crest Factor: High-sensitivity metrics for impulsive impact faults (like cracked bearing raceways).
- Spectral Centroid & Band Powers: Tracks shifting natural frequencies as components degrade.
This compresses thousands of raw time-domain samples down to a compact 16 to 32-element feature vector, requiring negligible memory.
Detecting the Unknown: Unsupervised Autoencoders
In physical plants, you cannot train supervised classifiers because true failure data is rare—operators do not deliberately run multi-million-dollar turbines to destruction just to collect training labels.
Instead, we deploy an Autoencoder trained entirely on baseline normal operating data:
When the machine operates normally, the network reconstructs the spectral vector with minimal Mean Squared Error (MSE). When mechanical damage occurs (spalling, gear tooth chipping, or bearing cage collapse), the model cannot reconstruct the unseen frequency anomalies, and the reconstruction error spikes beyond a predefined threshold.
Implementation: On-Device Anomaly Scoring (C++)
#include "tensorflow/lite/micro/micro_interpreter.h" #include <math.h> // Threshold determined during validation on normal baseline datasets const float kAnomalyThreshold = 0.045f; const int kFeatureCount = 16; bool evaluate_machine_health(tflite::MicroInterpreter* interpreter, float* spectral_features) { TfLiteTensor* input = interpreter->input(0); TfLiteTensor* output = interpreter->output(0); // 1. Copy extracted FFT spectral features to model input for (int i = 0; i < kFeatureCount; i++) { input->data.f[i] = spectral_features[i]; } // 2. Invoke TinyML autoencoder inference interpreter->Invoke(); // 3. Compute Mean Squared Error (Reconstruction Loss) float reconstruction_error = 0.0f; for (int i = 0; i < kFeatureCount; i++) { float diff = input->data.f[i] - output->data.f[i]; reconstruction_error += diff * diff; } reconstruction_error /= kFeatureCount; // 4. Check if error exceeds safety limit if (reconstruction_error > kAnomalyThreshold) { // Trigger machine alert / telemetry flag return true; // Anomaly detected! } return false; // Operating normally }
Diagnostic Architecture Comparison
| Method | Computational Load | Training Requirement | Failure Sensitivity |
|---|---|---|---|
| Simple RMS Thresholding | Negligible (< 1% CPU) | None (Manual threshold) | Low (Only catches catastrophic end-stage failures). |
| Spectral Band Energy (FFT) | Low (DSP accelerated) | Expert harmonic rules | Moderate (Requires knowing bearing geometry). |
| TinyML Autoencoders | Low to Moderate (< 15 ms) | Unsupervised (Normal data only) | High (Catches subtle microscopic degradation patterns). |
Key Takeaways for Embedded Engineers
- Let DSP do the heavy lifting: Do not feed raw waveforms into neural networks. Compute an FFT or extract statistical moments first to reduce dimensionality by 99%.
- Leverage hardware-accelerated DSP: Use CMSIS-DSP on ARM Cortex-M or ESP-DSP on ESP32 to compute FFTs in under 5 milliseconds.
- Design for unsupervised learning: In industrial environments, build autoencoders that learn normal operational boundaries rather than trying to classify specific fault labels.

Comments
Post a Comment