
Digital Manufacturing
![]()
Università di Trento, Dipartimento di Ingegneria Industriale
Updated: 19/10/2026
Relevant for the mechatronics point of view
To give shape to a block of raw material (workpiece) there are three possibilities:
Important
Regardless the process, understanding its physics and the governing parameters is essential to design the manufacturing system and its control algorithms
Material removal processes and their control parameters
Machining parameters to be calculated are spindle speed, feed rate, and spindle power:
\[ \begin{aligned} \text{Rotational speed:}\quad & N = \frac{v}{\pi D_0} \\ \text{Diameter:}\quad & D_f = D_0 - 2d \\ \text{Feed rate:}\quad & f = N f_r \\ \text{Machining time:}\quad & T_m = \frac{L}{f} = \frac{\pi D_0 L}{f_r v} \\ \text{Material Removal Rate:}\quad & MRR = v f_r d \end{aligned} \]

Machining parameters to be calculated are spindle speed, feed rate, and spindle power:
\[ \begin{aligned} N &= \frac{v}{\pi D} \\ f &= N f_r \\ T_m &= \frac{t + A}{f} \\ A &= \frac{D}{2}\tan\left(\frac{\pi - \theta}{2}\right) \\ MRR &= \frac{\pi D^2 f}{4} \end{aligned} \]

Machining parameters to be calculated are spindle speed, feed rate, and spindle power. There are three types of milling:

\[ \begin{aligned} N &= \frac{v}{\pi D} \\ f &= N f_z z \\ MRR &= w d f \\ A &= \begin{cases} \sqrt{d(D-d)} & \text{side milling} \\ \sqrt{w(D-w)} & \text{face/end milling} \end{cases} \\ T_m &= \begin{cases} (L + A)/f & \text{side milling} \\ (L + 2A)/f & \text{face/end milling} \end{cases} \end{aligned} \]

| Parameter | Turning | Milling | Drilling |
|---|---|---|---|
| \(v\) (m/min) | \(v = \pi D_0 N\) | \(v = \pi D N\) | \(v = \pi D N\) |
| \(N\) (1/s) | \(N = \dfrac{v}{\pi D_0}\) | \(N = \dfrac{v}{\pi D}\) | \(N = \dfrac{v}{\pi D}\) |
| \(f\) (mm/min) | \(f = f_r N\) | \(f = z f_z N\) | \(f = f_r N\) |
| \(f_{z,r}\) (mm) | Feed per tooth (zahn) or per revolution | ||
| \(T\) (s) | \(T_m = L/f\) | \(T_m = (L + kA)/f\) | \(T_m = L/f\) |
| \(MRR\) (mm³/min) | \(MRR = d f_r v\) | \(MRR = w d f\) | \(MRR = \dfrac{\pi D^2}{4} f\) |
| \(P\) (kW) | \(P = MRR\, p_s\) | \(P = MRR\, p_s\) | \(P = MRR\, p_s\) |
| \(P_e\) (kW) | \(P_e = \dfrac{MRR\, p_s}{\eta}\) | \(P_e = \dfrac{MRR\, p_s}{\eta}\) | \(P_e = \dfrac{MRR\, p_s}{\eta}\) |
We have to set up a milling process on Aluminum, which has \(p_s = 12.56\) W min/cm³
The tool manufacturer suggests \(v = 1000\) m/min and \(f_z = 0.1\) mm/tooth
The mill has a diameter of \(30\) mm and does face milling with full overlapping, has \(3\) teeth and removes a layer of \(2\) mm
\[ \begin{aligned} N &= \frac{v}{\pi D} = \frac{1000\ \text{m/min}}{\pi\, 30\ \text{mm}} = 10610\ \text{rpm} \\ f &= f_z z N = 0.1\ \text{mm} \cdot 3 \cdot 10610\ \text{rpm} = 3183\ \text{mm/min} \\ MRR &= w d f = 30\ \text{mm} \cdot 2\ \text{mm} \cdot 3183\ \text{mm/min} = 190980\ \text{mm}^3/\text{min} \\ P &= MRR\, p_s = 190.98\ \text{cm}^3/\text{min} \cdot 12.56\ \text{W min/cm}^3 \simeq 2.4\ \text{kW} \end{aligned} \]
Note
The machinist must always ensure that the required maximum power does not exceed that available at the spindle. If not, some of the machining parameters must be reduced (usually \(d\) and or \(w\))
The cost of machining depends on:
Some costs depend on process parameters (mainly cutting speed)

