4.6 KiB
TODO: Add table of content
MSLA PCB Exposure: KiCad → Photon Mono 4
Using an MSLA (Masked Stereolithography Apparatus) resin printer for creating PCBs is a technique known as "Direct UV Exposure." Instead of printing a plastic part, you use the printer's LCD screen as a dynamic digital mask to cure photosensitive materials (etch resist, solder resist and silkscreen) on a copper board.
KiCad PCB layers need to be converted to .pm4n files for direct UV exposure on an Anycubic Photon Mono 4 (9024×5120 px, 17 µm/px, 1494.12 DPI) on the screen size of 153.408 x 87.040 mm.
Setup
1. KiCad: Set your design grid
In KiCad's PCB editor, go to Preferences → Preferences → PCB Editor → Grids and add a custom grid of 0.017 mm. This ensures trace edges land on pixel boundaries and avoids the sub-pixel rounding that causes the ±1px size error people see with arbitrary grids.
2. Create the Dummy.pm4n file
Open CHITUBOX Basic slicer (or any other slicer that works for your resin printer), select printer Anycubic Photon Mono 4, slice any tiny STL (e.g.: 1×1×0.05 mm box), and save as Dummy.pm4n in the same directory as export.sh.
This file is reused for every job — it carries the correct LCD resolution metadata.
3. Install dependencies
python3 -m venv .venv
source .venv/bin/activate
pip install pygerber Pillow numpy
Or activate the venv once and put source .venv/bin/activate in your shell profile.
4. Export multiple layers (e.g. copper + soldermask + silkscreen)
./export.sh \
--layers Front,Back,F.Mask,B.Mask,F.SilkS,B.SilkS \
--invert Front,Back,F.Mask,B.Mask,F.SilkS,B.SilkS \
--mirror Front,F.Mask,F.SilkS \
--exposure 60 \
../kicad2panel/panel/Flow_Controller_Panel.kicad_pcb
It should output:
Plotted to './output/gerbers/Flow_Controller_Panel-Front.gbr'.
Plotted to './output/gerbers/Flow_Controller_Panel-Back.gbr'.
Plotted to './output/gerbers/Flow_Controller_Panel-F_Silkscreen.gbr'.
Plotted to './output/gerbers/Flow_Controller_Panel-B_Silkscreen.gbr'.
Plotted to './output/gerbers/Flow_Controller_Panel-F_Mask.gbr'.
Plotted to './output/gerbers/Flow_Controller_Panel-B_Mask.gbr'.
output/pm4n/Flow_Controller_Panel-Front.pm4n
output/pm4n/Flow_Controller_Panel-Front.preview.png
output/pm4n/Flow_Controller_Panel-Back.pm4n
output/pm4n/Flow_Controller_Panel-Back.preview.png
output/pm4n/Flow_Controller_Panel-F_Mask.pm4n
output/pm4n/Flow_Controller_Panel-F_Mask.preview.png
output/pm4n/Flow_Controller_Panel-B_Mask.pm4n
output/pm4n/Flow_Controller_Panel-B_Mask.preview.png
output/pm4n/Flow_Controller_Panel-F_Silkscreen.pm4n
output/pm4n/Flow_Controller_Panel-F_Silkscreen.preview.png
output/pm4n/Flow_Controller_Panel-B_Silkscreen.pm4n
output/pm4n/Flow_Controller_Panel-B_Silkscreen.preview.png
4.1. Check the layer preview
Check the output/pm4n/Flow_Controller_Panel-*.preview.png images — traces should appear black on white background.
- background = UV exposed = resist removed = etched away
- traces = dark = resist kept = copper stays
4.2. Check the printer exposure
Open the .pm4n in Chitubox Basic slicer to visually verify before printing.
4.3. Adjust exposure
Start with --exposure 60 and bracket from there — Bungard presensitized at 405nm typically lands between 30–120s depending on board vintage and storage.
Export single layer (e.g. copper)
Export the front layer as gerber
kicad-cli pcb export gerbers -o output/gerbers -l F.Cu ../kicad2panel/panel/Flow_Controller_Panel.kicad_pcb
It should output
Plotted to 'output/gerbers/Flow_Controller_Panel-Front.gtl'.
Convert the gerber to pm4n and preview
python3 gerber_to_pm4n.py Dummy.pm4n output/gerbers/Flow_Controller_Panel-Front.gtl \
--invert --mirror --exposure 120
It should output
output/pm4n/Flow_Controller_Panel-Front.pm4n
output/pm4n/Flow_Controller_Panel-Front.preview.png
Open the preview image
xdg-open output/pm4n/Flow_Controller_Panel-Front.preview.png
Open the output/pm4n/Flow_Controller_Panel-Front.pm4n in Chitubox Basic slicer to visually verify before printing.
Troubleshooting
kicad-cli: command not found — add KiCad to PATH:
export PATH="/usr/lib/kicad/bin:$PATH"
Or on Flatpak:
alias kicad-cli='flatpak run --command=kicad-cli org.kicad.KiCad'
Expected Gerber not found — KiCad's layer→filename mapping:
| Layer | Filename stem |
|---|---|
F.Cu |
Front |
B.Cu |
Back |
F.Mask |
F_Mask |
B.Mask |
B_Mask |
F.SilkS |
F_Silkscreen |