Electronics

Arduino / CNC Shield Machine Controller

Mar 22

An open source design for a Arduino / CNC Shield based controller for CNC 1610 / 3018 machines. This controller is intended to replace the Woodpecker style controller boards supplied as standard with easily available open source parts.

arduino / cnc shield controller

Introduction

This project was conceived as a test environment for Grbl based firmware and desktop computer based software that interacts with CNC machines. A particular requirement was the ability to quickly upload different versions of the Grbl firmware, up to and including the latest 1.1h version. This was found to be difficult to do with the Woodpecker based circuit board supplied with the CNC 1610 machine as the firmware cannot be flashed through the USB interface. Although ways can be found around this by using an external AVR in-system programmer, this would not satisfy the requirement to be able to do this quickly and easily. A solution based around an Arduino with the Arduino bootloader installed would fulfil this need.

An Arduino Uno can easily be used to control the three NEMA 17 stepper motors that control the X, Y and Z axes of the CNC 1610 if it is used in conjunction with a CNC Shield, readily available on Amazon, eBay or AliExpress. A further requirement of this project was that it should also be able to control a variable speed spindle motor and support limit (stop) switches on all three axes. For the CNC Shield to be able to meet these requirements successfully, it needs some small modifications and also some additional external circuitry, in particular a pulse width modulation (PWM) capable DC motor driver. Whilst carrying out research on the web prior to designing this project, it was found that many other people have tried to put together a similar system and have run into similar problems as this project did in its development. For that reason, it was decided to document the project development and publish it here as a fully tested and working solution.

Project Description

arduino uno
Arduino Uno Clone

The project is based around the commonly available Arduino Uno, which is one of the core boards that Grbl was originally written for. This board can run any version of the Grbl firmware and also has the advantage of having the CNC Shield expansion board, designed to control three stepper motors for the X, Y and Z axes of a CNC machine using Pololu style stepper motor driver boards, giving a choice of stepper motor driver ICs including the A4988 (used here) or the DRV8825.

The CNC Shield board used here (a version 3.00 board as these are the most commonly available) does a good job of meeting the requirements of driving the stepper motors, but has some short-comings when end stops (limit switches) are used due to false triggering. This was seen in practice whilst developing this project, with false triggering causing the Grbl controller to go in to an unintended alarm state, especially when the spindle motor was powered on. This board as designed can only control a spindle motor as a two state (on or off) device and this is far from desirable in a CNC machine as it is very useful to be able to vary the spindle speed for different tooling or materials to be cut. The later versions of the Grbl firmware swap the z-axis limit input on Arduino pin D11 with spindle enable output on pin D12 to allow for a pulse width modulation (PWM) output on pin D11. In practical terms this simply means using the Z+ or Z- end stop connections on the CNC Shield as the spindle enable and the connection labelled SpnEn as the z axis limit input. Some simple wiring modifications can achieve this.

cnc shield
Arduino CNC Shield (ver 3.0)

The CNC Shield does not incorporate a spindle motor driver. This has caused some confusion on internet forums but to be clear, the CNC Shield cannot directly drive a DC spindle motor as the spindle enable output is a low current 5V output taken from the ATMEGA328P. This can source a maximum of 40mA - nowhere near enough to power a DC motor. The spindle enable output must therefore be used to control a DC motor driver circuit. A suitable spindle DC motor driver circuit proved surprisingly difficult to source from the usual suppliers. Motor driver circuits are available for hobbyist use, but they all came up short in terms of specification. The circuit must be able to operate from supply voltages up to 36V, handle continuous load currents of up to around 3A and most importantly be able to handle the DC motor's high in-rush currents, which were found to be up to 24A in even a small 775 style spindle motor on a CNC 1610 machine. A few MOSFET driver circuit boards were purchased, but were all found to be unsuitable. They all needed modification in order to be suitable for inductive loads (which generate back EMF) by the addition of a flywheel diode and even then none of the boards was found to be able to handle the peak in-rush currents, despite the published specification claiming they could. For this reason it was decided to design a new PWM Spindle Motor Driver as part of this project. Visit our PWM Spindle DC Motor Driver project page for full details of how to make this circuit board on either stripboard or printed circuit board.

The final part of the project was the power supply requirements. It was decided that the 24V 5A power supply which came with the CNC 1610 machine was to be retained and so a matching DC jack socket was obtained for power input. The Arduino Uno has a maximum power supply voltage of 12V however and so a step down voltage regulator had to be sourced. This requirement was easily met by a commonly available variable voltage regulator based on the LM2596S integrated circuit.

Project Construction

The design of the project presented here was to meet a specific need as outlined in the introduction. It is therefore intended that the design can be modified to suit individual circumstances and sufficient information and the required files have been provided in order for you to be able to do this.

Parts Required

