6  Model-Based Development and Use of a CNC Milling Machine

6.1 Introduction

CNC milling1 machines are at the heart of our manufacturing economy. In fact, GCode was originally developed for their use before being extended to other processes like turning, laser cutting, 3D printing, etc. We use them to make aircraft parts, car parts, molds, fixtures and tooling, surgery robots, spacecraft, gearboxes in wind turbines, scientific instruments, the list is endless. Perhaps most relevant for readers of this thesis: CNC Mills are often called mother machines because they are where we start when we want to build more machines.

In the introduction I mentioned that there are many unfilled manufacturing jobs in the west. Many of those roles are in CNC programming. In the industry, “CNC programming” doesn’t mean writing machine controllers, it means writing GCodes to run on CNC machines (using CAM software). Training new GCode programmers takes a long time because they must absorb the tacit knowledge required for the task. Understanding what will and won’t work in a CNC toolpath is especially hampered by the hidden optimization (Section 1.3.3): cutting physics is particularly sensitive to changes in translational rates due to machine acceleration. Designing CNC milling machines also remains an art; actual machine performance is the result of interactions between motors, machine physics, and controllers themselves. This might limit the rate at which new CNC firms enter the market, or the rate at which existing firms develop new models.

Many parts of this thesis revolve around the idea that we can formulate machine control as a constrained optimization problem. Model building is a prerequisite for machine controllers that are explicitly framed as constrained optimization solvers, and I demonstrated how these can be developed for motion control (Chapter 4) and for process and motion control as a coupled task in Chapter 5. I also discussed how models can be used as tools for machine users, enabling them to more easily operate and understand their machines (Section 5.10.3 and Section 5.11.1) and their materials (Section 5.11.3).

Here I want to do a few things. The first is to show that we can rapidly deploy the controllers that I developed in Chapter 2 on new hardware. The second is to show and then demonstrate one simple way that visualizing velocity plans can be valuable, and how models and machine data can be combined to make new measurements. Here I organize that around the idea that models can be used as a part of human-in-the-loop workflows for CNC programming and machine design.

First, I will cover the basics of machining physics in Section 6.1.1, and explain the state-of-the-art workflow in Section 6.1.2. I will also discuss existing work in the development of models for CNC in Section 6.1.4. I will then explain my methods for model-based design of a CNC machine in Section 6.2, and model-based operation of the same (6.3).

In the results section, I will show how motor models were used to evaluate trade-offs in motor selection for a machine (Section 6.4.2), and look at machined components and data from this machine’s operation (Section 6.4.3). I will show how models and our unique control architecture can be used to expose the hidden optimization to machine programmers in Section 6.3.1, and how those models can be combined with real-world measurements to estimate cutting force data from motor data (6.3.2).

To close the chapter, I will share and discuss the results in Section 6.4, and look ahead to the possibility of taking on CNC machining as an explicit constrained optimization problem (Section 6.5).

6.1.1 CNC Physics

Figure 6.1: This figure diagrams the basic physics happening when a CNC machine cuts through metal. The cutter (yellow) has a number of edges (called flutes, two in this case) and spins at some user-determined RPM. It is moved through the material at a translational rate, such that each revolving flute engages with a chip of a set width (called the chip load).

The physics of machining are arguably more intense than their counterparts in FFF, involving extreme shear rates, thermodynamics, tool life and geometry. The core of it is about chip load, which depends on the ratio between spindle RPM and translational velocity. Cutting an oversized chip will generate too much cutter force (leading to broken tools, a stalled spindle or actuator motor, or egregious excitation of the machine or part’s resonance). Cutting an undersized chip (smaller than or close to size of the flute’s tip radius) means that the cutting physics become rubbing physics: this generates an exceptional amount of heat, dulls tools or leads to material buildup on the flute edge, and in some cases can weld the cutter and the part together which almost always leads to a machine crash.

Figure 6.2: CNC endmills from left to right: fresh, used with small built-up edge formation, and crashed due to undersized chip loading (which leads to melting, rather than cutting).

Another important parameter is surface speed, which is the speed which the flute edge passes by the material being cut. It is a function of tool diameter and spindle RPM. Physically, this is related to the shear rate in the material as it is being separated from the work piece. Changes in shear rate affect chip formation: low shear rates tend to make larger chips (which can be difficult to evacuate from the work piece and can lead to “chip re-cutting”). Larger shear rates exert more total stress in the chip, leading it to break up into smaller chips that are more easily evacuated. The ideal shear rate for a cut is mostly a function of the material being cut and it’s temperature, but also of the tool geometry, sharpness and surface finish.

These physics all exert loads on the machine itself, it’s actuators, and the workpiece. Actuators must produce enough force to push the cutter through the piece, and spindle motors must produce enough torque to keep the tool rotating at the desired speed.

Most complex of all in CNC machining is the issue of resonance: any machine has a given natural frequency and if chip formation happens to excite the machine near that frequency, the whole system vibrates, causing inaccuracies or even tool breakage.

6.1.2 The State-of-the-Art CNC Workflow

CAM for 3D printing (aka ‘slicing,’ Section 5.2.2) is much simpler than CNC machining because each job is effectively one operation: slice into layers, produce perimeters and then infill for each layer. That is, same basic geometric algorithms can be applied to just about every different part. A machining job can include many (tens or hundreds) of different path planning strategies for different geometric features, each selected manually. I show a selection of these strategies in Figure 6.3.

This also applies to tool selection. For example there is an obvious trade-off between large removal rates using big tools and detailed operations using smaller tools. There are also special cases; a tightly dimensioned hole may require the machinist to select a purpose-made reaming tool, threaded features require threading tools, blended or chamfered corners require fillet or chamfer end-mills, etc.

Figure 6.3: These are just a few of the many CNC machining strategies available in one modern CAM tool (Autodesk Fusion). Each strategy has some unique parameters to tune, though most re-use a similar subset.

CNC CAM is similar to FFF Slicing where parameter selection is concerned. Once geometry and tools are selected, users must tune a litany of speed and cutting parameters. These define how fast the tool should move through the part, how much material should be cut with each pass (step over and step down), and how fast the spindle should run. These are known colloquially as speeds and feeds and affect cutting physics in the ways mentioned above. Starter values for feeds and speeds can normally be calculated from tabulated values for surface speed and chip load, but even tabulated windows can be large and need to be heuristically tuned.

