Skip to content

Design-rule values ​

The rule values a board is checked against, their overrides per pad, part and net, and the fab rule sets. Advanced. The DRC and ERC findings these rules raise are in findings.md; the sources and reasoning behind each value are in stackup-and-rules.md.

tsx
import PCB from '@pcbjs/core'
export default <PCB name="B" rev="0.1.0" rules={{ clearance: 0.2, thermal: { gap: 0.3 }, maskWeb: 0.13, edge: { width: 1.2, except: [J1] } }} />
ts
import { JLCPCB, mergeRules } from '@pcbjs/lib/rules'

const rules = mergeRules(JLCPCB, { clearance: 0.2 })   // JLCPCB with a wider clearance

Rules ​

Set on <PCB rules>, a preset or defineDefaultBoard({ rules }), in mm. Without any, BASE, which JLCPCB, PCBWay, OSH Park, Eurocircuits and Advanced PCB all accept.

RuleBASEUsed by
clearance0.1524copper to copper of another net; zone fill; the router
minTrackWidth0.1524track-width; the default route width
edgeClearance0.4copper to the outline; zones are inset by it
holeClearance0.3hole-to-copper; zone fill and the router; or { inner, outer, via }, see Hole rules by side
minHoleToHole0.5hole-to-hole; routed vias; or { pad, via } by kind of hole
minDrill0.3drill
minViaDrill0.3via-drill; the default via
minViaDiameter0.6via-size; the default via
minAnnularRing0.15annular-ring for vias; the default via
minPadAnnularRing0.2annular-ring for plated pads
silkMinWidth0.15silk-width; the default silk text thickness
silkMinHeight1the smallest silk ref height, see layout.md Silk refs
silkToPad0.15listed in README-fab, not enforced
maskExpansion0.05mask opening beyond each pad, per side
maskWebnonemask-web, see Mask web
maskWebByColornoneby mask colour, see Mask web
pasteShrink0paste shrink inside each SMD pad, per side
zoneMinWidth0.25pour necks narrower are removed
islands'remove''remove', 'keep' or { minArea }, pours.md Islands
thermalgap 0.5, spokeWidth 0.5, spokes 4, angle 90, minSpokes 2thermal reliefs, KiCad's defaults, merged key by key; angle also per pad and part
requireSourcingfalsea BOM row without any part number is the ERC warning unsourced-part
edgenone{ width, kinds?, except? }, see Edge band

Legacy fallback via: drill max(0.3, minViaDrill, minDrill), diameter max(0.6, minViaDiameter, drill + 2 × minAnnularRing), 0.3 and 0.6 in BASE. <PCB via={{ drill: 0.2, size: 0.45 }}> selects a board-wide preference independently of these minima. Fields merge individually over the fallback; explicit dimensions are emitted unchanged and DRC reports a violated drill, diameter or annular-ring minimum. Lowering manufacturing minima alone does not select smaller vias.

Hole rules by side ​

tsx
import PCB from '@pcbjs/core'
export default <PCB name="B" rev="0.1.0" rules={{ holeClearance: { inner: 0.33, outer: 0.28, via: 0.2 }, minHoleToHole: { pad: 0.45, via: 0.2 } }} />
  • outer holds on F.Cu and B.Cu, inner on inner layers, via from a via hole on every layer. minHoleToHole.via holds between two vias, pad between any other two holes. JLCPCB carries JLCPCB's values.
  • A number means both sides; an object merges side by side over the level below.
  • DRC and the fill use each side; the router and tuner keep the larger. Findings say (inner layers), (via hole) or (via to via), README-fab lists the sides.

Edge band ​

tsx
import PCB from '@pcbjs/core'
export default <PCB name="B" rev="0.1.0" rules={{ edge: { width: 1.2, kinds: ['courtyard', 'silk', 'pad'], except: [J_CAM0, J1[3], MH1] } }} />
  • Keeps a band width mm inside the outline and around cutouts clear of kinds, default all three.
  • except takes parts and pad or pin handles. An unplaced part is ignored.
  • Merges key by key over a lower level, so a board may add except. DRC edge-courtyard, edge-silk, edge-pad give the distance. The router ignores it.

