Skip to content

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.

Figure 1: The tools to be used: v-tip engraving bit for engraving traces (left), end mill for milling the edge cut (right).

Alternatively, Tapered end mill bits and tipped milling bits bits can be used as well.

Other sources for milling bits are:

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.

Figure 2: Clicking 'Board setup', the PCB icon with the gear at the top left in the PCB editor.

Figure 3: Changing the minimum clearance, minimum track width, and the minimum through hole diameter.

Figure 4: The DRC throws errors. It worked and discovered unfulfilled constraints.

Figure 5: The design rule violations need to be fixed manually. The track width can be fixed by selecting 'Tracks' in the selection filter to only select tracks and nothing else. Then, draw a selection box over the whole board. Click the wrench icon at the left side bar which opens the property manager. There, you could view the width of the tracks and change it.

Figure 6: For the holes, you can do the same. The parameter to change is 'Hole Size X'.

Figure 7: Running the DRC then does not lead to any errors.

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 .gerber files 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 .gerber files.
  • 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).

Figure 8: The generated files.

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.

Figure 9: For generating the tool path, use the program 'mill 2D PCB' for the Carvera CNC milling machine.

Figure 10: You could configure everything by working with the corresponding nodes in the displayed graph.

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

Figure 11: The generated tool path. Note that there are some parts of the path that are actually not desired at the locations of the tabs. This could be fixed by deactivating tabs or making the tabs longer. Furthermore it can be seen that some traces are not milled properly. I did not notice this at that point, but for future, it is very important to check that for milling.

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.

Figure 12: Pressing onto the stock to ensure it is flat.

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:

  1. Using the machine’s wireless probe.
  2. 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.
  3. 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. The S parameter specifies the speed of the spindle. To turn off the spindle, use M5.

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:

  1. 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.
  2. 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).