Artificial Intelligence in Mechatronics Applications

Chapter 11
Smart Manufacturing and Digital Twins

Bachelor Program in Mechatronics Engineering
Artificial Intelligence in Mechatronics Applications   •   Bachelor

Smart Manufacturing and Digital Twins

Introduction and Context

Manufacturing systems are increasingly connected, instrumented, and software-defined. A modern production line may contain programmable logic controllers (PLCs), robots, drives, sensors, machine-vision cameras, supervisory control and data acquisition (SCADA) systems, manufacturing execution systems (MES), enterprise resource planning (ERP) platforms, and cloud or edge-computing services. Artificial intelligence (AI) adds the ability to detect patterns, predict future conditions, optimize decisions, and support adaptive control.

Smart manufacturing is not simply the automation of individual machines. It is the coordinated use of physical equipment, industrial information systems, data, communication networks, and intelligent algorithms to improve safety, quality, delivery, flexibility, sustainability, and cost. A digital twin is a connected digital representation of a physical asset, process, product, or factory that is updated using operational data and used for monitoring, analysis, prediction, simulation, or control.

For mechatronics engineers, the strategic importance of these technologies lies in integration. AI cannot compensate for poor instrumentation, unreliable networks, unclear process ownership, or unsafe control logic. Successful digital transformation therefore combines mechanical and electrical engineering, automation, data engineering, operations management, cybersecurity, and human factors.

Learning Objectives

By the end of this chapter, students should be able to:

  1. Explain the architecture and purpose of smart manufacturing systems.
  2. Distinguish the roles of PLCs, SCADA, industrial IoT, MES, ERP, edge computing, and cloud platforms.
  3. Describe digital twins and differentiate them from static simulations or ordinary dashboards.
  4. Select suitable AI methods for quality inspection, predictive maintenance, process optimization, and energy management.
  5. Calculate and interpret important manufacturing-performance measures.
  6. Analyze an integrated manufacturing use case and identify technical, organizational, ethical, and cybersecurity risks.
  7. Propose best practices for implementing a safe and useful industrial AI system.

1. The Smart Manufacturing Architecture

1.1 From automation to intelligent production

Traditional automation executes predefined logic. A PLC reads inputs, evaluates a program, and writes outputs, commonly within a deterministic scan cycle. This is essential for machine sequencing and safety-related interlocking, but conventional logic is usually unable to recognize complex visual defects or infer gradual equipment degradation.

Smart manufacturing adds a data-and-decision layer. Sensors measure temperature, vibration, pressure, current, position, flow, energy, and quality characteristics. Industrial networks transport data. AI models transform data into classifications, forecasts, anomaly scores, or recommended actions. Human operators and engineers remain responsible for supervision, validation, and exceptional decisions.

A useful layered view is:

LayerMain functionTypical technologies
Physical processMaterial transformation and motionMotors, robots, conveyors, tools
ControlDeterministic real-time operationPLCs, motion controllers, safety PLCs
SupervisoryVisualization, alarms, historical trendsSCADA, historians, HMIs
Operations managementScheduling, genealogy, quality and work ordersMES
EnterprisePlanning, purchasing, finance and supply chainERP
IntelligencePrediction, optimization and decision supportAI, analytics, digital twins

The layers are connected but should not be treated as interchangeable. An AI prediction should not directly override a safety function unless the complete control system has been engineered, validated, and certified for that purpose. In many applications, AI provides a recommendation to a PLC or operator, while deterministic logic retains final authority.

1.2 PLCs and industrial control

A PLC typically performs a repeating sequence: input acquisition, program execution, output update, communication, and diagnostics. Its strengths include deterministic timing, robustness, maintainability, and suitability for harsh environments. Its limitations include restricted computational resources, dependence on engineered rules, and difficulty representing uncertain or high-dimensional data.

AI is therefore commonly integrated beside rather than inside the core PLC program. A vibration model may execute at an edge computer and send an anomaly state to the SCADA layer. A vision model may classify a product and transmit pass/fail information to the PLC through an industrial protocol. The PLC then applies interlocks, rejects a product, or pauses a machine according to validated logic.

1.3 SCADA, historians, and industrial IoT

SCADA systems supervise geographically distributed or plant-wide processes. They display states, alarms, trends, and operator controls. A historian stores time-stamped process values and events, making it possible to investigate production losses and train AI models.