Mask web ​

  • maskWeb: 0.13 asks for that much mask between two pad openings, each pad grown by its maskExpansion as the Gerber draws it; exactly maskWeb passes.
  • The DRC warning mask-web names both pads and the web, one finding per part naming its narrowest pair and counting the rest: mask web between pad U1/1 and pad U1/2 on F.Mask is 0.1 mm, narrower than 0.13 mm, and 43 more pairs of U1; the fab merges the openings.
  • Touching or overlapping openings pass, and so does a pad opening that meets a drawing on its mask layer, a gang opening.
  • JLCPCB carries 0.1, fab.md; the other sets check nothing.
  • maskWebByColor: { Black: 0.13 }, case ignored, picks by the stackup's or preset's color over maskWeb. A level setting maskWeb without a table drops the tables below.

Overrides ​

tsx
import PCB, { nets, defineFootprint, type FootprintProps } from '@pcbjs/core'

const Edge = defineFootprint(function Edge(props: FootprintProps) {
  return (
  <footprint {...props}>
    <pad num={1} at="0 0" size={1} clearance={0.12} pasteShrink={0.03} />
    <pad num={2} at="1.2 0" size={1} clearance={0.12} holeClearance={0.2} drill={0.4} />
  </footprint>
  )
}, { pins: ['1', '2'], prefix: 'J' })

const { A, B, GND, VCC } = nets()
GND.rules({ clearance: 0.3 })
VCC.rules({ clearance: { pad: 0.5, track: 0.4 } })
const J1 = Edge().connect({ 1: A, 2: B }).rules({ edgeClearance: 0.26, trackWidth: 0.1 })
const J2 = Edge().connect({ 1: VCC, 2: GND }).rules({ clearance: { track: 0.4, via: 0.4, zone: 0.4 }, thermal: { angle: 45 } })

export default (
  <PCB name="Overrides" rev="0.1.0" rules={{ clearance: 0.2 }}>
    <rect layer="Edge.Cuts" x={0} y={0} w={20} h={10} />
    <J1 at="0.8 5" />
    <J2 at="10 5" />
  </PCB>
)
LevelWhereKeys
padprops of <pad> in a footprintclearance, holeClearance, maskExpansion, pasteShrink, pasteRatio, thermal
partpart.rules({ … }), or rules={{ … }} on the <footprint> it draws, for every pad of the partclearance, edgeClearance, holeClearance, trackWidth, thermal: { angle }
neta net class, see route-options.md, or net.rules({ clearance }), an anonymous class net:<name> merged over the net's own classclearance
boardrulesevery rule
  • Precedence pad, part, class, board, key by key. The part level merges <footprint rules>, then .rules() calls in order.
  • Between two items, as KiCad: if either has an override toward the other, the larger override holds and classes and board are skipped, so clearance: 0.15 on a part lets any track 0.15 mm from its pads. Else the larger class clearance, else the board's.
  • holeClearance: the larger of hole and copper. edgeClearance: per pad. trackWidth: the narrowest track ending on a pad of the part, the larger of two parts.
  • Findings name the source: (part override of J1), (pad override of U3/4), (class power), plus , to tracks or , to its own pads when scoped.
  • The fill keeps an override toward zones or the pour's clearance, whichever is larger; router and tuner keep one toward tracks, never below the rules'.
  • pcbjs import board writes them from KiCad's clearances and the .kicad_dru rules it can map, import.md.

Clearance by kind ​

clearance is one length, or an object by the other item's kind: pad, track, via, zone, text. A kind left out keeps the class's or board's.

  • On a pad or part, self is the clearance between pads of one footprint, as J2 above; a plain length holds there too, as KiCad's local clearance.
  • pad takes the other pad's type, { pad: { tht: 0.5, smd: 0.2 } }, KiCad's Pad_Type; an npth or a type left out keeps the class's or rules'. A pad object replaces a lower one; findings say , to tht pads.
  • On a class or net it holds for its tracks and vias and counts as an override: power: { clearance: { track: 0.4 } }.
  • Two objects merge kind by kind, else the upper level replaces; a pad's clearance replaces its part's.
  • A pad's thermal is 'thermal', 'solid', 'none' or { connect?, angle? }, over its part's thermal.angle and the rules'; footprint and placement thermal maps take the same.

Fab rule sets ​

@pcbjs/lib/rules exports BASE, JLCPCB, PCBWAY, OSHPARK, EUROCIRCUITS and ADVANCEDPCB, frozen; mergeRules(base, ...overrides) returns a new set. A preset from @pcbjs/fab/... carries its fab's set, fab.md.

MIT licensed. A proof of concept, pre 0.1.