Milling parameters, then, are similar to FFF parameters: a user sets geometric and speed-related parameters that are only indirectly related to the underlying process physics that govern the system. Instead, they are directly related to the low-level instructions (GCodes) that we send to the machine.

Figure 6.4: This is a screenshot of the parameters available to configure one cutting strategy (a 2D Pocket) in Autodesk Fusion.

In all other ways, the state-of-the-art CNC workflow is similar to FFF. Users import part geometry into a CAM package, configure geometric and low-level parameters, export GCodes, and run them on their machines. They watch the machine and listen to it, iterate on their parameters, and make incremental improvements to their selections using their own intuitions for the process and machine physics.

6.1.3 Interaction of Cutting Parameters and Acceleration Control

A key focus in this chapter will be the interaction between machine controllers and cutter parameters, namely chip load.

With CNC milling, decelerating into a corner can change chip size dramatically. Machines need to slow down through corners to avoid violating their actuator constraints, but they manage to decelerate and accelerate at rates quite quickly. Spindles have very large rotational inertias, so we cannot rapidly slow them down to maintain chip load as the machine’s translational velocity changes. Instead, we simply have a lossy layer here. We may set up a job to run at a particular chip size, but tight corners in the job will be done at much lower speeds with a much smaller chip size2. CNC Controllers don’t expose this acceleration control layer to users, and it is not specified in GCodes.

6.1.4 The State-of-the-Art in Model-Based CNC

Because most research in model-based motion control is related to the optimization of milling machines, I have already covered most of the relevant research background for machining in Section 4.2. Specifically Sections 4.2.4, 4.2.5 and 4.2.6 for the industrial state-of-the-art and then Section 4.2.8 for the state-of-the-art in research. Section 2.6.2 compares control systems architectures used by other CNC machining researchers to those that I developed in Chapter 2. Here there are just two small additions.

6.1.4.1 Estimating Cutting Force

While the physics that generate cutting forces are intense (high shear rates, plastic deformation, heat and mass flow, etc.), we only need to model those physics if we want to look at cutting forces in small length scales: i.e. understand chip formation and evacuation, tool life, etc. In our case, we just want to understand the loads seen by the machine. A former CBA undergraduate researcher Chetan Sharma wrote his thesis on the topic [1], I was also able to find another masters’ dissertation: [2]. Both outline relatively simple models that output radial and tangential cutting forces as a function of straightforward geometric parameters (cutter size, cut depth, spindle rpm and linear feed rate), with four coefficients to fit for cutting force and edge force coefficients, each with tangential and radial coefficient respectively.

\[ \begin{aligned} F_t = K_{tc}ah(\theta) + K_{te}a \\ F_r = K_{rc}ah(\theta) + K_{re}a \\ \\ a = \text{cut area} \\ h = \text{cut height} \\ \theta = \text{chip thickness} \\ K_{tc}, K_{rc} = \text{cut force coefficients} \\ K_{te}, K_{re} = \text{edge force coefficients} \end{aligned} \tag{6.1}\]

[1] shows that coefficients can be estimated using data generated on-machine, using measured spindle power and force exerted on the workpiece (a load cell). There are a number of other efforts that replicate similar work, some of which are in Section 4.2.8.1 as I mentioned and a complete review is in [3]. In particular I would note that [4] and [5] both tackle the problem of identifying the \(a, h, \theta\) parameters from Equation 6.1 from part geometry, tool geometry, and toolpath interpolation.

So, estimating cut forces is not itself a new contribution, but other authors went to some length to build systems specifically for this purpose. In this case I extend data that the machine controllers from Chapter 2 already generate, and combine those with models from Chapter 4 to infer cutting forces.

6.1.4.2 Measuring Machine Stiffness and Resonance

In practice chatter causes more displacement than static loading. [2] adds resonance measurements: he uses a solenoid hammer to generate a step response of the tool, measuring the tools ‘ring’ using an inductive probe as a displacement sensor. Using this system, he generates a stability plot across spindle RPMs and depths of cut. In [6], the authors develop a system that samples from a Heidenhain machine controller at 10kHz to detect chatter in real-time using motor currents, and [7] develop a model-based adaptive controller to mitigate chatter. [4] implements a “machining digital twin” to optimize feed rates of a milling center in real-time to predict and automatically prevent chatter. Finally, for a broader overview of machining dynamics, we also have [8] and [9].

In my progress so far I have only used machine data to estimate cutting forces, but I think these works are worth mentioning here again because they show that the types of data I can produce using the systems developed here could be extended to model these physics.

6.2 Machine Design Tools

When we develop machines, we must select from discrete families of off-the-shelf parts with limited customization (especially if we are a small firm or individual with small order quantities). Of particular interest is motor selection, where we must consider characteristics of our motors and our machine’s kinematics since both affect the final performance.

For example, motor physics makes for natural trade-offs between availability of low- and high-end torque (Section 4.8.4). Motor parameters that help us understand these trade-offs are often available from manufacturers, but not always, and as I discuss in 4.8.4 even two identical motors (same make and model) may have slightly different parameters. The most useful motor selection tool that is normally available from manufacturers is the motor torque curve (where we see how much force the motor can generate across a range of speeds), but torque curves can change depending on motor drive voltage and controller type.

It is also sometimes difficult to understand how motor torque curves might couple into a machine’s dynamics, through its drive system (belts, leadscrews, linkages, masses, and frictions etc.). At MIT, spreadsheets are the state-of-the-art design tool of choice for this step [10]. Spreadsheets are excellent design tools, but they tend to require that we iteratively step through dynamical states (acceleration, velocity) to understand performance, and require that we use multiple spreadsheets to understand each component of our machine. They also require that we input model parameters manually, and they are of course not complete simulation tools that can be subjected to virtual operation.

In this section, I develop tools that allow us to virtually swap motors onto simulated hardware to analyze machine performance across a range of parameters. We do this using both abstract parameter spaces and using real toolpaths. I discuss the use of these tools in 6.4.2.

6.2.1 Virtually Comparing Motor and Machine Dynamics

In Section 4.3.1, I showed how we can develop motor models using a closed-loop motor controller and simple test inertia. In Section 4.3.2, I showed how we can use those models to develop kinematic models of machines that include mass and damping terms.

Both of those models remain separable, which means that given a set of motor models and a machine’s kinematic model, we can virtually compare performance across motor options.

Figure 6.5: Here we combine motor models (from left) and kinematic models (right), to generate force margin plots.

