We recently gave you some tips on purchasing your first milling machine, but what we didn’t touch on was CNC (Computer Numerical Control) systems for milling machines (or other machines, like lathes). That’s because CNC is a complex topic, and it’s deserving of its own article. So, today we dive into what CNC is, how it works, and ultimately if it’s right for you as a hobbyist.
A Brief History of CNC
As a Hackaday reader, you’re no doubt a tech savvy individual who is already at least somewhat familiar with the concept of CNC. It is, after all, just the automation of machining at its core. As you might expect, the history of CNC systems pretty closely mirrors the development of computers, and the two are directly linked. The first fully automated control systems began to appear in the 1950s with NC (Numerical Control). These used punch tapes (or similar instruction storage techniques) to direct machines — mostly milling machines, routers, and lathes.
Power feed for these machines had already been around for sometime. These used (and still use) electric motors or mechanical links to feed a particular axis on the machine at a consistent rate. The benefits were two-fold: it was a lot less labor for the machinist, and the smooth and consistent feed improved surface finishes and tool life.
By the ’50s, high-end machines had more advanced power feed controls that could be set for different speeds. Numerical control essentially just automated that existing technology. Operators could tell the machine when and where to move each axis, thereby removing the most time-consuming part of machining (the precise turning of handles).
This technology progressed pretty predictably from there: digital computers gave rise to CNC, removing the need for antiquated punch tapes. CAD (Computer-Aided Design) came along and made the design process digital, giving operators the ability to design a part and program the machine all on a computer. Computers got exponentially smaller, more powerful, and cheaper. The machine’s electronics improved, allowing for more precise control and better feedback. And, recently, the open source movement in particular has made CNC controlled machines readily available for the hobbyist.
The Benefits of CNC
The most obvious benefit of CNC, particularly in manufacturing, is automation. If a manufacturer needs to make thousands of identical parts, the CAD and CAM (Computer-Aided Manufacturing) process only needs to be done once. Then, a single operator can simultaneously run a handful of machines, simply loading and unloading parts and pushing “start.” This efficiency has led to the ability to mass produce complex machined parts (something that was done manually for the first half of the 20th century) with impressively high accuracy.
Another key benefit of CNC is precision and repeatability. Precision has always been an important part of machining, but maintaining tight tolerances when manually operating a machine isn’t simple. It requires the machinist to have good math skills, to know the machine, and to have a strong attention to detail. If the machinist turns a handle a few degrees too far, a part might need to be scrapped because it fails to meet the tolerances required by the engineer.
CNC machines, on the other hand, are very good at math. They know exactly where they’re supposed to be positioned, and can repeat their programming perfectly over and over again. Once a part program has been perfected by the CNC programmer, a manufacturer can rest assured that the parts are all going to come out identical to each other. As long as the machine is running properly and the tool is good, a single part program can be run indefinitely with perfect results.
Another benefit that is often overlooked, but extremely important in our modern world, is that CNC machines are capable of movements that humans cannot reproduce. Take a simple circular pocket as an example. It’s so trivial these days that we don’t even think about it — a CNC milling machine can cut it in many different ways using any tool that has a diameter smaller than the diameter of the pocket. But, in order to manually machine the same pocket, a machinist would either need a bore with the exact same diameter as the pocket, or a rotary table to rotate the part. And, the latter would require the rotary table’s axis to be exactly aligned with the axis of the circular pocket.
That’s because a circle requires two axes to be moved simultaneously and at varying speeds in relation to each other. A machinist simply cannot do that manually, at least not while maintaining any kind of realistic tolerances. Think of it like trying to draw a perfect circle on an Etch A Sketch, and now imagine you have to do that to tolerances of less than a thousandth of an inch. It just can’t be done manually, but it’s easy for a CNC mill to accomplish.
That same concept gets taken even further when the shapes become more complex, and when you add in a third, fourth, fifth, or sixth axis. Many of the products we take for granted now simply weren’t possible to manufacture until CNC came along, because they couldn’t be manually machined.
A CNC mill doesn’t care if it’s just moving in a straight line in a single axis, or if it’s coordinating the movement of six axes simultaneously. Sure, the part program gets bigger, but with modern storage and processing, that’s no longer an issue.
Types of CNC Systems
The most basic types of CNC are two-axis or three-axis systems designed to retrofit manual machines. These come in varieties for both milling machines and lathes, and essentially just integrate a computer and power feed. The computer controls the power feed for each axis, and attempts to compensate for backlash in each axis. That compensation is handled in either a closed loop or open loop manner.
In an open loop CNC system, there is no feedback. Signals are only sent one way, and the computer has no idea if what the machine is actually doing is correct. It simply relies on the machine to do what it’s supposed to do. Backlash is compensated for by a fixed amount, and so it has to be known before hand. This is how most inexpensive machines work, and it generally produces good results. However, the lack of feedback means backlash usually isn’t dealt with perfectly, and so it can be difficult to keep tolerances tight.
Closed loop CNC systems use encoders to provide feedback to the computer. This means things like backlash can be automatically compensated for — the computer simply verifies that the axis is moving by the desired amount, and adjusts accordingly if it’s not. However, closed loop systems require additional hardware and more sophisticated control computers, and so they are more expensive.
The major alternative to retrofit systems, of course, are machines designed from the ground up to be controlled by CNC. This is how most modern machines are built, as they can integrate a lot of additional features that are desirable. These include tool changers, automated coolant systems, additional axes (for rotating the part, machining at angles, and reaching into cavities), advanced spindles, and more. With a purpose-built machine, this can also all be packaged nicely in an enclosure to contain coolant and chips.
Both retrofit and purpose-built machines usually have two methods of creating part programs: G-code and conversational. The G-code mode takes instructions created on a separate computer (either by CAM software or manually written), and runs it exactly as it’s written. Conversational modes do that all on the control computer, allowing the operator to create programs right at the machine.
The benefit of conversational modes is that an operator can quickly create simple programs without having to involve a CNC programmer using CAD/CAM software. The downside is that the programs are usually simplistic, and making complex parts gets very cumbersome. Conversational programs are almost always only 2.5D as well, meaning that the Z axis can’t be moved at the same time as the X or Y axes. Creating G-code from CAD/CAM software allows you to take a complex 3D model and create a part program for it directly, so there are virtually no limits to the complexity of the program. Most modern job shops will use a combination of the two methods depending on need, but hobbyists will probably be most comfortable designing parts in CAD and using CAM to produce G-code.
The CNC Workflow
Conversational controls vary quite a bit depending on the manufacturer and model, and most of you will probably be interested in designing parts in CAD anyway. So, we’re going to be focusing on the G-code method of running a CNC machine. The process is pretty analogous to 3D printing (which also uses G-code), with CAM software taking the place of 3D printing slicer software.
The workflow starts with creating a 3D model of your part in CAD software, paying close attention to keeping all of your dimensions exact. It’s best to use parametric CAD software designed for mechanical engineering, as opposed to free form 3D modeling tools like Blender. Once you’ve got your 3D model, you’ll need to process it in CAM to create toolpaths, and then output G-code. Most modern CAD systems have integrated CAM software, and there is also standalone CAM software available. However, this software is generally very expensive. Autodesk Fusion 360 is a good free (for hobbyists) option that has both CAD and professional quality CAM.
When you switch to CAM, you’ll first need to set up the part to tell the machine how the part will be oriented, how big the piece of stock is, and how the part will be positioned within that stock. If the part will need to be reoriented (to mill the bottom, for example), then you’ll need to create multiple setups for each operation. You’ll also need to set up a tool library, which defines what tools are available (end mills, drills, etc.), and what their dimensions are.
The next step is to start creating tool paths to cut out the features of your part. Unlike with 3D printing, where the model is simply sliced into layers, CNC tool paths have to be manually created. You’ll be given a bunch of different options for kinds of toolpaths, such as contours (for cutting out a 2D profile), facing, and a variety of 3D contouring techniques. It takes a lot of experience to figure out which kinds of toolpaths to use, but you’ll find yourself using a handful very frequently.
When you create the toolpath, you’ll be given a number of options and parameters to define. These are things like which tool to use, spindle speed, feed rates, depth of cut, stepover, and so on. Again, these take a lot of experience to get right, but there are a number of tools like HSM Advisor out there that can help you with these settings. Generally, you’ll be balancing time, quality, and tool life. For this reason, it’s very common to take quick and heavy roughing passes to remove a lot of material in a short time, and then light finishing passes to remove the last little bit of material precisely and with a good surface finish.
Creating the toolpaths is where you’ll most likely spend most of your time, and it’s important to get it right to avoid wasting material on bad part programs, breaking tools, or possibly even damaging your machine. For that reason, it’s always a good idea to run the built-in simulation to make sure it’s cutting in the expected way, and that there are no collisions. Pay particular attention to where your fixtures, vice, and table are going to be, and that the tool won’t collide with any of them.
Once you’re satisfied that your toolpaths are all correctly setup, you’ll need to run a post processor to create the G-code for your machine to run. G-code is fairly standardized, but most machines have their own way of interpreting the code. So, the post processor acts as an intermediary between the CAM software and the CNC, and makes sure the G-code that is output is compatible with your machine. Most CAM software will have a fairly substantial post processor library, and it’s likely your CNC is already in there. If not, searching online for your CAM and CNC will allow you to find a compatible post processor (or a generic one might even work).
With G-code in hand, you’ll need to load it into the memory on your CNC. This is highly dependent on the CNC system you’re using. Some will let you simply load it from a USB stick or over a network, while other older controls might require you to load it over a serial or parallel connection. But, once the G-code is in memory, most will give you a visualization of the toolpaths that you can check to make sure everything looks right.
Once your stock is loaded into the machine, it’s important that you precisely set the origin point in X, Y, and Z. This has to match what was in the setup in the CAM software. Usually you’ll use a corner of the stock, or a specific point on your vice/fixture. What matters is that it’s a tangible point that you can reference. With that all set, you get to push the big alluring “start” button and let the machine get to work.
Don’t be surprised if you break a tool, or your surface finish is bad. These are all things that have a learning curve, and good design is always an iterative process. With enough experience, you’ll begin to learn what settings work best, and how to produce high quality parts. So, relish the learning process, and enjoy the fact that you no longer have to spend hours turning handles!