Manual - pcb2gcode/pcb2gcode GitHub Wiki

NAME

pcb2gcode - command-line tool for engraving PCBs using CNCs

SYNOPSIS

pcb2gcode [options]

DESCRIPTION

This manual page documents briefly the pcb2gcode command.

pcb2gcode is a program that takes the files typically produced by PCB (printed circuit board) designing tools, in particular Gerber (RS-274X) and Excellon (an RS-274C variant) files as parsed by gerbv, and produces files that can be used to control a CNC (computer numerical control) milling machine. These files are in G code format (RS-274D/NGC) that can be read, for example, by the linuxcnc EMC2 system.

When these files are executed, an engraving bit is used to remove the surface from a copper covered circuit board, thus creating isolated areas. In another step, holes are drilled into the board at the appropriate positions, and it can be cut out in another step. (For each step, a separate output file is created.)

OPTIONS

These programs follow the usual GNU command line syntax, with long options starting with two dashes ('-'). A summary of options is included below.

Instead of passing all options on the command line, nearly all options can be stored in a configuration file named millproject. There, options are given one per line as option=value pairs (without the two dashes), and can be separated by blank lines and commented (everything after a '#' character is treated as a comment). Options that don't take an argument (like metric) are entered as option=true or option=1 there.

Unless configured otherwise, numeric values are in units of inch and inch/minute. When the --metric option is given, they are in mm and mm/minute. For all options that are numeric, units can be specified. For example, 5 inches or 300revolutions/second. Specified units override the --metric option.

--front filename.gbr
Engrave the front side according to the given file (typically used in two-sided boards).

--back filename.gbr
Engrave the back side according to the given file.

--outline filename.gbr
Cut out the board to the shape exposed in the given file. Typically, there is only a polygon in this gerber file. Alternatively, this file can contain a closed line chain (see --fill-outline).

--drill filename.cnc
Convert the given file (containing drill sizes and positions) to G-code.