CNC Machines need to move around while providing cutting forces. To compare motor selections in this context, I developed a force margin analysis tool. Here, motor models define how much current can be generated in the motor stator as a function of the rotor speed. Using this model, and the motors’ \(k_t\) value \((A/Nm)\), we can estimate the amount of torque generated across these speeds. We can then combine this estimate with the kinematic model’s estimate for force required to accelerate the mass (just \(F=MA\)) and use the model’s damping terms to estimate forces lost to friction.

The tool takes a maximum current saturation parameter, and generates a force margin (maximum available force from the motor, less forces taken up by motion) across a grid of velocities and accelerations.

Figure 6.6: A one-axis force margin plot, which is mapped over axis velocities \((x, m/s)\) and accelerations \((y, m/s^2)\) with a contour (color map, \(N\)) rendering the force available from our motion system under those accelerations and velocities.

This plot can help us to select motors for our machine, and also forms the basis for the next tool, which can help us select operating parameters.

6.2.2 Selecting Motion Control Parameters using Models

Using force bandwidth plots (above), we can select (max accel, max velocity) parameter for our motion controller such that we guarantee a force bandwidth overhead in Newtons.

This is for use in a trapezoidal motion controller, which cannot use the entirety of the motor’s dynamic range (Section 4.7.1). That leaves us with a trade-off: high-end speed or low-end force.

Figure 6.7: Selecting motion parameters (maximum velocity, maximum acceleration) using motor models, kinematic models, and a force margin. At left, a selection that maximizes acceleration \((2200mm/s^2)\) but only allows for a maximum speed of \(5mm/s\) and at right, we make the opposite trade-off and select for high speed \((88mm/s)\) with only \(400mm/s^2\) of acceleration.

These are the core methods for selecting motors and motion parameters using models. I show how I used these methods together for our milling machine in Section 6.4.2.

6.3 Toolpath Inspection Tools

6.3.1 Visualizing Real Chipload

In this thesis I have discussed the idea of constrained optimization at length. Machines are limited by the physics of their motion systems and those are coupled into process physics. In particular I mentioned a hidden optimization in Section 1.3.3, where the velocity of a path plan is modified in real-time by machine controllers in order to avoid violating actuator and kinematic constraints.

Because our real-time controller is a software module, we can easily run path plans virtually to render the results of this optimization for machine operators before they run a job. In practice this just means that we run the machine controller in a configuration where it is disconnected from hardware, which is done using a change in the PIPES graph that runs the system. The motion controller’s outputs can then be rendered in 3D along particular points in the path, or as histograms that show statistics across the entire path.

In the case of this CNC machine, I use a trapezoid-based motion controller for acceleration planning (see Section 4.2.4). It’s outputs include the time-series basis spline that is normally sent to motors (and it’s velocity, acceleration, and jerk states), as well as an output of the current segment’s target velocity (as specified in the path plan), as well as the type of motion segment (a G0 “Rapid” (traverse) move, or a G1 “cutting” move).

3D output of the chip load deviation analysis tool, in a selected region of the pocket toolpath. This highlights segments of the trajectory where deviations are large.

To render these outputs, I use the same 3D Plotting software as in Section 5.11.1. I measure deviation of the trajectory’s actual feed rate from the target feed rates, normalizing it into the range \(0.0-1.0\) where \(0.0\) indicates no deviation from the target feed rate, and \(1.0\) indicates a complete stop.

\[ V_{dev} = (V_{targ} - V_{norm}) / V_{targ} \]

3D Plots allow careful inspection of toolpath components. For a broader look at the toolpath’s overall deviation from target rates, we can also produce histograms of this data.

Figure 6.8: An histogram across chip load deviation in the entirety of the pocket toolpath.

I use this tool as part of a comparison between the pocket and adaptive toolpath in 6.4.4.

6.3.2 Cutting Force Estimates

It is possible also to make cutting force estimates using a combination of real-time data from the machine and motion controller and our motor and kinematic models.

While the machine operates, we collect time-series data from the motors on their positions, velocities, accelerations, and their measurements for motor current. A complete table of data collected from motors during operation is available in Table 4.3. With the motor model (Section 4.3.1), we know that current is directly related to motor torque. Our machine’s drive ratios relate these torques to linear forces per axes, meaning that we can make a time-series of force vectors that were exerted into the machine’s axes during operation.

Much of that force is used only to accelerate and move the machine around. However, our kinematic models can estimate those currents for any velocity and acceleration. That means that we can develop a time series that combines our total force (a motor-model based measurement) with motive force (a kinematic-model based estimate) to calculate residual forces.

\[ \begin{aligned} F_{meas} = I_m \cdot k_t \\ F_{est} = F_f(vel, accel) \\ F_{cut} = F_{meas} - F_{est} \end{aligned} \]

In this step, I additionally filter both force estimates before combining them using a second order butterworth filter [11] with \(\omega=20.0Hz\) passed through scipy’s filtfilt function (to eliminate changes in the measurement’s phase).

Figure 6.9: 3D output of cutting force estimates, mapped onto the trajectory. This sample is from one stepdown pass in the pocket toolpath.

Histogram of cutting forces sampled across the entire pocket toolpath.

I use this tool as part of a comparison between the pocket and adaptive toolpath in 6.4.4.

6.4 Results and Discussion

Pictured: the Rat Rig Mill used in this work, outfit with a Saunder’s Machine Works fixture plate and vise, stock aluminum, GPenny Spindle (1.5kW ER16, 24000RPM, 65mm Diameter), and fit with NEMA23 stepper motors, and controllers as developed in this thesis.

6.4.1 Hardware Developed and Tested

I used the tools and methods described in this chapter to outfit a small milling machine. The machine was assembled from a Rat Rig Mill kit [12] and a GPenny Spindle which is rated to 1.5kW (about two horsepower) and runs up to 24000 RPM [13]. The spindle has an ER16 size collet and is 65mm in diameter, and is controlled by a generic variable-frequency drive powered on single phase 110V.

I added a Saunders Machine Works fixture plate and vise [14], and outfit the machine with my own motor controllers (from Section 4.4), picking motors using the process described below in 6.4.2. The motion system runs on a 48V switched-mode power supply, to which I added 10000uF of capacitance and two 47 Ohm bleed resistors (in series) to help linearize it.

6.4.2 Model-Based Selection of Motors and Motion Parameters for CNC