Industrial IoT (IIoT) extends connectivity to machines, sensors, products, and information systems. Important design questions include sampling rate, time synchronization, data ownership, protocol conversion, network segmentation, and data quality. Common industrial communication technologies include OPC UA, MQTT, Modbus TCP, PROFINET, EtherNet/IP, and time-sensitive networking. The correct choice depends on latency, determinism, interoperability, security, installed equipment, and lifecycle support.

Edge computing places computation near the machine. It reduces latency, limits bandwidth use, and may preserve operation when cloud connectivity is unavailable. Cloud computing provides scalable storage, fleet-level analytics, model training, and cross-site comparison. A practical architecture often uses both: real-time inference at the edge and long-term analysis in a controlled cloud or data center.

1.4 MES and the production context

An MES connects production activities with business planning. It may manage work orders, recipes, dispatching, quality records, electronic work instructions, material genealogy, labor reporting, and equipment status. AI predictions become more valuable when interpreted in this context. For example, a predicted failure is more actionable if the MES knows the product currently running, the next scheduled changeover, the available spare parts, and the quality implications of delaying maintenance.

2. Digital Twins

2.1 Definition and distinguishing characteristics

A digital twin is more than a three-dimensional computer-aided-design model and more than a dashboard. It has four essential characteristics:

  1. A defined physical referent: an asset, process, product, line, or factory.
  2. A digital representation: geometry, states, behavior, constraints, and relevant metadata.
  3. Data connection: operational or contextual data update the representation.
  4. A purpose: monitoring, diagnosis, prediction, optimization, training, or control.

A static simulation can estimate behavior under specified assumptions but may not be connected to a particular operating asset. A digital shadow transfers data from the physical system to the digital system, usually without an automatic digital-to-physical feedback path. A digital twin may support bidirectional interaction, although the level of autonomy varies.

2.2 Types of twins

An asset twin represents one machine, robot, motor, or tool. A process twin represents a transformation such as machining, welding, assembly, or heat treatment. A product twin follows a product through its life cycle, including design configuration, production history, and field performance. A system or factory twin represents interactions among machines, material flows, personnel, schedules, and utilities.

Twins can also be classified by purpose:

  • Descriptive: What is happening now?
  • Diagnostic: Why did it happen?
  • Predictive: What is likely to happen next?
  • Prescriptive: What action is likely to produce the best result?
  • Autonomous or adaptive: Can the system safely act and learn within defined boundaries?

A twin should not model every available variable. The model must be fit for purpose. Excessive complexity increases cost, latency, validation effort, and the risk of misleading users.

2.3 Hybrid modeling

Industrial twins often combine first-principles models with data-driven AI. A physical model may describe mass balance, thermal behavior, kinematics, or energy consumption. Machine learning can represent unmodeled friction, tool wear, disturbances, or nonlinear interactions.

A simplified state-space representation is:

xt+1 = f(xt, ut, dt, θ) + wt
yt = h(xt, ut, θ) + vt

Here, xt is the system state at time t, ut is the control input, dt is a disturbance, yt is the measured output, θ is a parameter vector, and wt and vt represent process and measurement errors. The functions f and h describe system dynamics and measurement relationships. The equations apply when a discrete-time state model is an adequate approximation and the variables have been defined consistently.

A digital twin may estimate unmeasured states using an observer or a Kalman filter, simulate future operation, and compare predicted measurements with actual measurements. Persistent residuals can indicate sensor faults, process drift, or equipment degradation. However, residuals should not automatically be interpreted as failures; changes in product, recipe, environment, or operating regime may produce the same symptom.

3. AI Applications in Smart Manufacturing

3.1 Quality inspection

Machine vision is a prominent application. A camera captures images under controlled illumination, and a model detects defects, classifies products, or measures dimensions. Classification assigns an image to a category; object detection identifies and localizes defects; segmentation labels pixels or regions; and optical metrology estimates geometric quantities.

A confusion matrix distinguishes true positives, false positives, true negatives, and false negatives. For a defect class:

Precision = TP ÷ (TP + FP)
Recall = TP ÷ (TP + FN)