Tools are subject to wear. It can affect two parts of the tool:
If the tool and the cutting parameters are chosen correctly, flank wear occurs before rake face wear
The wear law was formulated by Taylor: \(VT^n=K\), where:
\(VT^n=K \rightarrow \log(V) - n\log(T) = \log(K) \rightarrow \log(T) = \frac{1}{n}\log(V) - \frac{1}{n}\log(K)\)


The costs of machining production are related to:
Costs are dependent variables. The process parameters are independent parameters
Important
We can ask whether there are process conditions that maximize productivity and/or minimize costs
| Symbol | Meaning |
|---|---|
| \(C_p\) | Cost per piece |
| \(C_m\) | Machining cost |
| \(C_s\) | Setup cost |
| \(C_l\) | Loading cost |
| \(C_t\) | Tooling cost |
| \(L\) | Labor cost |
| \(O\) | Overhead |
In turning: \[ T_m = \frac{L}{fN}=\frac{\pi LD}{fV} \\ N_p = \frac{T}{T_m} = \frac{fK^{1/n}}{\pi LDV^{1/n-1}} \]
\[\begin{align} C_p &= C_m + C_s + C_l + C_t \\ C_m &= T_m(L_m + O_m) \\ C_l &= T_l(L_m + O_m) \\ C_t &= \frac{1}{N_p}\left[T_c(L_m+O_m) + T_g(L_g+O_g) + D_c\right] = \frac{C_{t0}}{N_p} \\ T_p &= T_{s,l} + T_m + \frac{C_{t0}}{N_p} \end{align}\]
Note
We have \(C_p=C_p(V)\) and \(T_p = T_p(V)\), so we can differentiate both to identify an optimal condition
Costs: \[\begin{align} \frac{\partial C_p}{\partial V} &= 0 \\ V_{o,c} &= \frac{K(L_m+O_m)^n}{[(1/n-1)C_{t0}]^n} \\ T_{o,c} &= (1/n -1)\frac{C_{t0}}{L_m+O_m} \end{align}\]
Times: \[\begin{align} \frac{\partial T_p}{\partial V} &= 0 \\ V_{o,t} &= \frac{K}{[(1/n-1)T_c]^n} \\ T_{0,t} &= (1/n -1)T_c \end{align}\]
Note
What do we optimize? Costs or times?



















Pros:
Cons:

Pros:
Cons:


Suitable for:
Masked time
Any operation that can be performed in parallel to machining is said to happen in masked time. Its cost is absorbed in the machining cost
Other operations happen in exposed time, which is added to the machining cost



It is mainly a matter of synchronizing motion

The Yardstick of Automation (1962)
| Order | Human attribute | Example |
|---|---|---|
| 0 | None | Utensili manuali |
| 1 | Energy | Powered machines and tools |
| 2 | Dexterity | Single-cycle automatics (dexterity = self-feeding) |
| 3 | Diligence | Repeats cycle; open-loop control |
| 4 | Judgment | Closed loop; numerical control; self-measuring |
| 5 | Evaluation | Computer control; model of process required for automation |
| 6 | Learning | Limited self-programming; some artificial intelligence |
| 7 | Reasoning | Inductive reasoning (cause-effects) |
| 8 | Creativity | Performs (original) design unaided |
| 9 | Dominance | Machine is master (HAL 9000) |

Requirements:

Encoder gain: pulses/rev — Axis gain: screw pitch × encoder gain (mm/pulse)