The following parts will be required to make the project. Please note that a suitable Arduino / CNC Shield Mounting Plate and a PWM Spindle DC Motor Driver are pre-requisites for the project. There are alternatives available for many of the parts on the list and so you may need to buy equivalent parts that may be more easily available in your locality. Also, the information links provided are intended to show examples of products that meet the requirements of the project and are not a recommendation of any particular supplier or product.

Part Description Manufacturer Part Number Quantity Information Link
Mounting Plate Arduino / CNC Shield Mounting Plate In-house / DIY - 1 Build Instructions
PWM Spindle Motor Driver PWM Spindle DC Motor Driver In-house / DIY - 1 Build Instructions
Arduino Uno Arduino Uno Clone3 Various - 1 Amazon
CNC Shield Arduino CNC Shield Expansion Board ver. 3.03 Various 1 Amazon
C1, C2, C3 0.1uF 50V Ceramic Capacitor1 Kemet C322C104K5R5TA 3 Kemet
Voltage Regulator LM2596 DC to DC Converter Board3 Various - 1 Amazon
DC Jack Socket Panel Mount DC Socket 5.5mm x 2.5mm2 Various - 1 Amazon
DC Jack Plug Panel Mount DC Socket 5.5mm x 2.1mm Various - 1 Amazon
Power Cable 18AWG Red and Black Power Cable3 Various - 1m of each Amazon
Ribbon Cable Ribbon Cable for 2.54mm Connectors3 Various - - Amazon
DuPont Connector Header Kit DuPont connector header kit with terminals and crimper3 Various - 1 Amazon
Heatshrink Tubing Heatshrink tubing kit - various sizes3 Various - 1 Amazon
M3 x 12mm Cap Head Screw M3 x 12mm Cap Head Screw3 Various - 5 Accu
M3 x 5mm Nylon Spacer 4.8mm X 3.2mm X 4.8mm Spacers - Nylon3 Various - 5 Accu
M3 Flat Washer M3 Form A Flat Washers (DIN 125)3 Various - 5 Accu
M3 Nut M3 Hexagon Nuts (DIN 934)3 Various - 5 Accu
M2 x 16mm Cap Head Screw M2 x 16mm Cap Head Screw3 Various - 2 Accu
M2 x 10mm Nylon Spacer 3.6mm X 2.2mm X 9.5mm Spacers - Nylon3 Various - 2 Accu
M2 Flat Washer M2 Form A Flat Washers (DIN 125)3 Various - 2 Accu
M2 Nut M2 Hexagon Nuts (DIN 934)3 Various - 2 Accu

1 Any 0.1uF ceramic capacitor of suitable size will work in this application. These capacitors are needed to modify the CNC Shield board as described in Fitting End Stop Limit Switches to a CNC Machine.

2 This socket should be chosen to match the connector on the power supply that you intend to use.

3 Given as an example only. Many alternative manufacturers and suppliers exist - choose suitable parts that are available to you locally.

Step by Step Guide

Step 1 - Mounting Plate

step one
1. Aluminium Mounting Plate

Firstly, make an aluminium mounting plate, following the instructions in the article Aluminium Mounting Plate for Arduino / CNC Shield.

The mounting plate shown in this photograph is shorter than the one described in the article as it was used for testing various DC motor driver boards. The design described in the article is the correct size for the PWM Spindle DC Motor Driver built for the final version of this project.

Step 2 - Power In DC Jack Socket and Cables

step two
2. DC Jack Socket and Cables

Attach the DC jack socket to the mounting plate where shown. Then solder on short lengths of power cable to the terminals on the DC jack socket, leaving sufficient length for the cables to reach the voltage regulator board. Ensure that you use heatshrink tubing to cover the soldered terminals. In this project, the centre terminal is positive, but you should check this against the power supply that you intend to use.

Step 3 - Arduino Power DC Jack Plug

step three
3. DC Jack Plug and Cables

The power cables should now be soldered on to the DC jack plug used to power the Arduino Uno. The centre terminal is positive and should be covered with heatshrink tubing once soldered. Heatshrink tubing can also be used to keep the positive and negative cables together throughout their length for neatness. The power cables should be left long enough to reach from the Arduino Uno to the output of the voltage regulator allowing for bends. See later images for guidance.

step four
4. Cables soldered on the Voltage Regulator board

Step 4 - Solder cables on to the Voltage Regulator board

The power cables from the Arduino Power DC jack plug should now be soldered on to the power out pads on the top side of the voltage regulator board.

Additional power cables should be soldered on to the power in pads on the bottom side of the board. These cables need to be long enough to reach the power in connector on the CNC Shield board (see later images for clarification).

Step 5 - Attach the Voltage Regulator board to the Mounting Plate

step five
5. Voltage Regulator Mounted on Plate

The voltage regulator board should now be bolted to the mounting plate using M3 socket head screws, nylon spacers, M3 washers and M3 nuts.

The DC jack socket cables can now be soldered on to the top side power in pads on the voltage regulator.

Step 6 - Attach the Arduino Uno to the Mounting Plate