In this subsection, I explain how I used the tools developed in 6.2.1 (alongside heuristics!) to select motors for use in the CNC Mill above. I was able to assess the hypothetical performance of each axis using each motor (a total of twelve combinations) to select the motors that would provide the desired force bandwidth in the range of speeds that I expected to drive the machine.

I selected four candidate motors from our stock bins at the CBA. Each is a NEMA23 size (a faceplate dimension standard, and a requirement of our machine’s frame), but have varying electrical properties and lengths. I used the method from 4.3.1 to generate an encoder calibration and model for each (this takes about 10 minutes per motor). The resulting torque curves are plotted below, and parameters are tabulated in 6.1, where I include values also for the motor that Rat Rig specifies for the CNC kit.

Figure 6.10: All possible motors (left) and their torque curves (right). Each was generated using measured parameters for the motor’s resistance, inductance, and rotor inertia, as well as model-fit terms for the motors’ \(k_t, k_e\) and rotor damping terms, using the method described in Section 4.3.1.
Name dut_a dut_bs dut_c dut_bp MFG
Size NEMA23x76 NEMA23x56 NEMA23x56 NEMA23x56 NEMA23x86
\(\tau_0\) \(1.85\) \(1.26\) \(1.20\) \(1.26\) \(2.45\)
\(A_{\text{max}}\) \(2.80\) \(2.12\) \(2.80\) \(4.24\) \(3.00\)
\(R (ohms)\) \(1.13\) \(1.50\) \(0.95\) \(0.38\) \(1.2\)
\(L (mH)\) \(4.80\) \(4.40\) \(3.00\) \(1.10\) \(4.0\)
\(J_{rot} (g \cdot cm^2)\) \(480\) \(300\) \(300\) \(300\) \(670\)
\(k_t\) \(0.553\) \(0.371\) \(0.323\) \(0.193\) n/a
\(k_e\) \(0.572\) \(0.399\) \(0.331\) \(0.245\) n/a
\(k_d\) \(0.0025\) \(0.00064\) \(0.00093\) \(0.0010\) n/a
\(v_{\text{max}} (rads/s)\) \(75\) \(104\) \(125\) \(165\) n/a
Table 6.1: Motors for comparison, and their parameters.

To generate kinematic models, I used the methods described in 4.3.2. In brief, this involved mounting one motor on each axis (I made a preliminary selection of dut_c for this, as it sits in the middle of the range of available performance), and having the motor follow a chirp signal using a set of preliminary PID gains. Parameters from those model fits are below, showing the machine’s relatively large damping terms \((k_{d,offset}, k_d)\) that are a result of it’s leadscrew transmissions.

Axis X Y Z
Drive Ratio \((mm/rad)\) \(1.27324\) \(1.27324\) \(0.63662\)
Moving Mass \((kg)\) \(9.932\) \(10.818\) \(4.392\)
J motor \((kg \cdot m^2)\) \(0.00003\) \(0.00003\) \(0.00003\)
J coupler \((kg \cdot m^2)\) \(0.000002873\) \(0.000002873\) \(0.000003180\)
J leadscrew \((kg \cdot m^2)\) \(0.000001419\) \(0.000001469\) \(0.000000706\)
\(k_{d, offset} (N)\) \(58.95\) \(60.27\) \(202.6\)
\(k_d (N/(m/s))\) \(375.0\) \(439.6\) \(1602.4\)
Table 6.2: Kinematic Parameters from our milling machines’ axes.

I then combined motor models and kinematic models to produce a force margin plot for the expected performance of each. For each axis, I generated four hypothetical combinations (one with each motor). I show each of those combinations in 6.11.

\(axes \times motors\)

Figure 6.11: Motors (left column) and machine axes (top row) can be combined virtually to produce force margin plots of each combination’s expected performance across a range of velocities and accelerations.

Using these models, we can see that the Z axis’ increased drive ratio (it uses a 4mm lead screw, whereas X and Y use 8mm lead screws) leads to — unsurprisingly — smaller achievable feed rates overall. It also has punishing damping terms. Heuristically, we know that maintaining high feed rates is important for machining with a low-rigidity machine, to keep overall removal rates up without exerting large forces. We can turn this heuristic into a force margin, supposing we only plan to exert 200N (about 20kgf) on the machine during operation in X and Y, and half of that in Z where cutting forces are lower (we tend to plunge more gently). Then we can select towards higher feed rates, so long as we maintain high acceleration. Since machining involves many retracts in the Z axis, we favor acceleration over maximum speed on this axis.

Figure 6.12: Selection for maximum velocity and acceleration parameters using force margin. Left: x-axis, right: y-axis.

Selection for maximum velocity and acceleration, for the z-axis, using force margin.
Axis X Y Z
Motor Selection (ours) dut_c dut_c dut_bp
Motor Selection (model) 23HS22-2804D 23HS22-2804D 23HS22-3008DP
Motor Selection (mfg) LDO-57STH86 LDO-57STH86 LDO-57STH86
Force Margin (ours) \((N)\) \(100\) \(200\) \(200\)
Force Margin (mfg) \((N)\) n/a n/a n/a
Max Velocity (ours) \((mm/s)\) \(110\) \(110\) \(75\)
Max Velocity (mfg) \((mm/s)\) \(50\) \(50\) \(25\)
Max Acceleration (ours) \((mm/s^2)\) \(2500\) \(2200\) \(3300\)
Max Acceleration (mfg) \((mm/s^2)\) \(300\) \(300\) \(200\)
Table 6.3: Selected motors, force margins, velocities, and accelerations for our machine’s axes. Includes a comparison to the machine manufacturer’s selections.

In the table above, I show the final motion parameters and force margins selected using this process. I also include parameters from the CNC machine kit manufacturer’s recommended setup.

In summary, this process is preferable over the state-of-the-art because it enables us to rapidly compare more possible design outcomes using real data from our hardware, rather than estimates. The simple metric here is that we were able to use four motor models and three axis models (each of which is fit in tens of minutes) to evaluate twelve combinations of each. Done manually (swapping each motor onto each axis) may take a day or longer. In addition, the models we use allow us to simulate operation across a wider range of parameters than those where we test them, and our controller allows us to virtually test the entire machine in a number of configurations.