| Parameter | Rise time | Overshoot | Settling time | Steady-state error | Stability |
|---|---|---|---|---|---|
| Kp | Decrease | Increase | Small change | Decrease | Degrade |
| Ki | Decrease | Increase | Increase | Decrease significantly | Degrade |
| Kd | Minor decrease | Minor decrease | Minor decrease | No effect | Improve if Kd small |
PLC is a controller that implements logic relationships between inputs and outputs. It provides a range of interfaces and registers:
Note
Can be either a separate hardware, or a software process running on the same computer that runs the CNC
The programming standard IEC 61131-3 provided this transition:
| Language | Type | Description |
|---|---|---|
| Ladder Logic | Graphical | Resembles relay logic diagrams, intuitive for electricians |
| Function Block Diagram | Graphical | Resembles block diagrams, intuitive for control engineers |
| Sequential Function Chart | Graphical | Resembles flow charts and finite state machines, intuitive for process engineers |
| Structured Text | Textual | Resembles Pascal, intuitive for software engineers |
| Instruction List | Textual | Resembles assembly, intuitive for firmware engineers |
Note
The standard states that languages must be interchangeable, i.e., the same program can be written in any language and must have the same behavior, different parts of a program can be written in different languages, and the program can be converted from one language to another
Note
Note
Note
Note
Textual languages are the most easy to implement and always available even on low-cost PLC and PLC IDEs
The CNC controller is the brain of the machine tool. It implements the judgement (A4) of Amber’s scale, and it is responsible for:
CNC controllers are characterized by:
CNC can control axes with increasing levels of sophistication:
| Reference | Symbol |
|---|---|
| Axis reference | |
| Machine origin | |
| Workpiece origin | |
| Registration point | |
| Support point |
Note
In turning, there is no tool radius compensation; rather, tool is measured by length and abutment, the latter being the offset w.r.t. the registration point
Any coordinate \(P_{wp}\) given in the workpiece reference frame \(O_{wp}\) is converted in machine coordinates \(P_m\), including tool length offset
\[ P_m = T_{wp \to m} P_{wp}; \qquad T_{wp \to m} = \begin{bmatrix} r_{11} & r_{12} & r_{13} & d_x \\ r_{21} & r_{22} & r_{23} & d_y \\ r_{31} & r_{32} & r_{33} & d_z + l_t \\ 0 & 0 & 0 & 1 \end{bmatrix} \]
\(d_{x-z}\) are coordinates of \(O_{wp}\) in \(O_m\)
Remember that the roto-translation matrix is:
\[ T = \begin{bmatrix} \cos\alpha\cos\beta & \cos\alpha\sin\beta\sin\gamma - \sin\alpha\cos\beta & \cos\alpha\sin\beta\cos\gamma + \sin\alpha\sin\gamma & d_x \\ \sin\alpha\cos\beta & \sin\alpha\sin\beta\sin\gamma + \cos\alpha\cos\beta & \sin\alpha\sin\beta\cos\gamma - \cos\alpha\sin\gamma & d_y \\ -\sin\beta & \cos\beta\sin\gamma & \cos\beta\cos\gamma & d_z \\ 0 & 0 & 0 & 1 \end{bmatrix} \]
The order of transformations is:
Machines with 3 controlled axes (no tool alignment) typically implement a simplified transformation that only accounts for the workpiece origin translation and rotation \(\theta\) about \(z\) and tool length:
\[ \begin{bmatrix} x_m \\ y_m \\ z_m \\1 \end{bmatrix} = \begin{bmatrix} \cos\theta & -\sin\theta & 0 & d_x \\ \sin\theta & \cos\theta & 0 & d_y \\ 0 & 0 & 1 & d_z + l_t \\ 0 & 0 & 0 & 1 \end{bmatrix} \begin{bmatrix} x \\ y \\ z \\ 1 \end{bmatrix} \]
Workplane tilt compensation
Even for 3 axes machines, it is customary to also include small rotations about \(x\) and \(y\) in the transformation matrix, to account for misalignments of the working plane and tool holder: this comes especially handy for 3-D printers
Reference positions (as \(O_{wp}\)can be measure in machine thanks to a touch probe:

Tool geometry can be measured in machine (exposed time) or by a tool presetter (masked time). The latter is preferred because it is faster and more accurate, and it allows to measure the tool geometry without having to mount it on the machine.

According to the Yardstick of Automation:
The general sequence for machining a part is:
The section within the red box is the machining cycle, i.e. the sequence of operations that can be cyclically repeated for each part
The structure of a part program generally follows a common structure:


In turning, X coordinates are in diameters. Two typical choices for origin:
Common choice for WP origin among machinists is the rightmost axial point on finished workpiece (turning) and topmost point on the finished workpiece (milling). This choice allows to quickly spot in a program safe fast motions (positive \(z\)), from dangerous fast motions (negative \(z\)) that can crash the tool into the workpiece or fixture.
ISO language (ISO/DIN 6983): sequence of [C][arg] where C is a letter and arg is a number. Valid commands are:
| Cod. | Command |
|---|---|
| A | Rotation about X |
| B | Rotation about Y |
| C | Rotation about Z |
| D | Tool diameter compensation |
| E | Secondary feedrate |
| F | Feedrate |
| G | Preparatory function |
| H | — |
| I | Circle center, X |
| Cod. | Command |
|---|---|
| J | Circle center, Y |
| K | Circle center, Z |
| L | — |
| M | Machine function |
| N | Block number |
| O | — |
| P | Third motion along X |
| Q | Third motion along Y |
| Cod. | Command |
|---|---|
| R | Third motion along Z |
| S | Spindle speed |
| T | Tool number |
| U | Second motion along X |
| V | Second motion along Y |
| W | Second motion along Z |
| X | Motion along X |
| Y | Motion along Y |
| Z | Motion along Z |

Types of functions:
G, T)X, Y, Z, A, B, C)M)G functions:
G00: rapid positioningG01: linear interpolationG02/G03: circular interpolation (CW/CCW)N1 T1 S500.0 M3 ; tool n°1, CW rotation, 500 rpm
N2 M8; ; fluid jets ON
N3 G00 X60.0 Z0.0; ; rapid positioning
N4 G01 X-0.5 Z0.0 F1000.0 ; facing
N5 G01 X20.0 F1000.0
N6 G03 X40.0 Z-5.0 I30.0 K-10.0 F1000.0 ; arc R=10.0
...
N128 M30 ; fine programma
N10 G00 X61.0 Z7.0
N11 G01 Z-94.5 F1000.0
N12 G01 G91 X5.0 F2000.0
N13 G00 Z7.0
N14 G00 X51.0
N15 G01 Z-88 F1000.0
N16 G01 G91 X5.0 F2000.0
N17 G00 Z7.0
N18 G00 X41.0 Z7.0
N19 G01 Z-59.4 F1000.0
N20 G01 G91 X5.0 F2000.0
N21 G00 Z7.0
N22 G00 X32.0
N23 G01 Z-57.6 F1000.0
N24 G01 G91 X5.0 F2000.0
N25 G00 Z7.0
N31 G00 X70.0 Z0.0
N32 G00 X35.0
N33 G01 X0.0 F1000.0 S2000.0
N34 G00 Z5.0
N35 G00 X30.0
N36 G01 Z-20.0
N37 G01 X25.0 Z-25
N38 G01 Z-52.0
N39 G02 X45.0 Z-62.0 I10.0 K0.0
N40 G01 Z-85.0
N41 G01 G91 X20.0 Z-15.0
N42 G01 G90 Z-150.0
N43 G00 X70.0
N44 G00 Z20.0
...
N98 M30

