We have already covered some of the basics of computer numerical control (CNC), but in this chapter, we will focus our attention on a specific machine that is widely available from various vendors on multiple shopping platforms (Amazon, AliExpress, eBay, etc.). The 3018 CNC machine is a very basic, rugged unit, well suited to modification and upgrade, and its design has proven to be workable. You can choose to acquire a fully (or mostly) built unit, a kit to make one, or you can build one from scratch. I have tried all three approaches with similar results. However, before a purchase is made, some criteria and use cases should be established.
For this chapter, our objectives revolve around understanding the anatomy of a CNC machine, going through a primer on the selection of a suitable unit, and getting set up and running, as outlined here:
To operate your CNC machine, we should first discuss some basic requirements that will be needed to fully take advantage of your machine:
TinkerCAD is not your only option; there are other more sophisticated packages. However, in my years of garage tinkering, I have had little need for more complex (and possibly more expensive) tools. You can create an account on Tinkercad at https://tinkercad.com.
You may also choose to run your machine using a Raspberry Pi single-board computer (SBC), which you would use as both the machine controller and the G-code sender. For this, you will need to install a suitable daughterboard (often called a hat) such as the Protoneer. We will not be exploring this approach in this book, but the concepts should not be too difficult to extend to something such as this. Add a small monitor and a keyboard, and your CNC machine is also a fully functioning (albeit dedicated) PC. Note: You will only require the PC to generate G-code and not connect it to your CNC machine if you have another means to send G-code to the CNC controller (such as an LCD controller with an SD card slot).
Note
As we deep dive into getting our machine set up and ready, you might consider heading over to https://howtomechatronics.com/tutorials/how-to-setup-grbl-control-cnc-machine-with-arduino/. This article breaks down CNC controllers further (many are Arduino-based) using a basic controller commonly available on Amazon. Look closely at the step calibration section because we will explore this deeper in this chapter as we get our machine ready.
Some of the basic components of a CNC machine were touched on in Chapter 1, The What and Why of CNC, but ahead of deciding which machine suits our purposes, we should know what the particulars are of each component. Here’s a view of a 3018 machine I built using some left-over frame parts from other projects and some 3D-printed components. The overall part count for the frame is very low, and most components can be obtained off the shelf. Most 3018 machines will look a lot like this:
Figure 2.1 – 3018 front view
Looking at the labeled components in the preceding photo, we have the following:
0
with this tool, we can be sure that our cuts (especially where we need to cut to specific depths, such as when drilling holes) are very accurate. This tool is not attached to a controller all the time, but rather is removed once the z axis is homed (that is, set to its lowest limit; in this case, Z=0
).A note on wasteboards
Wasteboards are consumables where CNC is concerned. Ideally, you would never need these because you will have precisely homed your z axis and your material to lie perfectly flat against the worktable, and your design ensures that your endmill will never touch the worktable. Of course, that implies a huge amount of trust in a machine, and no machine can be 100% trusted to perform exactly right all the time, every time. A wasteboard ensures that if there is an error, any damage is confined to it.
Now, let’s have a look at another view of the same machine. Figure 2.2 gives you a closer look at the same components we discussed up till now in this section, and we can see a few more:
Figure 2.2 – 3018 top view
Notice how the screws are holding the worktable to the frame underneath (which was harvested from a dead 3D printer) and are countersunk into the worktable. This ensures that whatever is placed on top of the worktable lies flat and can consume all the real estate presented by it. Looking at this picture, you see the 775-motor mount. There are different-sized motors that dictate what you have: a mill or a machine. The same motor mount (if you look very, very closely, toward the front) has these small notches/grooves cut into the inside of the mount. These allow you to insert a laser toolhead (which is typically square-shaped) into the same mount whenever you want to switch from CNC to laser and back. On one of my other machines, I have fastened my laser head to the side of the motor mount so that I don’t have to keep swapping toolheads.
3D printer and printed parts for this machine
This machine makes extensive use of spare parts in my parts bin as well as 3D printed parts found on https://www.thingiverse.com. Most designs on this site are free to use for non-commercial purposes without prior permission. There are other sites where you can download models and designs for a fee (such as https://cults3d.com/en), but there is plenty to explore at Thingiverse and Thangs (https://thangs.com/). These two sites are where I usually go for part designs when I am building from scratch. Most if not all the parts I 3D printed can also be purchased at various online shopping sites such as Amazon. In my case, I purchased an X-carriage (which includes the z-axis assembly) because the 3D-printed equivalents proved to be unreliable for heavy-duty use on previous builds.
Looking at Figure 2.2, we can see the following components:
Finally, let’s have a look at the rear of the CNC machine in Figure 2.3:
Figure 2.3 – 3018 rear view
In the preceding photo, you can again see the same familiar components as in Figure 2.2 and Figure 2.1. Notice the 8 mm rod mounts here. When I was building this machine, I ran out of the aluminum ones and I didn’t want to buy more (and wait for them to arrive), so I found a design online (and I did one of my own) and 3D printed it. Again, these are parts you can get online, no 3D printer required; I was just impatient to get moving. I printed eight of these in a few short hours.
In Figure 2.3, you can see the microcontroller mounted on the left. This unit has a USB port for connection to a computer so that G-code can be passed to it directly line by line. However, also of interest is the PWM header at the top left. If we had a motor that we could control that way, then we could use PWM to control motor speed. However, my criteria included laser support, and I wanted my laser to be controlled by PWM (so that the laser pulses instead of having a constant beam). The PWM header is therefore set aside for the laser toolhead I am planning for this machine later. The controller is encased in an enclosure with a fan over the central processor, and all electronics are powered by a laptop-style power supply.
Now, some of you may be wondering whether to buy or build your own CNC machine. There are pros and cons to both options. I chose to build my machine because I primarily wanted to use spare parts I had from other builds that I knew might require some customization. I also wanted some freedom to add functionality that might be limited by an off-the-shelf kit.
However, based on what you want to do with your machine and how much time and money you have to spend, you can also choose to buy a complete machine.
To make the buy-or-make decision easier for you, in this section, I will highlight all the considerations that you may need to take into account, based on my personal experience.
Before we begin, I want you to ask yourself the following questions:
The last question asked can dictate what sort of machine you choose. For example, BumbleBee (Figure 1.2 in Chapter 1, The What and Why of CNC) was designed to operate on workpieces that are too large to be moved by NEMA 17 motors, and my design criterion was to minimize the use of heavy-duty motors. Consequently, BumbleBee
sits on top of a workpiece, and the toolhead moves in all axes around it. This allows for the positioning of the whole machine over a specific piece of material that can be as large as I want it to be and then cut from it directly. On the 3018, you would have to cut your raw stock to fit on the machine first.
When you select a machine, consider carefully what your use cases are before you invest time and money into a specific unit. Still, even though we are focusing on the 3018 here, all the concepts apply to most other CNC and laser machines.
Once a selection is made, don’t rush off and buy it just yet from the first vendor you see (for a pre-built unit). Instead:
If you are thinking of building your own unit, you must be even more selective. The following are some example considerations:
Regardless of whether you are building or buying your CNC machine, you will have to go through some setup processes before confidently working on a project.
Once you have fully assembled your machine, you will need to set up the parameters that control it, prepare it for calibration, and run some tests before you put it into operation.
If you built your own machine from an open source design, you might also have downloaded a copy of the firmware for your microcontroller. In many cases, the controller already has firmware on board, but it may be obsolete; so, the first thing to do is determine whether you have the latest version installed. If you purchased a pre-built unit, then check with the vendor to make sure the firmware is up to date.
For off-the-shelf units/kits that come with everything, do not immediately overwrite the existing firmware with a generic version unless that is what is there already, since some vendors create their own flavor. Check with the vendor first to ensure you have an up-to-date installation, or, if you want to install your own, get whatever configurations they may have added and save yourself the headache of having to figure them out on your own. A great source of information is Endurance Lasers, which publishes a bunch of useful articles on CNC and lasers. For GRBL command information, you can go to https://endurancelasers.com/an-important-things-you-need-to-know-about-grbl-firmware/. You can also download the latest version of GRBL from its GitHub repo at https://github.com/gnea/grbl.
A machine built from scratch is going to require you to set up things such as the spindle motor thresholds, the step measurements (how much movement you get from each turn of your leadscrew), the limits of your work area for your machine, and much more. There is even a link to a firmware image just for 3018 machines. For some of my self-designed machines, I started with default settings, attempted to cut a rectangle of known size, and then measured what the actual rectangle dimensions were and adjusted the numbers until the rectangle was cut to match the dimensions of the design in the sender program.
Let’s touch on how to determine the settings for your leadscrews (there is a similar calculation for belts, but since the 3018 uses leadscrews, we will use this). Obviously, if you are buying a kit, you will not have to do this. As mentioned before, your controller may have firmware already loaded that has some default value for x, y, and z. Your machine may be set up for imperial or metric measures. The vast majority of machines I have encountered have been metric, so the example we will go through in this section will be using calculations based on the metric system. Let us first gather some information that we know about our motor:
So now, 200 steps per revolution translates to 2 mm of travel per revolution, so we have 200/2 steps per mm or 100 steps per mm. This also translates to 400 microsteps per mm (800/2).
If you are compiling the firmware, you would be setting the values in the firmware code (for the z motor, for x and y, the same setting is defined by the axis) as follows:
#define DEFAULT_Z_STEPS_PER_MM 100.0
The GRBL command to determine what the current value is for z is $102
. For y, the command is $101
, and for x, it is $100
. You can enter these in the sender program once you are connected to the machine to find out what the current firmware settings are.
If you don’t want to download and compile the source, you can enter the appropriate values in the terminal window of your sender software as follows:
$102 = 100
Now that we have determined the leadscrew settings, let’s look at how to load precompiled firmware and then make changes to the settings for our machine.
In the article from HowToMechatronics mentioned in the Technical requirements section, calibration is described in terms of using the wizard provided by the Universal G-code Sender (UGS) (see the G-code sender software section later in this chapter for an evaluated list of G-code sender applications) to set your steps. The onboard wizard starts with the default of 250 steps per mm and allows you to adjust this based on the amount of movement you see; for this, we will need a metric ruler with millimeter measurements. The process is fairly simple and involves the following steps:
Once you have entered those values and saved them into the firmware, your machine is largely ready (other than homing, which I will address in a later section when we begin testing and make our first cut).
To get your version of GRBL on your CNC machine’s controller, you will need specific software. Loading firmware is called flashing and makes it possible to use a variety of tools. If you are building a machine from scratch, I encourage you to select a board that already has a bootloader (effectively a program in memory on the controller that allows you to load updates to the firmware). Without a bootloader, flashing firmware is a little more complex.
While there are many ways and tools to flash firmware, the following are two popular methods:
XLoader.exe
file in the ZIP file you download.The following is a screenshot of the XLoader interface:
Figure 2.4 – XLoader interface
Figure 2.5 – Main screen for LaserGRBL
Once you select the Flash Grbl Firmware menu, you will be led to a dialog box that is very similar to XLoader’s:
Figure 2.6 – GRBL loader dialog box in LaserGRBL
There are other ways, of course, including freely available versions of Benbox (another laser engraving program that allows for custom versions of GRBL to be loaded from the Benbox vendor), but I have found the two methods I have discussed easy to use. Also worthy of mention is T2Laser, which also allows you to flash versions of GRBL from a menu of available distributions. However, your mileage may vary here, especially if you have your own custom-compiled version.
Your precompiled GRBL firmware file will have a .hex
extension. This is what you will need to provide to the firmware loader. You will also need to define the target COM port, represented by your USB port. I have noticed some loaders are not too comfortable reading the firmware file from network shares, so it is recommended to have the file loaded on the PC’s local drive somewhere.
Connecting a controller to a PC
Your CNC machine will appear as a USB device on your PC. I have had excellent success connecting various desktops and laptops to many devices and controllers with little to no issues. Frequently, the device driver is automatically loaded (depending on the nature of the controller). However, failing that, you may need to load the device driver, commonly referred to as the CH340 driver. The reason for the name is that this chip (the CH340) is a common component of Arduino boards on which most hobbyist controllers are based or are clones. Load this driver (it should come on storage media with your controller) if you are unable to get your PC to recognize the board. When I am working on a from-scratch build, I check connectivity and load drivers and firmware before the board is ever connected to the CNC machine itself. Once connected, a look into Device Manager (for Windows) will show you which port your controller is on (COM4, COM5, COM6, and so on).
It is important to pay attention to the baud rate once you are connected to your controller. Using an incorrect baud rate will cause some loaders to hang, and you will have to force close them and try again. The acceptable communication speed should be published by the vendor of the controller in their specifications.
Before we move on to looking at G-code sender programs, let’s briefly go over LCD controllers. There are many alternatives here, and how you connect depends on the boards you are using. If you are using a controller such as a Mana board, there is no provision to use an LCD controller, and you are limited to using a dedicated PC for the duration of your CNC operation. On the other hand, more modern controllers will have connectors, such as those you saw in Figure 1.6 in Chapter 1, The What and Why of CNC to add an LCD.
I am a big fan of the LCD controllers put out by MKS Base (or Makerbase). These come in a variety of sizes, with support for SD or microSD cards so that the LCD controller can stream G-code to your machine instead of your PC. Many of MKS’s products also include the provision for Wi-Fi to allow wireless control. Here is a photo of a 2.4” touchscreen unit I have set aside for my 3018. These units come in various other sizes, including 3.2” and 3.5”. When you purchase them, they may have the 3D printer firmware on them by default. However, MKS puts out CNC and laser firmware as well.
In Figure 2.7, you see that I have already loaded the CNC/laser firmware:
Figure 2.7 – The MKS TFT24 for my DIY 3018
The following photo shows you my FLSun Cube printer. Same LCD vendor, but a different model. The 3D printing firmware is FLSun’s modification of the baseline provided by MKS:
Figure 2.8 – Another TFT LCD with the default 3D printer firmware installed
Loading the firmware is very straightforward and requires the LCD to be connected to your controller and the controller connected to power. Prior to starting up, you load the desired firmware on an SD card and insert that into the LCD controller. When you connect power and the devices boot, the LCD automatically recognizes the firmware file and loads it. The great thing about this is that the LCD firmware will have most of the features to support upgrades, such as adding a laser, supporting endstops, and so on.
Let’s review the various G-code sender programs and the ways of loading firmware onto your machine’s controller. Recall that we need senders to send the G-code to the controller because most small microcontrollers have limited memory capacity to hold more than a small number of commands. The other alternative is to use an LCD controller that allows offline operation, but you still will need sender-type software to generate the G-code file to load into the LCD controller, especially given the availability of calibration wizards such as the one in UGS. In this brief compendium, I list some of the more popular applications with as much focus on multiplatform availability as possible:
Alternatives to GRBL
While we are focusing our attention on GRBL in this book, you should also be aware of other firmware that is available, such as Maslow CNC, TinyG, Marlin, Repetier, and Klipper. For example, while Marlin is very common for 3D printers, it can be modified/adapted to run a spindle instead of a hotend (the part of the 3D printer that lays down melted plastic).
Other available applications include Candle, CNCjs, Easel (subscription-based), Ultimate CNC, and LinuxCNC. Consider these as well if you would like to explore alternatives to what has been presented previously.
In the laser world, I have had good experience with three applications. The first is T2 Laser (https://t2laser.wordpress.com/), which I have used to flash firmware on both laser and CNC machines and actually can be used to control both. T2 is paid software, and if you select it, you will need to decide if you are going to use it on more than one PC because the license can be tied to a PC. If you plan to use multiple machines, purchase the license that comes with a dongle that allows you to use different machines (albeit one at a time).
By far, LightBurn (https://lightburnsoftware.com/) has been my favorite (albeit paid) application for laser work. Finally, LaserGRBL (https://lasergrbl.com/) has proven to be a very robust application for my purposes.
You may also run across a software called Benbox. While commonly available with some laser machines, some units come with modified versions of GRBL specific to the board on the unit. I have occasionally resorted to Benbox to test my laser and flash GRBL but I generally don’t use it because of its limited features.
With your machine now set up and operational, it’s time to cut your first piece of material. Before we begin, we will need a wasteboard. This is a piece of material that we can make mistakes with that will protect the worktable from the cutting/carving bit should we need to cut through our workpiece. Make this out of a piece of any plywood or MDF that you can get at your local big-box DIY store. I like these to be at least 1/4” (6 mm) thick to ensure I have some leeway to stop a cut if it gets deeper than planned and to protect my metal worktable, and to drill holes to screw in clamps to hold my workpiece.
If you prefer, you can also buy wasteboards from places such as Amazon, but those are typically configured for worktables made of 80/20 extrusions, such as my machine in Figure 1.1 in Chapter 1, The What and Why of CNC. Those have countersunk holes to secure the wasteboard using T-Nuts. If you have a flat plate, as I do with my machine in the photos in this chapter, use strong binder clips to hold the wasteboard in place.
Place your workpiece on top of the wasteboard. You can secure it to the wasteboard in one of two ways:
The following is an example of one of those wasteboards you can buy on one of my 3018 machines. Note all the holes in it that are countersunk with T-Nuts as well as the holes for securing it to the worktable:
Figure 2.9 – A wasteboard on one of my 3018 machines
The final step before we make our first cut is to home our axes. Let’s start with the z axis. The following photo shows one of these probes that I use. The way the probe works is to complete a circuit when the carving/cutting bit’s tip touches the probe:
Figure 2.10 – One of my Z-probes for the 3018
The Z-probe typically comes with instructions, but fundamentally, you are connecting it to the controller (or if you are using an Arduino, to the A5 and GND pins) and probe header, and then you set UGS to set Z=0
. There is a great video on YouTube that illustrates this far better than anything written: https://www.youtube.com/watch?v=PtJF8q3RrDo.
Next, set the X=0
and Y=0
points on your workpiece and, using UGS in the Machine Control menu, jog your axes to where you want X=0
and Y=0
to be and press the appropriate Reset Zero button.
This YouTube video also offers some additional detail on getting your axes ready: https://www.youtube.com/watch?v=A1zlL3q23HI. The presenter here uses a technique similar to how bed leveling is done on a 3D printer where Z=0 is set using a piece of paper. Something to keep in mind is that this is something you can’t really do as easily with some LCD controller firmware, which is why if I build a machine to be standalone, with an LCD controller, my preference is to have endstops to ensure the toolhead does not crash into the axes limits and I can home (set the origin) automatically every time. My DIY machine started out with no endstops but did end up with them just because it was far easier to calibrate.
With your axes set, it is time to run a test. I suggest you attempt to cut some basic shapes first: a triangle, a rectangle, and a circle. Using whatever design software you have, make these shapes, and set their depth to be smaller than the thickness of your workpiece so that you can just engrave the shapes. The easiest way to do this is to create the shape in your favorite CAD application and convert it to G-code. Load the shape in, generate the G-code, and then load the G-code into UGS (if that is what you are using). Start the spindle, execute the cut, and see the results. Once the machine is done, jog it back to its 0,0,0
location, stop the spindle if it is still turning, and turn off the machine so that you can inspect your results. Confirm the dimensions of your shape against what you intended them to be, and if everything measures up, you are ready to start doing some CNC milling.
In this chapter, we took a deep dive into what is needed to set up our CNC machine and prepare it to mill our workpiece. We also determined how to load firmware, calibrate it, and set the origin of the axes. Finally, we also learned how to prepare the necessary G-code to load into our machine. While we focused on a machine without an LCD controller, the only difference between using a sender program such as UGS and the LCD is that the LCD will require the G-code to be loaded onto an SD card and read directly from there. There would be limited functionality to reset zero on the axes, which then speaks to having endstops on your machine, something we will cover in greater depth when we get to upgrades.
Our next chapter will get into selecting our materials for milling, as well as the bits we need to use. We will also look into what and how various bits cut and when we should use them.
Where there is an eBook version of a title available, you can buy it from the book details for that title. Add either the standalone eBook or the eBook and print book bundle to your shopping cart. Your eBook will show in your cart as a product on its own. After completing checkout and payment in the normal way, you will receive your receipt on the screen containing a link to a personalised PDF download file. This link will remain active for 30 days. You can download backup copies of the file by logging in to your account at any time.
If you already have Adobe reader installed, then clicking on the link will download and open the PDF file directly. If you don't, then save the PDF file on your machine and download the Reader to view it.
Please Note: Packt eBooks are non-returnable and non-refundable.
Packt eBook and Licensing When you buy an eBook from Packt Publishing, completing your purchase means you accept the terms of our licence agreement. Please read the full text of the agreement. In it we have tried to balance the need for the ebook to be usable for you the reader with our needs to protect the rights of us as Publishers and of our authors. In summary, the agreement says:
If you want to purchase a video course, eBook or Bundle (Print+eBook) please follow below steps:
Our eBooks are currently available in a variety of formats such as PDF and ePubs. In the future, this may well change with trends and development in technology, but please note that our PDFs are not Adobe eBook Reader format, which has greater restrictions on security.
You will need to use Adobe Reader v9 or later in order to read Packt's PDF eBooks.
Packt eBooks are a complete electronic version of the print edition, available in PDF and ePub formats. Every piece of content down to the page numbering is the same. Because we save the costs of printing and shipping the book to you, we are able to offer eBooks at a lower cost than print editions.
When you have purchased an eBook, simply login to your account and click on the link in Your Download Area. We recommend you saving the file to your hard drive before opening it.
For optimal viewing of our eBooks, we recommend you download and install the free Adobe Reader version 9.