CNC USB Dual Layer PCB Milling




Introduction: CNC USB Dual Layer PCB Milling

About: Multiscale fabricator :)

I've recently built a CNC machine out of various pieces of high-quality salvage. With the money I saved in the construction of the system I bought a controller and software, the excellent MK2 CNC USB controller from Planet CNC. This forms the interface between the computer and stepper motor drivers and is controlled by a sophisticated program capable of importing Gerber files, DXF files and other useful formats. I'm using Pololu stepstick boards to drive my NEMA23 stepper motors but at the moment they are just sitting on a solderless breadboard; not the neatest of solutions. I decided that the first task I would use my CNC machine for would be making a PCB to tidy things up a bit. This is the story of how I used my system to make a completely different PCB. This instructable assumes that you have a CNC miller controlled by the Planet CNC CNC USB controller, properly aligned and calibrated.

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: Camera Setup

I'm using a cheap (£12) USB endoscope camera bought via eBay from China. It has a 10mm diameter metal body, very easy to mount. However the CCD on this cheap camera was 7 degrees off axis, so have plenty of adjustment room in your mounting bracket. The camera is mounted next to the spindle. To set up the camera:
Drill a small hole into the spoil board. Then:

Machine->Camera->Set offset->Mark /4801

Now start the camera:

Machine->Camera->Show Camera ... /480

Centre the camera crosshairs over the hole, at lowest possible Z height.

Machine->Camera->Set offset->Read 1 /4802

Increase Z as far as possible while still being able to see the hole, and re-centre the crosshairs.

Machine->Camera->Set offset->Read 2 /4803

This sets up the camera so that you can accurately place your spindle over a job or read off co-ordinates for transformation of tool paths (used later). It uses two points to compensate for possible mis-alignment of the camera, which would shift its apparent position when Z height is altered.

Step 2: PCB Design and Gerber Import

I use DesignSpark PCB to create my circuit board designs. It's free, and there is no limit to the size of board you can create (well, I think it goes up to 1mx1m... should be enough for most purposes). I've altered the design rules to make them more suitable for home milling, using this instructable for EagleCAD as a guide. I'm using through hole PCBs, which means that I can use the drilled holes to work out co-ordinates for transformation and alignment of the bottom layer. If you are using surface mount, you might want to add a few drilled pads for alignment. Don't forget when positioning these holes that your camera will not travel as far as your drill due to its offset. Export your artwork to Gerber once you've finished.

Clamp PCB onto spoil board, ensuring that the camera can reach the holes which will be used for the transform matrix. I use short wood screws and cup washers. You can attach a crocodile clip to one of these later when measuring your tool offset. Notice on the left side I've marked the limit of travel of my camera... my machine in it's current incarnation only moves 100mm in each axis, which means with my camera -35mm away in Y it can only move to +65mm in the Y axis.

Put the hole drill into the spindle, leaving the spindle at a safe height.
Move the drill to the XY position where the milling will start (bottom left of PCB).

Set the XY offset to this position:

Machine->Offset->Current XY /45251

Import the top copper Gerber file:

File->Import Gerber /115

Step 3: Gerber Import Window (units Are Mm)

I use a drill depth of 0.01mm (10um) with my 60 degree PCB milling bit, and a drill depth (for pad holes) of 3mm.

Step 4: Positioning the Gerber File

Move the origin of the file to the drill position:

Program->Shift->Extents to zero XY /336
WARNING! Do not use “Extents to zero”. This will alter Z height and therefore drilling/cutting depth. Check that the board Z matches the origin by viewing from the side:

View->Front View F2 /223

Return to top view:

View->Top View F1 /221

Measure the tool offset: wires should be attached to MK2 INPUT connector, one attached to GND, the other to INPUT 5 as in the picture from the USB CNC manual.

Step 5: Tool Offset Measurement

Attach the GND wire to your PCB. I use a crocodile clip attached to the screw which is clamping the PCB to the spoilboard. With the spindle at the highest Z, check that the electrical connection has been made by running a dummy test:

Machine->Tools->Measure Tool Offset Here /463

As the spindle lowers, touch the other wire to the PCB.The spindle should instantaneously stop and retract. If not, be ready to use the E-stop. If the tool sensor works correctly, clip the other wire to the drilling bit (it may not be electrically connected to the spindle body). If your bit is connected to your drill body, there may be electrical continuity between your spindle and your circuit board already if it is clamped to your machine bed. Use a non-conductive spoil board and insulate the clamps from the PCB in this case. Make the electrical connection to the PCB by holding the ground wire against it or something. Repeat the tool offset measurement:

Machine->Tools->Measure Tool Offset Here /463

NOTE: Andrej of PlanetCNC tells me that this is more correctly done by measuring Z offset:

Machine->Offset->Measure Offset Z /459

And he should know, having designed the board and written the software.
I'll try this method next time I mill a circuit board.

Remove the wire from the drill bit! You are now ready to begin drilling holes. Start your spindle and press “PLAY”.

Step 6: Top Copper Isolation

Once the hole drilling has finished the program will pause.
However, as the spindle needs to be moved manually you must stop the program here, using the STOP button next to PLAY. Stop the spindle and move to a convenient position for changing the drilling bit to the PCB etching bit.
Change the bit to one such as pictured above, then move the tool back to zero XY. Re-attach the tool sensor wire to the bit. Make sure that the copper that you are going to use to measure the tool offset is still electrically connected to the GND wire (i.e. hasn’t been isolated during milling). Measure the tool offset:

