Digital Twin for a Smart Factory Using an OpenPLC Controller on STM32H7

Summary of a lab-scale smart factory with an STM32H7 OpenPLC controller and a Three.js and Node.js digital twin that monitors and controls the real machine in 3D.

Daftar isi
  1. Watch the video
  2. The problem
  3. What is new in this work
  4. Research method
  5. The physical system
  6. The controller board
  7. The digital twin application
  8. Test results
  9. Discussion
  10. Conclusion
  11. How to read these results
  12. Why it matters
  13. Acknowledgement
  14. Selected references

Most factory dashboards show numbers: a sensor is on, a motor is running, a counter reached 120. They rarely show what the machine is actually doing. When a production line has many devices, that gap slows down diagnosis and decisions.

This article summarizes a paper that closes the gap with a digital twin: a live 3D copy of a lab-scale smart factory that mirrors the real machine and can also send commands back to it. The controller is an open-source OpenPLC runtime on a 500 MHz STM32H7 microcontroller instead of a commercial PLC.

Arifianto, M. J. F., Afianto, & Nugroho, W. (2025). Development of Digital Twin Modeling for Smart Factory using OpenPLC-Based Control System. Jurnal E-Komtek, 9(2), 582–592. DOI: 10.37339/e-komtek.v9i2.2856.

Watch the video

A short reel from the Mechatronics program on Instagram (@mechatronics_astratech) introduces this digital twin and OpenPLC research.

If the video does not load, watch it on Instagram.

The problem

The paper starts from three limits of conventional manufacturing systems:

  • Low line flexibility. Production lines adapt poorly to changing products.
  • Hard monitoring and control. Many complex devices are difficult to oversee.
  • Flat visualization. HMIs and dashboards show technical data in 2D, with no realistic picture of the process.

Commercial PLCs and HMIs are also relatively expensive and often imported. Earlier digital twin work either stayed at illustrations and block diagrams, or (as in a 3D SCADA system for olive oil mills, Martinez-Ruedas et al., 2024) needed extensive hardware and development tools. Many studies lacked real-time, two-way interaction with the physical system.

What is new in this work

The authors claim two contributions:

  1. An interactive 3D twin. It shows status, indicators, and the physical movement of mechanical parts, and users can zoom, pan, and rotate the view.
  2. A faster open-source controller. Low-power microcontrollers running OpenPLC are limited to roughly 16 to 48 MHz, and a Raspberry Pi costs more and takes tens of seconds to boot. The STM32H7 runs at 500 MHz, boots in hundreds of milliseconds, and offers digital and analog I/O plus network-ready communication (HTTP, MQTT, WebSocket, TCP/IP).

Research method

Flowchart of the research methodology: requirement analysis, then parallel design of electronics, mechanics, and the digital twin app, followed by integration, testing, and documentation.

The work follows four stages:

  1. Requirement analysis. Three subsystems: mechanical, electronic/control, and the digital twin application.
  2. System design. The three subsystems are designed in parallel. The 3D CAD model of the mechanics also feeds the digital twin app.
  3. Integration. Everything is connected over industry-standard protocols (TCP/IP, MQTT, WebSocket) through a server.
  4. Testing and evaluation. If the prototype does not match the requirements, it is modified and retested.

The five success indicators were: the board reads sensors and drives actuators; it exchanges data with the server; the machine runs the specified sequence; the twin visualizes the state in real time; and the twin can control actuators from the 3D view.

The physical system

The study focuses on a processing station that belongs to a larger planned smart factory line (processing, packaging, and storage stations).

Initial design of the smart factory with processing, packaging, and storage stations.

The prototype uses:

  • an aluminum profile frame built from the CAD design;
  • a mini conveyor with a 12 V DC motor;
  • pneumatic actuators that drive the gripper and a linear axis;
  • a proximity sensor at the end of the conveyor to detect workpieces.

The controller board

The control board is built around an STM32H7 microcontroller and programmed with OpenPLC. It reads sensors through digital I/O, runs the control logic (ladder, STL, IL, or FBD programs), and drives the actuators (the photo shows relay outputs on the board).

The STM32H7 OpenPLC controller board with terminal blocks and relay outputs.

OpenPLC keeps the programming familiar to automation engineers (ladder and function block style programs) on an open, low-cost platform.

The digital twin application

The twin is a web application built with Three.js (3D graphics in the browser) and Node.js (server). It shows sensor and actuator states and provides manual control of the conveyor, gripper, and pneumatic actuator.

Block diagram: a web application with Three.js and a WebSocket/TCP-IP module connects over LAN/WLAN to a Node.js server, which connects via MQTT to the OpenPLC controller with its sensors and actuators.

