I have been trying to get a replacement CNC controller board up and running for a few months now - fighting with LinuxCNC and a cheap Chinese Blue Board controller I bought off eBay. Although I can get it basically operational - enough to cut simple shapes out of MDF but I have been having a lot of problems getting enough accuracy to do anything more significant (and certainly not enough to reliably mill PCBs). If you are building up your own CNC or looking to replace the controller in an existing one I would recommend keeping away from this particular product.
After finding that more recent versions of GRBL now supports probing (which is essential for PCB milling) I have decided to change direction and control the CNC through an Arduino based system instead.
If you are not familiar with GRBL it is GCode interpreter for ATmega328p based Arduino boards that can generate the stepper motor sequences needed to control a CNC machine. There are a number of ways to send the G-Code to your Arduino - the Universal GCode Sender is a Java application that will run on any platform with a JVM and ChilliPeppr is a web based solution.
Because I haven't had much experience with GRBL I didn't want to jump right in and run the risk of damaging the chassis of my CNC machine with a misjudged configuration parameter. I've been wanting to build my own CNC for some time but I put that project on hold when I bought a pre-built one. I still had all the notes and research I did so it seemed like a good idea to dust it off, build a GRBL based controller board and use that to get a feel for the firmware and it's capabilities.
The larger CNC will still be used for cutting and precision milling - for the smaller one I would just like to do basic plotting and drawing. This means there will be very little lateral force applied to the tool head so I can use smaller stepper motors and be a bit more flexible with the physical design. The tools I am planning to use range from simple felt tip pens, a small engraver tool and possibly the recycled DVD laser I played with previously. The Z axis control will be a simple pen up/pen down signal which is left to the tool head to interpret, GRBL doesn't support this directly so I have come up with a workaround that I will describe later in the post.
GRBL doesn't control the steppers directly, you need to run the IO pins from the Arduino through a stepper controller board to actually drive the motors. I have an ITEAD Dual Stepper Shield that will do the job nicely. For the X and Y axis I am using a pair of linear actuators that I got from eBay (shown below).
These are 6V steppers with a 22.5 degree step (16 steps per revolution) and a 3mm screw pitch. This translates to an accuracy of just under 0.2mm per step which is not particularly fine - by using the microstepping features of the board controller I can increase the resolution though (albeit with a loss of torque). The total linear movement for these actuators is 60mm so I will be limited to a safe working area of 50mm x 50mm - enough for simple jobs.
The pin out of the ITEAD board doesn't correspond to the pins used by the default GRBL configuration so I decided to make a custom PCB to glue everything together. You can customise the pins that GRBL uses (with some restrictions) but using a separate board allowed me to combine some additional circuitry (like limit switch inputs, a regulator for the motors and a connector for the tool head) into a single circuit.
The schematic for the board is shown above. My apologies that it is not very readable in this resolution - once the project progresses a little more I will put it up on GitHub so you can access the full PDF version and the associated project files. I'll discuss the important components in the design in this post and provide some higher resolution schematics for them individually.
I am using a simple FTDI module to provide the serial connection and the regulated 5V power for the logic components. The motor controller requires it's own power supply so I'm using a LM317 to regulate a 9V input (from a standard wall plug DC converter) down to 6V for the steppers.
The core of the system is a minimal ATmega328p CPU circuit. To maintain accuracy in timing GRBL requires an external 16MHz crystal rather than just using the internal oscillator of the chip. Apart from that, a decoupling capacitor and the appropriate power connections there is really nothing special required. The RESET line is provided by a pull up resistor to VCC with a pushbutton to ground.
The circuit above shows the inputs for the limit switchs. While these are not necessary for the operation of the CNC they are certainly handy - if fitted you can use automatic homing rather than manually positioning the tool head and they provide a level of protection if you try to exceed the physical limits of the workspace. The circuitry for each switch is the same - if the input is shorted out the corresponding XLIMIT or YLIMIT input to the processor will be pulled low.
Although there are only single inputs for each of the two axis you can install switches at each end of the axis - if they are wired in parallel either switch being activated will pull the input low.
I mentioned earlier that I would be using simple up/down control for the tool head on the Z axis and GRBL doesn't directly support this. After looking at the GRBL code to see if it could be modified to produce that behaviour I decided that it would be easier to use an external method. In this case I am using an ATtiny85 to monitor the Z axis outputs (ZSTEP, ENABLE and ZDIR) and generate a TOOL output based on Z movement. I have ZSTEP connected to the T0 pin of the ATtiny so it can drive counter 0 directly (monitoring the input with software only could lead to missed steps).
The tool output will be active after a downward movement of 5mm in the Z axis, any upward movement will make it inactive. This output and the SPINDLE output from the GRBL is fed to the tool head through an RJ12 connector on the main board. The RJ12 socket includes power rails as well - both the regulated 5V line for logic and the unregulated input voltage if the head needs it's own high power source.
The image above shows the placement of the modules on the board - discrete components such as ICs, resistors and capacitors are not shown, I was just double checking that none of the modules would overlap in my design. I've kept the connectors for the motors, limit switches and tool head to the back of the board and the USB socket for the controller interface to the front. The schematic includes pin headers for power switches on both the 5V and motor voltage lines so they can be switched on and off individually. There is also support for indicator LEDs so it's clear when the device is powered up or not.
I haven't spoken much about the physical design of the chassis and, to be honest, I haven't given it a lot of thought. My general idea is to use a moving bed rather than a moving gantry for positioning. The image above (from another CNC project on the web) shows the general layout of this type of system.
On a CNC machine of this size it doesn't really matter which technique you use - I chose moving the bed because it allows me to keep both steppers in a fixed location which will ease cable management. The only cable that needs to be flexible is the one to the tool head and even that will only have to deal with short movements.
This project does involve some bootstrapping - once I am happy with the electronics and have proven I can control the steppers with reliability and accuracy I will duplicate the control board design for the larger CNC using higher power motor controllers. The components that make up the chassis of the smaller CNC will be a mix of 3D printed connecters and panels cut with the larger CNC.
I will keep updating with new posts as the project progresses and you can follow along on the The Garage Lab Slack Chat as well - to get an account simply use this form. Please feel free to jump in and show off your own projects as well - the more the merrier.