diff options
Diffstat (limited to 'knowledge/tooling/compose-board.md')
| -rw-r--r-- | knowledge/tooling/compose-board.md | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/knowledge/tooling/compose-board.md b/knowledge/tooling/compose-board.md new file mode 100644 index 0000000..41c8b25 --- /dev/null +++ b/knowledge/tooling/compose-board.md @@ -0,0 +1,48 @@ +# Compose board tool (compose_board.py) + +`tools/compose_board.py` builds a base board from routed module boards. It copies each module's footprints, tracks, vias, pours and drawings onto the base board as one tile (a KiCad group named after the sheet). It turns the tile 0 or 180° and moves it, and renames references and nets to the base board's schematic. The modules stay the source: rebuild to pick up a changed module. + +## Use + +``` sh +. tools/kicad_env.sh +cp libraries/templates/DIN_6TE/DIN_6TE.kicad_pcb myboard/myboard.kicad_pcb # start from an empty template +$KPY tools/compose_board.py myboard/compose.json +$KPY tools/sync_board.py myboard/out/myboard.net myboard/myboard.kicad_pcb # paths, values, fields +$KPY tools/silk_refs.py myboard/myboard.kicad_pcb +``` + +Close the board in KiCad first. The `.kicad_pro` is restored after SaveBoard. + +## Requirements on the schematic + +- **References offset per sheet:** the base schematic uses the modules' block sheets with references offset per sheet (`U1` → `U601` with offset 600). A block used twice is one sheet file with two instance paths. +- **Nets through the pads:** nets come from the base netlist through the pads. A module net takes the base net of its pads (`/Iso/GND_ISO` → `/Iso 1/GND_ISO`, `/Iso/TXD` → `/MB1_TXD`). All pads of a module net must agree, or the script stops and lists them. +- **`repin`:** a pad whose net the root sheet changed, such as an address strap that is GND in the module and +3V3 on the base board. Its module copper is left out from the pad up to the first via or junction. A pad that loses its only link shows in DRC as unconnected. + +## Spec (JSON) + +- `board`, `netlist`; +- `modules`: per module + - `board`, `sheet`, `offset`; + - `block`: the module's block rectangle in its own coordinates (pours, not the test outline); + - `rot` (0 or 180); + - `at`: top-left corner of the turned block on the base board; + - `skip`: e.g. the module's housing post, which the base template already has; + - `repin`; +- `parts`: base-sheet parts (pull-ups) placed from the netlist's footprint; +- `tabs`: `bottom` / `top` connector lists for [connector_tab.add_tabs](connector-tab.md). + - `tab_merge` (mm, default 3): bodies closer than this share one tab. + - The template outline is a `gr_rect`. Compose turns it into segments first, so `add_tabs` can split them. + +## What it handles and what not + +- Each tile's pours get priority `module priority + index`. Butting tiles' GND pours touch, which DRC reports as `zones_intersect` at equal priority. +- Copies keep the module's routing exactly. Base-board nets between tiles stay unrouted; route them afterwards, e.g. with the [Rust router](rust-router.md) and the whole board as `[[fixed]]` copper. +- Rotations other than 0/180° are not tested. +- KiCad API notes: + - `FOOTPRINT.Duplicate(addToParentGroup)` takes an argument; the other items' `Duplicate()` takes none. + - Cast copies with `Cast_to_FOOTPRINT`, `Cast_to_ZONE` and `.Cast()`. + - Pads keep the source board's net objects until `SetNet` is called with the base board's. + +Related: [KiCad notes (sync_board)](kicad.md), [Placer](placer.md), [DIN-rail board format](../topics/din-rail-format.md). |