The data path is:

  • Machine to browser. Sensor states go from the OpenPLC controller over MQTT to the Node.js server, then to the web app over TCP/IP and WebSocket, which updates the 3D model.
  • Browser to machine. A command in the 3D view travels back along the same path and moves a real actuator.
  • Network. LAN or WLAN, locally or through the internet.

The paper describes this as two-way interaction, which is the key difference from a monitoring-only dashboard.

Left: the Three.js digital twin. Right: the matching physical system.

Test results

Table 1 in the paper summarizes the initial tests. All components met their indicators:

Component Success indicator Result
Displacement sensor Detect and count workpieces 95% success rate
Conveyor actuator Responds according to logic Normal
Gripper and linear axis Move according to instruction 0.1 mm accuracy
OpenPLC control I/O response time below 500 ms 200 to 300 ms
Digital twin application Real-time visualization Real-time movement
Data communication Bidirectional (monitor and control) Both directions work
Sequence process Runs in the set order Normal

Two numbers matter most for practice. A 200 to 300 ms I/O response is well inside the 500 ms target for a lab demonstrator, and the 3D view follows the machine in real time. The 95% detection rate means roughly one in twenty workpieces was missed, which would need attention in a real production line.

Discussion

The authors argue that the twin bridges the physical and virtual factory:

  • Transparency. Bidirectional exchange keeps both sides synchronized, so operators can monitor, analyze, and control the process.
  • Cost and reliability. An open-source controller lowers system cost while staying reliable and flexible enough for the use case.
  • Interoperability. Standard protocols such as Modbus TCP/IP let physical devices and the simulation platform exchange data continuously.
  • Virtual commissioning. The authors state that testing through the twin shortens setup time and lowers the risk of operating errors.

Two challenges remain: scalability and latency when the system grows to more complex manufacturing operations. Future work points to edge computing and machine learning for faster processing, prediction, and autonomous decisions.

Conclusion

A lab-scale smart factory with an STM32H7 OpenPLC controller and a Three.js and Node.js digital twin was designed, built, and tested. The controller read sensors and drove actuators stably, and the twin displayed the machine state in interactive 3D with bidirectional control. The authors conclude that combining a digital twin with an open-source controller gives a more flexible and economical automation option and supports domestic products.

How to read these results

The paper is a prototype report, so keep its scope in mind:

  • The tests are initial ones on a single processing station. Sample sizes and test duration are not described.
  • The cost advantage is stated qualitatively; no cost comparison with a commercial PLC is given.
  • The setup-time reduction from virtual commissioning is reported as a finding but without measurements.
  • Latency and scalability were not tested under larger loads; the authors list them as open challenges.

Why it matters

This work shows that a digital twin does not need an expensive PLC and SCADA stack. A 500 MHz microcontroller, open-source PLC software, and browser-based 3D graphics are enough to build an intuitive monitoring and control view for teaching and small-scale automation.

Acknowledgement

The research was funded by the Directorate of Research and Community Service, Ministry of Education, Science and Technology (Kemdiktisaintek), Indonesia.

Selected references

  • Soori, M., Arezoo, B., & Dastres, R. (2023). Internet of things for smart factories in industry 4.0, a review. Internet of Things and Cyber-Physical Systems, 3, 192–204. doi:10.1016/j.iotcps.2023.04.006
  • Soori, M., Arezoo, B., & Dastres, R. (2023). Digital twin for smart manufacturing, a review. Sustainable Manufacturing and Service Economics, 2, 100017. doi:10.1016/j.smse.2023.100017
  • Biesinger, F., Meike, D., Kraß, B., & Weyrich, M. (2019). A digital twin for production planning based on cyber-physical systems. Procedia CIRP, 79, 355–360. doi:10.1016/j.procir.2019.02.087
  • Martinez-Ruedas, C., Flores-Arias, J.-M., Moreno-Garcia, I. M., Linan-Reyes, M., & Bellido-Outeiriño, F. J. (2024). A cyber–physical system based on digital twin and 3D SCADA for real-time monitoring of olive oil mills. Technologies, 12(5), 60. doi:10.3390/technologies12050060
  • Fujita, S., Hata, K., Mochizuki, A., et al. (2021). OpenPLC based control system testbed for PLC whitelisting system. Artificial Life and Robotics, 26, 149–154. doi:10.1007/s10015-020-00635-1
  • Hubacz, M., & Trybus, B. (2023). Dual-core PLC for cooperating projects with software implementation. Electronics, 12(23), 4730. doi:10.3390/electronics12234730

Artikel terkait

MikrokontrolerKomunikasi Serial

GPRS communication with Arduino and SIM300 DZ

Today I would like to share my experience about Arduino which communicates with GSM/GPRS module, SIM300 DZ from SIMCOM. Before I start, let me explain the…

2013 4 menit baca