step six
6. Arduino Uno on the Mounting Plate

The Arduino Uno board should now be bolted to the mounting plate using M3 socket head screws, nylon spacers, M3 washers and M3 nuts.

Step 7 - Attach the PWM Spindle Motor Driver to the Mounting Plate

step seven
7. PWM Spindle Motor Driver added

The PWM spindle motor driver board should now be bolted to the mounting plate using M2 socket head screws, nylon spacers, M2 washers and M2 nuts.

Step 8 - Mount the CNC Shield on the Arduino Uno

step eight
8. CNC Shield mounted on the Arduino Uno

The CNC Shield board can now be mounted on the Arduino Uno and the power in cables from the power in pads on the voltage regulator pushed into place in the power in connector of the CNC Shield. Do not tighten the screws on the power in connector just yet.

Note that if you intend to use the End Stop limit switches, then it is highly recommended that you read the Fitting End Stop Limit Switches to a CNC Machine guide and modify your CNC Shield board as described before completing this step.

Step 9 - CNC Shield to PWM Motor Driver Power Cables

step nine
9. CNC Shield to PWM Motor Driver Power Cables added

Positive and negative power cables should now be cut to length and connected between the power in connector on the CNC Shield (doubling up on the cable from the power in on the voltage regulator) and the power in connector on the PWM Spindle Motor Driver board. The screw terminals on both boards can now be tightened to hold the cables in place.

Step 10 - Set the Voltage Regulator Output Voltage

step ten
10. Voltage Regulator output set to 12V

Ensure that the DC jack plug is NOT connected to the Arduino before carrying out this step!

Connect the power supply to the DC jack socket on your controller assembly in order to power up the voltage regulator board. Attach your multimeter to the output pads of the voltage regulator board using spring-loaded clips if you have them, then adjust the potentiometer on the voltage regulator board until you get 12.00V output.

Disconnect the power supply and multimeter once you have completed this step.

Step 11 - CNC Shield to PWM Motor Driver Power Cables

step eleven
11. Stepper Motors and Spindle Motor Connected

Positive and negative power cables should now be cut to length and connected between the power in connector on the CNC Shield (doubling up on the cable from the power in on the voltage regulator) and the power in connector on the PWM Spindle Motor Driver board. The screw terminals on both boards can now be tightened to hold the cables in place.

The stepper motor cables should be connected to the CNC Shield board, noting the correct orientation of the connectors and also ensure the correct placement of the X, Y and Z axes. The spindle motor cables can also be connected to the PWM Spindle Motor Driver board, ensuring that the polarity is correct.

Step 12 - CNC Shield to PWM Motor Driver Signal Cable

step twelve
12. PWM Signal Cable connected

A 2 way female to female DuPont connector cable should either be purchased or can be easily made from commonly available kits of parts, including 2 wires stripped from a length of flat ribbon cable. A suitable crimp tool will need to be purchased in order to make up the cables yourself and this is well worth the investment as these types of connecting cables are used quite often.

The cable can then be used to connect the CNC Shield board to the PWM / GND connector on the PWM Spindle Motor Driver board. Note that this cable should only be connected to the SpnEn (Spindle Enable) output on the CNC Shield board if Grbl 0.9 or earlier is used and you do not wish to make use of a PWM variable speed spindle. To enable full variable speed spindle control, you will need to connect the cable to the Z- (or Z+) end stop as shown in the photograph. Ensure that in either case you get the orientation of the cable correct.

Step 13 - Connect the End Stop Limit Switches

step thirteen
13. End Stop Limit Switches connected

The end stop limit switches can now be connected to the CNC Shield board, ensuring the correct axis / end is attached to each input.

Step 14 - Connect the Z-Axis End Stop Limit Switch

step fourteen a
14a. Splitter Cable for Z-Axis End Stops

If you are not using a PWM variable speed spindle, then the Z-axis end stop limit switches can simply be connected to the inputs labelled as such on the CNC Shield board, in the same way as the X-axis and Y-axis ones.

This project does use a PWM variable speed spindle however and so the two Z-axis end stop limit switches have to be connected to the SpnEn (Spindle Enable) header on the CNC Shield board. In order to do this, a splitter cable was made up as shown in the photograph. The splitter cable was assembled using parts from the DuPont Connector Header Kit and the flat ribbon cable. The ends of the cables to be joined were simply soldered together and covered with heatshrink tubing.

step fourteen b
14b. Z-Axis Splitter Cable connected to the SpnEn Header

The Z-axis end stop limit switches can now be connected to the SpnEn (Spindle Enable) header on the CNC Shield using the splitter cable.

Download Design Files

License

You may use the designs described on this page for any commercial or non-commercial purpose that you wish, providing you credit Capella CNC with the creation of the original design on any product or updated design that you create or distribute. The simplest way to do this is to leave the Capella CNC logo and web address intact on any product or design that is produced.