Sunday, 2 September 2012

Repeatability - the holy grail of CNC

After getting our CNC running, we've spent a bit of time trying to work out the auto-calibration on our machine. The idea is that you select two opposite corners on the board, and the software works out the scaling and rotation (given that you may have plonked the PCB down at any old angle).

The rotation part of this works really well, but scaling has been a bit of a problem.
It seems that unless you are absolutely accurate with placing the drill head in the dead centre of each dot at the start, the scaling quickly goes to pot! Any tiny slight mis-alignment during the set-up stage is magnified and repeated many times over when the CNC tries to draw/drill the board.

Also, we struggled quite a bit with consistency.
Whether or not the scaling was correct, it should at least have been consistent - but this is something we had trouble with for a while. Until Robot Steve pointed out that the backlash in our stepper motors was massive! Because the motors themselves are geared down, there's quite a bit of play in the motor assembly. Although 2mm-3mm doesn't sound like a great distance, when you're working to keep a cumulative error over thousands of steps to less than 1mm, it's a massive amount of play.

The answer we came up with is as quick and dirty as it is cheap. Simply put, software compensation for backlash (or play or slop or whatever you call it) means keeping track of which direction each motor is spinning and when it changes direction, adding in a few extra steps to take up the slack first.

How we determine the number of steps required could involve some serious calculations about gear pitch, tooth count, complex trigonometry and more. So we used the SteveCode approach and just tried different numbers until it looked about right.


To reduce any error introduced by badly calibrating the machine, we also added in a fixed constant value for "scaling" - so for testing, where we're not concerned about rotation, we can have the machine plot a series of points from an NC drill file, without having to go through the calibration process every time.

All this seemed to work pretty well.
The last addition to the software is the ability to parse DXF files for hole placement - allowing us to draw a PCB in ExpressPCB and export to dxf, then import the dxf directly into our software as if they were NC drill files.


In ExpressPCB we drew a grid of holes, starting at 10,10, each 5mm apart then exported the layout as a dxf mecahnical drawing


The final dxf file is ready to load into our CNC software which it converts into an NC drill file during import. The NC drill file is then loaded just like any other and drawn on screen


This time we don't bother with calibration (we've already set the backlash and scaling values on the settings screen earlier) and set the machine drawing/drilling:



The key to getting a working CNC is repeatability. And in this case, we've got a brilliant, working, repeatable output! And here's our (second run) drawing being measured up for accuracy:


The input file (ExpressPCB exported dxf) had a grid of 4x4 holes, placed 5mm apart.
The centre points of each hole drawn with our felt-tipped pen are consistently within about 0.3mm which means we've met just about all of the criteria for the BuildBrighton CNC drilling machine challenge:

Less than £50 total build cost? Check (will publish full parts list shortly)
When put away, the total footprint does not exceed an A4 sheet (297mm x 210mm)
Ability to drill up to 80mm x 100m half-eurocard sized boards? Tick
All components are easily accessible from a variety of sources, such as eBay or Amazon marketplace.

The only part we've not actually proved yet is the drilling a 1mm hole inside a 2mm pad.
This is the same as drilling to within 1mm accuracy, and we've proved we can do that, with our cardboard printed output. So all that's left to do is make a collet for the brushless motor and connect a 1mm drill bit - then actually drill some boards!