G-code language
%es1 G71 *
N10 G30 G17 X+0 Y+0 Z-20*
N20 G31 X+150 Y+150 Z+0*
N30 G247 Q339=+1*
N40 T1 G17 S5000 F4000*
N50 G00 G90 X+14 Y-15 Z+10 G40 M8*
N60 G00 Z-10 G40*
N70 G01 Y+95 G41 F4000*
N80 G01 X+36 Y+140*
N90 G25 R10*
N100 G01 X+105*
N110 G24 R4*
N120 G01 G91 Y-55*
N130 G25 R14*
N140 G01 G91 X+35*
N150 G25 R5*
N160 G01 G90 X+105 Y+14*
N170 G24 R8*
N180 G01 X-15*
N190 G00 Z+10 G40*
N200 G38 M30*
N99999999 %es1 G71 *

G-code language
%es1 G71 *
N10 G30 G17 X+0 Y+0 Z-20*
N20 G31 X+150 Y+150 Z+0*
N30 G247 Q339=+1*
N40 T1 G17 S5000 F4000*
N50 G00 G90 X+14 Y-15 Z+10 G40 M8*
N60 G00 Z-10 G40*
N70 G01 Y+95 G41 F4000*
N80 G01 X+36 Y+140*
N90 G25 R10*
N100 G01 X+105*
N110 G24 R4*
N120 G01 G91 Y-55*
N130 G25 R14*
N140 G01 G91 X+35*
N150 G25 R5*
N160 G01 G90 X+105 Y+14*
N170 G24 R8*
N180 G01 X-15*
N190 G00 Z+10 G40*
N200 G38 M30*
N99999999 %es1 G71 *

