1PCB2GCODE(1) General Commands Manual PCB2GCODE(1)
2
3
4
6 pcb2gcode - command-line tool for engraving PCBs using CNCs
7
9 pcb2gcode [options]
10
12 This manual page documents briefly the pcb2gcode command.
13
14 pcb2gcode is a program that takes the files typically produced by PCB
15 (printed circuit board) designing tools, in particular Gerber (RS-274X)
16 and Excellon (an RS-274C variant) files as parsed by gerbv, and pro‐
17 duces files that can be used to control a CNC (computer numerical con‐
18 trol) milling machine. These files are in G code format (RS-274D/NGC)
19 that can be read, for example, by the linuxcnc EMC2 system.
20
21 When these files are executed, an engraving bit is used to remove the
22 surface from a copper covered circuit board, thus creating isolated
23 areas. In another step, holes are drilled into the board at the appro‐
24 priate positions, and it can be cut out in another step. (For each
25 step, a separate output file is created.)
26
28 These programs follow the usual GNU command line syntax, with long
29 options starting with two dashes (`-'). A summary of options is
30 included below.
31
32 Instead of passing all options on the command line, nearly all options
33 can be stored in a file named millproject. There, options are given one
34 per line as option=value pairs (without the two dashes), and can be
35 separated by blank lines and commented (everything after a `#` charac‐
36 ter is treated as a comment). Options that don't take an argument (like
37 --metric) are entered as option=true or option=1 there.
38
39 Unless configured otherwise, numeric values are in units of inch and
40 inch/minute. When the --metric option is given, they are in mm and
41 mm/minute.
42
43
44 --front filename.gbr
45 Engrave the front side according to the given file (typically
46 used in two-sided boards).
47
48 --back filename.gbr
49 Engrave the back side according to the given file.
50
51 --outline filename.gbr
52 Cut out the board to the shape exposed in the given file. Typi‐
53 cally, there is only a polygon in this gerber file. Alterna‐
54 tively, this file can contain a closed line chain (see
55 --fill-outline). This option is enabled by default, to disable
56 it use --fill-outline=false
57
58 --drill filename.cnc
59 Convert the given file (containing drill sizes and positions) to
60 G-code.
61
62 --preamble-text filename
63 gcode text preamble file, inserted at the very beginning as a
64 comment. All the round parenthesis will be converted to angled
65 parenthesis (due to gcode's comments limitations). You can use
66 this to include the license header at the top of the gcode out‐
67 put files.
68
69 --preamble filename.ngc
70 gcode preamble file, inserted at the very beginning
71
72 --postamble filename.ngc
73 gcode postamble file, inserted before M9 and M2
74
75 --tolerance unit
76 maximum deviation from toolpath
77
78 --nog64
79 do not explicitly set G64 inside the output gcode. This option
80 makes the gcode compatible with low-end cnc controllers (like
81 grbl)
82
83
84 For every option --x that takes a filename, there is an --x-output
85 option that specifies where the resulting G-code is saved, defaulting
86 to x.gbr. Instead of giving each output file name, the --basename
87 option can be used; the base name will be used as a prefix to the
88 default output file names. You can also specify the output directory
89 with --output-dir; if unspecified, the output files will be created in
90 the current directory.
91
92
93 The parameters that define engraving are:
94
95 --zwork unit
96 Z-coordinate at which engraving happens
97
98 --zsafe unit
99 Z-coordinate for movements between engraving steps
100
101 --mill-feed unit/minute
102 feed rate at which engraving takes place (horizontal speed)
103
104 --mill-vertfeed unit/minute
105 vertical mill feed rate used at the start of each engraving
106 path. If unspecified, --mill-feed/2 will be used.
107
108 --mill-speed rpm
109 spindle speed during engraving (rounds per minute)
110
111 --offset unit
112 distance by which the tool movement will be outset from the con‐
113 tours in the gerber file to be engraved. If you want to obtain a
114 PCB as similar as possible to the original file, you should set
115 this value to half of the tool diameter.
116
117 If this distance can't be satisfied because copper areas are too
118 close, a warning will be printed and the line will be drawn
119 between the areas. This behavior can be used to get voronoi-
120 style (flood-filling) areas; simply set the offset to a large
121 value (like 1 inch). When the vectorial mode is in use,
122 --voronoi is preferred.
123
124 --voronoi
125 enable the voronoi mode (requires --vectorial). This option is
126 more efficient than a large --offset value, and provides the
127 same result.
128
129 --extra-passes number
130 number of additional isolation passes For each extra pass,
131 engraving is repeated with the offset width increased by half
132 its original value, creating wider isolation areas. This option
133 is ignored when --voronoi is in use.
134
135
136 The parameters that define drilling are:
137
138 --zdrill unit
139 Z value down to which will be drilled
140
141 --zchange unit
142 Z-coordinate for movements with the drill head
143
144 --drill-feed unit/minute
145 feed rate for drilling (vertical speed)
146
147 --drill-speed rpm
148 spindle speed during drilling (rounds per minute)
149
150 --milldrill
151 If --milldrill is given, the milling head will be used to drill
152 the holes in the PCB. Holes up to the size of the milling head
153 will be drilled regularly (possibly creating a bigger hole than
154 intended), the other holes are created by moving the head in
155 circles using the feed and infeed parameters used in cutting.
156
157 --milldrill-diameter unit
158 diameter of milling head which is used with --milldrill; the
159 default value is same as --cutter-diameter.
160
161 --drill-side side
162 choose the drill side. Valid choices are front, back or auto
163 (default). In auto mode the drill side is automatically chosen
164 (always front unless only the back side is specified)
165
166 --onedrill
167 use only one drill bit size
168
169 --nog81
170 replace G81 with G0+G1. This option makes the gcode compatible
171 with low-end cnc controllers (like grbl), but also makes it big‐
172 ger and less clean
173
174 --nog91-1
175 do not explicitly set G91.1 (incremental arc mode distance) in
176 drill headers. Some controllers (like Roland's) does not sup‐
177 port G91.1 and they can wrongly interpret it as G91 (relative
178 distance). Since the default mode is usually "incremental", you
179 can safely remove G91.1 in most of the cases
180
181
182 Outline cutting takes another set of options:
183
184 --cutter-diameter unit
185 amount by half of which the tool path is outset from the shape
186 in the outline file
187
188 --zcut unit
189 Z-coordinate indicating where the outline cutting ends
190
191 --cut-feed unit/minute
192 feed rate at which outline cutting takes place (horizontal
193 speed)
194
195 --cut-vertfeed unit/minute
196 vertical cut feed rate used at the start of each cutting path.
197 If unspecified, --cut-feed/2 will be used.
198
199 --cut-speed rpm
200 spindle speed during outline cutting (rounds per minute)
201
202 --cut-infeed unit
203 maximum Z distance that is cut away in a single pass (positive
204 value; if less then zcut's value, there will be more than one
205 pass)
206
207 --fill-outline
208 If --fill-outline is given, it is assumed that the outline file
209 contains not a polygon but a closed chain of lines. The board
210 will be cut along the centres of these lines.
211
212 --outline-width unit
213 thickness of the lines that form the outline (if --fill-outline
214 is given); the default value is 0.15 mm/0.059 in.
215
216 --cut-side side
217 choose the cut side. Valid choices are front, back or auto
218 (default). In auto mode the cut side is automatically chosen
219 (always front unless only the back side is specified)
220
221 --bridges unit
222 add bridges with the given width to the outline cut. --bridges‐
223 num bridges will be created for each outline closed line. This
224 option requires --optimise
225
226 --zbridges unit
227 bridges height (Z-coordinates while engraving bridges, default
228 to zsafe)
229
230 --bridgesnum number
231 sets the numer of bridges to be created (--bridgesnum bridges
232 for each closed line)
233
234
235 The autoleveller feature allows you to mill your project on a surface
236 that isn't at exactly the same height in every point. To use the
237 autoleveller feature you need a probe tool connected to your machine.
238 The autoleveller process is composed by two parts:
239
240 · Initial probing, where the machine "probes" a grid of points and save
241 their heights. In order to save probing time, only the area where the
242 PCB will be milled will be probed.
243
244 · Actual milling, identical to the standard process, but with an addi‐
245 tional Z-correction (based on a bilinear interpolation of the probed
246 points)
247
248 Unfortunately each control software (LinuxCNC, Mach3, ...) uses differ‐
249 ent gcodes for the probing, the parameters and the macros, therefore
250 the output gcode won't be software-independent, and you have to choose
251 the used software with the option --software. For compatibility rea‐
252 sons, the gcode generated with --software=Custom is much bigger than
253 the gcode for a supported software.
254
255 --al-front
256 enable the autoleveller for the front side
257
258 --al-back
259 enable the autoleveller for the back side
260
261 --al-x unit
262 the width of the probing on the X axis. Lower values increase
263 the levelling precision but also increase the probing time (but
264 not the milling time)
265
266 --al-y unit
267 the width of the probing on the Y axis. Lower values increase
268 the levelling precision but also increase the probing time (but
269 not the milling time)
270
271 --al-probefeed unit/second
272 probe speed on the Z axis. Higher values decrease the probing
273 time but also increase the wear of the probing tool
274
275 --al-probe-on command(s)
276 insert these commands at the start of the probing sequence,
277 replacing the standard M0 command. You can use this argument to
278 add a M64/M65 command (LinuxCNC) to automatically enable the
279 probe tool. Use an at sign (@) to insert a newline
280
281 --al-probe-off command(s)
282 insert these commands at the end of the probing sequence,
283 replacing the standard M0 command. You can use this argument to
284 add a M64/M65 command (LinuxCNC) to automatically disable the
285 probe tool. Use an at sign (@) to insert a newline
286
287 --al-probecode code
288 custom Z probe code. For example, LinuxCNC uses G38.2 while
289 Mach3, Mach4 and TurboCNC use G31. If unspecified, G31 will be
290 used. This option is relevant only when --software=custom
291
292 --al-probevar number
293 custom Z probe result variable. For example, LinuxCNC and Mach4
294 use 5063 while Mach3 and TurboCNC use 2002. If unspecified, 2002
295 will be used. This option is relevant only when --software=cus‐
296 tom
297
298 --al-setzzero code
299 custom gcode for setting the current height as the zero of the Z
300 axis. For example, LinuxCNC uses G10 L20 P0 Z0 while Mach3,
301 Mach4 and TurboCNC use G92 Z0. If unspecified, G92 Z0 will be
302 used. This option is relevant only when --software=custom
303
304
305 pcb2gcode can repeat the PCB in a tile-x times tile-y grid of identical
306 PCBs. This feature can be activated by specifying the number of columns
307 and rows with --tile-x and --tile-y. If you don't specify a software,
308 or if you use --software=Custom, the resulting Gcode will be much big‐
309 ger (about original_size * tile-x * tile-y).
310
311 --tile-x columns
312 number of tiling columns. Default value is 1.
313
314 --tile-y rows
315 number of tiling rows. Default value is 1.
316
317
318 These options govern the general behavior of pcb2gcode:
319
320 --vectorial
321 enable the EXPERIMENTAL vectorial core. This new core offers
322 much better performances, higher precision, smaller output files
323 and support for internal cutoffs (like thermal pads). When
324 --vectorial is enabled, --dpi is ignored.
325
326 --software software
327 specify the gcode interpreter software; currently supported pro‐
328 grams are LinuxCNC, Mach3, Mach4 and custom. With custom you can
329 specify al-probecode, al-probevar and al-setzzero, in order to
330 generate gcode for an unsupported software.
331
332 --optimise
333 optimise the output gcode with Douglas-Peucker, reducing its
334 output size up to 95% (while accepting a very little loss of
335 precision). This option is enabled by default, to disable it use
336 --optimise=false
337
338 --dpi dpi
339 resolution used internally (defaults to 1000). If the software
340 freezes during the layer exporting, try to increase the dpi
341 value. Sane values for dpi are 1000/2000 for through-hole PCBs
342 and 2000/4000 dpi for SMT PCBs.
343
344 --mirror-absolute
345 mirror operations on the back side along the Y axis instead of
346 the board center, which is the default
347
348 --metric
349 use metric units for parameters. Does not affect output code
350
351 --metricoutput
352 use metric units for output code
353
354 --zero-start
355 set the starting point of the project at (0,0). With this
356 option, the projet will be between (0,0) and (max_x_value,
357 max_y_value) (positive values)
358
359 --no-export
360 do not create the output gcode files. You can use this to
361 quickly convert the input files to png/svg
362
363
364 The only options that can't be used in the millproject file are the
365 common ones and noconfigfile:
366
367 --noconfigfile
368 Disable the parsing of the millproject file. Use this option if
369 you want to manually pass all the arguments as command line
370 parameters
371
372 -?, --help
373 Show summary of options.
374
375 -v, --version
376 Show version of program.
377
379 gerbv(1), pcb(1).
380
381 For further information about pcb2gcode, see the project wiki ⟨https://
382 github.com/pcb2gcode/pcb2gcode/wiki⟩.
383
385 pcb2gcode was written by Patrick Birnzain and Nicola Corna, loosely
386 based on an earlier program of the same name by Jeff Prothero (Cynbe ru
387 Taren), which in term was based even more loosely on Matthew Sager's
388 gerber_to_gcode.
389
390 This manual page was written by chrysn <chrysn@fsfe.org> and Nicola
391 Corna <nicola@corna.info> for the Debian project (and may be used by
392 others).
393
394
395
396 2016-06-5 PCB2GCODE(1)