Milling PCBs using PCB2GCode

I'm trying my hands at milling a PCB.
It will be a USB isolator for my CNC.
Here I'm collecting my notes as a step by step guide to do the same again later.

Even if you are etching your PCB, drilling mounting holes and vias automatically could be a reason to visit your local CCC Erfa Kreis, Hackerspace or FabLab.


You start with Gerber files. (If you have hpgl or svg data, your CAM software should already be able to do this without pcb2gcode.)
  • .gbs - Gerber Bottom Solder Mask Data
  • .gbo - Gerber Bottom Overlay Data
  • .gbl - Gerber Bottom Layer Data
  • .gbp - Gerber Bottom Paste Mask Data
  • .gdd - Gerber Drill Drawing Data
  • .gko - Gerber Keep Out Layer
  • .gpb - Gerber Pad Master Bottom Data
  • .gpt - Gerber Pad Master Top Data
  • .gtl - Gerber Top Layer Data
  • .gto - Gerber Top Overlay Data
  • .gtp - Gerber Top Paste Mask Data
  • .txt (not human readable)
( filesuffix.com helped be with that list)


The go-to tool seems to be PCB2GCode.
Sadly it is only available for Linux. Not for Windows (where my MACH3 CAM software lives) nor MacOS.
However there seems to also be a beta website PCB2GCode online by Fablab Amersfoort.


The PCB2GCode website tells you to look at pcb2gcode --help. Nothing more.
No example. Not even an explanation of the file endings listed above. (They speak of .gbr wich is the only extension you'll not find a file for.)
Top-layer (.GTL) and bottom layer (.GBL) are easy.
TODO: Outline I have not a clue.
TODO: Drill data seems to be missing for me. :(


pcb2gcode --front USB_Isolator.GTL --back USB_Isolator.GBL --metric --zsafe 5 --zchange 100 --zwork -0.02 --offset 0.02 --mill-feed 100 --mill-speed 6000
Importing front side... done
Importing back side... done
Importing outline... not specified
Calculated board dimensions: 1.7in x 1.7in
Current Layer: back, exporting to back.ngc.
Warning: pcb2gcode hasn't been able to fulfill all clearance requirements and tried a best effort approach instead. You may want to check the g-code output and possibly use a smaller milling width.
Current Layer: front, exporting to front.ngc.
Warning: pcb2gcode hasn't been able to fulfill all clearance requirements and tried a best effort approach instead. You may want to check the g-code output and possibly use a smaller milling width.
No drill file specified.


Attention: Website only expect everything to be in these strange and obsolete "inches" thing.
The command line tool can be changed via
"--metric                            use metric units for parameters. does not affect gcode output"
for it's parameters but the output will still be imperial g-code.
No Rebels seem to have converted this imperial stronghold into metric units yet.

The website seems to require a drill file. The command line tool can do without.

--zwork The default seems to be "0.0008 inches = 0.02032 millimeters" for isolation milling.
--offset  You need to set half your tool diameter or a greater value for the --offset parameter.
--zsafe travel height
--zchange z height for changing from milling to drilling tool
--mill-feed feed rate
--mill-speed spindle RPM


Even when set to metric, MACH3 shows the maximum dimensions in imperial inches.
Use an electrical probe to set Z=0.
I made a special probe cable for this purpose as the toolheight-sensor wouldn't reliably touch the top side of the PCB.
Also make sure the PCB is insulated against the machine so the probe isn't always triggered.

I used paper to do this and also to level out the board (after meassuring all 4 corners).
TODO: My board was still slightly bent. I need a way to compensate for Z-differences in the 4 corners+center by software.

--mill-feed 100 --mill-speed 6000 seems to be a good value to start with.


I tried a chinese engraving tip and it wasn't a good fit.
The tiny Z errors and the fact that the engraving tip quickly gets bigger the deeper it gets are a bad combination.
The smallest flat cutter I could find is 0.8mm. Way too large. I need to look for something along the lines of 0.1mm.


DONE:  Wrote a program to take 9 Z meassurements and adjust the g-code PCB3GCode returns.

(EMC2 specific) There seems to be script named "etch_z_adjust" that uses the electrical probe to meassure the exact Z=0 height every 10cm before starting to mill.

A thin layer of cutting oil seems to help too.

(Reprap specific) This "PcbSubtraction " pcb2gcode postprocessor adds probe commands to the g-code itself but is limited to 315 probes per PCB.

There is also a MACH3 visual basic macro but I just can't find the actual code to try it.

Keine Kommentare: