Controlling a CNC Machine
Computer numerical control (CNC) machines have been around for as long as computers have been around to control them. In fact, the term “CNC” refers to the process in which a computer follows a set of instructions to send pulses to a stepper motor, power a spindle, heat an extruder, or pulse a laser. Whatever type of CNC machine it may be, it will have a computer driving it. For more information on what exactly a CNC is head to our CNC article:
For most industrial and high-end commercial CNCs, this means producing specialized computers for each type of machine. As for custom-made and hobbyist CNCs, they’ve had to dedicate PCs to control their machines, that is, until microcontrollers came into the scene.
While there are plenty of MCU boards to choose from, we’ll be focusing on the Arduino family and the corresponding software. Arduinos are widely used by hobbyists and developers. This is in no small part due to their availability and large community. Having an MCU board to control your CNC means that your computer only needs to output the G-code while the board manages the timing and interprets the G-code. It also frees you from having to deal with outdated parallel ports used for interfacing.
The Arduino, like all computers, needs a program to run. When people think of programs, they think of the software that runs on a PC. In our case, we’ll be discussing programs that run on an MCU, which are more specific in their function and work closer to the hardware. The proper term for this kind of software is firmware.
It’s worth noting that, if you currently have a different board, it is possible to change to Arduino, as long as it supports the hardware, should you want to use one of the featured firmware options.
In the following, we’ll be considering the best firmware for your Arduino-controlled CNC. The firmware presented varies in purpose and strength. Therefore, we’ll be comparing the various options in three main areas:
Before we dive into the firmware, we need to consider the limitations of an Arduino. While Arduino can work as the brains of a CNC controller, it isn’t “strong” enough to power the “limbs”. More accurately, the Arduino needs a way to supply sufficient current to hardware.
To do this, an Arduino shield is required to draw power from an external power supply. On top of that, shields connect the Arduino to stepper drivers that provide the pulses required to control the stepper motors.
There are many Arduino shields out there. Some notable ones would include the RAMPS and Arduino CNC shield. Things to consider include choosing the right one for your specific Arduino. Additionally, the types of connections on the shield and Arduino combo should suit the purpose. A 3D printer, for instance, will need the extra pins for heating and regulating a hot end. Therefore, the Arduino board selection itself is also very important. Another detail is whether the shield has integrated or modular stepper drivers. This matters if you want to be able to replace the drivers.
It’s also important to note that all-in-one options exist, such as the RAMBo board. This one, in particular, uses the same processor as the Arduino Mega. That said, we’ll go over the supported Arduinos with each firmware.
GRBL is perhaps the simplest firmware on this list. It began as a humble project looking to interpret G-code on an Arduino Uno. Now, it has grown into two different versions, regular GRBL, and GRBL Mega. The distinction between them is the boards they support. The first supports the Arduino Uno and other 328p Arduino boards. The GRBL Mega supports the Arduino Mega, which has more memory and pins for future improvements
GRBL gets its value from its simplicity; it interprets G-code without any bells and whistles. While it does have a few neat features, such as acceleration look-ahead and jogging mode, it excludes some more advanced functions like macros and canned cycles. According to the developers, this is because these features are better done on the software side of things.
Though GRBL does its job well, it may not do enough. GRBL currently only supports 3-axis machines. This means that machines requiring more than three steppers (like 3D printers) are out of the picture. Well, for now, at least, as this aspect is still in the works. For example, there are forks of the GRBL Mega project that support more axes in case you really can’t wait for its development.
Installing and setting up GRBL is pretty straightforward. Flashing GRBL is as easy as adding a library and uploading a sketch in the Arduino IDE. As for the configuration, GRBL has serial commands for adjusting settings post-flash. Once GRBL is set up, you may choose one of many G-code senders made for use with GRBL.
Supported Boards: 328p processor Arduinos or the Arduino Mega 2560
Klipper is a firmware that uses your Arduinos and combines them with a computer to control a CNC (yes, multiple Arduinos). Klipper takes a different approach to CNC control than most. With Klipper, the computer (in this case, a Raspberry Pi) takes care of the timing, physics, and G-code interpretation while the MCU follows the instructions on time.
What does this mean for the user? Essentially, you can have multiple Arduinos, or other boards, controlling different parts of your CNC. No longer would there be an issue with having a single board with enough stepper drivers or power. Even better, all of the configuration is done quickly and easily on the Raspberry Pi.
“Hold on,” you say, “multiple processors running a single machine… Sounds like a recipe for poor timing!” Klipper has you covered there too; currently, it runs with a timing precision of 25 ms and about 100,000 to 700,000 steps per second, depending on the MCUs.
Perhaps the biggest let down with Klipper is that it only supports 3D printers, though some have been able to run other CNCs with some minor tweaks. But, in case you like digging into code, just know that Klipper is coded in Python.
As for installation, expect a more involved process since it does run on an actual computer. If you’re familiar with OctoPi, the set up will look familiar. It requires running a few terminal commands to flash the firmware and a few more to get it working with OctoPi.
Supported Boards: Any AVR, ARM, or PRU boards + Raspberry Pi
Marlin is perhaps the most fleshed-out firmware on this list. It’s the firmware for any 3D printer and even supports CNC laser and spindle configurations. Marlin can be set up to run various printer styles and setups. If there’s a feature you want to add to your printer, Marlin would be the place to look to support it.
Marlin comes with neat features, such as automatic bed leveling with a probe and autostart files, but perhaps its greatest is its flexibility. Marlin is made with all printers in mind and therefore comes with a lengthy list of settings. These allow you to enable anything from a filament width sensor to case lights. For the entire configuration run down, visit their Configuring Marlin page.
Due to this flexibility, the setup of Marlin can be lengthy depending on the build. There are many things to configure when setting up Marlin, though there are some example configs to get you started. Besides this, the actual uploading of the firmware is simple thanks to the Arduino IDE.
Supported Boards: Almost any Arduino and others (Marlin Boards list)
This is an all-purpose firmware by Repetier. It comes with many configurations to work on a variety of printers and has a CNC mode for use with other tools.
When put side by side with Marlin, it may seem familiar or might even feel like a bit of a let down; it has fewer unique features and fewer people working on it. Meanwhile, others may argue that stable software may be more attractive than one that is constantly changing.
Repetier provides host and server software for communicating with your CNC. This may be a good choice for those who don’t want to worry about compatibility.
The most attractive and redeeming aspect of this firmware is its user-friendliness. Repetier has an in-depth step-by-step guide for configuring all the settings of your printer. They even provide a configuration tool for those intimidated by the many options. It allows for different levels of configuration and walks you through a neat list of selections. The actual install, like many on this list, takes advantage of the Arduino IDE to make it easy.
Supported Boards: All Arduino setups with at least 64 kB
This one is a bit of an oddball on the list. Maslow CNC firmware is, well, for the Maslow CNC. The Maslow is a uniquely-designed CNC router that relies on gravity to maintain its positional control. It hangs the router from two drive chains at an angle, resting the router on the stock. Maslow’s design allows it to be a large and affordable CNC router.
Maslow is on this list because it was designed with the Arduino as its controller. It even has a custom shield. While it may not support your current machine, like others on this list, it is an interesting choice for those looking to build a CNC machine from the ground up. Maslow provides its software, as well, giving you all the necessary tools.
And of course, it’s easily installed through the Arduino IDE. Overall, this makes the Maslow the least-customizable CNC firmware, but the most straightforward to set up.
Supported Boards: Arduino Mega 2056
(Lead image source: Caleb Favela / All3DP, disk91.com)
License: The text of "Best CNC Software for Arduino" by All3DP is licensed under a Creative Commons Attribution 4.0 International License.