The PCB-GCODE User's Manual: John T. Johnson May 18, 2014
The PCB-GCODE User's Manual: John T. Johnson May 18, 2014
Version 3.6.2.4
Copyright © 2014
John T. Johnson
pcbgcode@pcbgcode.org
May 18, 2014
ii
Some parts of the manual are for intermediate or advanced users. This icon alerts the
!
reader to this fact.
iii
Supporters
There is a great community that has built up around pcb-gcode where users freely offer
advice and help solve problems for other users. Despite the fact that pcb-gcode has always
been free and always will be, a few outstanding individuals have donated time or money
(which goes towards paying for web hosting for pcbgcode.org). Your generosity warms
my heart, and I thank you all!
• Art Eckstein is the tireless moderator of the Yahoo! group, and the phorum.
• Translations
– Anonymous (2007), Greg Brill, Paul Kiedrowski, Steven Manzer, Barry Ward,
Ward Elder, Art Eckstein, World of ElectroMechanica,
Austin Valley Software Corporation, webstudio.co.uk, Juan Posada,
Richard McCarthy, Keeley Electronics, Ron Watson, Andrew Mackenzie,
Łukasz Kuleszewicz, Alexandru Pirvulescu
• Code Contributions
– Martin L. Marriott - G-code optimizer
– Peter Zotov - Stencil generation for cream layers
• Beta Testers
– Art Eckstein, Brett Pound, Danny Miller, Fabrice Engel, Juan Posada,
Martin Marriott, Maurício Dias, Svend Poulsen, Zulfqar Ali.
iv
Contents
1 Introduction 1
1.1 Purpose . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 How it Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2
1.3.2 Isolation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.3 Drilling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 Setup 5
2.1 EAGLE compatibility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2 Installation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5
2.2.1 Downloading and unarchiving . . . . . . . . . . . . . . . . . . . . . . 5
2.2.2 Configuring EAGLE . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.3 Selecting g-code style . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2.4 Previewer Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Machine Setup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.4 Generation Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
2.5 GCode Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
2.6 Support . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
3 Using pcb-gcode 17
3.1 Running pcb-gcode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
3.2 Using EAGLE’s DRC . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.3 Previewer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
3.4 Saving and Loading Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.4.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24
3.4.2 Saving Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
3.4.3 Loading Settings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 26
v
vi CONTENTS
4 Customizing 27
4.1 G-Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27
4.2 Profiles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.3 Drill Rack Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
4.4 User GCode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
vii
viii LIST OF FIGURES
List of Tables
ix
x LIST OF TABLES
Chapter 1
Introduction
1.1 Purpose
Pcb-gcode is a User Language Program (ULP) for EAGLE PCB design software produced
by CadSoft. Pcb-gcode allows one to make printed circuit boards by using a CNC router
or milling machine to cut the traces out of the copper on the board. It also produces files
for drilling holes and creating stencils for cream layers. Two-sided boards are supported.
By "mechanically etching" the boards, no toxic chemicals are needed – making the process
more environmentally friendly. Turn-around times and costs are much reduced from
ordering a prototype from a board house.
1.2 Features
Though no program can be all things to all people, pcb-gcode has a lot of features to help
make it useful.
One or two sided boards There are checkboxes for selecting whether to generate files for
the top and/or bottom sides of the boards.
Outlines Generate gcode for cutting around the tracks of the PCB. Multiple passes are
possible, which helps eliminate the small slivers that may be left behind. There is
also an option to make only one outline pass.
Drills Generate gcode for drilling component and mounting holes. Tool changes are
supported, as well as a drill rack file.
Milling Milling code can be generated for any wires drawn on the Milling (46) layer.
1
2 CHAPTER 1. INTRODUCTION
Text Generates gcode to engrave any vector text that is on the Milling (46) layer.
Stencils Produce stencils for applying solder cream for surface-mount parts.
Spot drill holes Holes can be spot drilled with the outlines tool to help the drill bits to
start straight when drilling holes.
Tool change position Where the machine should go so that the tool can be changed.
Drill rack files Allows using one drill bit for a range of hole sizes in the board.
Profile Starting settings for particular styles of gcode, for example, Mach3 or EMC, among
others.
Embedding comments Comments documenting the settings a file was created with can
be inserted into the gcode.
User gcode For users that need to generate gcode for unusual situations.
File naming Several options exist for naming files according to the conventions of the
user’s controller, and their local language.
1.3.2 Isolation
Pcb-gcode has the ability to generate g-code that cuts out tracks with increasing amounts
of isolation. This is helpful because it can help eliminate small slivers of copper left
behind by the cutting process.
The isolation begins at a minimum amount and is increased by a step size until a
maximum amount is reached. The builtin previewer can be used to see how this isolation
works. See Figure 1.1. From the zoomed view shown in Figure 1.2 on the following page
you can see that the passes start out close to the track, then move out by a step size. The
colors of the preview tracks follow the standard resistor color codes, so brown is the first
pass, red is the second, orange the third, etc.
For the curious reader, the isolation is calculated as shown in Equation 1.1. You do
not need to know this to use pcb-gcode. Note that this formula is erroneous and that
the EtchingToolSize should be divided by 2 to yield the offset. Changing this now would
break many user’s setups, so it will be left as is. Most users arrive at the setting for the
etching tool size by trial and error, so it is likely a moot point.
Figure 1.2: Preview showing a zoomed version of the color-coded multiple passes. Brown is the first pass,
red the second, orange the third, etc.
1.3.3 Drilling
Compared to the isolation passes and files, drill file creation is relatively straight forward.
Each hole in the board is sorted according to size and distance from other holes of the
same size. G-code is created to position and drill each hole. Tool changes can be included
in the file so that the user or an automated tool changer can change the bit. Optionally a
rack file can be used.
Rack files contain a list of drills the user has available and the size holes they can be
used for. For example, if a library part has a 1mm hole, and another part has a 1.1mm
hole, a 1.1mm drill bit could be used for both. For more information on rack files, see
Section 4.3 on page 31.
Chapter 2
Setup
2.2 Installation
2.2.1 Downloading and unarchiving
Pcb-gcode can be downloaded from the Yahoo! group’s software folder. Unzip the archive
into a place where the operating system will allow files to be saved. For Windows, this
should be somewhere inside your Documents2 folder. For Mac OS X, it could be, for
instance, ~/Documents/Eagle/pcbgcode, and for Linux, somewhere off your home folder.
Be sure to preserve the directory structure in the archive. See Figure 2.1 on the next page.
Windows Note
Note that if you are using Windows, odd things might happen if you install pcb-gcode out-
side the Documents folder. This is due to Windows File Protection or Windows Resource
Protection, which try to keep files outside the Documents folder from being changed.
This could result in, for instance, the previewer always showing the same preview or
an Illegal phase 0 in main routine error. If you install outside the Documents folder
and have trouble, try installing under your folder inside Documents.
1 CadSoft changed the way numbers were represented internally with their release of version 6. This
effectively broke parts of pcb-gcode. Version 3.6 incorporates changes for compatibility with version 5 or 6.
2 For Windows XP: "C:\Documents and Settings", for Windows 7: "C:\Users\[yourname]\My Documents"
5
6 CHAPTER 2. SETUP
Figure 2.1: The proper directory structure after uncompressing the archive.
Now that pcb-gcode is uncompressed, Eagle must know where it is located. In Eagle’s
Control Panel, click Options | Directories, then put the path to pcb-gcode in the User
Language Programs field. See Figure 2.2 on the facing page.
To complete the setup, pcb-gcode must be told which type of g-code it should generate.
Open a board in Eagle, then click File | Run.... Locate the folder where pcb-gcode is
and select pcb-gcode-setup.ulp. You will see the screen in Figure 2.3 on the next page.
Select the style g-code that most closely matches your controller.
You will receive the warning shown in Figure 2.4 on page 8. If this is the first time
pcb-gcode has been run, just click Yes and skip the rest of this paragraph. If this is an
existing installation of pcb-gcode and gcode-defaults.h has been modified, make note of
the modifications before clicking Yes, then make those modifications as needed to the
new gcode-defaults.h file.
After clicking Yes, pcb-gcode-setup will be run again, and you will see the screen
shown in Figure 2.6 on page 11.
2.2. INSTALLATION 7
Figure 2.2: Add the path to pcb-gcode to the User Language Programs option.
email list for advice. Note that there are separate feed rates for X Y, and Z, and there is a
spindle speed setting for each of the four operations pcb-gcode can generate files for.
A Tool Dia. parameter is available to set the diameter of the tool used to etch and
for milling openings for stencils used to apply cream solder paste when surface mounted
parts are used.
Epsilon is the minimum move that will be written to the g-code file. For instance, if
Epsilon is set to 0.000100 then the g-code file will not contain movements less than 0.000100 .
This option will rarely need to be changed.
The Default Drill Rack File option allows for the selection of a rack file to be used
if one has not been setup for a particular board. In most cases this can be left blank to
start with. See Section 4.3 on page 31 for more information about setting up rack files.
10 CHAPTER 2. SETUP
Top Side Options having to do with the tracks on the top of the board, and drill holes
made from the top side of the board.
Generate top outlines Generate g-code to cut out the tracks, pads, pours and vias
on the top side of the board.
Generate top drills Generate g-code to drill holes from the top side of the board.
Generate top stencil Generate g-code to cut out a stencil for the top cream layer.
Bottom Side Options having to do with the tracks on the bottom of the board, and drill
holes made from the bottom side of the board.
Generate bottom outlines Generate g-code to cut out the tracks, pads, pours and
vias on the bottom side of the board.
Generate bottom drills Generate g-code to drill holes from the bottom side of the
board.
Generate bottom stencil Generate g-code to cut out a stencil for the bottom cream
layer.
Mirror X coordinates for the bottom of the board are usually negative. This makes
setting the origin for a two-sided board easier. Turning this option on causes
the X coordinates to be positive, however, the bottom tracks will be a mirror
image of what they should be. So in general, leave this option off.
Show preview Use the previewer in pcb-gcode to preview the g-code generated.
Width and height set the size of the preview window.
Generate milling Generate g-code for any wires the user has drawn on the Milling
(46) layer. Depth sets the milling depth.
Generate text Generate g-code to engrave any vector text the user may have placed
on the Milling layer. Depth sets the engraving depth. Not that text on the top
or bottom layers will be outlined just as the tracks are, whereas text on the
milling layer is engraved. That is, the tool along the center of the lines that
make up the letter.
2.4. GENERATION OPTIONS 11
Spot drill holes Spot drilling helps the drill bits center themselves and helps pre-
vent "walking." Depth sets the spot drill depth.
Prefer climb Prefer the climb direction when etching tracks, that is, the clockwise
direction.
Isolation The cutting tool can make several passes around the tracks at an increasing
distance each time. This helps eliminate slivers of copper that remain.
Single pass When turned on, only a single pass will be made around the
tracks on the board.
Minimum The minimum distance the cutting tool will be away from tracks.
That is, the starting isolation amount.
Maximum The maximum distance the cutting tool will be away from tracks.
The maximum isolation amount.
Step size The amount the isolation increases with each pass.
Operator message for gcode file Text entered in this field will be inserted into each NC
file generated, along with an operator pause command. Use this for reminders to
the operator, such as, “Use 30◦ bit for etching. Use 3mm bit for milling.”
NC File Comment from Board adds a comment with the name of the board file.
NC File Comment Date adds the date the g-code file is created.
NC File Comment Machine Settings adds settings related to the machine. Tool
size, Z axis settings, spindle on time, milling depth, text depth, tool change
position, XY feed rate, Z feed rate.
NC File Comment PCB Defaults Settings adds comments with the isolation set-
tings: min, max, and step size, which files were selected to be produced, and
the unit of measure.
Use user gcode (from user-gcode.h) inserts user g-code into the generated file. See
Section 4.4 on page 33 for more details.
Debug Flag sets the global debug flag. Used for development and troubleshooting.
2.5. GCODE OPTIONS 13
Do tool change with zero step after moving to the tool change position and paus-
ing for the operator to change the bit, the Z axis will move to Z0.000 and pause.
This allows the operator to adjust the bit length to touch the surface of the PCB.
Note that the tool should initially be set high into the spindle so that it won’t
dig into the PCB when it moves to Z0.
Flip board in Y instead of X changes the code generated so that after one side of
the board is cut, the board should be flipped in the Y axis to complete cutting
on the other side. The default is for the board to be flipped in the X axis.
Compact gcode eliminates some redundant commands in the g-code file, such as
having G01 on every line.
Use line numbers? inserts line numbers into the g-code file. The format shown
%05d will insert 5 digit numbers with leading zeroes.
Use simple drill code uses simple XYZ movements to create drill holes. Usually
DRILL_FIRST_HOLE and DRILL_HOLE are used, but some controllers don’t un-
derstand the command (typically G82).
File naming every option one could want for naming files.
Macros the following can be used in the file name to create the final file name. Note
that paths do not include a / at the end. Also note that / is always the path
delimiter, even on Windows. Eagle handles the conversion automatically.
14 CHAPTER 2. SETUP
Using the options shown in 2.7, here is how the filename for the top etching file will
be created:
• The board path and board name will be used. (Filename Base)
• The word for ’top’ will be substituted for $SIDE. (See Etching under Top (Component)
Side Files.
Using examples for the board path and name, the final file name would be:
/Users/john/Documents/pcbcode/examples/enabtmr.top.etch.tap
2.6. SUPPORT 15
2.6 Support
Several options are available for support. First and foremost, read this manual and ensure
that your question is not herein.
Yahoo! Group The Yahoo! group has over 3 000 members, many of whom are very active
and experienced in the use of pcb-gcode.
Phorum The online BBS where questions and answers may be posted, files downloaded,
etc.
Email Very limited email support is available. Please try all the other options first.
Onsite Support If you are in the Atlanta area, onsite support is a possibility. Please email
me.
16 CHAPTER 2. SETUP
Chapter 3
Using pcb-gcode
17
18 CHAPTER 3. USING PCB-GCODE
Figure 3.4: The pads are far enough apart to allow them to be isolated.
Figure 3.5: The two pads are too close together and cannot be isolated. A bridge is formed.
20 CHAPTER 3. USING PCB-GCODE
Figure 3.6: EAGLE’s DRC indicating the two pads are too close together.
3.3 Previewer
The previewer included in pcb-gcode shows a quick preview of the tool movements that
are sent to the NC file. The lines are color coded using the standard resistor color codes.
The first pass of the tool is drawn in brown, the second is red, the third is orange, etc.
The preview is enabled by turning on the Show preview option under the Generation
Options tab (See Figure 2.6 on page 11). After pcb-gcode creates the isolation or milling
for the current layer, a preview of the results will be shown in the previewer. Several keys
can be used to change the view, See Table 3.1. If you wonder about some of the unusual
keys, such as why e can be used to pan right, it is because of the Dvorak keyboard layout
that some use, including the author.
Key Function
1 Set zoom to 1x (no zoom)
2 Set zoom to 2x
+= Zoom in
-_ Zoom out
a← Pan left
de→ Pan right
w,↑ Pan up
so↓ Pan down
c Color on / off
qx Quit preview
The previewer does not read and interpret the NC files directly, but uses an internal
3.3. PREVIEWER 21
Figure 3.7: The previewer showing a multi-pass file for the bottom side of an example PCB included with
pcb-gcode. Each × represents a drill hole in the drill file.
representation of the tool movements. This gives an accurate representation of the tool’s
movements and size, without the overhead of interpreting several different styles of
g-code.
As can be seen in Figure 3.7, additional information is provided by the preview. In the
upper-left corner is the name of the board file that was processed to produce this preview.
At the upper-right, the viewer version number can be found. Just to the left of that is the
etching tool size set in pcb-gcode-setup. Just below the version number is the number
of passes generated. Back on the left-hand side near the top is an overview of the keys
available.
The four extents of the board are marked with red corners. At the upper right corner,
the X and Y coordinates are given. The X and Y coordinates are also given at the lower-left
corner. Note that in the figure, the X coordinate is negative because this is the bottom of
the board. In the lower right corner, a circle and crosshairs mark the origin point for the
22 CHAPTER 3. USING PCB-GCODE
Figure 3.8: The sample board docs/examples/04151_lcdi2c.brd with wires and mirrored text on the
Milling layer.
board.
If the milling and text options are turned on, the previewer will show any files
generated for the top and bottom milling and text. Since the Milling (46) layer is not a top
or bottom layer (it can be thought of as going through the board), NC files are generated
to mill any lines drawn on it from either the top or bottom side. So in other words, if
Generate milling is selected, both top and bottom milling files will be generated. The
same for text placed on the Milling layer. If Generate text is selected, both top and
bottom text engraving files will be generated. There is one caveat: if the text is mirrored,
it will be output in the bottom milling file. If the text is not mirrored, it will be output in
the top milling file. This is similar to the way text placed on the Top and Bottom layers
looks. The following example will help clarify this.
The example board docs/examples/04151_lcdi2c.brd shown in Figure 3.8 includes
wires (shown in blue) drawn on the Milling layer, as well as mirrored vector text (also
shown in blue) placed on the Milling layer. A prewiew of the bottom milling file is shown
in Figure 3.9 on the facing page. A preview of the bottom text engraving file is shown in
Figure 3.10 on the next page. You can see that the text is oriented properly for engraving
on the bottom side of the board. The object info for the text is shown in Figure 3.11 on
page 24.
The top milling file preview looks just like the bottom preview, and is not shown. The
top text engraving file was empty since there is no non-mirrored text on the Milling layer,
so its preview has also been omitted.
3.3. PREVIEWER 23
Figure 3.9: Milling generated for milling from the bottom side of docs/examples/04151_lcdi2c.brd.
Figure 3.10: Text engraving generated for cutting on the bottom side of
docs/examples/04151_lcdi2c.brd.
24 CHAPTER 3. USING PCB-GCODE
Figure 3.11: The object info for the mirrored text on the Milling layer. Note that the Mirror checkbox is on.
This indicates to pcb-gcode that the text should be engraved on the bottom side of the board.
For the curious reader, the previewer is written using a language called Processing,
which is somewhat Java-like. Three versions of the previewer are included in pcb-gcode,
one for each operating system supported: Mac OS X, Linux, and Windows. When the
previewer is enabled, pcb-gcode detects which operating system it is running on, and
runs the appropriate viewer.
3.4.1 Overview
Settings may be loaded and saved to settings files. This can be found on the Plugins tab,
and is shown in figure 3.12 on the next page. This allows the operator to set up groups
of settings for different PC boards, save them, and load them when manufacturing the
same board later. The settings saved include those on the Generation Options tab (shown
in figure 2.6 on page 11), as well as those on the Machine tab (see figure 2.5 on page 9)
except for the Units setting.
3.4. SAVING AND LOADING SETTINGS 25
Figure 3.12: The Plugins tab showing where settings can be saved and loaded.
26 CHAPTER 3. USING PCB-GCODE
!
There is a bug on some platforms that prevents pcb-gcode from setting the proper direc-
tory for the save dialog. Please ensure the directory is set correctly, otherwise your saved
files will not appear in the list of Settings.
Eagle Bug
i
settings from the Machine tab are saved in pcb-machine.h. When the settings are saved
from the Plugins tab, they are copied to filename.def and filename.mac files. When
loading, the opposite operation takes place.
Intermediate
Chapter 4
Customizing
4.1 G-Code
When the g-code style is initially selected at installation as discussed in Section 2.2.3 on
!
page 6, the profile (.pp) file selected is copied from the profiles folder to the settings
folder and to the file gcode-defaults.h. This is the file that pcb-gcode uses when
generating g-code files.
The listing found in Appendix A on page 37 can alse be used as a reference for editing
Intermediate
gcode-defaults.h. If there is a need to change the g-code generated by pcb-gcode, the
gcode-defaults.h file can be edited.
The definitions in the file are flexible in some aspects, and restricted in others. The
main restriction is that a definition that expects a certain number of parameters must be
given that number of parameters. Unused parameters can be passed as comments in the
g-code.
For example, if the controller does not understand the DWELL command, it can be
changed to a comment. In the listing, DWELL is defined to be:
46 string DWELL = " G04 " + PARAM + " % f " + EOL ;
This can be made into a comment the controller will ignore by surrounding it with
COMMENT_BEGIN and COMMENT_END:
46 string DWELL = COMMENT_BEGIN + " G04 " + PARAM + " % f " + COMMENT_END
+ EOL ;
The %f that pcb-gcode needs is still there, but the command is now just a comment as
far as the controller is concerned. This is only an ex-
ample. EAGLE han-
The definitions use previous definitions as much as possible. This helps make the files dles line endings au-
more readable, and makes future changes easier as well. For instance, EOL is defined in tomatically depend-
line 22 to be "\n". Changing the line ending of all generated code would be a simple ing on the operat-
ing system it is run-
matter of changing the single definition of EOL, rather than editing every line. ning on. If line
endings in gener-
ated NC files need
27 to be changed, a
conversion program
should be used.
28 CHAPTER 4. CUSTOMIZING
The first option on line 11, FILENAMES_8_CHARACTERS, tells pcb-gcode whether it should
limit filenames to 8 characters. This is used for DOS control software such as TurboCNC.
RAPID for rapid moves with the cutting tool out of the material.
FEED for movements with the cutting tool in the material.
ARC_CW for cutting an arc clockwise.
ARC_CCW for cutting an arc counter-clockwise.
DWELL pause for a number of seconds. Number of seconds (a float) is passed.
Feeds Movements at cutting speed, uses FEED and the coordinate definitions above.
TOOL_CODE the tool selection code. Passed the tool number (an integer) as a
parameter.
TOOL_MM_FORMAT a tool size formatted for millimeters. Passed a tool size
(float).
TOOL_INCH_FORMAT a tool size formatted for inches. Passed a tool size (float).
TOOL_CHANGE the command issued when a tool is to be changed. Takes tool
number and tool size as arguments.
TOOL_CHANGE_TABLE_HEADER the tool table header comment inserted in
the g-code.
TOOL_CHANGE_TABLE_FORMAT generates an entry for the tool table. Note
that this is a function.
4.2 Profiles
Profiles, which are found in the profiles folder, control the format that pcb-gcode uses
!
when writing g-code. The files ending in .pp are the list of files shown when pcb-gcode
is initially set up (See Section 2.2 on page 5), and also in the list of profiles in the GCode
Styles tab. When a profile is selected, it is copied to settings/gcode-defaults.h. A
sample profile is shown in Appendix A on page 37.
Advanced
To create a custom profile, such as for a controller that is not already supported,
begin with a profile that most closely matches the g-code the controller supports. Se-
lect this profile in GCode Styles and Accept the change. This will copy the profile
to settings/gcode-defaults.h. Generate code for a test board and open the gen-
erated files in an editor. Find commands that the controller does not support, and
edit gcode-defaults.h to generate the proper code. When testing is complete, copy
settings/gcode-defaults.h into the profiles folder, renaming it with a descriptive
name and the extension .pp. Edit the file and change the author and description fields.
And of course, save a backup somewhere outside the pcb-gcode folder heirarchy. To share
this profile with other users of this controller, upload the profile file to the Profiles folder
on the Yahoo! group.
For information on editing gcode-defaults.h, See Section 4.1 on page 27.
tool The tool number to use. This is somewhat arbitrary unless the machine has a tool
changer or you have offsets or lengths set up for different tool numbers. Tool
numbers can begin at any reasonable number, such as T01, T16, etc.
drill_size The size of the actual drill. These should be in ascending order from smallest
to largest.
minimum The smallest hole size this drill should be used for.
32 CHAPTER 4. CUSTOMIZING
Taking tool T01 as an example. It is a 0.500mm drill, and it will be used for all holes
from 0.000in up to 0.025in. Meaning, if there is a 0.01500 hole in the board, it will be
drilled with this bit. If there is a 0.04500 hole, it will not be drilled with drill T01, but
another drill will be used, if a good match is available.
Looking at the table, it can be seen that all hole sizes from 0.000in up to 0.125in have
been accounted for. If, say, a 0.13000 hole is in the board, an error message will be given
saying a drill is not available for that size hole.
Rack file are selected by the following method: first, if there is a rack file with the
same name as the board, but with the extension .drl, it will be used. Next, a default rack
file will be used if it has been set in pcb-gcode-setup (See Figure 2.5 on page 9). Finally,
if neither of those is available, the rack file settings/default.drl will be used from the
pcb-gcode directory. If all these attempts fail and no rack file can be found, a table of
drill sizes will be written to the drill file. In most cases this works well, but sometimes it
can result in, for instance, drilling ten holes with a 0.03100 , then stopping and asking for a
0.03200 bit. Obviously, the same bit could have been used for both sets of holes. That is
why rack files exist.
!
degree. If you don’t see an option in the profile that suits your needs, you can add your
code to the user-gcode.h file. To enable user g-code, run pcb-gcode-setup, click the
GCode Options tab, then turn the Use user gcode... option on. Generate a set of NC
files for a board. Let’s say, for example, that after you change the tool when you’re drilling
Advanced
from the bottom of the board, you want the tool to move to X5 Y5 Z5, turn the spindle off,
then turn it back on. Since this has to do with drilling the bottom of the board, we should
look at the ...bot.drill.tap (bottom drill) file. An excerpt from a file is shown in Listing 4.3.
That’s where we want our code to go. Now you can open user-gcode.h in your favorite
editor, and use the Search or Find feature to find the line with Bottom Tool Change End.
Here’s an excerpt from the user-gcode.h file:
1 TOOL_ZERO_BEGIN [ BOTTOM ] = " ( Bottom Tool zero begin ) \ n " ;
2 TOOL_ZERO_END [ BOTTOM ] = " ( Bottom Tool zero end ) \ n " ;
3 TOOL_CHANGE_END [ BOTTOM ] = " ( Bottom Tool Change End ) \ n " ;
4 TOOL_ CHANGE_B EGIN [ TOP ] = " ( Top Tool Change Begin ) \ n " ;
Notice that all the lines have a \n before the last " and that the last line is the only one
that ends with a semi-colon ;. Generate the files again. Open the bottom drill file in the
editor and have a look. Here’s how the sample looks now:
1 G90
2 ( Tool Change Begin )
3 ( Bottom Tool Change Begin )
4 M05
5 G00 X0 .0000 Y0 .0000 Z2 .0000
6 M06 T01 ; 0.0236
7 ( Bottom Tool changed )
8 ( Tool changed )
9 G00 Z0 .0200
10 M03
11 G04 P3 .000000
12 ( Bottom Tool Change End )
13 G00 X5 Y5 Z5
14 M05 ( spindle off )
15 G04 P3 .000000 ( wait 3 seconds )
16 M03 ( spindle on )
17 G04 P3 .000000 ( wait 3 more seconds )
18 ( Tool Change End )
19 G82 X -1.6200 Y1 .2900 Z -0.1000 F9 .80 R0 .0200 P0 .250000
20 G82 X -1.8800 Y0 .5900
21 G82 X -1.9500 Y1 .4900
22 G82 X -1.9500 Y1 .8100
4.4. USER GCODE 35
Note that the lines added to the user-gcode.h file are now in the generated g-code from
lines 13-17.
Since we put our code in the TOOL_CHANGE_END[BOTTOM] definition, it will only be put
in files for the bottom side of the board. So the code will be in the bot.drill file. If we only
wanted our code in files for the top side, we would have put the code in TOOL_CHANGE_END
[TOP]. You can probably guess that if we wanted the code in both the top and bottom
files, we would have put the code in TOOL_CHANGE_END[TOOL_CHANGE_END[ALL]. To conclude,
the steps to follow are:
2. Find the file that you want the code to be put in (bot, top, etc.).
3. Find the location in the file that you want the code.
1 //
2 // Options for pcb - gcode . ulp .
3 // Often used options are at the top of the file .
4 // Copied to gcode - defaults . h by the setup program .
5
6 //
7 // author = John Johnson
8 // description = Mach3 - EMC for Windows
9 //
10
11 int F I L E N A M E S _ 8 _ C H A R A C T E R S = NO ;
12
13 //
14 // Comments .
15 //
16 string COMMENT_BEGIN = " ( " ;
17 string COMMENT_END = ")";
18
19 //
20 // Format strings for coordinates , etc .
21 //
22 string EOL = "\n"; /* standard line ending */
23 string PARAM = "P"; /* some use P , some # for parameters */
24 string FORMAT = " % -7.4 f " ; /* coordinate format */
25 string FR_FORMAT = " F % -5.0 f " ; /* feedrate format */
26 string IJ_FORMAT = " I " + FORMAT + " J " + FORMAT ;
27 string R_FORMAT = " R " + FORMAT ;
28
29 //
30 // Modes
31 //
32 string INCH_MODE = " G20 " + EOL ;
33 string IN CH_ MO DE_ COM MEN T = COMMENT_BEGIN + " Inch Mode " + COMMENT_END + EOL ;
34 string METRIC_MODE = " G21 " + EOL ;
35 string M E TR I C _ M O D E _ C O M M E N T = COMMENT_BEGIN + " Metric Mode " + COMMENT_END + EOL ;
36 string MIL_MODE = " M02 ( Please setup MIL_MODE in gcode - defaults . h ) " + EOL ;
37 string MICRON_MODE = " M02 ( Please setup MICRON_MODE in gcode - defaults . h ) " + EOL ;
38 string ABSOLUTE_MODE = COMMENT_BEGIN + " Absolute Coordinates " + COMMENT_END + EOL + " G90 " + EOL ;
39
40 //
41 // G codes
42 //
43 string RAPID = " G00 ";
44 string FEED = " G01 ";
45 string ARC_CW = " G02 ";
46 string ARC_CCW = " G03 ";
47 string DWELL = " G04 " + PARAM + " % f " + EOL ;
48
49 //
50 // M codes
51 //
52 string SPINDLE_ON = " M03 " + EOL + DWELL ;
53 string SPINDLE_OFF = " M05 " + EOL ;
37
38 APPENDIX A. SAMPLE MACH3 PROFILE
bridges, 18 gcode-defaults.h
definitions of commands, 28
compatibility
eagle, 5 installation, 5
isolation
download site, 5 description, 3
drill settings, 12
depth, 8
description, 4 Java, 8
dwell, 8 javaw.exe, 8
rack files, 31
simple g-code, 13 keys
substitutions, 31 previewer, 20
eagle pcb-gcode
DRC, 18 running, 17
Error previewer, 20
Illegal phase 0, 5 keys, 20
etching option, 10
tool diameter, 9 window size, 10
profiles, 31
feed rates, 9 definitions of commands, 28
files
naming, 13 settings
loading, 26
g-code path to, 26
comments, 12 saving, 24
compact, 13 saving and loading, 24
customizing, 27 setup tabs
line numbers, 13 GCode Options, 12
options, 12 GCode Style, 6
profiles, 31 Generation Options, 10
style, 6 Machine, 8
user, 12, 33 Plugins, 24
39
40 INDEX
spindle
spin up time, 8
stencil
Generate bottom option, 10
Generate top option, 10
tool diameter, 9
support, 15
on site, 15
Phorum, 15
Yahoo group, 15
tool change
position, 8
zero step, 13
unit of measure, 8
user gcode, 33
z axis
down, 8
feed rates, 9
high, 8
up, 8