modified kikit script
This commit is contained in:
@@ -1,24 +1,306 @@
|
||||
## Panelize the board
|
||||
# Install kikit
|
||||
|
||||
Install `kikit`:
|
||||
```bash
|
||||
pipx install --system-site-packages kikit
|
||||
```
|
||||
|
||||
Panelize a finished PCB:
|
||||
```bash
|
||||
mkdir -p panel
|
||||

|
||||
|
||||
|
||||
# KiKit Fixture Post-Processor
|
||||
|
||||
Post-processing script for KiKit panelized PCBs that places any generated panel
|
||||
inside a fixed CNC fixture coordinate system.
|
||||
|
||||
The script:
|
||||
|
||||
- Centres the finished panel inside a predefined fixture opening
|
||||
- Adds mechanical alignment pin holes
|
||||
- Draws fixture reference geometry
|
||||
- Moves the complete design so the fixture origin is always at `(0, 0)`
|
||||
|
||||
The resulting output is intended for repeatable CNC manufacturing workflows
|
||||
where drilling, routing, and UV exposure all share the same physical fixture
|
||||
and machine datum.
|
||||
|
||||
---
|
||||
|
||||
# Fixture Geometry
|
||||
|
||||
## Outer Fixture Frame
|
||||
|
||||
| Parameter | Value |
|
||||
|---|---|
|
||||
| Width | 200.0 mm |
|
||||
| Height | 130.0 mm |
|
||||
|
||||
## Inner Fixture Opening
|
||||
|
||||
| Parameter | Value |
|
||||
|---|---|
|
||||
| Width | 153.4 mm |
|
||||
| Height | 87.0 mm |
|
||||
|
||||
The inner opening defines the usable panel area.
|
||||
|
||||
The region between the outer frame and inner opening forms the fixture rails.
|
||||
|
||||
---
|
||||
|
||||
# Alignment Pins
|
||||
|
||||
The script inserts four non-plated alignment holes:
|
||||
|
||||
- Diameter: `Ø 3.172 mm NPTH`
|
||||
- Naming: `PIN1`–`PIN4`
|
||||
- Positioning: fully user-defined absolute coordinates
|
||||
|
||||
This allows:
|
||||
|
||||
- deterministic CNC coordinates
|
||||
- compatibility with existing jigs
|
||||
- custom asymmetric fixtures
|
||||
- reuse across multiple panel layouts
|
||||
|
||||
---
|
||||
|
||||
# Coordinate System
|
||||
|
||||
After processing:
|
||||
|
||||
- The fixture outer top-left corner is positioned at `(0, 0)`
|
||||
- All PCB data is translated accordingly
|
||||
- Every generated panel shares the same global coordinate system
|
||||
|
||||
This creates deterministic CAM output suitable for automated tooling and
|
||||
repeatable fixture-based manufacturing.
|
||||
|
||||
---
|
||||
|
||||
# Usage
|
||||
|
||||
Place `fixture_postprocess.py` next to the source `.kicad_pcb` file and run KiKit:
|
||||
|
||||
```bash
|
||||
kikit panelize \
|
||||
--layout 'type: grid; rows: 1; cols: 2; space: 0mm' \
|
||||
--tabs 'type: fixed; width: 48mm; vcount: 1' \
|
||||
--cuts 'type: mousebites; drill: 1mm; spacing: 1.5mm' \
|
||||
--post 'origin: tl; script: move_to_origin.py' \
|
||||
--framing 'type: none' \
|
||||
../Flow_Controller.kicad_pcb panel/Flow_Controller_Panel.kicad_pcb
|
||||
-p myPreset.json \
|
||||
../Flow_Controller.kicad_pcb \
|
||||
panel/Flow_Controller_Panel.kicad_pcb
|
||||
```
|
||||
|
||||

|
||||
---
|
||||
|
||||
# Panel Layout Parameters
|
||||
|
||||
## Grid Layout
|
||||
|
||||
Adjust the panel dimensions using:
|
||||
|
||||
```text
|
||||
rows: <n>
|
||||
cols: <n>
|
||||
```
|
||||
|
||||
Examples:
|
||||
|
||||
- `1×1`
|
||||
- `1×2`
|
||||
- `2×2`
|
||||
|
||||
The script automatically recalculates centering offsets for the resulting panel size.
|
||||
|
||||
---
|
||||
|
||||
## Tool Diameter Compensation
|
||||
|
||||
The following values should match the routing tool diameter:
|
||||
|
||||
```text
|
||||
space
|
||||
slotwidth
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```text
|
||||
space: 2.1mm
|
||||
slotwidth: 2.1mm
|
||||
```
|
||||
|
||||
This is typically equal to the outline routing bit diameter.
|
||||
|
||||
---
|
||||
|
||||
# Processing Pipeline
|
||||
|
||||
The post-processing script performs the following operations:
|
||||
|
||||
1. Reads the fully panelized KiKit output
|
||||
2. Calculates the panel bounding box
|
||||
3. Calculates the offset required to centre the panel inside the fixture opening
|
||||
4. Translates the complete board dataset:
|
||||
- footprints
|
||||
- tracks
|
||||
- vias
|
||||
- zones
|
||||
- drawings
|
||||
- board outlines
|
||||
- substrate geometry
|
||||
- locked items
|
||||
5. Places four NPTH alignment pin footprints
|
||||
6. Draws fixture reference rectangles on the `User.1` layer
|
||||
7. Repositions the design so the fixture outer top-left corner equals `(0, 0)`
|
||||
|
||||
---
|
||||
|
||||
# Fixture Visualization
|
||||
|
||||
The script draws two rectangles on the `User.1` layer:
|
||||
|
||||
- Outer fixture boundary
|
||||
- Inner fixture opening
|
||||
|
||||
These graphics:
|
||||
|
||||
- are visible in KiCad
|
||||
- help verify positioning visually
|
||||
- are NOT placed on `Edge.Cuts`
|
||||
- are NOT exported into manufacturing Gerbers or NC drill files
|
||||
|
||||
They exist purely as fixture reference geometry.
|
||||
|
||||
---
|
||||
|
||||
# CNC Workflow
|
||||
|
||||
| Operation | File | Purpose |
|
||||
|---|---|---|
|
||||
| Drilling | Excellon `.drl` | PCB holes + fixture alignment pins |
|
||||
| Routing | `Edge.Cuts` Gerber | Board outlines and mousebite tabs |
|
||||
| UV exposure | Copper Gerbers | Soldermask/alignment registration |
|
||||
|
||||
Because all outputs share:
|
||||
|
||||
- identical `(0,0)` origin
|
||||
- identical alignment pin locations
|
||||
- identical fixture geometry
|
||||
|
||||
the PCB can remain mounted in the same physical fixture for the complete process.
|
||||
|
||||
No re-alignment or re-fixturing is required between operations.
|
||||
|
||||
---
|
||||
|
||||
# Alignment Pins
|
||||
|
||||
The script inserts four non-plated alignment holes:
|
||||
|
||||
- Diameter: `Ø 3.172 mm NPTH`
|
||||
- Naming: `PIN1`–`PIN4`
|
||||
|
||||
Users may override any coordinate manually.
|
||||
|
||||
---
|
||||
|
||||
# Default Pin Placement Calculation
|
||||
|
||||
For the default fixture dimensions:
|
||||
|
||||
```python
|
||||
OUTER_W_MM = 200.0
|
||||
OUTER_H_MM = 130.0
|
||||
|
||||
INNER_W_MM = 153.4
|
||||
INNER_H_MM = 87.0
|
||||
```
|
||||
|
||||
the resulting suggested coordinates are:
|
||||
|
||||
| Pin | X (mm) | Y (mm) |
|
||||
|---|---|---|
|
||||
| PIN1 (top) | 100.0 | 10.75 |
|
||||
| PIN2 (right) | 188.35 | 65.0 |
|
||||
| PIN3 (bottom) | 100.0 | 119.25 |
|
||||
| PIN4 (left) | 11.65 | 65.0 |
|
||||
|
||||
---
|
||||
|
||||
# Fixture Configuration
|
||||
|
||||
Edit the constants at the top of `fixture_postprocess.py`:
|
||||
|
||||
```python
|
||||
# ============================================================
|
||||
# Fixture geometry
|
||||
# ============================================================
|
||||
|
||||
OUTER_W_MM = 200.0
|
||||
OUTER_H_MM = 130.0
|
||||
|
||||
INNER_W_MM = 153.4
|
||||
INNER_H_MM = 87.0
|
||||
|
||||
# ============================================================
|
||||
# Alignment pins
|
||||
# Absolute fixture-space coordinates in millimetres
|
||||
# ============================================================
|
||||
|
||||
PIN_DIAMETER_MM = 3.172
|
||||
|
||||
# Suggested defaults:
|
||||
# top = centered in top rail
|
||||
# right = centered in right rail
|
||||
# bottom = centered in bottom rail
|
||||
# left = centered in left rail
|
||||
|
||||
PIN1_X_MM = 100.0
|
||||
PIN1_Y_MM = 10.75
|
||||
|
||||
PIN2_X_MM = 188.35
|
||||
PIN2_Y_MM = 65.0
|
||||
|
||||
PIN3_X_MM = 100.0
|
||||
PIN3_Y_MM = 119.25
|
||||
|
||||
PIN4_X_MM = 11.65
|
||||
PIN4_Y_MM = 65.0
|
||||
```
|
||||
|
||||
These values may be adjusted freely without changing the placement logic.
|
||||
---
|
||||
|
||||
# Design Constraints
|
||||
|
||||
The generated panel must fit completely inside the inner fixture opening.
|
||||
|
||||
If the panel exceeds the available space, the script emits:
|
||||
|
||||
```text
|
||||
WARNING: panel … is larger than the inner opening
|
||||
```
|
||||
|
||||
Possible solutions:
|
||||
|
||||
- reduce `rows`
|
||||
- reduce `cols`
|
||||
- reduce KiKit frame width
|
||||
- reduce spacing
|
||||
- use a smaller PCB design
|
||||
|
||||
---
|
||||
|
||||
# Intended Use Case
|
||||
|
||||
This workflow is intended for:
|
||||
|
||||
- CNC isolation milling
|
||||
- UV mask alignment systems
|
||||
- repeatable prototyping fixtures
|
||||
- hybrid PCB manufacturing workflows
|
||||
- automated or semi-automated PCB handling
|
||||
|
||||
The primary design goal is deterministic panel placement independent of PCB size.
|
||||
|
||||
## Exporting gcode files from KiCad
|
||||
|
||||
|
||||
Reference in New Issue
Block a user