--- jupyter: description: 'PCB traces in planex2d: three nets on a 2.54 mm pitch offset from their paths, round pads united and drills subtracted, with every edge named after its net and the areas checked in closed form.' --- # Traces and pads The copper of a circuit board is built from paths offset to traces, round pads and drilled holes, with every edge named after its net. The example has three nets on a pitch of 2.54 mm, each a path with a 45° jog. A trace is the path offset by half its width of 0.4 on both sides, with round ends. ```python import math import planex as px ``` ```python nbsphinx="hidden" from docs_figures import Row, Vertices ``` ```python routes = {} for k in range(3): y0, y1 = 2.54 * k, 2.54 * (k + 1) routes[f"net{k}"] = [(0, y0), (5, y0), (7.54, y1), (12, y1)] traces = {net: px.FromPolyline(path, name=net).Offset(0.2) for net, path in routes.items()} ``` ## Check A trace of half-width d = 0.2 covers 2d along its length L, plus two round ends of together π d². At each of the two 45° bends, a sector of d² θ / 2 is added on the outside. On the inside, the term of the length counts a kite of d² tan(θ / 2) twice, so it is subtracted once. ```python d, theta = 0.2, math.pi / 4 L = 5 + 2.54 * math.sqrt(2) + (12 - 7.54) exact = 2 * d * L + math.pi * d**2 + 2 * d**2 * (theta / 2 - math.tan(theta / 2)) for net, trace in traces.items(): print(net, "area", trace.mass, "exact", exact) ``` ## Pads and drills Round pads of diameter 1.7 at both ends of each trace are united with the traces, and drills of diameter 1.0 are subtracted (Figure 1). The pads take the name of their net, and the drills are named `drill`. ```python copper = list(traces.values()) drills = [] for net, path in routes.items(): for x, y in (path[0], path[-1]): copper.append(px.QuickSketch().Circle(x, y, 0.85, name=net).Face()) drills.append(px.QuickSketch().Circle(x, y, 0.5, name="drill").Face()) board = px.Subtract([px.Unify(copper), *drills]) print(sorted({e.name for e in board.edges}), len(board.wires), "loops") ``` ```python nbsphinx="hide-input" Row((px.Compound(list(traces.values())), "Three traces"), (board, "The board"), caption="Three nets: traces, then pads united and drills subtracted") ```