# Development of a Small CNC Machining Center for Physical Implementation and a Digital Twin
## 4 Materials and Methods
### Contouring Regime and Circular Interpolation  
The basic principle of motion control on CNC machines, from the point of view of generating the trajectories along which the tool must move, is as follows: each trajectory, regardless of its complexity, is broken down into straight line segments and circular arcs. Similarly, in the case of translational movements, regardless of the number of numerical control axes available on the CNC, the trajectories are usually generated by combining the movements of two translational axes, in the XY, XZ, and YZ planes. Although it is theoretically possible, the displacement obtained by combining movements on three axes simultaneously is very rarely used in practice. The movement mode in which simultaneous movements on several axes take place and machining operations (cutting) are performed during these movements is called the contouring mode. As mentioned above, a contour in a plane (the XY plane for the case study) is generated by decomposing it into entities, such as line segments and circular arcs. There are two categories of interpolation algorithms, depending on the elementary trajectory generated, line segment or arc, linear interpolation algorithms, and circular interpolation algorithms. Even within these two categories, there are several types of algorithms. In the following, the construction of a simulation diagram will be pursued to allow the study by simulation of the contouring regime in general, with particularization on circular interpolation. On the basis of the studies presented in [29; 30], considering the coordinates x(t) and y(t) of a point on the circular arc, the relations can be written as:  
\[ \begin{cases}x(t)=R[K_{1}sin(f\cdot t+\varphi)-K_{2}sin(f\cdot t)]\\ y(t)=R[K_{1}sin(f\cdot t)+K_{2}sin(f\cdot t+\varphi)]\end{cases}  \tag{9}\]  
where:  
R is the radius of the circle [m];  
f is the sine function frequency [Hz]  
\(\varphi\) is the sine function phase [rad];  
K\({}_{1}\) and K\({}_{2}\) are constants to be specified later. Further relations can be written as:  
\[v=\omega\cdot R=\frac{2\pi}{T}\cdot R. \tag{10}\]  
where:  
v is the feed speed on the circular trajectory (constant) [m/s];  
T is the time to generate a full circle (period) [s]. \(\omega\) is the angular velocity [rad/s]. Also, it can be stated that:  
\[T=n\cdot T_{s}. \tag{11}\]  
where:  
Ts is the sampling period [s];  
N is the total number of samples. Combining relations (10) and (11), the total number of samples can be calculated as:  
\[n=\frac{2\pi\cdot R}{v\cdot T_{s}}. \tag{12}\]  
The smallest value of the angular displacement on the axis (angular increment) \(\alpha_{\text{incr}}\) can be calculated with the following relation:  
\[\alpha_{incr}=\frac{2\pi}{T}\cdot T_{s}=\frac{v}{R}\cdot T_{s}. \tag{13}\]  
Also, the smallest value of the linear displacement (linear displacement increment) \(\text{l}_{\text{incr}}\) can be calculated with the following relation:  
\[l_{incr}=2R\cdot\frac{\alpha_{incr}}{2\pi}=\frac{v}{\pi}T_{s}. \tag{14}\]  
Since the sine function used and the interpolation algorithm, respectively, have a numerical character, the relations can be written further as:  
\[f=\frac{2\pi}{NT_{s}}. \tag{15}\]  
where:  
N is the number of samples per period. For N, the relation can also be written as:  
\[N=round(n). \tag{16}\]  
where _round_ is a MATLAB function that rounds the bracketed value to the nearest integer.