PCB_GCODE GCode Generation Utility

Copyright© 2004-2005 by John Johnson Software, LLC All Rights Reserved

Please contact johnatl@mac.com.

OSI Certified Open Source Software. This work is now distributed under the Artistic License from the Open Source Initiative. I would like to see and possibly include any changes you make to the software. Thanks!

This is release 3.3.2 revision 329

This program generates g-code for milling PC boards. It creates gcode for milling trace outlines for the top and bottom. This can be done with a progressive offset so that slivers between most traces are removed. It also generates drill files as seen from the top and bottom, with pauses for changing bits; fill data (not really need with the progressive offset feature); and milling layer data as seen from the top or bottom of the board. This would be used to score or perforate the board for breaking it out, as well as outlines for mechanical parts, connectors, etc.

More Information

There is a Yahoo! group dedicated to the users of pcb-gcode. There you will find other users, a mailing list for discussing pcb-gcode, photos of users machines and boards, databases of suppliers, bugs, faqs and suggestions, and more. Also, please add yourself to the pcb-gcode Frappr map. To date I haven’t received any spam from them.

Installation

Unzip the pcb-gcode archive and move the files to the ulp folder inside the Eagle folder. This will probably be c:\program files\eagle-4.11 for Windows people, /Applications/EAGLE-X11 for Mac people. Sorry, I don’t have a Linux box running Eagle at the moment.

Using PCB-GCODE

From Eagle’s Board Editor (that’s where you lay out your board), in the command line (just below the tool bar at the top) type:

run pcb-gcode

The first time you run pcb-gcode, you will be given the option of running the setup program. I recommend you do this. This will let you select the flavor of gcode to suit the controller for your machine, such as TurboCNC, EMC, Mach, etc. You may also select Metric or Imperial units, the size of tools you use, and more. If you want to run setup again later, you may run this command:

run pcb-gcode --setup

or

run pcb-gcode-setup

To generate gcode files, from the board editor run this command:

run pcb-gcode [filename]
Where:
Option Function
filename Is an optional path and root filename for the generated files.

If you do not specify a filename, the name of the board file will be used. For example, if your board is named enabtmr.brd, the generated files will use enabtmr as the root filename. The top layer would be enabtmrtop.nc, etc.

The files are named as follows (assuming the root filename is ‘file’):
Name Function
filetop.nc Outline of traces for the top layer.
filebot.nc Outline of traces for the bottom layer. Note that the coordinates in this file are negative. That means when milling the bottom, you origin at the right side of the board.
filetf.nc Fill for the top layer. Mills away excess copper. (Generally not needed.)
filebf.nc Fill for the bottom layer. Mills away excess copper. (Generally not needed.)
filetd.nc Drill file for the top layer. Asks for drill bits in succession, smallest to largest. A table of all sizes needed is at the beginning of the file.
filetd.nc Drill file for the bottom layer.
filemb.nc Mill data as seen from the bottom of the board.
filemt.nc Mill data as seen from the top of the board.

Options

As noted earlier, the values in the options files can now be set using the setup program:

run pcb-gcode --setup

Generation Options

Options controlling what is in the gcode files, and how the gcode files are generated.

Be sure and set Units to the correct unit of measure.

Top Side

Generate Top Outlines Track outline data for the top layer. xxxtop.nc
Generate Top Drill Drill data for the top layer. xxxtd.nc
Generate Top Fill Fill data for the top layer. xxxtf.nc Not needed if using the progressive isolation (which most people use).

Bottom Side

Generate Bottom Outlines Track outline data for the bottom layer. xxxbot.nc
Generate Bottom Drill Drill data for the bottom layer. xxxbd.nc
Generate Bottom Fill Fill data for the bottom layer. xxxbf.nc Not needed if using the progressive isolation (which most people use).

Board

Generate Milling Milling layer data for the board. xxxmt.nc Milling data as seen from the top. xxxmb.nc Milling data as seen from the bottom.

Isolation

Default 0.0001 A practical minimum distance to outline the tracks for the first pass of the cutting tool.
Maximum 0.080 The maximum isolation value.
Step 0.007 How much larger the isolation grows with each pass.

Using the options above, 12 passes will be made on each side of the board. The first pass uses an isolation value of 0.0001, the next 0.0071, and so forth until 0.0771 is reached. 0.0771 is the last pass, since the next pass would be greater than 0.080.

This system works quite well, and eliminates the need for using the fill files (i.e. filetf.nc and filebf.nc), which can be very slow, with lots of motion in the Z axis.