Precision measures the proportion of predicted defects that are actually defective. Recall measures the proportion of actual defects detected. TP, FP, TN, and FN denote true positives, false positives, true negatives, and false negatives. These measures assume a defined positive class and a fixed decision threshold. In safety-critical or high-cost applications, recall may be prioritized, while excessive false rejects may reduce throughput and require human review.

Accuracy, (TP + TN) ÷ (TP + TN + FP + FN), can be misleading when defects are rare. A model that labels every product as good may have high accuracy but zero defect recall. Validation data must represent lighting changes, product variants, operators, machine conditions, and unusual but important defects.

3.2 Predictive maintenance

Predictive maintenance estimates the probability or timing of failure from sensor and maintenance data. Useful features include vibration spectra, temperature trends, motor current, acoustic emissions, cycle time, lubrication condition, and alarm history. Methods include anomaly detection, remaining-useful-life regression, survival analysis, and supervised classification.

A maintenance decision should combine model output with consequence, inspection cost, spare-part lead time, production schedule, and safety requirements. The objective is not merely to maximize prediction accuracy. It is to reduce total risk and cost while preserving availability and quality.

3.3 Process optimization

Process optimization adjusts controllable variables such as speed, feed, temperature, pressure, robot trajectory, dwell time, or dosing rate. The objective may be to minimize energy or scrap subject to quality, throughput, and safety constraints.

A general constrained formulation is:

minimize J(u)
subject to g(u) ≤ 0,
h(u) = 0,
umin ≤ u ≤ umax

Here, u is the vector of controllable decisions, J(u) is the objective function, g(u) represents inequality constraints, h(u) equality constraints, and umin and umax operating limits. The formulation is valid only when the objective, constraints, and feasible operating region are defined. In industrial use, optimization must also account for uncertainty, model error, actuator limits, and safe fallback behavior.

Model-predictive control (MPC) repeatedly predicts future outputs over a finite horizon, solves a constrained optimization problem, applies the first control action, and repeats after new measurements arrive. AI can improve the prediction model or estimate disturbances, but the closed-loop system requires stability analysis, constraint handling, and commissioning under controlled conditions.

3.4 Energy management

Energy intelligence combines submetering, production data, tariffs, equipment states, and environmental information. A basic specific energy consumption measure is:

SEC = E ÷ Q

where E is energy consumed, commonly in kWh, and Q is accepted production quantity, such as units or kilograms. Thus, SEC has units such as kWh/unit. Comparisons are meaningful only when product mix, operating conditions, quality level, and system boundaries are comparable.

AI can forecast demand, detect abnormal consumption, schedule flexible loads, identify compressed-air leaks, and coordinate storage or on-site generation. A reduction in energy intensity is not automatically beneficial if it causes increased scrap, slower delivery, or unsafe operation. Multi-objective evaluation is necessary.

3.5 Flexible production and scheduling

Flexible manufacturing requires rapid changeovers, modular equipment, reconfigurable robots, and adaptive scheduling. AI may predict operation times, allocate jobs, sequence products, or recommend workforce and machine assignments. Scheduling models must respect precedence, machine eligibility, material availability, setup time, due dates, and maintenance windows.

A useful performance measure is overall equipment effectiveness (OEE):

OEE = Availability × Performance × Quality

where each factor is expressed as a fraction between 0 and 1. A common definition is:

Availability = Planned Production Time − Stop Time ÷ Planned Production Time

For clarity, the numerator is interpreted as (Planned Production Time − Stop Time). Performance compares ideal cycle output with the time available, and Quality is accepted units divided by total units. Definitions must be standardized because organizations sometimes classify planned stops, minor stops, and speed losses differently.

Worked example. A line has 450 minutes of planned production time and 45 minutes of unplanned stop time. It produces 760 units at an ideal cycle time of 0.5 minutes per unit, of which 730 are accepted. Availability is (450 − 45) ÷ 450 = 0.900. Performance is (0.5 × 760) ÷ 405 ≈ 0.938. Quality is 730 ÷ 760 ≈ 0.961. Therefore, OEE is approximately 0.900 × 0.938 × 0.961 ≈ 0.811, or 81.1%. The result is useful only if the measurement definitions and time boundaries are consistent.

4. Data, Models, and Deployment

4.1 Data quality and governance

