from jitx.anchor import Anchor
from jitx.shapes.primitive import Polyline, Text
from jitx.symbol import Direction, Pin, Symbol
[docs]
class OpAmpSymbol(Symbol):
"""Op-amp triangle with OUT, INp, INn and its Vp and Vn supply pins.
Use it for a single op-amp part, whose supplies belong on the same symbol.
"""
pin_name_size = 0.7
pad_name_size = 0.7
OUT = Pin((4, 0), 4, Direction.Right)
Vp = Pin((0, 4), 4, Direction.Up)
INn = Pin((-4, 2), 4, Direction.Left)
INp = Pin((-4, -2), 4, Direction.Left)
Vn = Pin((0, -4), 4, Direction.Down)
value = Text(">VALUE", 0.5, Anchor.C).at(0, 5)
reference = Text(">REF", 0.5, Anchor.C).at(0, 5.7)
art = [
# Op-amp triangle
Polyline(0.2, [(-4, -4), (4, 0), (-4, 4), (-4, -4)]),
# Power supply lines
Polyline(0.2, [(0, -2), (0, -4)]),
Polyline(0.2, [(0, 4), (0, 2)]),
# Input symbols
Polyline(0.2, [(-3.2, -2), (-2, -2)]), # + symbol horizontal
Polyline(0.2, [(-2.6, -1.4), (-2.6, -2.6)]), # + symbol vertical
Polyline(0.2, [(-3.2, 2), (-2, 2)]), # - symbol
]
[docs]
class OpAmpUnitSymbol(Symbol):
"""Op-amp triangle with OUT, INp and INn and no supply pins.
Use it for one amplifier of a multi-amplifier part, with the supplies on a
separate unit such as a BoxSymbol.
Create one per amplifier in the component's ``__init__``, put the supplies
on a :py:class:`~jitxlib.symbols.box.BoxSymbol`, which maps its own pins,
and map each amplifier's ports to its unit with a
:py:class:`~jitx.symbol.SymbolMapping`. For a quad part whose ``OUT``,
``INn`` and ``INp`` are lists of four ports and whose ``Vp`` and ``Vn``
are single ports:
>>> class QuadOpAmp(Component):
... OUT = [Port() for _ in range(4)]
... INn = [Port() for _ in range(4)]
... INp = [Port() for _ in range(4)]
... Vp = Port()
... Vn = Port()
... landpattern = SOIC(num_leads=14).narrow(
... 8.65, span=Toleranced.min_max(5.8, 6.2)
... )
...
... def __init__(self):
... self.amps = [OpAmpUnitSymbol() for _ in range(4)]
... self.supply = BoxSymbol(
... columns=Column(up=PinGroup(self.Vp), down=PinGroup(self.Vn))
... )
... self.mapping = SymbolMapping(
... [(self.OUT[i], amp.OUT) for i, amp in enumerate(self.amps)]
... + [(self.INn[i], amp.INn) for i, amp in enumerate(self.amps)]
... + [(self.INp[i], amp.INp) for i, amp in enumerate(self.amps)]
... )
Each port appears in exactly one mapping: each amplifier's three ports in
``mapping``, and the supplies in the box's own mapping.
"""
pin_name_size = 0.7
pad_name_size = 0.7
OUT = Pin((4, 0), 4, Direction.Right)
INn = Pin((-4, 2), 4, Direction.Left)
INp = Pin((-4, -2), 4, Direction.Left)
value = Text(">VALUE", 0.5, Anchor.C).at(0, 5)
reference = Text(">REF", 0.5, Anchor.C).at(0, 5.7)
art = [
# Op-amp triangle
Polyline(0.2, [(-4, -4), (4, 0), (-4, 4), (-4, -4)]),
# Input symbols
Polyline(0.2, [(-3.2, -2), (-2, -2)]), # + symbol horizontal
Polyline(0.2, [(-2.6, -1.4), (-2.6, -2.6)]), # + symbol vertical
Polyline(0.2, [(-3.2, 2), (-2, 2)]), # - symbol
]