Misc

Do tool change with zero step This is used to set the length of drill bits and cutters. When this option is turned on, a tool change will use the following steps. The X, Y, and Z will move to the Tool Change Position set in the Machine tab. The spindle will turn off. The program will pause. The operator changes the tool, placing the new tool very far into the chuck. The operator tells the controller to Run. The Z axis moves to the 0.0 position. The program pauses. The operator loosens the chuck, and allows the tool to drop until the tip touches the board or other reference. The operator tightens the chuck and tells the controller to Run. The tool is set to the correct length, and milling or drilling will proceed.
Flip board in Y instead of X Some user’s machines are better suited to flipping the board in Y when changing sides, rather than X. If this is your case as well, turn this option on.

Machine

Options for your particular machine.

Z Axis

Z High A Z position that will clear all fixtures, clamps, etc.
Z Up The Z axis is moved to this position when moving between tracks or holes. Usually small, 0.050” or less.
Z Down Where the Z axis moves to when milling track outlines. Usually quite small, -0.005” for example.
Drill Depth How far down to move Z when drilling holes. Usually a small amount more than the thickness of the board, -0.100”, for example.
Drill Dwell How long, in seconds, to pause at the bottom of each hole drilled. 0.100 is a good place to start, and won’t matter much unless your Z axis needs time to settle between moves.
Milling Depth How deep to mill Mill layer data. Usually a small amount more than the thickness of the board. -0.070” for a 1/16” thick board, for example.

Tool Change

Position X
Position Y
Position Z
Where to move the tool so you will be able to change the tool.

Spindle

Spin up time How long the controller should wait for the spindle to come up to speed after a spindle on command.
Etching Tool Size Size of the endmill or cutter used for milling track outlines.

Feed Rates

X Y How fast the X and Y move when milling tracks.
Z How fast the Z moves down when drilling or milling tracks.

GCode Style

Select your controller from the list, or the one most like yours, then click the Accept button. This set up your gcode-defaults.h file. If your controller is not listed and you customize gcode-defaults.h, please email it to me for possible inclusion in the next release. New controller files may also be available on the Yahoo! pcb-gcode group.

Misc

NC File Comment from Board Adds a comment to the .nc file that tells which .brd file was used to generate it.
NC File Comment Date Adds the date the .nc file was generated.
NC File Comment Machine Settings Add settings from pcb-machine.h as comments to the .nc file.
NC File Comment Pcb Defaults Settings Add settings from pcb-defaults.h as comments to the .nc file.
Debug Flag Turns on various debugging information in the .nc files.

Customizing the GCode

The gcode-defaults.h file contains definitions for generating g-code. You can make changes if you need to, but be sure and leave in all the format specifiers, such as %f, %d, etc. These are used as a sort of fill in the blank by the program. Although the definitions may seem complex at first, by breaking them down into pieces, hopefully you will be able to make the changes you need. If you need help, post a message on the Yahoo! pcb-gcode group.

When customizing, I recommend you start with one of the standard .pp files that is close to what you need. For example, mach.pp. Use the setup program to install this as your GCode Style. Now make any chances you need in gcode-defaults.h. When you have everything working the way you want, copy gcode-defaults.h to your own .pp file, such as gizmo.pp. If you are willing, upload your gizmo.pp file to the Yahoo! pcb-gcode group, so that others with a Gizmo can use the .pp file. Thanks!

How To

Andrew Payne has an overview of using pcb-gcode.

Design your schematic in Eagle.

Create your board in Eagle. I usually change the Width in the Net Classes (under the Edit menu) to 0.030” if I’m trying to squeeze a trace between IC legs, or 0.040” to 0.050” otherwise. When you Autoroute, the router will use the width that you specified. Keep in mind that the traces need to be a certain distance apart, or the outline routines will consider them one and the same, and glob them together. Set the Clearances in DRC to the size of your cutter to check for this. Change the Restring parameters in DRC to make the pads and vias larger, if you find that they are to small after milling the traces. You can also try the pcb-gcode.dru included in this archive. In the DRC window, click the Load button to load it.

In the command line area (between the board and the toolbar with buttons) run pcb-gcode. Files will be generated to create your board and stored in the same place as the board file.

run pcb-gcode

Mill your board using TurboCNC, EMC, Mach, etc. I mill mine in this order: filetop.nc, filetd.nc, flip the board (in X, though you can change this), origin at the same point (which is on the right side now), and run filebot.nc.