Different CNC manufacturers implement proprietary languages that extend the basic G-code with advanced features:
Heidenhain language
0 BEGIN PGM es1 MM
1 BLK FORM 0.1 Z X+0 Y+0 Z-20
2 BLK FORM 0.2 X+150 Y+150 Z+0
3 CYCL DEF 247 DEF. ZERO PEZZO ~
Q339=+1 ;NUMERO ORIGINE
4 TOOL CALL 1 Z S5000 F4000
5 M8
6 L X+10 Y-10 Z+10 R0 FMAX
7 L Z-10 R0 FMAX
8 L Y+95 RL F AUTO
9 L X+36 Y+140
10 RND R10 F AUTO
11 L X+105
12 CHF 4
13 L IY-55
14 RND R14
15 L IX+35
16 RND R5
17 L X+105 Y+14
18 CHF 8
19 L X-15
20 L Z+10 R0 FMAX
21 STOP M30
22 END PGM es1 MM
Algorithms for Computer Numerical Control — machining complex shapes

The CNC kernel is the part of the CNC controller that implements the real-time control loop. It is responsible for:
Note
Beside these tasks, the rest of the CNC also takes care of the GUI, programs selection, editing and storing, networking, tables management (presets and tools), interaction with the PLC, and other non-real-time tasks. The CNC kernel is the part of the CNC that is real-time and must be implemented in a real-time operating system (RTOS)
Profiling is where motion algorithms are implemented. For every block:

Discrete time-base (clock steps of \(t_q\)) and feedrate quantization. Block durations must be scaled to a multiple of \(t_q\) yet maintaining the same block length. The actual feedrate is reduced accordingly.

\[ \Delta t_1 = \frac{f_m - f_s}{a}, \quad \Delta t_2 = \frac{f_m - f_e}{d}, \quad \Delta t_m = \frac{l}{f_m} - \Delta t_1 \frac{f_m + f_s}{2 f_m} - \Delta t_2 \frac{f_e + f_m}{2 f_m} \]
\[ \Delta t^* = \mathrm{int}\left(\frac{\Delta t}{t_q} + 1\right) t_q = \Delta t_1 + \Delta t_m^* + \Delta t_2, \qquad \Delta t_m^* = \Delta t_m + \Delta t^* - \Delta t \]
Discrete time-base (clock steps of \(t_q\)) and feedrate quantization. Block durations must be scaled to a multiple of \(t_q\) yet maintaining the same block length. The actual feedrate is reduced accordingly.

\[ \int_{t_s}^{t_e} f(\tau)\,\mathrm{d}\tau = \frac{\Delta t_1}{2}(f_m^* + f_s) + \Delta t_m^* f_m^* + \frac{\Delta t_2}{2}(f_m^* + f_e) = l \]
\[ f_m^* = \frac{2l - f_s \Delta t_1 - f_e \Delta t_2}{\Delta t_1 + \Delta t_2 + 2\Delta t_m^*}, \qquad a^* = \frac{f_m^* - f_s}{\Delta t_1}, \qquad d^* = \frac{f_e - f_m^*}{\Delta t_2} \]
In short segments there’s no time enough to reach the nominal feedrate: \(\Delta t_m \le 0\)

\[ \int_{t_s}^{t_e} f(\tau)\,\mathrm{d}\tau = \frac{a\Delta t_1^2 + d\Delta t_2^2}{2}; \quad a\Delta t_1 = d\Delta t_2 \]
\[ \frac{\Delta t_1^2 (a + a^2/d)}{2} = l \]
\[ \begin{aligned} \Delta t_1 &= \sqrt{\frac{2l}{a + a^2/d}} \\ \Delta t_2 &= \frac{a}{d}\Delta t_1 \\ \Delta t_2^* &= \Delta t^* - \Delta t_1 \end{aligned} \qquad f_m^*(\Delta t_1 + \Delta t_2^*) = 2l \qquad \begin{aligned} a^* &= \frac{f_m^* - f_s}{\Delta t_1} \\ d^* &= \frac{f_e - f_m^*}{\Delta t_2^*} \end{aligned} \]
\[ \begin{aligned} X(t) &= X_0 + \Delta X \lambda(t) \\ Y(t) &= Y_0 + \Delta Y \lambda(t) \\ Z(t) &= Z_0 + \Delta Z \lambda(t) \end{aligned} \]

