Finally time for some hardcore electronics! The amount of hardware and software available for CNC controllers is pretty extensive. Several companies offer integrates packages that will do all the necessary functions. There are several approaches, the LPT port powered or external motion controller systems which use MACH 3 software, and the Arduino powered systems. There are a few others, but these seem to be the most popular.
The LPT and aftermarket motion controller connected systems use the PC software to interpret G-code and send stepper driver ready digital signals via the port to a Break Out Board as mentioned earlier. The BOB has optoisolators to isolate the PC from the motor drive signals, and essentially just provides a place to connect the stepper driver boards to the PC. Thus the name Breakout Board. Separate stepper driver boards either individual or multichannel are then used to actually drive the motors for each axis. Small CNC systems typically use 3 axes, X, Y, and Z. Other axes can be added to the system which include a rotary axis to do machining of objects by rotating them, and tilt axes that can tilt the Z axis to either side to provide ability to do angular cuts. These are beyond the scope of this project.
Some examples of LPT based systems are the LinuxCNC software, which is open source, and the MACH3 and MACH4 software which is not free, but reasonably priced at a few hundred dollars. PlanetCNC software is also free, and uses a USB based BOB and separate stepper drivers. Finally, Arduino based CNC using the GRBL g-code interpreter is the system I have chosen to use. It can run up to 3 axes by using the onboard digital I/O of the Arduino to control stepper drivers, interface limit switches, and even control the spindle motor. Arduino based systems are very cheap, the entire controller can be built for less than $200, and all the software is free.
I want to take a close look at the Arduino platform for a CNC controller, at least the hardware that I ended up using. and look at the GRBL software for converting g-code to X-Y-Z positioning. I will touch on loader software for the Arduino, and loading the Arduino from Windows in a later blog. With much oration and hand waving, let’s get started!
The Arduino series of microcontroller boards has turned out to be a fantastically popular small open source computing platform for just about any project you can think of. From robots to IOT devices, to sensor platforms, drones, whatever application you have can pretty much be done on an Arduino. This has also led to a plethora of add on boards that plug into the I/O headers on the Arduino mainboard, known as “shields”. Motor drivers, network interfaces, sensor interfaces, displays, LED panels, audio players, GPS, GSM cellphone, you name it, somebody has a shield to do it.
The first and still very popular Arduino was the Uno. It uses an ATMega328 microcontroller chip. The board integrates a power supply, USB connector for power and communications, and an integral FTDI USB-serial converter. It can be programmed via hex downloads from the USB port, or using an external programmer. A free IDE programming environment is available which allows you to use canned libraries of software, or write your own “sketches” as they are called to do whatever task is required.
There are 14 programmable digital I/O lines and 6 analog inputs, along with another half dozen power pins brought out to 2 rows of single row female headers that form the interface connectors. Arduino “Shields” can be plugged into these stacking connectors, most shields have stackthrough connectors so boards can be stacked several layers deep.
A 6 pin ICSP programming header is also provided. The ATMega can be programmed through this header, but it also has a pre-programmed bootloader burned into the internal ROM which allows programs to be downloaded from a PC using the USB port. We’ll get into that a bit later when we install the GRBL software. Another free program is available to download hex files into the Uno.
Shown below are a couple of the many clone Arduino boards available.
Intro to the CNC Electronic Hardware
There are several shields and driver boards specifically made for CNC systems such as the TinyG, the CNC Shield, and the GRBL shield. I will just go over some of the most popular systems out there, there are a plethora of boards out there.
The first board we will look at is the CNC shield. This is an open source board manufactured by dozens of different manufacturers both here and abroad. It consists of an Arduino shield board with a bit of interfacing hardware and sockets for plugin style motor controllers. These are postage stamp style stepper drivers that plug into headers on the CNC Shield. Up to 4 motors can be controlled using this shield, and the controllers can handle in the range of 1-2 amps per phase, typically.
These drivers can be Allegro Microsystems A4988 chip drivers, which handle up to 1A typically, or a bit more with a heatsink and forced air cooling. They can do 1-1/16 step drive with built in thermal limiting and an adjustable current limit. They are also short circuit protected, and run at up to 35V input. The Texas Instruments DRV8825 drivers are similar, but can handle an input of up to 45V, 1.5A without heatsink and 2.2A with heatsink and forced air cooling. They also have adjustable current limit, short circuit and thermal protection, and can go to 1/32 step microstepping.
This board was my first choice, but in general it cannot handle enough current for the larger 2.8A NEMA23 stepper motors that the CNC uses, so I decided not to use them. They are very popular, however, for use with 3D printers, as they are more than sufficient to drive the NEMA17 motors used in those systems. The 3D printers also require the fourth axis for filament feed systems, so these are ideal. The CNC Shield in one of its many incarnations, with an DRV8825 driver shown beside it:
Now let’s take a look at the GRBL Shield. This is manufactured by Synthetos, the same company that makes the TinyG. It is a smaller shield type board with 3 motor drivers installed. It can drive 2.0A at 30v, up to 1/8 microstepping, with independent current control for each channel. It uses the TI DRV8818 stepper driver chips. This is a nice board, but again, did not quite meet my requirements. It is shown here:
After a lot of reading and looking around, I found that the smaller systems such as the CNC shield and the GRBL shield were a bit lightweight for the system I had in mind. Both of these boards have multi channels of stepper drives, but can only handle stepper motors up to about 2 amps. This is more than adequate for a NEMA 17 stepper motor used in typical 3D printers, but I needed a bit more sputz to drive the 2.8A NEMA 23 motors that I had in mind. All of the single board systems are a bit light weight for a serious CNC machine. I also don’t like the fact that if one driver or some minor component on the board burns out, the whole multi-hundred-dollar board is garbage. Much better to have a modular approach where it’s easy and cheap to replace individual components.
So, I went with a screw terminal shield for my Arduino, but used an Arduino Nano instead of the Uno. The Screw Terminal Shield which is a passive backplane that simply brings out all the arduino I/O connections to screw terminals so that I can easily connect them to individual stepper drivers. I chose a Single Axis TB6560 3.5A Stepper Stepping Motor Driver Board. This is a small board with integrated heat sink about 3.5″ square, utilizing the Toshiba TB 6560 stepper driver chip. It has a heatsink on the back, and is capable of driving a single motor of up to 3.5A@24V. It has opto isolated inputs, and settings on board for current, step size, hold current and decay mode. One board is needed for each stepper motor.
The Arduino Nano with Screw Terminal board is on the left, the Stepper Driver board is shown below right:
The stepper driver board has simple connections for Motor supply, motor windings, and Step, Direction, and Enable inputs with an isolated 5V supply input for the optos. This made wiring the system a snap. Each stepper driver is simply wired to its associated axis motor, and to the Arduino as shown below. 2 wires per axis, and a common power connection and Enable signal daisy chained to each board. The wiring will be a bit more complex when I add the limit switches, for now I will rely on the soft limits built into the GRBL controller. I could also add a couple of push button switches for the Feed Hold and Resume circuits, and a reset button. I’m not using the coolant output nor the PWM spindle speed output yet. I have to come up with a way to control a universal motor (the spindle router) with the PWM signal before that gets added. I could also use a standard relay module to turn the spindle on and off under software control, or add a Laser using the Spindle PWM output.
Note that the pin layout shown is for GRBL firmware version 0.9 and above. It is slightly different on earlier versions. Make sure you have the right diagram for your software. This Diagram also shows an Arduino Uno, the Nano pinout is almost exactly the same, as shown below.
The only thing left was a power supply. I had Mean Well LRS-350-24 supply kicking around which was ideal. With 4 motors running, the current draw would max out at just under 12A, so a 350W supply was needed. I mounted all of the electronics on a simple aluminum panel..
Since I built this, OpenBuilds has come out with a cool sort of enclosure for the power supply. It encloses the terminals to prevent accidental touches, and has an IEC (computer) power plug, switch, power LED, and output plugs. Nice clean unit. Check it out at Openbuilds.com.
So, that’s it for this edition. Next edition, we’ll look at loading the GRBL software into the Arduino, and some of the options for outputting G-code from the PC. Then, we’ll fire it all up and see if we contain the magic smoke or not!
[You do, of course, know that all electronic components work because they contain Magic Smoke. If you cause the Magic Smoke to leave the component, by whatever means, it does not work any more!]