Machine->Tools->Measure Tool Offset Here /463

Detach the wire from the bit. You are now ready to begin isolation of your tracks. In the G-code editor on the right of the CNC interface find the line which says:


You can do this from:

Program->Lines->Select Next Pause /313

This is the HALT code. Right click the line after and

Start from Selected Line.

Resume program from selected line; isolation will start. I like to spray WD-40 onto my board during this process, so I also like to put a lens cap onto my camera; the silicone cap from an electronic cigarette fits perfectly :). WD-40 helps reduce the amount of dust sprayed around during milling, especially useful if you’re using a fibre re-enforced board. Rumour is that it also improves the quality of your cut.
Congratulations! You should now have a PCB with the top copper layer cut and holes drilled in appropriate places. Now for the tricky bit...

Step 7: Selection of Co-ordinates for Transformation

Turn the board over and screw it to your spoil board. Make sure that the edges of your design fall within the travel of your machine. Now you need to choose some holes from which the transform is calculated by measuring their positions with your camera. Choose holes which cover as much range in X and Y as possible, not forgetting that as your camera is offset from the spindle the camera may be limited in its movement if your circuit design takes up the whole of your machine working area. My camera is offset from the spindle by -35mm in the Y axis, which means I can’t capture holes at the top edge of my circuit design (>65mm Y) due to the limited travel of my machine (100mm in Y). It’s OK though, just choose other holes as close to the limits as possible. Three holes are the minimum for the transformation, but you can capture more if you like.

Load the bottom copper Gerber file. Although holes have already been drilled into the PCB during the top copper milling, I like to still have the drill checkbox checked. This means that the drill path appears in your machine view window, allowing you to accurately choose hole centres. Don't do this if you're using surface mount devices though...

In the screenshot above, the red line at the centre of the screen shows the drill plunging to make a hole. If you select that line and double right click with the mouse, the section of the G-code (right panel) that describes the line is highlighted (line 195). You can see the co-ordinates of the line above (line 192). These are the co-ordinates of the centre of the drill hole you will enter into the points section of the transform matrix later. With your circuit board facing bottom copper up, match drilled holes to holes in the bottom copper file.

Step 8: Transformation Continued...

The hole marked 1 in the above picture is the nearest hole to 0,0 on my machine. As the board has been flipped, this has the greatest X and Y values. Mark the co-ordinates from the G-code onto the board to avoid any confusion. Clear any offset from the machine:

Machine->Offset->Zero /451

Now move the camera to the first point and centre the crosshairs in the hole. Capture the point:

Machine->Transformation->Capture & Measure Points->Capture->Capture point (0)/48101

This captures the first point. Move the camera to the second point and repeat the process. Notice that the number of points captured so far appears on the right of the menu (zero for the first point, above). When you have captured all of the points, you need to calculate the transformation matrix:

Machine->Transformation->Calculate Transformation Matrix From points... /483

Step 9: Transformation and Bottom Copper Milling

The co-ordinates of the captured points appear in the To (X Y) columns on the right of the points table above. Select a line and enter the points you read off from the Gerber file in the Points From (X Y) text boxes. Press the Update (Updat) button; the From points appear in the table. Repeat for all of the captured points. Now you are ready to calculate the transformation matrix. Pressing the Calculate button on the dialogue box calculates and automatically enables (applies) the transformation matrix.

WARNING!!! The transformation matrix applies to ALL machine co-ordinates... jog directions are changed, if the board is flipped then jogging –X will move +X! If rotation is applied (and it usually is), moving in X will also involve travel in Y and vice-versa. LIMIT SWITCHES WILL NOT WORK!!! Do not home the machine with transform enabled!!!

Re-measure the tool offset and then check if the transformation has been accurate. Select a drill hole line as previously in the machine view, double right click to find the G-code, right click that line: Go To – Selected Line XY The tool should move directly above the hole. If so, you are ready to start isolating the bottom copper. If not, clear the captured points:

Machine->Transformation->Capture & Measure Points->Clear->Clear Points (3)/48201

and try repeating the points capture and transform procedure. Don’t forget that you have G-code which includes hole drilling. Find the line which says:


again. Right click the line after and

Start from Selected Line

Bottom copper isolation should start. With a bit of luck you should have a two layer PCB when it has finished.
Depending on your cut quality you might have some ragged edges which can be polished up with a bit of fine grit silicon carbide paper. Also, I found lots of little bits of copper swarf between my tracks, which could possibly cause short circuits. Once it was finished I put the circuit board into an ultrasonic bath with warm soapy water for ten minutes to clean these out.

I hope this helps, happy milling!


Be the First to Share


    • Tiny Speed Challenge

      Tiny Speed Challenge
    • Woodworking Contest

      Woodworking Contest
    • Trash to Treasure Contest

      Trash to Treasure Contest


    Edwin c jossy
    Edwin c jossy

    2 years ago

    I had some issues with scaling when i first started. I found that the solution to my problem was the units used in Eagle(pcb software) did not match the units I used in mach3(cnc software). Both must be in mm or inches, else it does not scale properly.