def crystal(name="crystal", value: 'HZ' = "16M", *, gnd: 'NET', a: 'NET', b: 'NET', footprint: 'FOOTPRINT' = "SMD-3225_4P"): return make_component(name, "X", [gnd, a, b], [], value, prefix="Y")
def led(name: str, *, a: 'NET', c: 'NET', color="red"): """LED (Light-emitting diode)""" assert color in [ "red", "green", "yellow", "orange", "blue", "white", "amber", "pink", "uv" ] # red orange # yellow orange # super red # amber yellow return make_component(name, "D", [a, c], [], [])
def inductor(name: str, inductance: 'H', *, p1: 'NET', p2: 'NET', power: 'W' = 1, current: 'A' = 1): """Inductor""" inductance = tofloat_L(inductance) assert inductance > 0.0 assert tofloat_P(power) > 0.0 assert tofloat_I(current) > 0.0 return make_component(name, "L", [p1, p2], [], inductance)
def res( name: str, resistance: 'Ω', a: 'NET', b: 'NET', *, voltage: 'V' = None, # This is just an alternative way to provide power. power: 'W' = 1, tolerance: '%' = 2, temp_range: 'RANGE' = [0, 125]): """Resistor""" resistance = tofloat_R(resistance) assert resistance > 0.0 return make_component(name, "R", [a, b], [], resistance)
def ucap(name: str, capacitance: 'F', a: 'NET', b: 'NET', *, voltage: 'V' = 10, tolerance_down: '%' = -10, tolerance_up: '%' = 15, polarized: bool = False, temp_range: 'RANGE' = [0, 85]): """Unpolarized Capacitor""" capacitance = tofloat_C(capacitance) assert capacitance > 0.0 return make_component(name, "C", [a, b], [], capacitance)
def diode(name: str, *, a: 'NET', c: 'NET', model: str = "1N4148", current: 'A' = 2): """Diode. ----- """ current = tofloat_I(current) assert current > 0.0 return make_component(name, "D", [a, c], [], {"model": model})
def battery(name: str, voltage: 'V' = 1.5, *, p: 'NET', n: 'NET', capacity: 'C' = 1000, primary: bool = True, chemistry: str = 'LiFePO₄', footprint: str = 'AA'): """A simple battery / cell. Capacity can be expressed in C (columbs), A*s, As, or Ah. Unit suffixes are supported too. TODO: Add energy capacity in Wh or J. """ voltage = tofloat_V(voltage) assert voltage > 0.0 capacity = tofloat_Charge(capacity) assert capacity > 0.0 return make_component(name, "B", [p, n], [], [voltage, capacity])
def tie(name: str, a: 'NET', b: 'NET', *, physical=False): """Basically a zero ohm perfect resistor. It is used to connect different nets. Often will have no representation on PCB at all. But could be also realized as a 0 ohm resistor or jumper, or a link.""" return make_component(name, "R", [a, b], [], 0.0)
def fuse(name: str, a: 'NET', b: 'NET', *, current: 'A' = 1, type="polyfuse"): return make_component(name, "F", [a, b], [], { "current": current, "type": type })
def switch(name: str, a: 'NET', b: 'NET', *, omentary: bool = True): """Switch""" return make_component(name, "SW", [a, b], [], {"momentary": momentary})
def schottky(name: str, *, a: 'NET', c: 'NET', model: str = None): """Schottky diode""" return make_component(name, "D_Schottky", [a, c], [], {"model": model})
def zener(name: str, *, a: 'NET', c: 'NET', voltage: 'V', model: str = None): """Zener diode""" voltage = tofloat_V(voltage) assert voltage >= 0.1 return make_component(name, "D_Zener", [a, c], [], {"model": model})