David's CNC From The Boonies


Thanks to the helpful folks at the Homebrew_PCB Yahoo group, for their encouragement and advice, I've got the first build of a miniature CNC milling/drilling rig for small PCBs.

This demonstrates that anyone with basic software skills (and little or no mechanical skills, and few tools) can get a budget CNC setup together for less than US$200.


Project Objectives

My priorities for this CNC implementation have been:


Mechanical

Here's a small pic of the whole rig - click on it to open the fullsize pic in another window or tab:

small picture of CNC rigAs you can see, I'm a software guy who goofed off during high school metalwork classes.

I've got a 5.25-inch CD sitting at lower right, to give an idea of the machine's size.

The machine's footprint is slightly larger than a sheet of A3 paper.

At the top left, you'll see a shelf, atop which is a PIC16F877A-based controller module (pictured below), which talks to the host PC via 115k RS232 serial link, and drives the three stepper motors and drill motor relay.

As the keypad and ASCII LCD module imply, it's not just an overpowered stepper controller - the PIC controller and software support a user interface sufficient for calibrating the machine prior to each drilling run, and also operating manually and independently of the host for those occasional one-off holes.

At the lower left, underneath the wooden drilling platforms, you'll see one rectangular aluminium plate sitting atop
another larger plate.

The smaller top plate is moved along the larger bottom plate in the Y direction. The larger bottom plate is moved in the X (left-right) direction.

Both plates are driven by unipolar stepper motors, geared 1:1 driving steel threaded rod 6mm thick and approx 1mm pitch. Each plate slides over lengths of 1mm x 15mm x 15mm aluminium angle girder. Lubrication sufficient for the stepper motors' limited torque is achieved with plain CRC spray (can pictured on top).

As for the drill, this is even less elegant - note the aluminium levers, connected at one end to the drill stand, and at the other end by string leading up to the third stepper motor. It's not visible from the photo, but the Z axis (raising/lowering the drill) is implemented by a small hobby gearbox, rigged to 1:16, which winds the cord round a 3mm hardened steel axle. The 1:16 gearing, together with the thinness of the axle, is well within the torque of the stepper motor.

