Printed Circuit Board Milling


Creating Gerber Files

from KiCad

You can export Gerber files from the KiCad PCB editor by using the GUI. The process is called 'plotting', in accordance with traditional nomenclature. For workflow automation, however, you want to make use of the Python scripting interface. Here is an example script from the official code repository.

I wasn't able to find documentation for the pcbnew Python module and ended up using pydoc to create an HTML documentation page.

from Eagle

from Fritzing

Creating G-code from Gerber Files


Building From Source


There are a bunch of command line arguments for pcb2gcode. For example,

pcb2gcode --metric --front My_PCB.gbr --zsafe 20 --zchange 10 --zwork -1 --offset 0 --mill-feed 10 --mill-speed 800

The alternative (and more elegant) way is to write the settings to a file called millproject, which will be picked up by pcb2gcode by default.

Sending G-code to the Milling Machine


LinuxCNC ( is a command-line tool for sending G-code to a CNC machine. G-code can be sent over the parallel port of a PC or via a PCI extension card installed in a desktop PC.

Building LinuxCNC from Source

Installing the dependencies on a Debian Linux distribution like Ubuntu:

sudo apt-get install libudev-dev libmodbus-dev libusb-1.0-0-dev bwidget libtk-img tclx8.4 

Getting the source code:

git clone

Building the source:

cd linuxcnc
./configure --with-realtime=uspace --enable-non-distributable=yes

Using LinuxCNC with AXIS

AXIS is the standard graphical user interface for LinuxCNC. To start LinuxCNC with the AXIS GUI you need to edit the .ini file that you provide to linuxcnc as parameter. Add the [DISPLAY] section if it is missing, and add the line DISPLAY = axis like shown below.

DISPLAY = axis


You can use a scouring pad or the rough side of a kitchen sponge to enhance the board visually and, more importantly, to remove copper chips that may have stuck inside the milled tracks and cause short circuits. Use a dab of ammonia for better results.