This process also led to the selection of dramatically improved motion parameters over the manufacturer’s recommended settings: 2x (xy axes) and 3x (z axis) increase in top speeds and 8x (xy axes) and 16x (z axis) increases in acceleration. The manufacturer selected motors have much higher rated holding torque over my selections, but a torque curve for their motor seems to be unavailable, meaning that they may have selected motors based on holding torque alone without analyzing performance at high speeds. Their selections surely also encode many of their heuristics, so we may simply differ in that regard. They also deploy open-loop steppers, where loss of a single step can be extremely troublesome, whereas our closed-loop motors allow us to push closer to the machine’s limits without worrying about occasional hiccups. That is to say, their margins to machine performance are probably much larger.

6.4.3 Machining with Models

I modeled a small test piece, test_a, with two bosses at 1/4” depth each, to mill out of aluminum. The part is small, but I tried to include some common geometric features: small islands, both rounded and sharp corners, and dogbones, which are relieved sharp corners of roughly the same diameter as the cutting tool (bottom left and far right of each figure below).

I generated three toolpaths for this part using Autodesk Fusion version 2701.1.18. I selected a three-flute helical endmill at 1/4” diameter, which I thought would approximately saturate the spindle power during high speed machining. The toolpaths generated (see Figure 6.13 and parameters in Table 6.4 below) include a conventional pocket where voids are milled using concentrically increasing paths that are offset from the pocket edge, and an adaptive clearing toolpath, which is a “high speed machining” strategy that clears pockets using a series of smaller arcs. The third toolpath is another pocket, set up as a finishing pass: it clears a small amount of material that is intentionally left over during higher speed, higher load operations (to produce a smoother finish).

All three toolpaths are configured to generate the same chip load, using the spindle’s maximum RPM and relatively high linear feed rates. The chip load value was selected heuristically, using mine and our shop director Dan Gilbert’s own knowledge in machining. However, the machining strategies have different cutter engagement areas (cut depth x cut width). The adaptive path strategy is developed to maintain a uniform engagement area, avoiding slotting (where the tool cuts across its full width) by generating a series of small arcs to traverse through narrow sections. The pocket toolpath does not do this, and so its engagement area is variable - again, see Table 6.4 for numerical values.

Figure 6.13: The two toolpaths that I tested, a 2D Pocket (above) and 2D Adaptive Clearing path (below). Both were generated in Autodesk Fusion 360, with parameters listed below in Table 6.4.
Table 6.4: Cutting parameters for the machining experiments.
Final Parameters Used Value Meaning
All Toolpaths
Spindle RPM \(24000RPM\) Spindle’s rotational speed.
Surface Speed \(478m/min\) Speed at cutting edge.
Cutting Feed rate \(78mm/s\) Translational rate.
Chip Load \(0.065mm\) Linear translation per endmill tooth appearance.
Ramp Angle \(0.6^\circ\) Helical angle for plunges.
Ramp Diameter \(6mm\) Helical diameter for plunges.
Pocket Toolpath
Stepover \(2.5mm\) Depth of cut.
Stepdown \(0.75mm\) Width of cut.
Cut Engagement Area \(1.875-4.763mm^2\) Area of cut \((w \cdot d)\)
Adaptive Toolpath
Stepover \(0.5mm\)
Stepdown \(6.35mm\)
Cut Engagement Area \(3.175mm^2\)
Finishing Pass
Stepover \(0.4mm\)
Stepdown \(6.35mm\)
Cut Engagement Area \(2.54mm^2\)

6.4.3.1 Discussion of the Model-Based Machining Experiments

In this subsection I am going to describe the process that I went through — using a few of my tools and a heavy helping of heuristics — to develop the parameters in Table 6.4 above. While it does not constitute a rigorous evaluation of the process, I think that it is useful to include to describe the types of workflows that modelling can aid. For reference, I am familiar with machining as a process but have not accumulated more than ten hours of total time programming CNC machines. Of course, I developed an understanding for their physics during the course of this project, but my tacit knowledge in the domain is limited when compared to a “seasoned” machinist.

I developed these parameters primarily guided by chip load and cutter engagement heuristics. I tuned parameters first for the adaptive path, using the machine simulation (in particular, histograms of chip load deviation were most useful (6.8)) to select a feed rate where the motion systems’s acceleration limits (selected in 6.4.2) would not cause egregious deviations from the target chip load during cornering.

I ran this machining job a total of six times, making small adjustments to feed rates and cutter engagement areas as I proceeded. I started with the adaptive toolpath and initially selected a smaller spindle speed and only half of the final feed rate and cut depth in Table 6.4, to maintain the target chipload but minimize cutting forces on the machine as I had no sense of what those forces may be. The very first run stalled the spindle during the initial ramp in (the red helical moves in Figure 6.13), after which I halved the ramp angle. The second run (an adaptive path) was successful.

I then used the cut force estimation plots (Figure 6.9) to assess my use of the machine’s available force under real cutting conditions. Seeing that my initial parameters used only tens of newtons of (estimated) cut force during the heaviest sections of the operation, I doubled the feed rates, step-down, and spindle RPM. This maintains the target chip load, but increases the total cutting force. The limit at this point was the spindle RPM.

Figure 6.14: First Chips on the CNC Machine (video), cutting at 1/2 of the final depth, feed rate, and spindle speed. Image at right is a thermal camera frame around the same time (thermal video).

Having access to a thermal camera was an additional aid; I used this to assess whether the endmill was generating too much heat, i.e. melting metal rather than cutting it. An heuristic here is that we want to see the heat energy going into the chip rather than the part.

During the third test I had parameters set to the rates in the table above, except for the ramping feed rate, which I had lowered out of fear. This turned out to be the wrong intuition: the ramping rate, in combination with the higher spindle RPM, decreased the chip load such that the ramp failed again, melting the material rather than cutting it. The sacrificial endmill for this run is at right in Figure 6.2. I picked up on this for two reasons: (1) the endmill had obviously welded itself to the part and (2) the chips that were emerging at this point were much smaller than those that were thrown out of the part during the last successful cuts.

Chips ejected during cutting. Looking at these provides valuable feedback; it is not uncommon for a machinist to measure chip thickness to ascertain what realized chip loads are during their toolpaths.

For the final test of the adaptive path, I increased the ramp feed rate to match the other paths in the toolpath. Ramping can be difficult to figure out, since cutting edges at the bottom tip of an endmill have more variable geometry than their side edges - the center of the tool also spins at “zero” RPM which presents its own set of problems that I won’t discuss at length, but you can imagine how steep ramp angles may exacerbate those issues.

