aboutsummaryrefslogtreecommitdiff
path: root/knowledge/topics
diff options
context:
space:
mode:
authorLouis <louis@dnge.de>2026-11-11 10:08:41 +0100
committerLouis <louis@dnge.de>2026-11-11 10:08:41 +0100
commit2e433fcd0d1afadd8ab786dd30d7d4546bdee43d (patch)
treef2a5603703d56b08c1eaa672eaf529ec4b2cc3fa /knowledge/topics
downloadhw-toolchain-2e433fcd0d1afadd8ab786dd30d7d4546bdee43d.tar.gz
hw-toolchain: placer, routers and KiCad helpers for agent-driven hardware work
Rust placer (simulated annealing) and negotiated-congestion router for 2-layer KiCad boards, pnr.sh to place, route, DRC-check and install candidates, Python KiCad helpers, repo conventions (AGENTS.md) and the tool documentation under knowledge/. Konnect (KiCad MCP, AGPL) as a submodule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'knowledge/topics')
-rw-r--r--knowledge/topics/3d-models.md30
-rw-r--r--knowledge/topics/din-rail-format.md65
-rw-r--r--knowledge/topics/netclasses.md47
-rw-r--r--knowledge/topics/placement-for-routing.md37
4 files changed, 179 insertions, 0 deletions
diff --git a/knowledge/topics/3d-models.md b/knowledge/topics/3d-models.md
new file mode 100644
index 0000000..095b96e
--- /dev/null
+++ b/knowledge/topics/3d-models.md
@@ -0,0 +1,30 @@
+# 3D models: where to get them
+
+Use manufacturer models first. They are usually exact and coloured, and they come with dimensions you can check against the datasheet. Draw your own only when there is none. Always check the placement with [Model check](../tooling/model-check.md) and a `kicad-cli pcb render`.
+
+## Phoenix Contact
+
+No account is needed. Product URLs look like `https://www.phoenixcontact.com/en-us/products/printed-circuit-board-terminal-mkds-1-8-35-1751303` (`…-mkds-1-<n>-35-<PN>`).
+
+1. On the product page, under the product pictures, click **3D view and CAD download**. This opens Phoenix's embedded TraceParts viewer.
+2. Set **File format** to **STEP AP214** and click **Download**. A Friendly Captcha runs automatically (proof of work, no puzzle). The browser gets a ZIP with `pxc_<PN>_<rev>_<name>_3D.stp` and `<PN>.txt` (TraceParts metadata).
+3. The same format list also offers KiCad footprints and symbols (SamacSys, SnapMagic) and many other formats.
+
+Some product pages have a direct button named after the .stp file. It requests a signed `product-download.phoenixcontact.com` link that `curl` can fetch, with no ZIP or captcha.
+
+Scripted access:
+
+- phoenixcontact.com answers `curl` and plain HTTP fetchers with 403 (bot protection). A real browser (e.g. Playwright) works.
+- A cookie banner covers the page. Driving the Downloads controls through the DOM avoids clicking it: select the `<select>` option, then `button.click()`.
+- The download is a signed S3 link (`traceparts-cache.s3.eu-west-1.amazonaws.com/...`, valid for 6 h) that `curl` can fetch.
+
+Model frame (MKDS 1, probably the same for Phoenix terminal blocks in general):
+
+- Origin at a body corner: x 0…length, y 0…depth (3D, y up), board surface at z = 0, pins below.
+- The wire entry is the y = 0 face, pin 1 at x = 2.0 mm, pin row at y = 3.6 mm.
+- For a KiCad-generator-style footprint (pin 1 at the origin, wire entry at +Y), the model needs offset (−first pin x, −pin row y, 0) and no rotation, e.g. `(xyz -2 -3.6 0)`.
+- The file is an assembly (about 25 solids with colours, about 3 MB), which `tools/model_check.py` refuses. Check a flattened copy instead (see [Model check](../tooling/model-check.md)), and keep the original in the library for its colours.
+
+## easyeda2kicad conversions
+
+Their offsets and rotations are often wrong. Check every converted model with [Model check](../tooling/model-check.md).
diff --git a/knowledge/topics/din-rail-format.md b/knowledge/topics/din-rail-format.md
new file mode 100644
index 0000000..e418ebc
--- /dev/null
+++ b/knowledge/topics/din-rail-format.md
@@ -0,0 +1,65 @@
+# DIN-rail board format
+
+The board format that `tools/din_template.py`, `tools/height_check.py`, `tools/housing_inputs.py` and `tools/connector_tab.py` assume: one flat base PCB in a 3D-printed DIN-rail housing, with modules (KiCad design blocks) placed on it as tiles. The housing CAD model itself is not part of this repo. The tools need only its dimensions, which live in `dims()` in `tools/din_template.py`.
+
+## Layout
+
+- Height (perpendicular to the rail) is fixed. Width grows in TE steps.
+- One shared base PCB lies flat at the lowest level of the housing. Modules are design blocks placed on it as tiles, not separate PCBs.
+- Two rows of tiles, one along the top edge and one along the bottom edge, with a strip between them for power and the shared bus. A full-height tile at one end is allowed.
+- Field connectors and jacks exit through the top or bottom shoulder of the housing, at the board edge. The side walls along the rail are covered by neighbouring devices and are never used.
+
+## Dimensions
+
+Commercial DIN housings are 17.5 mm per TE, 90 mm tall and 53–58 mm deep, with a raised front 45 mm wide.
+
+- **Housing outer:** width k × 18 − 0.5 mm (18 mm per TE as spaced in distribution boards, 0.5 mm play), height 90 mm, front 45 mm wide and centred, shoulders 22.5 mm each.
+- **Walls:** 2.0 mm printed walls and a 0.5 mm PCB-to-wall gap give a PCB of k × 18 − 5.5 mm by 85.0 mm:
+
+ | TE | PCB width |
+ | -- | --------- |
+ | 2 | 30.5 mm |
+ | 4 | 66.5 mm |
+ | 6 | 102.5 mm |
+ | 12 | 210.5 mm |
+- **Height zones:** within the PCB height, the outer 20 mm at the top and bottom sit under the shoulders (low parts and edge connectors). The central 45 mm sits under the front (tall parts).
+- **Tiles:** a top and a bottom row of about 38 mm each, plus a bus strip of about 9 mm. The corner posts take room that no tile can use.
+- **Height limits** (checked by [Height check](../tooling/height-check.md)):
+ - top side: 31 mm, and 45 mm inside the front-cap box;
+ - outside the shoulder step lines (|y| > 33 mm): falling 1:1 from 19 mm to 9.5 mm at the PCB edge;
+ - bottom side: 3 mm for parts and clipped THT leads.
+
+## Edge connectors on a tab
+
+The PCB edge is 2.5 mm inside the outer wall face (0.5 mm gap + 2.0 mm wall). So where a connector sits, the PCB runs out as a 2.0 mm tab into the wall notch, and the connector's mating face or wire entry ends flush with the tab edge.
+
+- **Why 2.0 mm:** the face sits 0.5 mm behind the outer wall face. That is easy to reach with a plug, ferrule or screwdriver, guided by the notch, and never proud of the housing when print tolerances add up. The connector is fully supported, and the tab closes most of the opening under it.
+- **Tab width** = the connector bodies (not their courtyards). Adjacent connectors share one tab and one notch.
+- **Tools:** `tools/connector_tab.py` draws the tab. [Housing inputs](../tooling/housing-inputs.md) prints the numbers for the housing's notches.
+- **The block keeps its edge:** pours, group bboxes and the router's area keep ending at the old edge; only the outline grows.
+
+## Mounting
+
+- **Screw stack:** a countersunk M3 from the back passes through the base plate, a spacer and the PCB into a heat-set insert in a shell post.
+- **PCB holes:** NPTH 3.2 mm at ±(PCB width/2 − 4.5), ±28.5 mm from the board centre (+Y = top edge). Each hole has an Ø7 keep-out for parts.
+- **Clips:** two rail clips per housing, so at least 4 TE while the screws sit at the corners.
+
+## KiCad templates
+
+`tools/din_template.py [k ...]` (KiCad's Python) writes, for each TE count k:
+
+- **`libraries/footprints/HW.pretty/DIN_Housing_<k>TE.kicad_mod`**, origin at the board centre, marked "not in schematic" and excluded from BOM and position files. It has:
+ - the 4 NPTH holes;
+ - an F.CrtYd keyhole per hole (shell post Ø7 + 0.25 plus its rib to the side wall);
+ - a B.CrtYd per spacer (Ø6 + 0.25). DRC's courtyard checks then flag parts on posts, ribs and spacers;
+ - on Dwgs.User: the front-cap box, the shoulder step lines and height notes;
+ - the housing STEP `${HW_LIB}/3dmodels/HW.3dshapes/DIN_Housing_<k>TE.step` as its 3D model at 35 % opacity, if you have one.
+- **`libraries/templates/DIN_<k>TE/`**, a KiCad project template:
+ - board outline k × 18 − 5.5 × 85 mm, centred at (150, 100) on A4;
+ - grid and origins at the board centre;
+ - design rules from `tools/din_base.kicad_pro`;
+ - net classes from [Net classes](netclasses.md).
+
+## Materials
+
+PETG or ASA, not PLA, which softens in warm cabinets. Printed parts are not V-0 like commercial housings, so keep mains out or use a flame-retardant material.
diff --git a/knowledge/topics/netclasses.md b/knowledge/topics/netclasses.md
new file mode 100644
index 0000000..d3f290f
--- /dev/null
+++ b/knowledge/topics/netclasses.md
@@ -0,0 +1,47 @@
+# Net classes
+
+Use one net-class table for every board in a repo, kept in one file and written into each project by `tools/netclasses.py`. Modules are pasted onto shared base boards as design blocks, so their classes must not drift or clash. The router takes its track widths from these classes too.
+
+## Use
+
+``` sh
+python3 tools/netclasses.py modules/*/*.kicad_pro libraries/templates/*/*.kicad_pro # write
+python3 tools/netclasses.py --check modules/*/*.kicad_pro # report drift
+python3 tools/netclasses.py --table other.json board.kicad_pro
+```
+
+The table is `netclasses.json` at the repo root. Without it the script uses a small generic default (Ethernet, USB, Power, Ground, Default 0.2 mm). Format:
+
+``` json
+{
+ "clearance": 0.2, "via": 0.6, "drill": 0.3, "default_width": 0.2,
+ "track_widths": [0.2, 0.25, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0],
+ "classes": {
+ "Ethernet": [0.25, 0.25, 0.2, ["*/ETH_TX?", "*/ETH_RX?"]],
+ "Bus": [1.0, null, null, ["+3V3", "+5V", "+24V"]],
+ "Power": [0.5, null, null, ["*/3V3", "*/VBUS", "Net-(*-SW)"]],
+ "Ground": [0.4, null, null, ["GND"]]
+ }
+}
+```
+
+Each class is `[track width, diff-pair width, diff-pair gap, patterns]`, listed in priority order. The script writes `net_settings.classes`, `netclass_patterns`, and the track-width, via and diff-pair palettes. All other project settings stay as they are. `tools/din_template.py` applies the table to new templates.
+
+Close the project in KiCad first. An open editor writes its own copy back on save, and reverting the board does not reload net classes.
+
+## Rules
+
+- **One source.** Edit the table, then write it into every project.
+- **Sheet-independent patterns:** `*/RTD_COM`, not `/My Sheet/RTD_COM`. The same list then works in a module's test project and on the base board under any sheet name.
+ - Global power nets (`+3V3`, `GND`) match by name.
+ - Auto-named nets use wildcards for the reference, e.g. `Net-(*-SW)` for any buck switch node. Better still, give such nets a label.
+- **Names are reserved repo-wide.** Module-specific classes live in the same table. A pattern that matches nothing does no harm, and no other module can reuse a name with other widths.
+- **Widths are defaults, not minimums.** Short, narrower escapes (e.g. 0.2 mm out of a small pad) stay legal. Keep a margin over the fab's minimum: 0.2 mm on two layers, where 0.10 mm is a typical minimum.
+- **Pattern matching:** KiCad matches patterns against the whole net name. When several match, the lower `priority` (earlier in the table) wins.
+
+## Sizing hints
+
+- **Supply bus** carrying about 2 A: 1.0 mm of 35 µm outer copper carries about 2 A at 10 °C rise (IPC-2221).
+- **Local rails** of a few hundred mA: 0.5 mm keeps the drop and inductance low.
+- **Field lines at screw terminals** (0–10 V, tach, digital outputs, RS-485): about 0.4 mm. The signals are small, but ESD and surge currents run from the terminal to the TVS.
+- **Ethernet 10/100 and full-speed USB** on short runs (< 20 mm) need no impedance control on a 2-layer board. The classes exist so that the pairs route together.
diff --git a/knowledge/topics/placement-for-routing.md b/knowledge/topics/placement-for-routing.md
new file mode 100644
index 0000000..2a01f36
--- /dev/null
+++ b/knowledge/topics/placement-for-routing.md
@@ -0,0 +1,37 @@
+# Placement for routing
+
+Rules learned while routing dense 2-layer boards (an ESP32 + Ethernet controller module, an RTD front end, a sniffer board). Every rule here was a failed route first. Check them before routing. [Placement check](../tooling/placement-check.md) catches only some of them, because the ratsnest cannot see routing channels.
+
+## Fine-pitch ICs (QFP, 0.5 mm pitch)
+
+- **Fan-out band:** keep about 1 mm between a pin row's outer pad ends and the next part's pads. At 0.63 mm, a regulator-output pin could not reach its cap 1.3 mm away. A 0.2 mm track needs 0.2 + 2 × 0.2 mm, plus margin. The [Placer](../tooling/placer.md) enforces this band.
+- **Caps in pin order:** a column of decoupling caps beside a pin row must follow the pins' order. If two caps are swapped, one pin's line cuts across its neighbour. Slot optimisers miss this, because the ratsnest does not care, so set such caps by hand, next to their pins.
+- **Pin groups that leave together** (SPI, chip select, interrupt) need a clear band in front of them, toward where they go. A crystal resistor sitting over the CS pin blocked it; a 1 mm shift fixed it.
+- **Route first the pin that must cross a bundle.** The middle pin of a group is boxed in if its neighbours are routed first. The negotiating router handles this by itself.
+- **Analog supply pins in one row** join on the inside of the pad ring. The outside stays free for the PHY lines.
+- **Fine-pitch parts on the 0.05 mm grid:** put their origins on multiples of 0.05 mm, or the router's cells fall between the pins.
+
+## Passive strips
+
+- **Grid:** 2.4 mm pitch, rows 4.0 mm apart. A pitch of 1.6–1.8 mm left pads with no escape.
+- **Order the slots** by which pin each part serves. `tools/placement_slots.py` searches the order; check it by hand afterwards.
+- **Lines that pass through a row** need a gap of at least 1.1 mm between pads per 0.2 mm line. A row of 0603 pull-ups at 1.5 mm pitch across a 6-line bus blocked it.
+
+## Pull-ups on a bus
+
+- Do not put them where the bus fans out of the IC.
+- Stack them at the edge of the channel the bus runs in, with the supply pads facing out.
+ - Lines that continue past a stack can tap only two pull-ups without crossings: one from the lane between the supply and signal pads, one from outside.
+ - The third needs a crossing. Put its pull-up at the bottom, so its line can dip under the outside line and come up below its pad.
+ - Order the stack so that this dip is also a crossing the pin orders need anyway.
+- A vertical pull-up directly over the pin it serves is good where the pin's line ends there, not in the middle of a bus.
+
+## Direction of 2-pad parts
+
+- A ferrite between two rails faces the rail it feeds: its filtered pad toward the caps it supplies. Facing the other way, the filtered rail wrapped around and enclosed the input pad.
+
+## Modules and blocks
+
+- No F.Cu under a module that has pads on its underside. B.Cu under it is fine.
+- Block nets stay inside the block's tile, so it can become a design block. Make the module board the tile plus the copper-to-edge clearance on the sides that face other blocks, so DRC enforces this. Alternatively, use `area = "pours"` in `route.toml`.
+- No test-harness connector on a module board, if the module is only ever built inside a larger board. A breakout header only adds lines that cross the tile and are deleted when the block is reused. Use no-connect flags on the interface pins, and `[[escape]]` lines in `route.toml` so they stay reachable.