Industrial data commonly contain missing values, duplicated events, sensor drift, inconsistent tags, clock offsets, recipe changes, and undocumented manual interventions. A trustworthy system requires a tag dictionary, asset hierarchy, time synchronization, units, calibration records, data lineage, and clear ownership.

Training data must be separated into training, validation, and test sets without leakage. For time-dependent production data, random splitting may place nearly identical observations from the same production run in both training and test sets, producing an unrealistically optimistic result. Chronological or group-based splitting is usually more appropriate.

Models should be evaluated using operationally relevant metrics. A vision model may require recall by defect type and false-reject cost. A forecast may use mean absolute error:

MAE = (1 ÷ n) ∑ᵢ₌₁ⁿ |yᵢ − ŷᵢ|

where n is the number of observations, yi is the actual value, and ŷi is the prediction. MAE has the same units as the target variable and is less sensitive to large errors than squared-error measures.

4.2 Deployment and the MLOps lifecycle

Industrial AI should be managed through a lifecycle: define the decision, collect and label data, establish a baseline, train and validate, conduct a pilot, integrate with plant systems, monitor performance, manage versions, and retire or retrain the model when conditions change.

Monitoring must include both technical and operational indicators: data completeness, latency, input distribution shift, prediction confidence, false alarms, missed defects, operator overrides, downtime, scrap, and energy intensity. A model that remains statistically accurate but no longer supports a valuable decision is not successful.

AI outputs should have a clear status, such as advisory, semi-automatic, or automatic. Confidence thresholds, human escalation, audit logs, rollback capability, and safe fallback logic are essential. Explainability may involve feature importance, saliency maps, example-based explanations, or a physical rationale. Explanations should support engineering decisions rather than create a false impression of certainty.

5. Cybersecurity, Safety, and Governance

Connecting operational technology increases the attack surface. Threats include unauthorized control, ransomware, manipulation of sensor data, theft of recipes, model poisoning, denial of service, and compromise of remote access. Important controls include network segmentation, least privilege, multifactor authentication, asset inventories, secure configuration, patch management, backups, logging, anomaly detection, and tested incident-response plans.

Safety and cybersecurity are related but not identical. A cyber event can create a hazardous state, while a safe machine can still expose confidential production data. Risk assessment should address functional safety, machine guarding, emergency stops, software changes, and the consequences of incorrect AI recommendations. AI should not silently replace certified safety functions.

Governance questions include who owns production data, whether workers are informed about monitoring, how performance data affect employment decisions, how suppliers use collected data, and how long records are retained. Regulatory obligations vary by jurisdiction and application. Traceability, documented validation, access control, and human oversight are prudent baseline practices, especially where products affect health, transport, or public safety.

6. Illustrative Case: Digital Twin for an Automated Packaging Cell

Background

Consider a fictional food-packaging plant operating a robotic pick-and-place cell. The cell contains conveyors, a vision camera, a robot, a sealing unit, a PLC, SCADA, and an MES. The plant experiences intermittent seal defects and unplanned stoppages in the sealing unit.

Problem

The existing system records alarms but does not connect them to product batches, ambient conditions, recipe settings, or maintenance history. Operators often respond after defects have accumulated. Management wants to improve quality without reducing throughput.

Analysis

Engineers first define the decision: whether to adjust sealing temperature and dwell time, divert products for inspection, or schedule maintenance. They instrument seal temperature, heater current, pressure, conveyor speed, ambient humidity, product recipe, and accepted/rejected status. The MES supplies batch and work-order context, while the historian supplies time-series data.

A process twin predicts expected seal quality from recipe and operating variables. A separate anomaly model detects unusual heater-current and temperature-response patterns. The models are evaluated on later production batches rather than randomly mixed samples. Because a missed defect is more costly than a temporary manual inspection, the operating threshold is selected to achieve high recall while controlling false rejects.

Approach and solution

The edge computer receives synchronized data and calculates features. It sends an advisory state to SCADA: normal, inspect, or maintenance-check. The PLC remains responsible for interlocks, emergency behavior, and the validated reject mechanism. When the state is “inspect,” the MES creates a quality hold and associates affected products with the relevant batch and machine state. Maintenance personnel receive a work order only when the anomaly persists beyond a defined duration and is supported by corroborating evidence.

The twin also simulates alternative temperature and speed settings before engineers test them on the line. A controlled trial compares defect rate, false rejects, cycle time, and energy consumption against a baseline.