Figure 6.15: Machining the adaptive path with final parameters (video). Image at right is a thermal camera frame around the same time (thermal video).

With that last adjustment, I had a good recipe for the adaptive path. One more note here is that I swapped the uncoated endmill for a similar tool with an ANF coating (Aluminum Non Ferrous). This is a proprietary PVD (Physical Vapor Deposition) coating [15] that is designed to decrease friction and increase hardness at the tool surface, which in turn is said to reduce heat flux into the tool itself. Looking at the thermal images from Figure 6.14 and 6.15 above, (130 vs. 71 degrees at the hottest point), we can see that this holds some water.

I copied those parameters into the adaptive path, but had to find new stepover and stepdown parameters. I initially estimated that I could get away with a 2mm stepdown, to finish the part in only three depth passes. This test failed during the second step-down, stalling the spindle. I used the cutting force analysis tool to check the force exerted by the machine during that pass, and decreased the stepdown to 0.75mm, producing a total of eight depth passes. The second run of the pocket toolpath was successful.

The site of failure in the first pocket toolpath.

Figure 6.16: Machining the pocket path with final parameters (video). Image at right is a thermal camera frame around the same time (thermal video).

In all, the tools I developed were useful to understand the machine’s feed and force limits, and anticipate slowdowns due to acceleration before the parts were run. These types of feedback are not available in state-of-the-art CNC workflows where motion control and process parameter selection are separated and machinists tend to rely purely on tacit knowledge and intuitions e.g. about how a machine should sound when it is operating. Here, we can add quantitative data for these analysis where it was previously unavailable.

However, I had to rely heavily on heuristics to successfully machine parts. Clearly missing from this work is a cutting force model, a spindle power model, and properly articulated heuristics or calculation of chip loads (two failures came from spindle stalls, and one from chip melting). I discuss this, and the possibility of producing real-time user (and controller) process feedback in Section 6.5.

6.4.4 Chip Load Deviation and Cutting Force Estimates

“High Speed Machining” strategies like the adaptive toolpath tested here are a (relatively) new phenomenon in the CNC industry. They became possible when machine controllers became fast enough to handle the very-many small arcs and segments that they are made up of. Their operation is slightly counter-intuitive; in an adaptive path our machines spend about half of their time not cutting (circling around to the next cut), whereas traditional toolpaths engage the tool more frequently.

Figure 6.17: This plot compares chip load deviation (6.3.1) for the pocket (left) and adaptive (right) toolpaths, including a sample of the 3D trajectory with deviations highlighted and histograms from the entirety of each toolpath (not including rapid / traversing motion). All plots are normalized to the same range \((0-1)\) where \(1\) indicates a full stop (total deviation) and \(0\) indicates that the machine is moving at the target feed rate, matching the programmed chip load.

We can use our analysis tools to look at the differences in real machine operation across these two paths, reason about interactions between the motion controller and toolpath, and discuss limits to the current set of tools I have developed.

The first thing to notice is in the chip load deviation comparison above. We can see in the histograms that the pocket toolpath (left) actually deviates less overall from targets than the adaptive path (right). There is a clear concentration of deviation in the adaptive path around \(0.4,\) my estimate is that this corresponds to the cornering velocity through the chosen radius of the path’s lead-in and lead-out segments (where it turns around to start a new cut). We can see that in the 3D plot as well. These radii are also tuneable parameters in our CAM tools, and so it may be possible to use these virtual motion controllers to more intelligently pick those. In fact, ascertaining the maximum speed for a kinematic system through an arc is quite simple (so long as axes accelerations are uniform or close to it) (\(V_{max,corner} = \sqrt{A_{\text{max}}r}\)). In my tests, I used default radii from Autodesk Fusion, which are likely tuned for industrial grade machines, which obviously do not match our small CNC mill in terms of motion performance.

Another note here is that this cornering is done partially during the cut and partially during traverse into the next cut. CAM tools do not calculate cutter engagement area, so it is difficult from those alone to ascertain where in these distributions the velocity deviation may cause issues (if the deviations appear only when we are linking two cuts, they matter only in terms of total part time). In our case, we can combine our cut force estimates with chip load deviations to plot deviations only where our cut force is larger than some value: below I chose \(25N\) as a dead band.

Figure 6.18: Distributions of chip load deviations from all moves labelled as cutting moves in CAM outputs (above) vs. from all moves with cut force estimates \(> 25.0N\).

The differences in the distributions above is subtle, but shows us that about half of the adaptive path’s worst deviations (around \(0.4\)) take place in areas of low engagement / low cut force. Finally I will note that the worst deviations in the adaptive path (where there are many corners, but most with some radius) are smaller than the worst in the pocket toolpath (where there are less corners overall, but those corners have sharper angles).

The pocket toolpath was faster overall; a total of \(153s\) of operation. The adaptive path took \(216s\).

Figure 6.19: This plot compare cutting force estimates (6.3.2) for the pocket (left) and adaptive (right) toolpaths, including a sample of the 3D trajectory with forces highlighted and histograms from the entirety of each toolpath (not including rapid / traversing motion). All plots are normalized to the same range \((0-150N)\).

Comparing cut force estimates in both toolpaths provides some more insight as to the strengths and weaknesses of either strategy. In the histograms above, we can see that the adaptive path uses overall lower cut force, and has a much smaller maximum force (around \(60N\)) than the pocket (~ \(115N\)). The 3D plot shows us where these hot-spots are: in the regions where the pocket toolpath must slot, i.e. cut with the full width of the tool. This is the primary weakness of traditional toolpaths: slotting is inevitable in parts with narrow channels to cut, which leads to high variability in cutting loads during machining. Slots also present chip evacuation issues, as the cutter has limited space around it to throw chips.

6.4.5 Summarizing Discussion

In this chapter, I showed that basic motor and kinematics models can be used to:

  1. Help us to design machines (6.4.2), in virtually combining motor and axes faster than would have been possible were we to physically couple and measure each, and in using those models to intelligently select optimal motion control parameters with guarantees (rather than guesses) about those parameters’ feasibility.
  2. Help us to predict what will really happen when we run our machines (6.3.1), in simulating as-optimized toolpath velocities using our software-defined machine controller.
  3. Generate new data (cutting force estimates, 6.3.2) that can be used to understand what is happening as we run our machines.

