kicad2ems.core.templates¶
Templates: parametric groups of drawn shapes (kicad2ems.core.shapes) that the
Draw page places with a click and that are then ordinary shapes, edited as any
other. No Qt here: each template's parameters and the shapes it makes.
t = TEMPLATES['can']; t.name, t.tip, t.params # Param(key, label, ...)
v = defaults('circulator', stack, 'F.Cu') # {key: value}, sized to
# the board's stack
shapes = make('can', v, stack, 'F.Cu', at=(x, y))
shapes = make('fence', v, stack, 'F.Cu', along=[trace, ...])
sub = substrate(stack, 'F.Cu') # the copper's height and thickness and
# the dielectric under it (h, er, tand)
w = line_width(50, sub) # a microstrip's width for 50 ohm
The templates (each's shapes centred on `at`, along x, unless said):
can a shield can: a metal box over the board, air inside it (the
air drawn after the metal hollows it, open at the bottom),
and a fence of metal posts through the board under its walls
dr a dielectric resonator puck beside a microstrip line, the line
ported at both ends
circulator a microstrip Y-junction circulator (examples/rf_circulator's
design): a ferrite puck set into the substrate, a copper
junction disc, three arms 120 deg apart with quarter-wave
transformers, ports at their ends, and a magnet over it
sma an edge-launch connector as a square coax: a metal body round
a PTFE channel and a metal pin onto a 50 ohm line (`at`: the
board's edge; `facing` the way the connector points)
absorber a sheet of lossy dielectric (an absorber's loss as er and
tan d: the solvers have no magnetic loss)
fence metal posts along each side of the selected traces (`along`)
Line widths are worked out on the stack (core.lines.formulas.microstrip, over
the dielectric down to the next copper layer). Heights are the stack's: a
shape on the top layer stands on its copper (cu_z + t) and goes up; on the
bottom layer it hangs below and goes down.
- class kicad2ems.core.templates.Param(key: str, label: str, default: object, unit: str = '', tip: str = '', lo: float = 0.0, hi: float = 1000.0, decimals: int = 3, kind: str = 'float', choices: tuple = ())[source]¶
One of a template's numbers (or a tick, or a choice): its key, label, default, unit and range; kind 'float', 'int', 'bool' or 'choice' (`choices`).
- class kicad2ems.core.templates.Template(key: str, name: str, tip: str, params: tuple, place: str = 'point', prompt: str = '', make: object = None)[source]¶
A template: its name, what it makes (tip), its parameters and how it is placed: 'point' (a click: its centre, or the board's edge for the connector) or 'traces' (the selected traces).
- kicad2ems.core.templates.coax_pin(zc, d, er)[source]¶
The side (mm) of a square pin in a square channel d mm across, filled with er, for a coax of impedance zc ohm (a round pin's 60/sqrt(er) ln(1.0787 d / dp) in a square outer, the pin's equivalent diameter 1.18 x its side).
- kicad2ems.core.templates.defaults(key, stack=None, layer='F.Cu', along=None)[source]¶
A template's parameters' values, those that depend on the board (a line's 50 ohm width; a fence's offset from its trace) worked out.
- kicad2ems.core.templates.fence_posts(points, offset, pitch, both=True)[source]¶
The posts' centres [(x, y)] along a centre line `points`, `offset` mm to its side (both: on each side), `pitch` mm apart at most, evenly from end to end.
- kicad2ems.core.templates.line_width(z0, sub)[source]¶
A microstrip's width (mm) of impedance z0 ohm over the substrate `sub` (substrate's: Hammerstad and Jensen's, the copper's thickness left out as examples/make_rf_examples.py leaves it, so that the circulator is the example's on its board).
- kicad2ems.core.templates.make(key, values=None, stack=None, layer='F.Cu', at=(0.0, 0.0), along=None)[source]¶
The shapes of template `key` with `values` (defaults' for those not given) on `layer` of `stack` (core.shapes.stack_of's; None: the default two-layer board), at point `at` (model mm) or along the traces `along`. ValueError: values that make no sense (a can smaller than its walls).
- kicad2ems.core.templates.substrate(stack, layer)[source]¶
What a template on copper layer `layer` stands on, from a stack (core.shapes.stack_of's): dict(z (the copper's lower face), t (its thickness), surface (the copper's outer face), up (+1: the layer faces up, the board's top half; -1: down), h, er, tand (the dielectric between it and the next copper layer inward, er and tand weighted by thickness), zref (that layer's z), zb, zt (the board's dielectric bottom and top)).