How to Fabricate PCBs (In-House)

This page is a reference explaining how to fabricate PCBs from copper-foiled stocks using a CNC milling machine. The milling machine present at our Fab Lab is a Carvera Makera. It is assumed that you already have a PCB design in KiCad.
Introduction
For PCB fabrication there are different possibilities. The one that is used in Fab Labs is milling traces out of a sheet of hard paper with a layer of copper. This material is also called FR-1 (fire retardant). There are several more types of fire retardant materials (FR-2, FR-3, ...) as well, but FR-1 is used, since it is easiest to mill that.
Milling PCBs to other materials might lead to end mills wearing down more quickly. Apart from that, the dust from other materials (e.g. FR-4) might be poisonous. This article describes how to combine using a milling machine and a laser.
A flat machine bed is crucial for achieving accurate results. To ensure this, the entire bed is best to be milled flat. This is usually done once. If PCBs are milled regularly on your machine, this has probably already been done.
Tools
Default tools to be used for milling PCBs are 0.2 mm V-bit for the traces and a 0.8 mm end mill for the outlines.

Alternatively, Tapered end mill bits and tipped milling bits bits can be used as well.
Other sources for milling bits are:
- https://www.gis-tec.com/deutsch/d_fraeser_fpcb_mc.htm
- https://www.gis-tec.com/deutsch/d_fraeser_fpcb_uc.htm
Finding Your Design Rules
To find the design rules for your machine, mill the following layout using the procedure described below.

This way, you can see which trace width and which distance between traces can be milled using your setup.

In this case, that would be 0.01inches (0.254mm) min trace width and 0.07inch (0.1778mm) min trace distance. As a minimum through hole diameter you need to choose one that is larger than the diameter of your end mill. For a 0.8mm end mill, through holes should have a diameter of 1mm. Otherwise, the tool path for the through holes will not be generated correctly.
These rules can be put into KiCad to check if your PCB design is possible to be fabricated using the design rule check in the PCB editor. I recommend you to generously increase the minimum trace width. Also, make sure that when you have diagonal traces that their distance is larger than horizontal/vertical traces. The reason is that KiCad does not check distances of diagonal traces properly.
Applying the Design Rules
Going back to your design in KiCad, add the design rules and check if they are fulfilled using the design rule check (DRC). The process is shown by one a previous design.






Note that when drawing tracks, they are drawn with the minimum track width. To change the track width after drawing, that needs to be done following the procedure described above.
Generating the Tool Path
To generate a tool path there are different possibilities:
- 2D images with colors black and white resembling the traces, edges, and holes of the PCB are to be loaded into mods. Those images need to be generated from the
.gerberfiles exported from KiCad (shown below). PDF files with the black-white images can be extracted directly from KiCad as well. - FlatCAM can be used to generate tool paths from
.gerberfiles. - The tool pcb2gcode also exists.
I only used the first approach, which will be described below in more depth.
Export the relevant layers for fabrication as .gerber files. The shown menu can be reached via 'File' > 'Fabrication Outputs' > 'Gerbers'. The relevant layers can be all copper layers 'Cu', and 'Edge.Cuts'. Clicking 'Plot' creats the corresponding .gerber files in the given output directory. If your design includes through-holes, you need to generate drill files as well (clicking on the button on the lower right).


For creating the necessary image files, one can use gerber2img. It is important for the aspect ratio of the images to stay the same so that traces, drills, and edges are placed consistently on top of each other. For that, first load the edge cut and lock the dimensions and the origin.

Continue loading the drill file and the traces.

It could be that the images that come out of gerber2img contain pixels that are not completely white or not completely black. This can lead to unwanted circles later in the tool path generation.