Outcome

In this illustrative scenario, the plant reduces the time between the onset of heater degradation and maintenance intervention. It also improves traceability because each quality decision is linked to a recipe, batch, sensor state, and model version. The system does not eliminate operators; it changes their role from searching manually through alarms to reviewing prioritized evidence and managing exceptions.

Learning points

The principal benefit comes from integration rather than from a single algorithm. The case demonstrates the need for clear decisions, reliable instrumentation, contextual MES data, edge deployment, human oversight, versioned models, and a safe separation between advisory AI and deterministic control.

7. Implementation Strategy and Critical Evaluation

A sensible implementation begins with a high-value, measurable problem rather than a desire to “use AI.” The organization should establish a baseline, identify process owners, map data flows, verify instrumentation, and estimate the cost of errors. A pilot should be small enough to control but representative enough to expose real operating variation.

Technology selection should favor interoperability, maintainability, cybersecurity, and lifecycle support. Open information models and documented interfaces reduce dependence on one supplier. Engineers should avoid collecting data without a defined use, deploying black-box models where a simple rule is sufficient, or optimizing one metric at the expense of system performance.

Digital twins also have limitations. Models become obsolete when equipment, products, software, or operating policies change. Sensors may not measure the variables that matter most. Correlation does not establish causation. Rare failures create limited labels. A highly accurate model in a laboratory may fail after deployment because of domain shift. Simulation can produce false confidence when assumptions are not validated against physical measurements.

Contemporary developments include foundation models for industrial documents and multimodal inspection, physics-informed learning, federated learning across plants, synthetic data generation, industrial knowledge graphs, and reinforcement learning for operational decisions. These developments are promising but require careful validation. Generative systems can produce plausible but incorrect recommendations, and reinforcement learning should not explore unsafe actions on live equipment without a verified simulator, constraints, and a controlled transition strategy.

Chapter Summary

Smart manufacturing integrates physical equipment, PLC control, SCADA supervision, industrial IoT, historians, MES, ERP, analytics, and AI. Each layer has a distinct responsibility; AI should enhance engineering decisions without bypassing deterministic safety and control functions.

A digital twin is a purpose-driven, data-connected representation of a physical asset, process, product, or factory. It may be descriptive, diagnostic, predictive, prescriptive, or adaptive. Hybrid twins combine physical knowledge with data-driven models and are often more useful and explainable than purely empirical systems.

Important applications include machine vision, predictive maintenance, process optimization, energy management, flexible scheduling, and production traceability. Metrics such as precision, recall, MAE, SEC, availability, and OEE must be defined consistently and interpreted in operational context. Effective deployment depends on data quality, time synchronization, model validation, monitoring, version control, human oversight, cybersecurity, and safe fallback behavior.

The strategic lesson is that digital transformation is socio-technical. Its success depends not only on algorithms, but also on reliable instrumentation, interoperable architecture, skilled personnel, responsible governance, and measurable business and engineering outcomes.

Key Terms

Smart manufacturing: Integrated, data-enabled production using automation, connectivity, analytics, and intelligent decision support.

Digital twin: A connected digital representation of a physical asset, process, product, or system used for a defined operational purpose.

PLC: Programmable logic controller used for deterministic industrial control.

SCADA: Supervisory control and data acquisition system for monitoring, alarms, visualization, and supervisory operation.

Industrial IoT: Networked industrial devices and systems that collect, exchange, and use operational data.

MES: Manufacturing execution system that coordinates and records production operations.

Edge computing: Processing data near the physical source rather than exclusively in a remote cloud.

Digital shadow: A digital representation updated by the physical system without necessarily providing a feedback path.

Asset twin: Digital twin focused on an individual machine, device, or component.

Hybrid model: Model combining first-principles knowledge with data-driven learning.

Predictive maintenance: Maintenance planning based on predicted degradation or failure risk.

Machine vision: Image-based sensing and analysis for inspection or measurement.

Precision: Fraction of predicted positive cases that are actually positive.

Recall: Fraction of actual positive cases correctly detected.

OEE: Product of availability, performance, and quality factors.

Specific energy consumption: Energy used per accepted unit of production.

Model drift: Reduction in model validity caused by changes in data, equipment, products, or operating conditions.

