CNC 3040

I recently purchased a CNC 3040 mill.

CNC 3040

In my regular posts I have been including small details of my progress but would like to include some finer details here.

The CNC3040 is a low cost mill that I purchased from the UK.

A lot of these mills are coming this way from China at the moment and they represent excellent value for money if your prepared to work on them a little.

The motors that came with the mill are not Nema steppers but cheaper copies. However they seem to be doing the job fine.

Thus far I have run an hour long cut with no issues.

However I would not class these cnc mills as turn key solutions.

My mill arrived well packaged and in excellent time but no software came with it.

Also the large majority of mills are parallel port driven.

For the large majority of people this is no big issue as they will have an old PC laying about with a parallel port. I have had plenty of experience with parallel devices. Interfacing with these controllers is a snap *if* you have a pc or laptop with a parallel port.

Some laptops have problems driving cnc controllers due to power management issues within the hardware itself.

However do bear the need for a parallel port in mind as I didn’t think it would be half as much of a problem as it turned out to be …

Some points to note here :

– Usb->Parallel cables really don’t cut it. I have yet to see one that works correctly.

– You will be basically devoting a whole entire machine to loading gcode and sending it to the parallel port. This is all software like Mach3 and TurboCNC does.

– None of this is plug and play. From my perspective Mach3 is a big clunky mess. TurboCNC is okay. But once again it all seems an enormous over head for merely generating gcode. To be fair generating gcode isn’t easy. But it has to be easier than it is.

After a bit of messing with this and trying to get an Apple Mac Book Pro to drive the CNC I have gone down a different path using an Ardunio.

I had a spare Ardunio micro controller. Now given that an old pc was not available and that the usb->parallel cable did not work ( and you will some people saying they do but it seems these are a more expensive cable ) it seemed worth a try. For this to be successful you need a few things.

– Ability to solder up a simple pin header plug. I made mine out of dress pins and some old project board I had from Jaycar.


You can find plenty of documentation on steppers and stepper drivers. Most drivers I have sen have two wires per motor.

One wire is direction. The other is step. Now comes a little detail which is that you need to know what pins on the micro controller are step and direction ( if you just downloaded a pre-built version of grbl ) and you need to know what pins on your cnc controller are the step and direction pins for each motor.

If I was doing this again I would have just have downloaded the WinAVR and compiled the GRBL myself the first time and adjusted the pin settings in the config.h file to match my soldered plug and controller. Instead I did it the other way around which resulted in 2-3 different soldering and resoldering sessions before I got it right.

Then when your done put it all in a little case to hold the controller and the plug. I used an old cd game cover.

Next up is the grbl for Ardunio. Firstly let me say the standard build is broken. You will spend forever trying to get it to do arcs.

The developer hasn’t touched it in awhile. Your better bet is to get

GRBL 0.7a

I have been using this build for a few weeks now with no problems. Handles arcs fine. In fact it is so stable I am loathe to move my setup to a full size pc.

In case your wondering how this goes you have the grbl on to the micro controller ( plenty of discussions exist on how to compile it and how to do this already ) it will sit as a server device constantly checking its rs232 port for serial input.

To feed it input you can either write a script in your preferred controller ( Mach3 / TurboCNC ) or use a stand alone python script to stream your gcode. I did the latter.

Here is my python code :

import serial
import time
from msvcrt import kbhit

gcode = []
f = open('','r');
for line in f:

# Check we don't have some messed up out of bounds instruction

for line in gcode:

a = line;
a = a.replace("X",",X");
b = a.replace("Y",",Y");
c = b.replace("Z",",Z");
d = c.replace("J",",J");
e = d.replace("I",",I");

parsed = e.split(",");

for command in parsed :
if len(command) > 0 :

if command[0]=="X" :
x = eval(command[1:])
if ( x > 110.0 or x < -110.0 ) : print "Step " + command + " is out of bounds" exit(1); if command[0]=="Y" : y = eval(command[1:]) if ( y > 145.0 or y < -145.0 ) : print "Step " + command + " is out of bounds" exit(1); # Begin feeding gcode to grbl s = serial.Serial("COM12",19200) s.write("r") time.sleep(2) # Wait for grbl to initialize s.flushInput() # Flush startup text in serial input endthis = 0 i = 0 for line in gcode: if endthis == 1 : raw_input(" Press to exit and disable grbl.")

if kbhit() :
line = "G0X0Y0"
endthis = 1

if line == "RESTING" :
print "Resting ... "

else :

print 'Sending: ' + str(i) + ' ' + line;
s.write(line + 'r')
grbl_out = s.readline()
print ' : ' + grbl_out.strip()

raw_input(" Press to exit and disable grbl.")


My code has a few useful additions. One is bounds checking. Most home cnc machines do not come with limit or home switches by default. My code checks each gcode entry to make sure it isn’t going to make the cnc machine slide off the table. It also enables you to break out of the cnc session by hitting and key.

Leave a Reply