Introduction: How to Mill a Circuit Board With a Stepcraft Mill and EagleCAD
In this tutorial, we are going to be using EagleCAD, a PCB design tool, to generate toolpaths for fabricating circuit boards using a Stepcraft CNC Mill (or any other CNC mill that accepts standard G-code). Through this tutorial, I am going to assume a familiarity with EagleCAD and with basic CNC operation. Knowledge of G-Code is not expected. This process has been tested using a Stepcraft Mill, and the UCCNC controller software. I don’t see any reason why it shouldn’t work with other mills/controllers that accept normal G-code, but it has not been tested. Feel free to beta test.
If you are unfamiliar with EagleCAD and CNC stuff these links are a great primer.
- Sparkfun’s excellent EagleCAD tutorials #1, and #2.
- G-code, and other CNC stuff @ CNC Cookbook
The Eagle file I'm working off of here is attached to this page. Feel free to download it for reference. All of the traces and outlines are already drawn.
Attachments
Step 1: Install the Software
Before I get started, I want to acknowledge that there are some great tools out there for generating gcode for milling pcbs. FlatCam and pcbgcode are two that are used often. There are a couple major differences from what we are going to do.
Flatcam and pcbcode automatically generate milling paths to outline each trace, we are going to be drawing our own. This allows for more control over where the tool moves and makes more efficient and faster jobs and less wear on the tools. We're using a ULP (more on this later) inside of Eagle, so there is no separate software to install. This simplifies the workflow. And finally, we will have our Drills actually milled to size. This means that if you draw a 1/4inch hole, it will be milled to 1/4inch instead of requiring a 1/4inch drill bit to drill the hole.
We are going to be using a User Language Program inside of EagleCAD to generate our gcode. To install it, download it from this page and put a copy in /Eagle/ulp/. Restart Eagle and you should see it in the control panel. To run a ULP, simply type RUN in the command line followed by the name of the ulp, but we'll get to that later.
First lets draw some lines
Attachments
Step 2: Setup the EagleCAD Project
We're starting with a very simple Eagle file. It's a resistor, an LED, and a two pin header for power. The completed files are attached to this page. At this point I've already laid out the board. I am displaying Layers 1-20, 45, and 46. I find it easiest to draw toolpaths this way, without any extraneous information displayed.
We're going to start by drawing in the Mill toolpaths. As mentioned above, we can use 4 different endmills here, a 0.01inch, 0.015inch, 0.031inch, and 0.062inch. The width of the Wire we're drawing selects the tool. To select a tool, simply change the width of the Wire to match the diameter of the tool. I like to use the largest tool possible for a situation. In this example I will be using a 0.031 endmill because I don't need anything smaller. For some fine pitch surface mount parts you will need to go as small as 0.01 to fit between the leads. In the Command Line type: "layer 46" to select Layer 46 for drawing, then type: "wire" to select the Wire tool. Change the width of the Wire to 0.031 by typing into the dropdown menu then draw wires around each trace, isolating them from the others. You'll notice the wire over-laps the pads of the 2pin header slightly, this is not a problem. If you don't like it, you can use 0.062 width here instead.
Next is Drills. Each hole that goes all the way through the board is included in the Drills file, and they are all milled to size. This includes three different elements, Holes, Vias and Pads (only through-hole pads). Drills also uses a 0.031 endmill, so if you have a Drill with a diameter smaller than the endmill diameter, it isn't going to work (and will create an error in the gcode file). Using endmills other than 0.031 is currently not supported. I have two 0.125 holes on this board for mounting. With Drills, there is no need for additional prep work before running the ULP.
The Dimension layer is next. This is the layer that defines the outline of the board. The Dimension layer is Layer 20, and the outline is by default a Wire with a width of 0. It will generate a toolpath no matter what the width for a 0.031 endmill. These toolpaths define the path of the CENTER of the tool, which means with a tool diameter of 0.031, the board will be undersized by 0.031. If you don't need a precisely sized pcb, don't worry about it. If you do, you must offset the Dimension outline be 0.0155inch from the center of the board. I also like to change the width of the Wire to reflect the tool diameter.
Step 3: Generate Gcode
In the command line, type: “run stepcraft.ulp” and you should see a dialog pop up. You will need to measure the thickness of your PCB carefully and input it into the Dialog Box (in mm). You can also change the target layers for the Milling and Dimension toolpaths, and the milling depth. I use 1.6mm thick FR-2 PCB’s with 1oz copper cladding, and these setting work well for me. You can also select (or de-select) any of the three outputs if you don’t want to generate a Mill, Drill, or Dimension file.
Under the Advanced tab, you can change the speeds and feeds for each different tool, and select what you want to export with the Drills file. Please use caution when changing these values, tiny end mills are fragile and expensive.
Once the settings are set, press Generate, and it should produce 3 files in the folder of your .sch and .brd files. They will be labeled filename_mill_031.nc, _drill.nc, and _dimension.nc. These are your 0.031 mill file, your drill file, and your dimension file. Open them in a text editor and you’ll see g-code. Open them with a g-code visualizer, such as camotics, and you should see the toolpaths.
Step 4: Run the Jobs
From here you can run the files as any other job in UCCNC. I do the Mill, then Drill, then Dimension jobs. You want to do Dimension last, because it will cut out the board. I have a piece of upsidedown PCB as a waste-board which I have faced so that it is perfectly level and flat. I use double sided tape to hold down my work pieces.
Getting the Z axis zeroed correctly and accurately is REALLY important for doing PCB milling. If you're off by a few thousands of an inch it's easy to break these tiny endmills. Using a touch-off sensor would be very helpful here, see my Instructable on building one if you like.