MLOps: Practices for deploying, monitoring, governing, and maintaining machine-learning models.

Industrial cybersecurity: Protection of operational technology, control systems, data, and connected equipment from cyber threats.

Review Questions

Short Answer Questions

  1. What distinguishes a digital twin from a static simulation?
  2. State the principal roles of a PLC, SCADA system, and MES.
  3. Why can accuracy be misleading for rare-defect inspection?
  4. Define edge computing and identify one industrial advantage.
  5. What are the three factors in OEE?

Long Answer Questions

  1. Explain how AI can be integrated with a PLC-controlled production line without compromising deterministic control and safety.
  2. Compare asset, process, product, and factory digital twins, giving one application for each.
  3. Discuss the data-governance requirements for training and deploying an industrial AI model.
  4. Explain how a hybrid digital twin combines physical models and machine learning, including its advantages and limitations.
  5. Evaluate the cybersecurity, workforce, and ethical implications of connecting a factory to cloud-based analytics.

Analytical / Application Questions

  1. A vision system detects 92 defective products, of which 80 are truly defective. There are 10 additional defective products it misses. Calculate precision and recall, then explain which operational cost each metric represents.
  2. Design an architecture for a flexible robotic assembly cell integrating sensors, PLC, SCADA, edge AI, MES, and a digital twin. Identify data flows, control boundaries, and at least four cybersecurity controls.
  3. A factory wants to reduce energy consumption by changing machine schedules using AI. Propose an evaluation plan that measures energy, throughput, quality, delivery performance, and safety rather than energy alone.

Multiple Choice Questions with Answers

Question 1

Which system is primarily responsible for deterministic machine sequencing and real-time interlocking?

A. ERP

B. PLC

C. Data lake

D. MES

Correct Answer: B. PLC

Question 2

Which feature most clearly distinguishes a digital twin from a static CAD model?

A. It always contains a three-dimensional rendering

B. It is connected to relevant physical-system data for a defined purpose

C. It cannot be used for prediction

D. It replaces all physical sensors

Correct Answer: B. It is connected to relevant physical-system data for a defined purpose

Question 3

A defect-inspection model identifies 90 products as defective, of which 72 are truly defective. What is its precision?

A. 72%

B. 80%

C. 90%

D. 18%

Correct Answer: B. 80%

Question 4

Which metric measures the proportion of actual defects that a model detects?

A. Recall

B. Precision

C. Availability

D. Specific energy consumption

Correct Answer: A. Recall

Question 5

What is a principal advantage of edge computing in industrial applications?

A. It eliminates the need for sensors

B. It guarantees perfect predictions

C. It can reduce latency and continue operating during cloud disconnection

D. It replaces all PLC logic

Correct Answer: C. It can reduce latency and continue operating during cloud disconnection

Question 6

A line has availability 0.90, performance 0.80, and quality 0.95. What is its OEE?

A. 0.684

B. 0.720

C. 0.855

D. 2.650

Correct Answer: A. 0.684

Question 7

Which statement about AI and machine safety is most appropriate?

A. An unvalidated AI model should directly replace emergency-stop logic

B. AI recommendations should be separated from validated safety functions unless the complete system is appropriately engineered and certified

C. Cybersecurity is unrelated to safety

D. Safety is guaranteed when model accuracy exceeds 90%

Correct Answer: B. AI recommendations should be separated from validated safety functions unless the complete system is appropriately engineered and certified

Question 8

Why is random splitting of time-dependent production data potentially misleading during model validation?

A. It always decreases model accuracy

B. It may place closely related observations from one production run in both training and test sets

C. It prevents any use of historical data

D. It removes all sensor noise

Correct Answer: B. It may place closely related observations from one production run in both training and test sets

Question 9

Which digital-twin type primarily follows configuration and history of an individual product through its life cycle?

A. Product twin

B. Asset twin

C. Network firewall

D. SCADA alarm

Correct Answer: A. Product twin

Question 10

If a process consumes 500 kWh to produce 1,000 accepted units, what is its specific energy consumption?

A. 0.5 kWh/unit

B. 2 kWh/unit

C. 500 kWh/unit

D. 1,500 kWh/unit

Correct Answer: A. 0.5 kWh/unit

Artificial Intelligence in Mechatronics Applications
Chapter 11 of 15