For arc interpolation:
\[ \begin{aligned} X(t) &= X_c + R\cos(\vartheta_0 + \Delta\vartheta \lambda(t)) \\ Y(t) &= Y_c + R\sin(\vartheta_0 + \Delta\vartheta \lambda(t)) \\ Z(t) &= Z_0 + \Delta Z \lambda(t) \end{aligned} \]
Warning: feedrate may be reduced
\[ f_{m,a} = \min\left(f_m, \sqrt{aR}\right) \]
Two alternative G-code syntax for arcs:
G[02|03] X[\(X_f\)] Y[\(Y_f\)] I[\(I\)] J[\(J\)]G[02|03] X[\(X_f\)] Y[\(Y_f\)] R[\(\pm R\)] (radius sign discriminates which arc to take)\[ \begin{aligned} \vartheta_0 &= \cos^{-1} I/R \\ \vartheta_f &= \cos^{-1} (X_f - X_c)/R \\ X_c &= X_0 + I \\ Y_c &= Y_0 + J \\ R &= \sqrt{I^2 + J^2} \\ R^2 &= (X_f - X_c)^2 + (Y_f - Y_c)^2 \end{aligned} \]
Center coordinates (two alternatives depending on the sign of \(R\))
\[ \Delta x = X_f - X_0, \qquad \Delta y = Y_f - Y_0 \]
\[ X_c = X_0 + \frac{1}{2}\left(\Delta x - \mathrm{sign}(R)\,\frac{\sqrt{-\Delta y^2 (\Delta x^2 + \Delta y^2)(-4R^2 + \Delta x^2 + \Delta y^2)}}{\Delta x^2 + \Delta y^2}\right) \]
\[ Y_c = Y_0 + \frac{\Delta y}{2} + \mathrm{sign}(R)\,\frac{\Delta x \sqrt{-\Delta y^2 (\Delta x^2 + \Delta y^2)(-4R^2 + \Delta x^2 + \Delta y^2)}}{2\Delta x^2 \Delta y + 2\Delta y^3} \]
Jerk-limited profiling:

The above presented algorithm assumes that the instant speed goes to zero at each corner. This is not acceptable in real CNC machines, for two reasons:
To solve these issue we need to plan the velocity profile across multiple blocks of G-Code. This is called look-ahead
Approach:
Step 1: calculate velocities:

Long segments, \(v_i < v_m\):
A. \(v_f > v_m\), \(s_0 < s_1 < s_2 < s_f\)
B. \(v_f < v_m\), \(s_0 < s_1 < s_f < s_2\)


Long segments, \(v_i > v_m\):
A. \(v_f > v_m\), \(s_1 < s_0 < s_2 < s_f\)
B. \(v_f < v_m\), \(s_1 < s_0 < s_f < s_2\)


Short segments:


Short segments:





Convert back from curvilinear abscissa to time, one block at a time:
G00 blocks mark full stops at cornersMachine tools are precision systems — laser interferometry

Compensating for error means to measure errors and to apply corrections to the machine tool commands. This is a closed-loop control approach
Look-ahead can alter trajectory, especially at corners:







A Wollaston prism is a beam-splitting prism that splits a beam of light into two beams with orthogonal polarizations. The two beams are diverging at a small angle (typically 15–30 arcmin). The prism is used to measure the straightness of an axis by measuring the lateral displacement of the reflected beam.




High precision machine tools are equipped with a laser interferometer to measure the actual position of the axes.
Note
Laser beam can be affected by refraction index changes and by air turbulence, so the machine is usually equipped with a temperature and pressure sensor to correct the measured distance and the laser is usually enclosed in a protective tube to avoid air turbulence.

paolo.bosetti@unitn.it — https://pbosetti.github.io/DigMan/