(I'd only need to replace the stepper motors with hamsters in treadmills, and it would definitely be fit for the Flintstones!)

The drill is a common cheap hand-held hobby drill with a 1.0mm bit. Mounting is a cheap drill stand (from Jaycar, now sadly discontinued), screwed into the roof.


The Controller

The electronics are just as primitive, almost. As soon as I get this rig's software fully working, and successfully milling (or at least drilling) boards, I'll use the rig to create a whole new integrated controller/communications board for itself.

At present, the whole thing is built on connected veroboards (pictured):
pic of cnc controller board
The small veroboard (some term it 'stripboard') at left has a MAX232 TTL to RS232 level convertor chip, for interfacing the main board to a PC serial port (notice cable/connector).

The main board has a PIC 16F877A microcontroller, with several of its I/O pins feeding into ULN2003 Darlington arrays for driving the three stepper motors and the drill motor relay.

(I could have easily got away with a 28-pin PIC package (eg 16F876A or even 16F873A), but I wanted to add a keypad and a, 20x2 LCD module.

The three 8-pin header connectors at bottom right connect to each of the three X, Y and Z stepper motors. At top centre, you can see a relay which is used to turn the drill on/off. The picture shows the keypad header (I added the LCD header, as well as the drill motor relay, after the picture was taken).

The LCD display and keypad have proved indispensable while testing. I still use them for pre-drill calibration, as well as for manually drilling one-off holes.

The whole rig is powered from a cheap 12V 1A mains plugpack. Just enough juice with barely a mA to spare.


The Software

(Just updating this section after a couple of weeks' hacking).

The software is almost ready for production use, and I've done a few successful drilling runs on a small but functional board (a MAX232-based RS232 interface module, the size of a postage stamp).

Overview

I'm doing my PCB layouts in Cadsoft Eagle, Light (free) Edition. Within Eagle, I run a script which exports all the drill coordinates to an importable Python script.

The host program (written in Python) reads these coordinates, performs a quick calibration sequence, then invokes commands on the PIC to move the carriage in X,Y directions, raise/lower the drill (the Z direction), and switch the drill on/off.

Host PC Side

The host-side software, for me, has been by far the more interesting bit. I've done it all in Python (by far the most comfortable and productive language for me).

To get accuracy (despite the mechanical crudeness) I've used a novel calibration procedure. At the start of a drilling run, the host program asks the user to position the bottom left hole under the drill, then the bottom right hole. This quick procedure gives the program two crucial pieces of information:
Given these two vectors, the host program gets all the crucial calibration information it needs, including:
As you've probably guessed, this allows the user to stick the board anywhere on the CNC carriage, rotated at any angle. This calibration procedure wipes out all the mechanical errors. Also, it eliminates the need for precision cutting of the board - which would require the artwork to reside at exact locations relative to the board edges.

(Don't even think about trying to file a software patent on this one, because people will find this page in the caches of Google, Wayback etc, cite it as prior art and will burn you in court!)

With this calibration done, the host program vectorises all the drill points, applies the scale and rotation factors, gererates accurate absolute CNC coordinates, then executes the drilling sequence for each hole.

Note that if my PCB layouts don't have useful reference holes near the bottom left and bottom right, I just add a couple of 'reference pads' in Eagle's layout editor.

PIC Side

In summary, the PIC-side software talks a simple serial-based protocol to the host PC, and supports several command primitives, including:
The PIC controller module also includes an LCD module (for displaying status and CNC coordinates) and a 12-button keypad (for manual operation of the machine, needed for the calibration sequence described above, and also useful for one-off manual hole drills).


Performance

Despite the primitive mechanical design, I've managed to get some reasonable performance, very likely to be adequate for PCB milling and drilling:

X-Y resolution
976dpi, 0.026mm, 0.001in
(note - reduced by width of drill bit tip)
Z (drill height) resolution
4572dpi, 0.0056mm, 0.00022in
max board length
200mm, 7.88in
max board width
130mm, 5.11in
drill range (Z)
10mm, 0.393in
accumulated errors, X Y and Z
0
travel time, full X range
23.87 seconds
travel time, full Y range 15.5 seconds
travel time, full Z range
5.68 seconds
max travel time, all axes
45 seconds
X-Y travel speed
5.45mm/s, 0.21 in/s
Z travel speed
1.7mm/s, 0.069 in/s
Effective hole drilling accuracy
Depends on how well user performs the calibration sequence - I'm getting to within 0.2mm, which is well within acceptable tolerances.


Parts and Costs

Total parts cost (not including wastage from occasional botch-ups) has come to approx NZ$237, roughly equal to US$191

Item
Price (NZD =~ 0.7 USD)
wood sheet, 15mm chipboard
$5.00 (offcut from hardware shop)
threaded rod, 6mm x 10mm pitch
$7.00
aluminium angle girder, 15mm x 15mm x 1mm x 660mm
$8.00
aluminium X-Y trays, 3mm thick
$32.00, including precision cutting/folding by aluminium supplier
steel brackets, for mounting rods/motors/gears
$5.00 (4 @ $1.25)
plastic drill stand
$25.00
hobby drill
$40.00 (easily removed and used as hand drill for other applications)
stepper motors
$66.00 (3 @ $22.00)
relay (for turning drill on/off)
$5.00
PIC 16F877A microcontroller
$15.00
LCD module
$24.00
12-key keypad
$10.00
ULN2003A Darlington arrays
$8.80 (2 @ $4.40)
MAX232A-compatible IC
$4.20
20MHz crystal
$4.50
78L05 low power voltage regulator
$1.80
veroboard
$4.50
assorted plugs, headers, passive components, hardware
$10.00
12V 1A DC mains plugpack
$8.50
TOTAL
NZ $284.30 =~ US $191.00


A First Result

As a test, I laid out, etched and drilled the simplest useful board I could think of: a MAX232-based RS232 to PIC adapter module. I've got the "print to photo paper, laminate onto PCB, peel and etch" routine down pat now, so this was a great chance to try out the CNC drilling.

Result is a handy spare RS232-PIC adapter module, smaller and more attractive than the ugly veroboard version I've been using.

Pictures below:

top view of first CNC-drilled PCBbottom view


Conclusion

As a mechanically-challenged software guy, with only the most basic set of tools, this CNC implementation was a time-consuming challenge. I made numerous mistakes, laughable blunders for the mechanically adept, but from these have learned many valuable lessons.

Perhaps the hardest part was the precision work - drilling of the plates and brackets and mounting the tracks. There's a bit of rotational play in the top Y plate which I'll have to correct in the software, which is a slight pain in the butt.

In retrospect, the biggest weakness is the X-Y linear bearings - aluminium on aluminium is less than ideal. If I revise the mechanical design, I'll change on of the surfaces to high-density plastic, and have a fine adjust on the aluminium side which will provide for smooth yet play-free motion in both directions.

Other areas I want to look at include:
If I'm needing to do much more mechanical work in the future, I'll likely put out feelers to team up with a skilled person in my area, who can learn from by software/PIC skills while I learn from his/her mechanical skills.

Meanwhile, with a few design refinements, there's a possible opportunity to market and sell this in a kit and/or fully-assembled form, with the PIC pre-programmed, and a host CD containing the host-side software as python source (as well as standalone EXEs for those still stuck in Windows).


About the Author

I'm David McNab, an all-rounder spread across several diverse disciplines.

Some months ago, I invented a PIC-based medical appliance, for which there's a worldwide niche market large enough to prove worthwhile. However, the tool-up costs charged by contractors for manufacturing this appliance are beyond my immediate budget, so I'll have to hand-build and sell a small run of units to raise the funds for larger-scale production.

To this end, I've created this CNC rig to speed up the PCB creation. With some software work, it'll also be capable of milling the plastic enclosure, and thus eliminate the expense of short-run laser-cutting.

If any of this has interested you, or you simply want to get in touch to share ideas/inspirations, please feel welcome to get in touch. My email is david at freenet dot org dot nz



Copyright © 2005 David McNab, all rights reserved.
Permission is hereby granted to reproduce this page verbatim (including this copyright notice) in print or electronic form,
as long as the URL http://www.freenet.org.nz/cnc is included as a link to this original page, and the author is notified by email.

Page created 27 June 2005 by David McNab, of Auckland, New Zealand.