To stop the auto-router from doing annoying things like putting vias under ICs and components, create a rectangle in layer vRestrict under the part. I like to put a rectangle of tRestrict around each pad, or set of pads, for ICs and components. This keeps you from having to solder on the top of the board. You can make these changes permanent by editing the libraries.

I highly recommend using a simulator to view your g-code before committing it to copper. CNC Simulator is free. See also VEGA DATA-View. If you know of a good NC viewer for the Mac or X11 on the Mac, please drop me a line.

Fine Tuning

My goal, and probably yours, is to mill tracks as wide as possible, without shorting to other tracks, pads, or vias, and with enough spacing between so that you can solder the pads without solder bridges. This procedure outlines how I fine tuned my setup to accomplish that.

Included in this release are a board and schematic (04151_lcdi2c.*), pictures are available at the Yahoo! pcb-gcode group or my .Mac site .

Track Width

First, you should establish the safe minimum track width your router can produce. Experimentation is your best bet here. You’ll also want to determine what size cutter to use. I’ve heard the bits from Think & Tinker are quite good. Until I order the Think & Tinker bits, I’m using a 60 degree half round carbide bit. Most cutters are tapered, so depth control is essential. If the PCB is higher, the cut path will be wider, hence the tracks will be narrower, if there is anything left. On my router, I use a piece of wood with a cavity milled out that is the side of my PCB stock. I secure the PCB using fiberglass double-sided carpet tape. The adhesive is very agressive, and works well.

After experimentation, I determined that I could mill 16mil tracks. This allows me to squeeze a track between IC pads, which was one of my original goals. I layed out the board using a 16mil track width (See 04151_lcdi2c.brd). To figure out the right tool size, I began at 0.001, and worked my way up. Look at the picture 0_005.jpg. In the center, you can see three IC pads. There is a track between the bottom two pads. You can see (hopefully!) that the track and the IC pads have a small amount of space between. To maximize the track and pad size, we want to minimize this space. The next picture is 0_007.jpg. This is when I tried 0.007 as the tool size. You can see that the track and pads are wider, and that the lines of each are still seperate and distinct. Now look at 0_009.jpg. See anything wrong? The third IC pad down, and on the left had merged into the track next to it. Not a good thing. So we need to back off on the tool size. As I was writing this, I noticed that at 0.007, the IC looks fine, but some of the tracks and pads at the 14 pin connector had merged. So, 0.005 is the ideal tool size.

At this point, you probably want to mill a board, and see how everything looks. If it’s okay, you can set up the DRC to make sure all your boards have the necessary clearance for milling.

Set up Eagle’s DRC

We can use Eagle’s DRC (Design Rule Check) tool to help design boards that will mill correctly. To do this, we use a similar technique to the one above, start with approximate values, and adjust them until they are right. I decided to start with 0.007. See the picture setting_clr_0_007.jpg. When I clicked the Ok button, I got the list of violations show in clr0_007.jpg. At this point, I’m only worried about the Clearance errors. You can see there are only three, and they are justified, as shown by the zoomed in portion of the board. I increased the clearance to 0.008 to see what would happen. The result is shown in clr0_008.jpg. A lot of errors. Since I milled this board and know that it is okay as is, I want to use 0.007 as the clearance value. If a track is closer than that to a pad, I want an error, because it probably won’t mill correctly. Now I go into DRC and set all the clearances to the value that I determined was right, in this case 7mils (0.007). See setting_other_clr_0_007.jpg. You may want more pad-to-pad and pad-to-via clearance. Again, experiment to find out.

Final Results

The final product can be seen in the pcb.jpg picture. No, this isn’t the 04151 board that I provided the board and schematic for. It’s already loaded and in service. We can see a few things from this board though. Look at the circled area labeld A. There are small slivers there that could easily peel up and short the adjacent tracks. This can be corrected by making DEFAULT_ISOLATE smaller, in case a path never was made through this area since they are so small. You might try making ISO_STEP smaller, so that more passes will be made through the area. You can also try making ISO_MAX larger, in case the over all area milled away needs to be larger. Although not the case for the A area, you can see in the D area that more passes would have cleaned out the rest of the slivers from around the “A” character. Beginning in area B is a larger sliver. This one should be okay, since it is wider, and not at risk of peeling so easily. Now take a look at area C. Those are thermals around the IC pads, and they look great. Thermals are probably the smallest area to be milled away, except for the inside spaces of letters like A B, etc. Keep an eye on the thermals when changing parameters.

Have fun!
Regards,
  JJ