added UVtools patch

This commit is contained in:
cpu
2026-06-14 11:38:45 +02:00
parent f5eca9efa4
commit 9bcea25f78
14 changed files with 577 additions and 840 deletions

111
Readme.md
View File

@@ -118,94 +118,81 @@ Use the project [kicad2gcode](https://gitea.virtonline.eu/2HoursProject/kicad2gc
## Appendix: Automated script
Automate the conversion from KiCAD to print files using a script.
Automate the conversion from KiCAD to print files using a CLI.
### 1. The `Dummy.pm4n` file
Make sure you have the `Dummy.pm4n` file specific to your printer. See the section [5. Create the `Dummy.pm4n` file](#5-create-the-dummypm4n-file) above.
### 2. Install dependencies
### 2. Install UVtools wrapper
Follow the UVtools wrapper [installation guide](UVtools/Readme.md)
### 3. Export KiCAD gerbers
```bash
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.
### 3. Export multiple layers (e.g. copper + soldermask + silkscreen)
```bash
./export.sh \
--layers F.Cu,B.Cu,F.Mask,B.Mask,F.SilkS,B.SilkS \
--invert F.Cu,B.Cu,F.Mask,B.Mask,F.SilkS,B.SilkS \
--mirror F.Cu,F.Mask,F.SilkS \
--exposure 60 \
kicad-cli pcb export gerbers \
-o gerbers \
-l F.Cu,B.Cu,F.Mask,B.Mask,F.SilkS,B.SilkS \
../kicad2panel/panel/Flow_Controller_Panel.kicad_pcb
```
It should output:
Output:
```bash
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
Plotted to 'gerbers/Flow_Controller_Panel-Front.gtl'.
Plotted to 'gerbers/Flow_Controller_Panel-Back.gbl'.
Plotted to 'gerbers/Flow_Controller_Panel-F_Silkscreen.gto'.
Plotted to 'gerbers/Flow_Controller_Panel-B_Silkscreen.gbo'.
Plotted to 'gerbers/Flow_Controller_Panel-F_Mask.gts'.
Plotted to 'gerbers/Flow_Controller_Panel-B_Mask.gbs'.
```
#### 3.1. Check the layer preview
Check the `output/pm4n/Flow_Controller_Panel-*.preview.png` images — traces should appear black on white background.
### 4. Exposure
We need to **invert all** layers: `F.Cu,B.Cu,F.Mask,B.Mask,F.SilkS,B.SilkS`.
We need to **mirror all front** layers: `F.Cu,F.Mask,F.SilkS`.
Traces should appear black on white background.
- background = UV exposed = resist removed = etched away
- traces = dark = resist kept = copper stays
#### 3.2. Check the printer exposure
Open the `.pm4n` in `Chitubox Basic` slicer to visually verify before printing.
#### 3.3. Adjust exposure
Start with `--exposure 60` and bracket from there — Bungard presensitized at 405nm typically lands between 30120s depending on board vintage and storage.
### 4. Export single layer (e.g. copper)
Export the front and back **copper** layers for 120 seconds exposure
```bash
pcb-expose.sh Dummy.pm4n gerbers/Flow_Controller_Panel-Front.gtl \
--invert --mirror --exposure 120 \
--output pm4n/Flow_Controller_Panel-Front.pm4n
Export the front layer as gerber
```bash
kicad-cli pcb export gerbers -o output/gerbers -l F.Cu ../kicad2panel/panel/Flow_Controller_Panel.kicad_pcb
```
It should output
```bash
Plotted to 'output/gerbers/Flow_Controller_Panel-Front.gtl'.
pcb-expose.sh Dummy.pm4n gerbers/Flow_Controller_Panel-Back.gtl \
--invert --exposure 120 \
--output pm4n/Flow_Controller_Panel-Back.pm4n
```
Convert the gerber to pm4n and preview
Export the front and back **soldermask** layers for 300 seconds exposure
```bash
python3 gerber_to_pm4n.py Dummy.pm4n output/gerbers/Flow_Controller_Panel-Front.gtl \
--invert --mirror --exposure 120
pcb-expose.sh Dummy.pm4n gerbers/Flow_Controller_Panel-F_Mask.gtl \
--invert --mirror --exposure 300 \
--output pm4n/Flow_Controller_Panel-F_Mask.pm4n
pcb-expose.sh Dummy.pm4n gerbers/Flow_Controller_Panel-B_Mask.gtl \
--invert --exposure 300 \
--output pm4n/Flow_Controller_Panel-B_Mask.pm4n
```
It should output
Export the front and back **silkscreen** layers for 300 seconds exposure
```bash
output/pm4n/Flow_Controller_Panel-Front.pm4n
output/pm4n/Flow_Controller_Panel-Front.preview.png
pcb-expose.sh Dummy.pm4n gerbers/Flow_Controller_Panel-F_Silkscreen.gtl \
--invert --mirror --exposure 300 \
--output pm4n/Flow_Controller_Panel-F_Silkscreen.pm4n
pcb-expose.sh Dummy.pm4n gerbers/Flow_Controller_Panel-B_Silkscreen.gtl \
--invert --exposure 300 \
--output pm4n/Flow_Controller_Panel-B_Silkscreen.pm4n
```
### 5. Verify
Open the preview image
```bash
xdg-open output/pm4n/Flow_Controller_Panel-Front.preview.png
```
Continue at the [4. Check the printer exposure](#4-check-the-printer-exposure) section.
Open the `.pm4n` files in **Chitubox Basic** slicer to visually verify before printing. See the section [4. Check the printer exposure](#4-check-the-printer-exposure).
---