The present study aims to explore the further application of digital twins in intelligent manufacturing, typically for machining processes to obtain and monitor process parameters in a real-time manner, which is not actually considered with currently available relevant technology. Therefore, we attempted to develop a digital twin system, based on a small-scale milling station, which can specifically achieve real-time monitoring in machining process parameters, i.e., stress and strain variation on the milling surface of the workpiece. We believe this is crucial to ensure the quality of the milling surface, as the data obtained can be used as inputs for optimum control of the milling process. The real-time data of stress and strain are obtained by integrating with our developed DT system the finite element modeling approach, which calculates the relevant data in a real-time manner. This section details the framework, and also every single component, of our developed DT system.
3.1. The Framework of Our Developed Digital Twin System
This paper presents a prototype designed to assess the feasibility and applicability of the proposed technical solution. Our developed DT system consists of three fundamental components: the design of the physical twin (i.e., the hardware milling station), the virtual twin (the virtual model of the milling station), and the FEM-based computer simulation module for obtaining real-time variation of stress and strain. The framework of the whole system is shown in
Figure 1.
First of all, the DT system can conduct real-time control and monitoring of the motion sequence of the milling station which is basically a three-axis gantry machine. For real-time control, our virtual twin is integrated with a graphic user interface (GUI), where the user can input motion commands which are sent to the machine controller (i.e., the Siemens S7-1200 PLC) and, subsequently, drive the coordinated motion of the three axes. During the operation of the physical machine, the real-time motion parameters of each axis are measured by the rotary encoder, which is sent to the virtual twin that drives the synchronous motion of the virtual model, with the relevant data also displayed on the GUI; hence, the real-time monitoring is achieved. The real-time monitoring overlooks not only that there is no malfunction in the motion behavior of the physical machine, but also the motion accuracy in estimating the deviation between the command (expected) and actual motion parameters.
Apart from real-time monitoring, control, and synchronization of axis motion sequence, the machining process parameters, especially the stress/strain variation, can be monitored in a real-time manner. Real-time variation of stress and strain on the surface (of a workpiece) being processed are calculated by a solver, based on FEM approach, which is implemented in ANSYS workbench [
19]. The input of the FEM-based mathematical model, i.e., the real-time variation of the applied milling force, is obtained from the force sensor (parallel beam pressure sensor with a maximum range of 100 kg) and stored in the control PLC which is, then, transmitted to the database and subsequently accessed by the ANSYS FEM solver. Hence, the real-time deformation of the milling surface, characterized by the process parameters stress and strain, can be monitored.
To verify the validity of our FEM solver, as well as the accuracy of obtained stress/strain data, we physically measured the real-time strain variation over the milling surface using a laser range finder, which is then compared with our FEM simulated results (such comparison and verification are presented in
Section 4.2).
In selecting the platform for the creation of the virtual interface in this study, Unity 3D was chosen, considering its renowned user-friendly interface. Unity is designed to be a cross-platform game engine that allows for flexibility in deploying applications across different operating systems and devices. This is particularly advantageous if the digital twin system needs to run on diverse hardware configurations, in contrast to Unreal engine. In addition, the choice of Unity for data transmission via the TCP socket protocol suite might be influenced by the ease with which Unity facilitates networking and communication between different components of the digital twin [
20].
3.2. The Physical Twin
The physical twin stands for the hardware platform of the actual milling station, as shown in the bottom left of
Figure 1. Detailed views showing the configuration of this milling station are shown in
Figure 2.
In the present study, we considered a small-scale milling machine, which is a mock-up of the actual machine in a real industrial scenario, and this is due to the constraints of our experimental condition, e.g., budget constraints, space constraints, the policy restrictions in the laboratories that do not allow us to carry out metallic processing, etc. Nevertheless, within the permissible experimental conditions, we attempted to reproduce, as closely as possible, the real industrial scenario, despite the simplifications introduced, i.e., we extensively used industrial devices including PLC-based control systems, industrial actuators, sensors, etc.
As shown in
Figure 2, our small milling machine has the gantry configuration, enabling the end tool (i.e., end effector) having linear motion in three directions, i.e., x, y, and z axes. Such linear motion in each axis is realized using lead-screw transmission modules driven by stepper motors. The lead of the screw shaft is 2 mm/rev, meaning a linear displacement of 2 mm for each revolution made by the stepper motor.
Primarily, the physical twin pertains to a corporeal apparatus employed for the direct execution of a designated process. This component assumes responsibility for pragmatic operations, encompassing material processing and morphological alterations, thereby furnishing authentic data to underpin the experimentation. Instead of one hundred percent reproducing the real industrial scenario, we did introduce simplifications but tried our best to remain as close as possible to the real industrial applications, e.g., used the PLC-based control system, and also as many industrial actuators and sensors, etc., as we can within the constraints of our experimental conditions. Upon confirmation of the applicability of our approach, as reported in this paper, the immediate future work will consider applying our approach in real scenarios, and we will try to find a way to completely reproduce the real industrial cases.
For the control system, the Siemens Programmable Logic Controller (PLC), version S7-1214C, was used to control the axis motion and machining process. The Siemens S7-1200 is a compact PLC which is widely applied in small- and medium-scale industrial automated systems, and is particularly suitable in most basic control applications, such as controlling the motion sequence for machines such as gantry machine tools, Cartesian robot arms, etc. [
21,
22]. The compact design of S7-1200 can effectively minimize spatial requirements and enhance adaptability across diverse applications. It can manage complicated control tasks, thus achieving efficient automation and precision in control processes. A special feature of S7-1200 is due to its wide choices of communication interfaces, with Ethernet protocols such as TCP/IP and PROFINET, series protocols like RS422 and RS485, and even wireless communications. This diversity allows integration into the relevant control system of various devices and systems, thus enabling a comprehensive networking infrastructure and seamless data exchange. As compared with other models of PLCs, the S7-1200 is not only compact and versatile (over, e.g., Mitsubishi, FX3U series), but is also much less expensive (over SIEMENS S7-1500), which renders it ideal for small/medium-scale applications like that of our study. Further, a PLC is apparently more powerful than microcomputers, e.g., Raspberry Pi and Arduino, in the context of CPU capability, driving power of I/OS, etc. As we always retain the possibility of expanding our facility by integrating with more industrial devices, e.g., pneumatic and electromagnetic actuators, electromagnetic valves, and relays, as well as industrial sensors, all of which are unable to be driven by Raspberry Pi and/or Arduino, a PLC is, thus, preferred. To obtain motion parameters of each axis, i.e., the actual angular displacement and speed of respective stepper motors, rotary incremental encoders are mounted with the stepper motors of each axis. The encoders feed back the measurements to PLC through digital input terminals of the PLC. To obtain real-time applied milling force imposed on the workpiece, a balanced beam pressure sensor is used, which feeds back its measurements to the PLC through a communication terminal applying MODBUS RTU protocol. To measure the real-time strain variation, characterizing the deformation of the milling surface, a laser rangefinder (BLG-50) is used.
The workpiece considered in our study is the housing of a gear pump, as shown in
Figure 3. Instead of considering iron, the actual material that is used for such parts, our workpiece, again as a mock-up, is made of resin material. The surface to be milled is its front face, which is indicated in
Figure 3.
The motion control program for the gantry milling machine is developed using the Siemens-provided software platform, i.e., TIA portal V18 [
23], installed in the master computer. Communication between the master computer and the PLC is via the TCP/IP protocol, enabling the control program to be transferred to the PLC. Structured control language (SCL) is the main programming language for this axis motion control program, which also follows the PLCopen standard [
24].
Figure 4 shows the program flow chart, indicating the following basic control functions for the three axes of the gantry milling machine:
Home: executed before and after a set of tasks, ensuring the robot gripper is in its initial position (zero) before starting the next task.
Hand control mode: enables manual operation of the robot arm.
Automatic control mode: enables coordinated motor movement of the three axes for effective object handling.
3.3. The Virtual Twin
The virtual twin, as the virtual counterpart of the aforementioned physical twin, was developed based on Unity 3D [
25], which basically includes digital twin (DT) models representing virtual models for the tangible process execution terminal with the gantry machine, and the workpiece. Continuous real-time data synchronization and amalgamation between the DT and the physical world were realized (to be discussed in
Section 3), which enables our developed DT to simulate, monitor, and analyze the entirety of the process.
The virtual twin of our milling station, together with the workpiece, is shown in
Figure 5. The relevant 3D models were created using PTC Creo [
26] and saved as STEP format files, including the milling machine assembly, the gear pump housing, etc. We then used a Blender plugin (OCC Import) [
27] to convert the STEP files to Blender format, which is further converted into FBX formatted files readable by Unity 3D (as it cannot directly read either STEP or Blender files). It is noted that conversions of file formats do result in loss of certain information, e.g., material properties, chemical compositions, etc. In addition, we also applied the merging of some model parts in the original machine assembly to simply the model in the virtual twin, thus reducing the computational load. Despite the simplification and the conversions made in the virtual twin modeling, we always pay special attention to retaining the key information essential to our modeling, such as motion pairs defining the relative motion of, e.g., lead-screw and nut, a key dimension of the workpiece.
3.4. Finite Element Modeling (FEM) of Milling Surface Deformation
A simulation computation terminal, based on ANSYS Workbench, was developed, which uses the finite element modeling (FEM) approach to simulate the machining processing under various work conditions, especially with different applied cutting force. The real-time process parameters that are vital to machining processing can be obtained, including strain and stress on the workpiece and cutting tool, etc.
To enable automatic execution of this simulation module, we applied a Python pip pyWbunit [
28] using Python script, which defines all necessary model settings to automatically drive the computational model in ANSYS Workbench, instead of using ANSYS GUI for setting up and running the model manually. The flowchart of the simulation procedure, as defined with this Python script, is shown in
Figure 6.
As for the mathematical model, we developed this based on ANSYS static structure analysis module, which is actually the static force model. This model is described as below:
Elastic mechanics equation: Constitutive equation for linear elastic materials:
where
is stress,
E is Young’s modulus (elastic modulus), and
is strain.
Equilibrium equation: Equilibrium equation:
Here,
is stress within the cross-sectional area
A, and
F represents the external forces acting on the structure.
Displacement–force relationship: Displacement–force relationship for elastic bodies:
where
u is displacement,
A is the cross-sectional area,
E is Young’s modulus, and
is stress.
For elastic bodies, the relationship between strain and displacement can be expressed as follows:
Here,
is strain, and
u,
v, and
w represent the displacements in the
x,
y, and
z directions, respectively.
3.5. Data Collection and Transmission
The force sensor’s load feedback data are acquired by the PLC through the MODBUS RTU communication protocol. The motor parameters, on the other hand, are gathered via the built-in pulse generator of the PLC. Encoder data collection is executed with the high-speed counter integrated in the PLC. We developed necessary communication interfaces, by programming scripts in both C# and Python, to achieve real-time communication and data exchange in between the physical milling machine (the physical twin) and its DT counterpart (the virtual twin). Real-time retrieval of readings from the rotary encoder (with the machine axis motion parameters) and the force sensor (with the applied milling force), which are stored in the PLC, are first transferred to the database (
Figure 1) of our virtual twin through TCP/IP communication protocol.
For motion control with the DT system, the database is accessed by Unity 3D, which finds rotary encoder readings to drive the virtual model of the milling machine (
Figure 5) for a synchronous motion with its physical twin (
Figure 2). Such data transmission is carried out through TCP/IP protocol, by adopting the S7Net plugin [
29]. With S7Net, the C# script reads and writes data at specific PLC addresses, thus enabling data transmission. For preparation of such data transmission with S7Net, the Siemens TIA portal needs to configure the protection setting for full access and disable optimization access in every DB block used. The Visual Studio version 2015 and later must be used with Microsoft. Net Framework 4.5.2 and its higher version.
For FEM simulation, the ANSYS-based solver (
Section 3.4) accesses the database to find the force sensor reads, i.e., the applied milling force, to drive the computation, obtaining real-time variation of stain and stress. Data transmission from the database to ANSYS Workbench is performed by applying Snap 7 [
30], which is, again, based on TCP/IP protocol.
After Unity is launched, the communication script will attempt to establish a connection with the PLC. Upon successfully establishing the connection, the methods within the update loop will continuously search for data from designated offset addresses within the PLC. These addresses should be preconfigured to store data related to the gantry machine’s position in the database (DB) block. Subsequently, these data will be transmitted to the monitoring script of the virtual milling machine to regulate its real-time positional information.
Data from the UI panel, related to the virtual control of the physical system, is written to another pre-established offset address, and
Figure 7 and Algorithm 1 show the UI panel design and pseudocode, respectively. These data include the user’s desired speed and direction for the machine’s movement. They are transmitted directly to the PLC’s motion control module, enabling the control of the machine’s movement through the PLC’s control panel, thereby achieving real control over the gantry machine tool. Furthermore, after switching the panel, it is possible to transfer “data regarding the direction and magnitude of force” to another offset address in the PLC. These data will be read and transmitted to ANSYS using Snap7 by a Python script, and, finally, ANSYS will complete the calculations. The data connectivity diagram is shown in
Figure 8.
Algorithm 1 UI Class Pseudocode |
- 1:
UI Class attributes and methods //Initialize UI Class attributes currentNumber ← “0” - 2:
currentBool ← [0,0,0] - 3:
screenText, XText, Ytext, Ztext, digital, digital1, result, Input ← Initialize attributes // OnDigitClick Method OndigitClick(digit) IF currentNumber==“0” - 4:
THEN currentNumber ← digit - 5:
end - 6:
else - 7:
currentNumber ← currentNumber + digit - 8:
end - 9:
screenText.text ← currentNumber // StrToFloat Method StrToFloat(FloatString) // if FloatString ≠ null and float. Tryparse(FloatString. ToString(), out foat result) then - 10:
RETURN result - 11:
end - 12:
RETURN 0.0f // Ondigit Method OnClearClick() currentNumber ← “0” - 13:
screenText.text ← “0” // OnDigit Method OnDigit(digit) index ← (int.Parse(digit) - 1)/2 - 14:
direction ← int.Parse(digit)% 2== 0 ?−1 : 1 - 15:
IF index ≥ 0 and index < 3 THEN - 16:
currentBool[index]← currentBool[index] + direction - 17:
end // Update Method Update() result[0]← StrToFloat(currentNumber) - 18:
XText.text ← “X:” (Input.outputAngleX/2) - 19:
YText.text ← “Y:” (Input.outputAngleX/2) - 20:
ZText.text ← “Z:” (Input.outputAngleX/2) - 21:
For i←0 to 2 do - 22:
digital[i] ← currentBool[i]==1 - 23:
digital1[i] ← currentBool[i]==−1 - 24:
result[i+1] ← digit[i] or digit1[i] ? result[0] : 0.0f - 25:
end
|
3.6. DT Monitoring System
In our DT system, the control of the gantry machine tool can be managed by applying either a human–machine interface (HMI) or Unity 3D. During the operation of the milling machine, its control PLC continuously receives and transmits real-time data, which serves as a data conduit facilitating the establishment of a comprehensive mapping between the physical twin and the virtual twin involving the Unity 3D and ANSYS-based FEM solver. The flow of data exchange among various modules for both the physical twin (the gantry machine with rotary encoders, the force sensor, and the laser range finder) and the virtual twin (the virtual model in Unity 3D and the ANSYS-based FEM solver) is displayed in
Figure 9. This enables effective real-time monitoring of the entire working procedure of this milling machine station, including real-time motion behavior and its accuracy, real-time applied milling force, the resulting simulated deformation variation with the accuracy of simulated results, etc.
The PLC, serving as a data conduit, is responsible for the continuous transmission of force-sensing data to ANSYS, a simulation software. These data, acquired during the machining process, are instrumental in the execution of mechanical simulation analyses within the ANSYS framework. The outcomes of these analyses are subsequently extracted as results, contributing deformation data of the processed entity.
For monitoring of motion precision and accuracy of each axis of the milling machine, for both the physical twin and the virtual twin, we use the rotary encoder readings as the reference. These readings are compared with expected motion parameters to ensure the motion accuracy of the physical machine being controlled by our DT system. On the other hand, these readings are compared with the motion parameters from the virtual machine in Unity 3D (
Figure 5) to examine whether the physical twin and the virtual twin are seamlessly synchronized.
For monitoring of the real-time applied force, the force sensor readings are accessed by the PLC, which is then transmitted to our DT system through TCP/IP protocol.
For monitoring of the real-time deformation of the workpiece during the milling process, the applied milling force readings from the force sensor are accessed by the ANSYS-based FEM solver to obtain real-time stress and strain data of the workpiece. To further verify the accuracy of simulated results from our FEM solver, we use the laser range finder, which physically measures the actual deformation condition of the workpiece, i.e., the strain over the processed surface, in a real-time manner during the milling process. The readings are then stored in the PLC, which are, in turn, accessed by our DT system through TCP/IP protocol and compared with the simulated results. The flow of communication and data transmission of the system is shown in
Figure 9 below.