The following script can be used to binarize the images which fixes this problem.
#!/usr/bin/env python
# usage:
# `clean_pcb_png.py name_of_image.png`
from PIL import Image
import numpy as np
import typer
from pathlib import Path
def main(img_path: Path, threshold: int = 128):
suffix = img_path.suffix
stem = img_path.stem
directory = img_path.parent
# Open the image and convert to grayscale
image = Image.open(img_path).convert("L")
dpi = image.info.get("dpi")
# Apply threshold
binary_image = image.point(lambda p: 255 if p > threshold else 0)
# Save the binary image
save_kwargs = {"format": "PNG"}
if dpi:
save_kwargs["dpi"] = dpi
output_path = Path(directory) / f"{stem}_binarized{suffix}"
binary_image.save(output_path, **save_kwargs)
if __name__ == "__main__":
typer.run(main)
In the following, it is shown how to generate the tool path for a PCB using mods.


Default milling parameters I recommend (all values in mm):
- Tool 1 (engraving)
- diameter: 0.2 (depends on the bit used)
- cut depth: 0.12 (default)
- max depth: 0.12 (default)
- offset number: 8
- offset step-over: 0.5
- Tool 2 (cutting)
- diameter: 0.8 or 1 (depends on the bit used)
- cut depth: 0.6
- max depth: thickness of the stock (minus 0.3mm if a vacuum table was used)
- offset number: 1
- offset step-over: 0.5

For generating the tool path for drilling the holes, there are two options. The first one is to use the generic mods program for generating G-code for milling 2D PCBs.

Another option is to use the Carvera program. There, the drill holes can be set as traces image. Note, that the tool 1 parameters need to be adjusted for milling (default is using tool 1 for engraving).

Preparing to Mill
Ensuring stock is flat
To achieve optimal results and minimize the risk of breaking mill bits, ensure that your PCB stock material is perfectly flat. Normally, this is done using a straight edge, but if you do not have one readily available, you can use a caliper gauge. Holding it against the back of the material while looking towards a light source allows to check for gaps. If gaps are present, carefully bend the stock material until it was is flat as possible.

Fixturing Using Tape
To secure the stock material on the machine bed, use a thin, non-reinforced double-sided tape. In general, the cheapest double-sided tape works best. Reinforced tapes should be avoided as they can create uneven surfaces. For proper adhesion while still allowing easy removal, apply three strips of tape across the entire width.



Fixturing Using a Vacuum Pump
If there is a vacuum bed, this can be used as well. Small PCBs can be fixtured by putting them above the pocket in the lower left corner. If the stock is not big enough to cover all holes, they have to be covered otherwise, such as with tape or other pieces of PCB stock.

When milling the PCB, it is then very important to not mill through the whole stock, but to leave a small clearance of, e.g. 0.3mm so there are no holes the air can flow through.

Milling
There are three ways to correctly set the Z = 0 position:
- Using the machine’s wireless probe.
- Using a multimeter in continuity test mode (or a dedicated continuity tester) by placing probes between the copper layer and the V-bit, then slowly lowering the Z-axis in small steps.
- Listening for the V-bit (or the fat end mill) scratching the copper layer. This should also be done slowly and in small steps. Note, that it is important to turn on the spindle to do that. This can be done using the G-code:
M3 S5000. TheSparameter specifies the speed of the spindle. To turn off the spindle, useM5.

Then, mill the PCB, by loading the G-code onto the machine and starting the operation. Details on how to operate the milling machine are left to be explained at another place.

Afterwards, the PCB needs to be cleaned. This is done in two steps:
- Scratching with a razor blade or the blade of a utility knife over the surface. Thereby the angle of the blade w.r.t. the traces when looked from above was 45 degrees. The angle of the blade w.r.t. the surface of the board surface when looked from the side should be sharp. The blade was pulled, not pushed. This was done once in one direction and then from the opposite direction after turning the PCB.

- Cleaning residuals with steel wool. Note that one should use steel wool with thinner strings. When one uses the thinner steel wool, that should be done not at the electronics production work spaces in the lab, but at the other side of the room, at the work bench.

The final result then should look somehow like this (yes, the outcome is not consistent with the PCB designed above, but this is due to the images available :P).
