Wednesday, 29 June 2011

Setting the scale on the CNC machine

So far we've managed to create our own g-code from ExpressPCB layout files and got our CNC machine moving to our own home-built g-codes. Now the last piece of the puzzle is to get our machine to move according to the g-code created from the ExpressPCB layout. Sounds simple?

It should be - but so far the CNC machine seems to be making up it's own scale! Sometimes a command of G0 X5 Y0 (move 5 "units" in the x-axis) causes the gantry to travel a few cm, and other times, it tries to travel further that the maximum distance available!

What we're aiming for is a CNC that moves in inches.
To calibrate our machine, we want to be able to draw dots at 0.1" intervals.
The idea being that after replacing the pen with a 1mm drill bit, we can make our own PCBs with a 0.1" pitch that fit perfectly into the breadboard prototyping boards.

Here's how we got on....

The first thing was to get the CNC machine to draw something, using a known scale.
Unfortunately we didn't know anything about the machine - we discovered that the stepper motors we 1.8 deg/step with micro stepping (they were originally painted over!) but without details on the lead screws, we had no idea how many steps per mm were required. So the plan was to draw a shape - or series of shapes - using g-codes to draw one unit lengths (e.g. GO X1 Y0 would draw a horizontal line in the x-axis, one "something" in length).

From here we measured our "one unit" using some digital calipers and found it to be 0.821 inches in length. We decided to use inches as units (since we know that breadboard and vero board uses 0.1" pitch, it made sense to stick to inches). So with our current Mach3 set-up showing 2000 steps per mm and knowing this produced a line 0.821 inches long, changed the steps per mm to (2000/0.821) = 2436.05

With this new setting, we drew a grid of dots, each 0.1 "units" apart.
We also, for comparison, drew grids using 2400 steps and 2500 steps per mm.

After drawing the grid, we compared the output to some 0.1" pitch vero board.
The grid drawn at 2436 was ok for a small area, but much beyond 10 holes, and the drawn dots and the actual dots on the vero board started to drift. This means we need a value either slightly higher or slightly lower than 2436 (actually, we expected this to be the case, which is why we'd already drawn extra grids at 2400 and 2500).

At 2500 the dots in the grid seemed to drift out of alignment quite quickly, after four or five dots:

(The angle of the photo reduces the effect of the drift, but it is very noticable when viewed from directly above)

At 2400 we seem to have a perfect match. The grid of dots remained perfectly in line along the full length of the vero-board.

The angle of this photo does not really make the perfect alignment obvious, but each of the dots stays in the exact centre of each hole on the vero board.

So it looks like we've finally got the CNC set up and working properly!
The real test will be when we pre-drill some copper board BEFORE etching.
In theory, the press-n-peel transfer and the drilled board will line up perfectly.
But since it's gone midnight now, and BuildBrighton is closing it's doors for another few days, that'll have to wait until next time........