Chapter 13
Embedded AI, Analytics and Intelligent Decision Making
Bachelor Program in Mechatronics Engineering
Embedded Systems in Mechatronics
•
Bachelor
Embedded AI, Analytics and Intelligent Decision Making
Introduction
Mechatronic systems increasingly sense, interpret, and act on their environment. A motor drive may detect bearing degradation, a robot may classify an object before grasping it, and a mobile machine may estimate its remaining operating range. These capabilities depend on embedded artificial intelligence (AI): the deployment of signal-processing, statistical, and machine-learning methods close to the physical process, often on a microcontroller, programmable-logic device, industrial computer, or edge gateway.
Edge intelligence is not simply a smaller version of cloud AI. An embedded system must satisfy real-time deadlines, limited memory, restricted energy budgets, intermittent connectivity, safety requirements, and long service lives. A model that is accurate on a laboratory computer can be unusable when it exceeds the available RAM, introduces unacceptable delay, or produces an unsafe decision under sensor failure.
This chapter develops a systems approach to embedded AI for mechatronics. It considers the complete chain from sensing and signal conditioning to features, inference, decisions, actuation, monitoring, and maintenance. Particular attention is given to data quality, anomaly detection, predictive maintenance, latency, memory, energy, explainability, bias, and functional safety.
Learning Objectives
After studying this chapter, a student should be able to:
Distinguish signal processing, analytics, machine learning, and intelligent decision making in an embedded system.
Design a reliable data and inference pipeline for a mechatronic application.
Apply suitable anomaly-detection and predictive-maintenance approaches.
Estimate inference latency, memory use, and energy consumption.
Evaluate model performance under class imbalance, drift, sensor faults, and changing operating conditions.
Integrate AI outputs with confidence thresholds, fallback logic, and safety constraints.
Assess explainability, bias, cybersecurity, and governance in AI-enabled machines.
1. Embedded Intelligence as a Closed-Loop System
A useful architecture contains six functional stages:
Sensing: acquisition of vibration, current, temperature, position, pressure, acoustic, or image data.
Signal conditioning: amplification, filtering, calibration, synchronization, and conversion.
Feature or representation generation: calculation of quantities such as root-mean-square vibration, spectral energy, statistical moments, or learned embeddings.
Inference: estimation, classification, regression, anomaly scoring, or remaining-useful-life prediction.
Decision logic: conversion of predictions into actions, alarms, maintenance requests, or safe-state transitions.
Feedback and monitoring: logging outcomes, detecting drift, updating thresholds, and validating the complete system.
The distinction between prediction and decision is essential. A classifier may report a 0.82 probability of a bearing fault, but the controller must decide whether to stop the machine, reduce speed, request inspection, or continue operation. That decision depends on severity, cost, uncertainty, operating context, and safety constraints.
Embedded AI closed-loop architecture
Figure: Embedded AI closed-loop architecture
Figure: Closed-loop architecture for embedded AI in a mechatronic system.
2. Data Quality and Signal Preparation
AI performance cannot exceed the quality of the information supplied to it. Important data-quality dimensions include:
Completeness: missing samples, gaps, and unavailable channels.
Validity: values within physical and sensor limits.
Consistency: agreement among sensors and across time.
Accuracy: closeness to the physical quantity being measured.
Timeliness: whether the sample represents the current machine state.
Label quality: correctness and repeatability of fault or maintenance labels.
Representativeness: coverage of loads, speeds, temperatures, operators, machines, and failure modes.
Sampling must reflect the dynamics of interest. For a band-limited signal with highest relevant frequency fmax, ideal uniform sampling requires fs > 2fmax, where fs is the sampling frequency. In practice, the sampling rate is selected higher than this theoretical minimum, and an anti-aliasing low-pass filter is applied before analog-to-digital conversion. Aliasing is especially dangerous because it creates plausible but false frequency content.
For a finite window containing N samples xi, the mean and root-mean-square (RMS) value are:
μ = (1/N) ∑ᵢ₌₁ᴺ xᵢ
xRMS = √[(1/N) ∑ᵢ₌₁ᴺ xᵢ²]
Here, μ has the same units as the signal and xRMS is nonnegative with the same units. These expressions describe a finite sample window and assume samples are sufficiently representative of the operating state. RMS is useful for vibration and current magnitude, but it does not by itself identify a fault.
Common preprocessing operations include detrending, normalization, resampling, windowing, filtering, and sensor fusion. Normalization parameters must be calculated from training data and stored with the deployed model. Recomputing them from each new window can leak information and make the model behave inconsistently.
A practical data-quality gate should reject or downgrade inference when sensor saturation, impossible values, excessive missingness, timing errors, or implausible rates of change are detected. “Unknown” or “insufficient evidence” is often safer than forcing a class label.
3. Analytics and Machine-Learning Models
Embedded analytics ranges from deterministic calculations to learned models.
3.1 Deterministic and statistical methods
Thresholds, moving averages, control charts, frequency analysis, and state observers are often transparent and computationally inexpensive. A moving average over a window of length W is:
yt = (1/W) ∑ᵢ₌₀ᵂ⁻¹ xₜ₋ᵢ
It reduces random variation but introduces delay and can hide rapid faults. Thresholds should be related to operating context; a current limit suitable at low load may be inappropriate during acceleration.
3.2 Supervised learning
Supervised classification learns a mapping from features x to a class y, such as healthy, imbalance, misalignment, or overload. Regression predicts a continuous quantity such as temperature or remaining useful life. Typical models include linear models, decision trees, random forests, support-vector machines, and neural networks.
A binary classifier can be evaluated using true positives (TP), false positives (FP), true negatives (TN), and false negatives (FN). Important measures are:
Precision = TP/(TP + FP)
Recall = TP/(TP + FN)
Precision answers: of the alarms raised, how many were correct? Recall answers: of the actual faults, how many were detected? In safety-related fault detection, false negatives may be more costly than false positives, so accuracy alone is inadequate, particularly when faults are rare.
3.3 Unsupervised and semi-supervised anomaly detection
When failure labels are scarce, a model can learn normal behavior and assign an anomaly score. Examples include distance from a normal feature distribution, reconstruction error from an autoencoder, isolation forests, and one-class support-vector machines. An alarm threshold should be selected using validation data that represents normal operating variation, not merely chosen because it produces a visually attractive result.
If a normal feature vector has mean μ and covariance matrix Σ, the squared Mahalanobis distance is:
d² = (x − μ)ᵀ Σ⁻¹ (x − μ)
This measure accounts for correlation among features. It requires an invertible or suitably regularized covariance estimate and is meaningful only when the normal-data distribution is reasonably stable. A large distance indicates unusual behavior, not necessarily a particular physical failure.
3.4 Predictive maintenance
Predictive maintenance estimates degradation before functional failure. Three common approaches are:
Condition-based rules: maintenance is triggered by a measured condition exceeding a limit.
Fault classification: the system identifies a known fault type.
Remaining useful life (RUL) estimation: the system predicts time, cycles, or distance until a defined failure criterion.
RUL models must define the failure criterion, prediction horizon, uncertainty, censoring of assets that have not failed, and consequences of error. A point estimate without uncertainty can encourage premature confidence. Maintenance planning should combine model output with operating hours, spare-part availability, safety requirements, and inspection evidence.
4. Deployment Constraints at the Edge
4.1 Latency and deadlines
End-to-end latency includes acquisition, buffering, preprocessing, inference, decision logic, communication, and actuation. If a control task has period T, a safe design requires worst-case execution and communication delays to remain within the available deadline, not merely that average latency is small. A model with occasional long execution times may violate a real-time requirement even when its mean time is acceptable.
For a pipeline with stages of durations t1, t2, …, tn, sequential latency is:
Ltotal = ∑ⱼ₌₁ⁿ tⱼ
This equation assumes stages execute sequentially for one decision. Pipelining can improve throughput, but the first-result latency and scheduling interference must still be analyzed.
4.2 Memory
For a dense neural-network layer with nin inputs and nout outputs, the number of weights is nin × nout. If each weight uses bw bytes, weight storage is:
Mweights = nin nout bw
Biases, activations, stacks, buffers, operating-system memory, and model metadata must also be included. Quantization from 32-bit floating point to 8-bit integers can reduce parameter storage by a factor of four, but scale factors, calibration error, and possible loss of accuracy must be evaluated. Quantization-aware training generally performs better than uncalibrated conversion when the model is sensitive to numerical precision.
4.3 Energy
Electrical energy consumed over an interval is:
E = ∫₀ᵀ P(t) dt
where P(t) is power in watts and T is time in seconds, giving joules. If power is approximately constant, E ≈ PT. For a device performing r inferences per second, with energy Ei per inference, the inference power contribution is approximately PAI = rEi. Sensor operation, memory access, radio transmission, and idle power can dominate this value; optimizing only arithmetic operations may therefore produce little system-level benefit.
5. From Prediction to Safe Decision
A model output must not directly command hazardous actuation without validation. A robust decision layer may include:
confidence or anomaly-score thresholds;
temporal persistence, such as requiring several consistent observations;
plausibility checks against physical limits;
hysteresis to prevent alarm oscillation;
sensor-redundancy or cross-check logic;
a defined fallback or safe state;
event logging for traceability and review.
For example, a mobile robot may slow down when obstacle probability exceeds a warning threshold and stop when probability exceeds a higher critical threshold. However, thresholds do not replace independent safety functions. A certified emergency stop, protective scanner, or hardwired limit may be required because a learned model can fail under distribution shift.
Uncertainty should influence action. A high-confidence normal result may permit continued operation; a low-confidence result should request another measurement, reduce speed, or transfer the case to a human inspector. This is a form of selective prediction, in which the system is allowed to abstain rather than make every decision.
6. Explainability, Bias, and Robustness
Explainability has several meanings. A decision tree can be intrinsically interpretable; a neural network may require post hoc explanations such as feature importance or saliency maps. Explanations should be checked against engineering knowledge. A visually persuasive explanation is not evidence that the model is causally correct.
Bias in mechatronic AI often arises from unbalanced operating data rather than social categories alone. Examples include training mostly at one speed, using one machine revision, collecting data only in warm conditions, or labeling only catastrophic failures. The resulting model may perform well in testing but poorly on a new machine or under a new load.
Robust evaluation should separate training, validation, and test data by time, machine, or production batch when appropriate. Randomly mixing adjacent samples from the same run can cause leakage and overestimate generalization. Report performance by operating regime, fault type, sensor condition, and asset—not only as one aggregate score.
Distribution shift occurs when deployment data differs from training data. Causes include wear, changed controllers, sensor replacement, environmental variation, and process redesign. Monitoring should track feature distributions, missingness, confidence, alarm rates, and maintenance outcomes. Retraining requires version control, validation, rollback capability, and approval; automatic model updates in safety-critical equipment are inappropriate without controls.
7. Worked Example: Vibration Anomaly Detection
An accelerometer produces a 1,000-sample window in units of m/s². A normal operating reference has feature mean
μ = (2.0, 0.50)ᵀ and covariance
Σ = [[0.25, 0], [0, 0.04]]. A new window produces
x = (3.0, 0.70)ᵀ. The covariance is diagonal, so:
x − μ = (1.0, 0.20)ᵀ.
The squared Mahalanobis distance is:
d² = (1.0²/0.25) + (0.20²/0.04) = 4 + 1 = 5
Thus d = √5 ≈ 2.24. The window is farther from normal behavior than either feature alone might suggest. Whether it becomes an alarm depends on a threshold selected from validation data and on the operating condition. The calculation does not identify the fault mechanism; it only indicates that the combined feature pattern is unusual.
Suppose the deployed pipeline requires 2 ms for acquisition and buffering, 1 ms for preprocessing, 3 ms for inference, and 1 ms for decision logic. Sequential end-to-end latency is:
Ltotal = 2 + 1 + 3 + 1 = 7 ms.
If the deadline is 10 ms, the nominal budget is met, but worst-case execution, interrupt delays, communication, and scheduling must still be measured. A design review should also specify what occurs if the sensor is saturated or inference exceeds its deadline.
8. Illustrative Case: Edge Predictive Maintenance for a Conveyor Drive
Background. A factory conveyor uses induction motors and gearboxes. Unexpected bearing failures stop a production line, while replacing healthy bearings causes unnecessary cost.
Problem. The existing controller records motor current and vibration only when an operator observes noise. The data is irregular, labels are incomplete, and the edge controller has 256 kB of RAM and limited network connectivity.
Analysis. Engineers first define the maintenance event: a bearing is considered failed when vibration exceeds a validated mechanical limit and inspection confirms damage. They discover that vibration changes strongly with motor speed and product load. Therefore, a single global threshold would produce many false alarms. Data is collected across speeds, loads, temperatures, healthy replacements, and known seeded faults where safe.
Approach. The system applies anti-alias filtering, validates sensor ranges, segments vibration into windows, and calculates RMS, crest factor, kurtosis, and selected spectral-band energies. A compact anomaly model is trained primarily on verified healthy data, while a separate classifier is used only for fault types with adequate labels. Speed and load are included as context. The embedded implementation uses integer quantization after calibration. An alarm requires two anomalous windows within five minutes, unless a separate hard safety limit is exceeded.
The decision layer has three outcomes: continue operation, request inspection and reduce nonessential load, or enter a safe stop. If data quality fails, the model abstains and the controller uses conservative rule-based protection. All model versions, thresholds, input-quality flags, and decisions are logged.
Outcome. In an illustrative validation, the system detects degradation earlier than operator observation and reduces nuisance alarms after conditioning thresholds on speed. The result is not accepted solely because of a high test score: engineers also verify timing, RAM use, behavior after sensor disconnection, and safe-state operation. Maintenance staff receive an anomaly trend and contributing features rather than an unexplained “AI fault” message.
Learning points. The main engineering achievement is system integration, not model selection alone. Clear failure definitions, representative data, context-aware thresholds, abstention, and safety fallback are necessary for trustworthy deployment.
9. Governance, Safety, and Professional Practice
AI-enabled machinery must be governed as an engineered product. Responsibilities include identifying hazards, defining operating limits, recording requirements, controlling software versions, protecting data, and preserving audit trails. Relevant safety work should align with applicable machinery-safety, functional-safety, cybersecurity, and quality-management standards; the exact standard depends on the industry and risk classification.
A risk assessment should ask:
What happens if the model misses a dangerous condition?
What happens if it generates repeated false alarms?
Can an attacker alter sensor data, model files, thresholds, or logs?
Can an operator understand and override a recommendation appropriately?
Is there an independent protective function?
Can the system be updated and rolled back securely?
Model accuracy is not a safety integrity argument. A statistically accurate model may still be unsuitable as the sole protective measure. Safety-related control should use appropriate deterministic safeguards, diagnostics, redundancy, and validated failure responses.
Privacy can also matter. Cameras, microphones, and production logs may capture workers, proprietary processes, or personal information. Data minimization, access control, retention limits, encryption, and documented purpose are professional obligations.
10. Contemporary Directions and Best Practices
Current development trends include tinyML, event-driven sensing, hardware neural accelerators, federated learning, digital twins, multimodal sensor fusion, and continual monitoring of deployed models. These technologies can reduce communication and energy use, but they introduce new concerns. Federated learning does not automatically guarantee privacy; digital twins are only as reliable as their models and calibration; and continual learning can cause catastrophic forgetting or incorporate corrupted data.
A disciplined deployment workflow is:
Define the physical problem, failure criterion, decision, and safety consequence.
Establish sensor specifications, sampling, calibration, synchronization, and data-quality rules.
Collect representative data with traceable labels and metadata.
Create leakage-resistant training, validation, and test splits.
Choose the simplest model that meets the engineering requirement.
Quantize or compress only after measuring the effect on decisions.
Integrate confidence, abstention, fallback, and independent safety functions.
Test hardware-in-the-loop, fault injection, sensor disconnection, overload, timing overrun, and power interruption.
Monitor deployment, version models, review drift, and retain rollback capability.
The central principle is that embedded AI is a component of a cyber-physical system. Its quality must be judged by safe and useful system behavior, not by an isolated benchmark.
Chapter Summary
Embedded AI combines sensing, signal processing, feature generation, machine learning, decision logic, and feedback monitoring. Data quality—especially validity, timing, representativeness, and labeling—determines whether a model can be trusted. Deterministic analytics, supervised learning, and unsupervised anomaly detection each have appropriate applications and limitations.
Deployment requires analysis of end-to-end latency, worst-case timing, memory, quantization, and energy. Accuracy must be supplemented by precision, recall, uncertainty, operating-regime analysis, and tests against distribution shift. Predictions should pass through confidence checks, temporal logic, plausibility checks, abstention, and safe fallback functions before influencing actuation. Explainability, bias, cybersecurity, privacy, traceability, and regulatory compliance are engineering requirements rather than optional additions. Effective predictive maintenance therefore depends on integrated system design, not on selecting the most complex model.
Key Terms
Embedded AI: AI executed near the physical process on an embedded or edge device.
Edge computing: Processing data locally rather than sending all data to a remote cloud.
Aliasing: False frequency content caused by inadequate sampling.
Feature: A measured or calculated quantity used by an analytical model.
Data drift: Change in input or output data characteristics over time.
Anomaly detection: Identification of behavior that differs from an established normal pattern.
Mahalanobis distance: Correlation-aware distance from a reference distribution.
Predictive maintenance: Maintenance planned using estimated equipment condition or future failure.
Remaining useful life: Estimated operating time or cycles before a defined failure criterion.
Precision: Proportion of positive predictions that are correct.
Recall: Proportion of actual positive cases that are detected.
Quantization: Representation of numerical values with reduced precision.
Inference latency: Time required to produce a model output and associated decision.
Selective prediction: A model strategy that abstains when evidence is insufficient.
Distribution shift: Difference between training conditions and deployment conditions.
Explainability: Ability to communicate or analyze reasons for a model output.
Fallback: Predefined behavior used when an AI result is unavailable or unreliable.
Data leakage: Accidental use of information during training that would not be available in deployment.
Review Questions
Short Answer Questions
Why is a prediction not the same as a mechatronic decision?
State two causes of aliasing and one method of preventing it.
Define precision and recall.
Why can random splitting of time-series samples overestimate model performance?
Name three elements of a safe AI decision layer.
Long Answer Questions
Explain the complete embedded-AI pipeline from sensing to feedback monitoring, including likely failure modes at each stage.
Compare threshold rules, supervised classification, and unsupervised anomaly detection for predictive maintenance.
Discuss how latency, memory, and energy constraints influence model selection at the edge.
Explain why accuracy alone is insufficient for evaluating an AI-enabled safety-related machine.
Describe a governance and lifecycle process for deploying, monitoring, updating, and rolling back an embedded model.
Analytical / Application Questions
Design an anomaly-detection architecture for a robotic gearbox. Specify sensors, sampling considerations, features, model type, alarm logic, and fallback behavior.
A model has high recall but very low precision in a factory with rare faults. Analyze the operational consequences and propose changes to thresholding, data collection, and decision logic.
An edge device meets its average 8 ms inference target but occasionally requires 25 ms while the control deadline is 10 ms. Explain why the design is unsafe or unsuitable and propose an engineering verification and mitigation plan.
Multiple Choice Questions with Answers
Question 1
Which statement best distinguishes an AI prediction from an embedded-system decision?
A. A prediction is always deterministic, whereas a decision is random.
B. A prediction estimates a condition, whereas a decision selects an action using context, uncertainty, and constraints.
C. A prediction uses sensors, whereas a decision never uses sensors.
D. A prediction is made in hardware, whereas a decision must be made in the cloud.
Correct Answer: B. A prediction estimates a condition, whereas a decision selects an action using context, uncertainty, and constraints.
Question 2
What is the principal purpose of an anti-aliasing filter before analog-to-digital conversion?
A. To increase actuator torque
B. To remove high-frequency content that could appear falsely after sampling
C. To convert floating-point values to integers
D. To label maintenance data automatically
Correct Answer: B. To remove high-frequency content that could appear falsely after sampling
Question 3
If TP = 90 and FN = 10, what is recall?
A. 10%
B. 50%
C. 90%
D. 100%
Correct Answer: C. 90%
Question 4
For a sequential pipeline with stage times of 2 ms, 1 ms, 3 ms, and 1 ms, what is the nominal total latency?
A. 3 ms
B. 5 ms
C. 6 ms
D. 7 ms
Correct Answer: D. 7 ms
Question 5
Which situation is an example of data leakage?
A. Testing a model on a completely separate production batch
B. Using future maintenance information to construct a training feature
C. Checking sensor saturation before inference
D. Quantizing a deployed model after calibration
Correct Answer: B. Using future maintenance information to construct a training feature
Question 6
What does a large Mahalanobis distance usually indicate?
A. A guaranteed specific bearing failure
B. That the combined feature vector is unusual relative to a reference distribution
C. That the sensor has zero noise
D. That the classifier has perfect recall
Correct Answer: B. That the combined feature vector is unusual relative to a reference distribution
Question 7
Why might an embedded model use 8-bit integer weights instead of 32-bit floating-point weights?
A. To increase model storage and computation requirements
B. To eliminate the need for validation
C. To reduce memory and often computation cost, subject to accuracy checks
D. To guarantee immunity to distribution shift
Correct Answer: C. To reduce memory and often computation cost, subject to accuracy checks
Question 8
Which response is most appropriate when sensor data fails a validity check?
A. Force the model to output the most common class
B. Ignore the failure and continue hazardous actuation
C. Abstain or use a defined conservative fallback
D. Increase the sampling frequency indefinitely
Correct Answer: C. Abstain or use a defined conservative fallback
Question 9
Why is accuracy often misleading for rare-fault detection?
A. Accuracy cannot be calculated for classifiers
B. A model can appear accurate by predicting the common healthy class while missing faults
C. Accuracy measures only memory usage
D. Rare faults always produce false positives
Correct Answer: B. A model can appear accurate by predicting the common healthy class while missing faults
Question 10
Which practice best supports safe model lifecycle management?
A. Automatically replacing the model without testing
B. Removing logs to save memory
C. Version control, deployment monitoring, validation, and rollback capability
D. Using one test sample from the laboratory
Correct Answer: C. Version control, deployment monitoring, validation, and rollback capability