Each of these contributions still relies heavily on tacit knowledge in machine design and in machine operation. The design workflow required heuristic estimates for requirements, i.e. in estimating how much force bandwidth is enough and what types of feed rate will be desired during operation. The machining workflow incorporated tacit knowledge for chip load (and it’s relationship to feed rates and spindle speed), an understanding of how cutter engagement area relates to cut force, and an understanding of spindle limits.

As in the FrankenPrusa (5.4.2), our workflow doesn’t add any new instruments to the machine (besides motors, which are of course required in any configuration), it only modifies control software. This makes progress towards our mentioned goal of retrofitting existing hardware with smarter controllers.

6.5 Future Work

This work covers only the very basics of what model-based CNC might entail. We want to go towards a more complete workflow, where models enable machinists to make better parts, more rapidly, and where models can help to train new operators.

I think the framework for doing this is clear; we need computational models of our machines, i.e. software objects that can be used to simulate our hardware and its control. These can be inspected at a high level and inform heuristic parameter selection, and (as they are developed) be used to directly optimize pieces of the process. By developing models on the hardware where they are used, we avoid the common issue where models diverge from reality, becoming more troublesome than they are useful.

The CNC industry is old and resistant to sudden change; we cannot realistically propose that we should retrofit everyone’s hardware to accomplish these goals. However, there may be minimal changes available, and much of the modelling work can be useful even at coarse precision within existing workflows.

Other researchers that I have mentioned here and in other background sections are also making progress in this regard, but as I have noted the architectures that they use to assemble their controllers are limited in important ways. In particular, each of them wraps their new methods around existing GCode interpreters. I am proposing that once we can remove that bottleneck we will be enabled to approach the problem more directly. From where we are at the moment, I would proceed in a few steps.

6.5.1 More Instrumentation and Faster Networks

I have shown in Chapter 2 how the control framework I develop in this thesis allows us to attach new sensors to hardware and easily correlate those readings to machine control states. In Chapter 5 I showed how these readings can be used to generate models for machine operation, and other researchers have added similar instruments to CNC machines to perform similar works in this context. [16] is an excellent review of the emerging sensors used in CNC machining research. The authors note that one of the pressing research gaps lies in learning how those sensor readings can be integrated with machine controllers and with CAM tools, and how data can be synchronously collected across workflows.

I think that the tools that I have developed here show promise in that regard, but there are clear bandwidth requirements described in that paper that lie beyond what I have shown here. To that end, improving overall performance of the tools that I have developed will be a critical step if we are to extend them towards an end-to-end autonomous machining workflow.

This may only require that we integrate faster link layers into OSAP; at the moment I mostly use \(3000 \text{Kbps}\) network segments and USB-CDC devices. Integrating Ethernet-based network segments or even simpler custom embedded links based on SPI (where e.g. \(50000 \text{Kbps}\) is not difficult to achieve using modern microcontrollers) may be the method of choice. This will also require faster microcontrollers than the ones I primarily use, but those too are becoming ubiquitous.

Roughly in order of their value to the modelling efforts, the sensors that I think are most valuable to add on top of smart motor drives are:

  1. Spindle power readings, either via integration with existing spindle controllers or using out-of-band current measurements via hall-effect current clamps.
  2. Accelerometers and microphones for high-frequency data.
  3. Load cells to measure forces directly.
  4. Small thermal cameras and sensors.

6.5.2 Predicting Cutting Forces

Cutting models themselves are already very well understood, the challenge in our framework is to fit them with instrumentation available on our machines.

It’s clear that spindle load is a primary limit in many machining systems, stalling spindles is more common than stalling a machine’s kinematics. In the hardware that I developed here I didn’t have time to instrument the spindle, but doing this would have the clear benefit first of understanding its power constraints, but also as a tool to develop cutting force models: the torque required to shear the material apart, at a known tool tip diameter, is probably a key instrument in learning those models. In fact, where realtime feedback is available to CNC operators, spindle load is typically the first to appear, meaning that these data are at least readily available within state-of-the-art machine controllers (but is presented as a simple load percentage — it is measured in amps, as in any other motor model, so the last step is fitting some \(k_t,\) which I expect is well understood by machine and spindle manufacturers).

The primary challenge that I expect in developing cutting models is measuring cutter engagement area — that is, how much of the tool’s surface area is passing through uncut material? This is dependent on the machine’s position in the part (of course!) but more importantly is dependent on the current state of the stock geometry, as it goes from a block to the finished part. Computational representations for constantly changing geometry are challenging; probably the simplest is a voxel space, but the memory required to store 3D voxels quickly becomes punishing as we increase resolution.

These are also highly dependent on variables that frequently change: the average CNC shop stocks hundreds of unique tools, and hundreds of thousands are available in the industry. Each has variable geometry, but also variable surface coatings, etc. Models developed for cutting forces would have to be transferable across this heterogeneity if they are to pose any practical use, or they need to be easily developed using test equipment available in most shops: i.e. the machine itself.

6.5.3 Intelligently Selecting Feeds, Speeds, and Engagement Areas

If we can predict cutting forces, selecting feeds (linear traversal rates), speeds (spindle RPMs), and engagement areas (step-down, step-over, etc.) is likely an easier task. At a coarse step, this is as simple as writing down ideal chip load heuristics, and then selecting cutter engagement areas such that spindle load and motion system loads do not exceed the machine’s limits. There is a space of these solutions that lie along two degrees of freedom: linear feed rate corresponds directly to an optimal spindle RPM (given a chip load), and total cut area can be framed either with a set step-down (producing a step-over such that area remains equal) or a set step-over (producing a step-down…). As I showed in the printing section, we can then apply heuristics that describe how hard we want to work: how much proportion of the machine’s underlying limits do we want to deploy in the cut?

The other constraint here (in these selection problems, constraints are helpful) has to do with chatter, which I discussed only briefly in this chapter but is in practice probably the predominant problem faced by machinists and CNC programmers. Chatter occurs when the cutting edge excites the machine / tool / part structural system at its resonant frequency. It is primarily a function of three things: frequency response of that system, input frequency (spindle speed \(\times\) number flutes), and the cutting force (excitation amplitude). Perhaps the most challenging of all is that part stiffness changes during the course of the job. Modelling that in a feed-forward manner is difficult but not impossible, it just requires tight coupling between geometric representations and the controller (as already mentioned above for cutting models: voxels are heavy).

