1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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.
|