--preamble-text filename
gcode text preamble file, inserted at the very beginning as a comment. All the round parenthesis will be converted to angled parenthesis (due to gcode's comments limitations). You can use this to include the license header at the top of the gcode output files.

--preamble filename.ngc
gcode preamble file, inserted at the very beginning

--postamble filename.ngc
gcode postamble file, inserted before M9 and M2

--g64 unit
maximum deviation from toolpath, overrides internal calculation

For every option --x that takes a filename, there is an --x-output option that specifies where the resulting G-code is saved, defaulting to x.gbr. Instead of giving each output file name, the --basename option can be used; the base name will be used as a prefix to the default output file names. You can also specify the output directory with --output-dir; if unspecified, the output files will be created in the current directory.

The parameters that define engraving are:

--zwork unit
Z-coordinate at which engraving happens

--zsafe unit
Z-coordinate for movements between engraving steps

--mill-feed unit/minute
feed rate at which engraving takes place (horizontal speed)

--mill-speed rpm
spindle speed during engraving (rounds per minute)

--offset unit
distance by which the tool movement will be outset from the contours in the gerber file to be engraved. If this distance can't be satisfied because copper areas are too close, a warning will be printed and the line will be drawn between the areas. This behavior can be used to get voronoi-style (flood-filling) areas; simply set the offset to a large value (like 1 inch).

--extra-passes number
number of additional isolation passes For each extra pass, engraving is repeated with the offset width increased by half its original value, creating wider isolation areas.

The parameters that define drilling are:

--zdrill unit
Z value down to which will be drilled

--zchange unit
Z-coordinate for movements with the drill head

--drill-feed unit/minute
feed rate for drilling (vertical speed)

--drill-speed rpm
spindle speed during drilling (rounds per minute)

--milldrill
If --milldrill is given, the milling head will be used to drill the holes in the PCB. Holes up to the size of the milling head will be drilled regularly (possibly creating a bigger hole than intended), the other holes are created by moving the head in circles using the feed and infeed parameters used in cutting.

--drill-side
use the coordinates for the specified side for drilling. Valid choices are front back and auto

--onedrill
use only one drill bit size

--nog81
replace G81 with G0+G1. This option makes the gcode compatible with low-end cnc controllers (like grbl), but also makes it bigger and less clean

Outline cutting takes another set of options:

--cutter-diameter unit
amount by half of which the tool path is outset from the shape in the outline file

--zcut unit
Z-coordinate indicating where the outline cutting ends

--cut-feed unit/minute
feed rate at which outline cutting takes place (horizontal speed)

--cut-speed rpm
spindle speed during outline cutting (rounds per minute)

--cut-infeed unit
maximum Z distance that is cut away in a single pass (positive value; if less then zcut's value, there will be more than one pass)

--fill-outline
If --fill-outline is given, it is assumed that the outline file contains not a polygon but a closed chain of lines. The board will be cut along the centres of these lines.

--outline-width unit
thickness of the lines that form the outline (if --fill-outline is given)

--cut-front
cut from the front side. Default is from the back side

--bridges unit
add bridges with the given width to the outline cut. --bridgesnum bridges will be created for each outline closed line. This option requires --optimise

--zbridges unit
bridges heigth (Z-coordinates while engraving bridges, default to zsafe)

--bridgesnum number
sets the numer of bridges to be created (--bridgesnum bridges for each closed line)

The autoleveller feature allows you to mill your project on a surface that isn't at exactly the same height in every point. To use the autoleveller feature you need a probe tool connected to your machine. The autoleveller process is composed by two parts:

  • Initial probing, where the machine "probes" a grid of points and save their heights
  • Actual milling, identical to the standard process, but with an additional Z-correction (based on a bilinear interpolation of the probed points)

Unfortunately each control software (LinuxCNC, Mach3, ...) uses different gcodes for the probing, the parameters and the macros, therefore the output gcode won't be software-independent, and you have to choose the used software with the proper argument.

--al-front
enable the autoleveller for the front side

--al-back
enable the autoleveller for the back side

--software software
the height probing commands are different from software to software. Use this option to select the used software; currently supported softwares are LinuxCNC, Mach3, Mach4 and custom. With custom you can specify al-probecode, al-probevar and al-setzzero, in order to generate gcode for an unsupported software. For compatibility reasons, the custom gcode is much bigger (3-4 times) than the gcode for a supported software.

--al-x unit
the width of the probing on the X axis. Higher values increase the levelling precision but also increases the probing time (but not the milling time)

--al-y unit
the width of the probing on the Y axis. Higher values increase the levelling precision but also increases the probing time (but not the milling time)

--al-probefeed unit/second
probe speed on the Z axis. Higher values decrease the probing time but also increase the wear of the probing tool

--al-probe-on command(s)
insert these commands at the start of the probing sequence. You can use this argument to add a M64/M65 command (LinuxCNC) to automatically enable the probe tool. Use a at sign (@) to insert a newline

--al-probe-off command(s)
insert these commands at the end of the probing sequence, replacing the standard M0 command. You can use this argument to add a M64/M65 command (LinuxCNC) to automatically disable the probe tool. Use a dollar sign ($) to insert a newline

--al-probecode code
custom Z probe code. For example, LinuxCNC uses G38.2 while Mach3, Mach4 and TurboCNC use G31. If unspecified, G31 will be used. This option is relevant only when --software=custom

--al-probevar number
custom Z probe code result variable. For example, LinuxCNC uses 5063 while Mach3, Mach4 and TurboCNC use 2002. If unspecified, 2002 will be used. This option is relevant only when --software=custom

--al-setzzero code
custom gcode for setting the actual height as the zero of the Z axis. For example, LinuxCNC uses G10 L20 P0 Z0 while Mach3, Mach4 and TurboCNC use G92 Z0. If unspecified, G92 Z0 will be used. This option is relevant only when --software=custom

These options govern the general behavior of pcb2gcode:

--optimise
optimise output gcode, reducing its output size up to 95%, while accepting a very little loss of precision

--dpi dpi
resolution used internally (defaults to 1000). If the software freezes during the layer exporting, try to increasethe dpi value. Sane values for dpi are 1000/2000 for through-hole PCBs and 2000/4000 dpi for SMD PCBs.

--mirror-absolute
mirror operations on the back side along the Y axis instead of the board center, which is the default

--svg
output SVG file (EXPERIMENTAL)

--metric
use metric units for parameters. Does not affect output code

--metricoutput
use metric units for output code

--zero-start
set the starting point of the project at (0,0). With this option, the projet will be between (0,0) and (max_x_value, max_y_value) (positive values)

The only options that can't be used in the millproject file are the common ones and noconfigfile:

--noconfigfile
Disable the parsing of the millproject file. Use this option if you want to manually pass all the arguments as command line parameters

-?, --help
Show summary of options.

-v, --version
Show version of program.

SEE ALSO

gerbv(1), pcb(1).

For further information about pcb2gcode, see the project wiki https://github.com/pcb2gcode/pcb2gcode/wiki/Manual.

AUTHOR

pcb2gcode was written by Patrick Birnzain, loosely based on an earlier program of the same name by Jeff Prothero (Cynbe ru Taren), which in term was based even more loosely on Matthew Sager's gerber_to_gcode.

This manual page was written by chrysn <[email protected]> and Nicola Corna <[email protected]> for the Debian project (and may be used by others).

⚠️ **GitHub.com Fallback** ⚠️