# Development of a Small CNC Machining Center for Physical Implementation and a Digital Twin
## 6 Experimental Tests
\begin{table}
\begin{tabular}{c c c} \hline \hline
**Block** & **Block Name** & **Function** \\ \hline \multirow{4}{*}{Encoder} & \multirow{4}{*}{The Encoder block outputs the number of pulses from a quadrature encoder on a rotary motor connected to an Arduino board. Each increase in the number of encoder pulses indicates that the motor is rotating clockwise. Each decrease in the number of encoder pulses indicates that the motor is rotating counterclockwise. The total number of pulses represents the incremental position of the rotating motor. \\ \cline{1-1}  & & \\ \cline{1-1}  & & \\ \cline{1-1}  & & \\ \cline{1-1}  & & \\ \cline{1-1}  & & \\ \cline{1-1}  & & \\ \cline{1-1}  & & \\ \cline{1-1}  & & \\ \cline{1-1}  & & \\ \cline{1-1}  & & \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Main blocks from the Simulink Support Package for Arduino Hardware used in the structure of the simulation diagram in Figure 21.  
Figure 22: MATLAB–Simulink diagram for real-time control of X- and Y-axes motions. The diagram in Figure 22 also used two \"Numerical PID controller\" subsystems of the type shown in Figure 3 and two \"Reference position generation\" subsystems of the type shown in Figure 9. The sampling period used for the real-time control system was T = 0.001 s.  
Also used in the diagram in Figure 22 was the user function (introduced via a MATLAB Function block) \"Speed\", which had the following syntax:  
\[ \begin{array}{c}\text{function [pin1, pin2, pwm] = fcn(speed)}\\ \text{pin1}=1;\\ \text{pin2}=0;\\ \text{if speed < 0}\\ \text{pin1}=0;\\ \text{pin2}=1;\\ \text{end}\\ \text{pwm}=\text{abs(speed)};\end{array}  \tag{25}\]  
_Design of the Experiments_  
Simulations were carried out under varying working conditions, including feed rates, moving masses, and cutting forces, to adapt the tuning of the PID controllers process to the real behavior of the system. For each configuration, multiple PID sets were tested, either directly from autotuning or refined manually, based on the Ziegler-Nichols logic. Each simulation output was evaluated using three quantitative indicators:  
* Settling time (T\({}_{\text{s}}\));
* Steady-state error (E\({}_{\text{ss}}\));
* Maximum trajectory deviation (E\({}_{\text{max}}\)). Using a weighted objective function, the resulting performance data were aggregated:  
\[J=\alpha_{1}\cdot T_{s}+\alpha_{2}\cdot E_{ss}+\alpha_{3}\cdot E_{max} \tag{26}\]  
where \(\alpha_{1}\) = 0.4, \(\alpha_{2}\) = 0.4, and \(\alpha_{3}\) = 0.2, accentuating stability and the positional accuracy. This concept allowed a balanced comparison between configurations, avoiding subjective or single-criterion selection. The configuration Kp = 140, Ki = 0, Kd = 0.05 achieved the lowest global score (J = 0.245). Excellent performance indicators were registered: settling time = 0.566 s, steady-state error = 0.025 mm, and maximum deviation = 0.183 mm. These values were consistent across both positioning and 2D circular interpolation regimes. Although not based on a complete factorial design, the procedure reflected a practical applied statistical method. The process enabled not only the identification of the best-performing configuration in absolute terms but also an evaluation of trade-offs under different scenarios. Two final configurations--one PI and one full PID--were selected and implemented on the real CNC system. Subsequently, experimental tests, run under the same conditions as the simulations, were designed to test the predicted behavior. Due to the limited stiffness of the system, soft materials were chosen for the experimental tests. The chosen material (NECURON 651, NECUMER GmbH, Bohmte, Germany) fell into this category and also had a good machining behavior. (The chips generated were discontinuous and did not affect the surface of the tool and/or the machined part.) This was important because the CNC equipment had no cooling or chip evacuation systems. The tool clamping system also limited the maximum diameter of tools that could be mounted in the main spindle to 6 mm.