A Simple CNC Machine - Part 3

Another update on my mini-CNC project - progress has been a little slower than I hoped for but I've reached an important milestone now - moving motors!

As you can see there are some issues with the precision of the movement - each of those moves is supposed to be 20mm. It doesn't quite make the full 20mm and doesn't return to the same starting point. I'll discuss those issues later in the post but first I would like to talk about the circuit itself.

CPU Schematic

I intended to use the GRBL firmware from the start which requires an ATmega328p with an external 16MHz oscillator. The circuit I used is a basic minimal Arduino compatible circuit with reset, the oscillator and a decoupling capacitor for power stability. The schematic is shown above.

ISP Programmer

For the bootloader I simply used Optiboot and flashed it to the AVR using my simple ISP board - you could also use a USB programmer or even an Arduino to do this as well.

To avoid any potential problems I simply flashed the GRBL HEX file using avrdude - GRBL is very configurable after flashing and I didn't need to change the default GPIO pins that it used so it seemed to be the best solution.

Unfortunately I ran into some unexpected problems during this process - the flashing process would halt partway though (anywhere between 2% and 50% of the image). After a bit of hair pulling I narrowed the problem down to the FTDI adapter I was using.

FTDI Adapter

I bought a few of these on eBay (they are fairly common) and it seems the voltage from the 5V output on the adapter (which I was using to power the logic circuit) only supports very low currents - writing to flash could cause the voltage to drop below the 2.7V brown out level and reset the CPU. Switching to an adapter from a different source solved the problem. Both adapters I used are based around the same FTDI chip so the problem would appear to be in the regulator on the board. I had assumed the 5V line would simply pass through the 5V from the USB connector directly - seems I was wrong.

If you have strange reset issues while using an FTDI adapter it might be worth checking the power coming out, especially if you've bought a cheap one from eBay - it could save you a lot of debugging time.

Signal Trace

Once I managed to get GRBL flashed everything worked like a charm. The pulses coming from the AVR are nice and sharp compared to what I was getting through the printer port with LinuxCNC. After double checking the power from the LM317 regulator I was ready to hook up the motor controller and configure GRBL.

The first step of the configuration is to determine the capabilities of your motor. The linear actuators I have didn't have a lot of information available about them but I managed to get the basics - they have a 22.5 degree step (16 steps per revolution) and a 3mm pitch on the thread screw. This works out at 5.333 steps per mm (or 0.1875mm per step if you want to look at it that way). The ITEAD motor controller supports microstepping so I started with the maximum of 1/8 giving me 128 steps per revolution (42.667 steps per mm or around 0.02mm per step).

GRBL Configuration

I am using Universal GcodeSender to control GRBL on the AVR and it provides a friendly interface to set the configuration. I simply put the appropriate values in for steps per mm and left the rest as defaults.

As you saw in the video at the start of the post the movement isn't very accurate at all. With smaller movements (2 or 3mm) it seems better but longer movements are very inaccurate. I've playing with some of the other settings such as maximum acceleration and velocity without any improvements.

There are a number of things that could be causing this. The motors have a very low step count (16 steps per revolution) and running with microstepping reduces step accuracy so one of the first things to do is to disable microstepping and see how it performs.

Other than that the power going to the motors could be an issue. The regulator supports up to 1A of current draw but the plug pack I am using is only rated for 750mA - I had assumed that this would be enough for these small motors but I could be wrong. Another potential issue is voltage drop as the motor steps which could cause the motor not to complete some steps.

Both of these can be tested by simply monitoring the power supply as I step through a movement sequence and both are easily resolved by redesigning the motor voltage regulator and using a beefier plug pack. I'll spend the next day or two testing these.

Single Channel Controller

The single channel stepper controller boards I ordered for the larger CNC have arrived as well. I'm happy enough with the logic board for the smaller CNC so I will build up a similar board for it. I know that the motors and power supply on the larger CNC are fine so I shouldn't have the same issues with it. I will need the larger device to build the chassis for the smaller one anyway so I have a good excuse for the diversion.

The project is going well so far and I'm learning a lot more about steppers, power supplies and CNC control software in the process - one of the goals I had when I started.

Stay tuned for more updates.