It may be more productive to rely on real-time estimates of cutter force (of the kind that I explored here), and known values for excitation and the machine and tool’s stiffness — leaving just the part stiffness and damping as free parameters. These change not only as the part becomes smaller, but also when we excite the part from different locations. During operation of one-such chatter detecting machine, we may be able to use a rolling estimate of that excitation to differentiate which direction in the stability plot we are heading (into more or less excitation, which could tell us which direction we need to turn in (RPM, \(v(s)\)) in order to reduce chatter).

This sounds like a good start, but practitioners will note that once you have entered chatter you are already done for, the part may be ruined even if you correct the issue shortly thereafter. This is why predictive models are important. Either we need to model geometry so completely that feed-forward controllers can reliably avoid chatter, or our chatter detection models need to be tuned well enough that they can detect the conditions that arise just before chatter begins.

6.5.4 CNC Machining as an Explicit Constrained Optimization Problem

So, if we can manage cutting force models, spindle instrumentation, and chatter, we can probably pick most parameters for any given CNC operation, if we are provided with a tool and a machining strategy — i.e. one of those shown in Figure 6.3. However, when I have spoken to practical machinists about this project, they cite these early steps (tool selection, strategy selection and ordering, and part fixturing) as their largest burdens for overall productivity.

In this thesis I showed that it is possible to solve machine “speeds and feeds” in FDM, using an online optimization of motion and process via models. This included similar components to those that would be applicable in machining. It is my expectation that it will soon become possible to solve this problem (and the others) using direct optimization. The computational linchpin is the geometric representation of the stock being machined, and the memory required to properly represent that as it changes. Luckily, GPUs with exceptionally large memories are being developed for AI workloads, and those will be applicable here. In Section 7.7 I discuss at more length how the work in this thesis connects to the reinforcement learning methods that may be applicable for machining.

6.5.5 Generating Useful Outputs for Machinists

I want to close the section with a note on the utility of automated systems, and who they are made useful for. Overall I think that the goal of completely automating machining is suspect: as in other cases in automation, developers of technology can be too eager to replace humans with intelligent systems. Especially in machining, which is filled with corner cases, gotchas, and valuable tacit knowledge that is very difficult to articulate in computational models, we should not make this a primary goal.

Instead, work on modelling machining is probably most useful (and most immediately productive) in helping machinists to better develop their understanding of the process: to understand cutting physics with models, rather than to develop models that replace their intuition.


References

[1]
C. Sharma, “Automatic modeling of machining processes,” {M.Eng.} thesis, Massachusetts Institute of Technology, 2021.
[2]
K. Dunwoody, “Automated identification of cutting force coefficients and tool dynamics on CNC machines,” {M.A.Sc.} thesis, The University of British Columbia, 2010.
[3]
V. F. C. Sousa et al., “Cutting forces assessment in CNC machining processes: A critical review,” Sensors, vol. 20, no. 16, 2020, doi: 10.3390/s20164536.
[4]
R. Ward et al., “Machining digital twin using real-time model-based simulations and lookahead function for closed loop machining control,” The International Journal of Advanced Manufacturing Technology, vol. 117, no. 11, pp. 3615–3629, 2021, doi: 10.1007/s00170-021-07867-w.
[5]
X. Tong, Q. Liu, Y. Zhou, and P. Sun, “A digital twin-driven cutting force adaptive control approach for milling process,” Journal of Intelligent Manufacturing, vol. 36, no. 1, pp. 551–568, 2025, doi: 10.1007/s10845-023-02193-2.
[6]
D. Aslan and Y. Altintas, “On-line chatter detection in milling using drive motor current commands extracted from CNC,” International Journal of Machine Tools and Manufacture, vol. 132, pp. 64–80, 2018, doi: 10.1016/j.ijmachtools.2018.04.007.
[7]
C. M. Giorgio Bort, M. Leonesio, and P. Bosetti, “A model-based adaptive controller for chatter mitigation and productivity enhancement in CNC milling machines,” Robotics and Computer-Integrated Manufacturing, vol. 40, pp. 34–43, 2016, doi: 10.1016/j.rcim.2016.01.006.
[8]
T. L. Schmitz and K. S. Smith, Machining dynamics: Frequency response to improved productivity. Springer, 2009. doi: 10.1007/978-0-387-09645-2.
[9]
Y. Altintaş and E. Budak, “Analytical prediction of stability lobes in milling,” CIRP Annals, vol. 44, no. 1, pp. 357–362, 1995, doi: 10.1016/S0007-8506(07)62342-7.
[10]
A. H. Slocum, FUNdaMENTALs of design.” Massachusetts Institute of Technology; Course materials for MIT 2.75. Available: https://meddevdesign.mit.edu/fundamentals-of-design/
[11]
S. Butterworth et al., “On the theory of filter amplifiers,” Wireless Engineer, vol. 7, no. 6, pp. 536–541, 1930.
[12]
Rat Rig Mill.” Rat Rig, Portugal, 2024. Available: https://ratrig.com/products/rat-rig-mill
[13]
GPenny 1.5kW spindle.” GPenny Machine Company, Shenzhen, China, 2019. Available: https://gpennymachine.com/
[14]
“Universal fixture plate kit.” Saunders Machine Works, Ohio, USA, 2020. Available: https://saundersmachineworks.com/
[15]
“Aluminum nonferrous coatings.” Seco Tools, 2020. Available: https://www.secotools.com/article/a245_a345_family_of_end_mills
[16]
A. Shokrani et al., “Sensors for in-process and on-machine monitoring of machining operations,” CIRP Journal of Manufacturing Science and Technology, vol. 51, pp. 263–292, 2024, doi: 10.1016/j.cirpj.2024.05.001.

  1. Note that while “CNC” stands just for Computer Numeric Control and technically i.e. a 3D printer is a CNC Tool, in practice we often simply use “CNC” to mean CNC machining.↩︎

  2. Many readers will be familiar with High-Speed-Machining, a series of milling strategies developed somewhat recently. These generate tool-paths that effectively minimize cornering radii for the majority of the work that they do. These were a kind of magic when they were introduced, and were realizable only when modern machine controllers could readily handle the complexity of the instructions produced. It is my intuition that this insight was not so much about maintaining high feed rates, but that the resulting geometries mean that more of the actual milling time is spent at the target feed rate - i.e. tight corners, which produce feed rates lower than those set in parameters, were minimized.↩︎