Relay Matrix

A 4 x 16 crosspoint switch matrix routing a multimeter to a board's test nodes one at a time: ABUS1 to the node, ABUS2 to ground, each closed crosspoint lit.

STATIONCLI/PROCEDURERelay Matrix

Node voltages

PASS00:15.71Node voltages (1/1)Passed

Run It

Every instrument is mocked, so the example runs without hardware.

bash
git clone https://github.com/tofupilot/panelscd panelstofupilot run relay-matrix

The procedure

procedure.yaml
name: Relay Matrixversion: 1.0.0plugs:  - key: switch_matrix    name: Switch matrix    python: plugs.switch_matrix:SwitchMatrixmain:  - key: nodes    name: Node voltages    python: phases.relay_matrix:scan_nodes    measurements:      - key: vref        name: VREF node        unit: "V"        validators:          - operator: ">="            expected_value: 2.45          - operator: "<="            expected_value: 2.55      - key: v3v3        name: 3V3 node        unit: "V"        validators:          - operator: ">="            expected_value: 3.2          - operator: "<="            expected_value: 3.4    ui:      panel: panels/matrix.html

The panel

panels/matrix.html
<div class="inst"><svg viewBox="0 0 320 210" role="img"><rect x="1" y="1" width="318" height="208" rx="10" fill="#0d1014" stroke="#20262c" stroke-width="1.5"/><path d="M66.0 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(68.6 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">VIN</text><path d="M81.8 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(84.4 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">VBUS</text><path d="M97.6 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(100.2 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">5V0</text><path d="M113.4 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(116.0 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">3V3</text><path d="M129.2 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(131.8 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">1V8</text><path d="M145.0 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(147.6 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">1V2</text><path d="M160.8 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(163.4 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">VREF</text><path d="M176.6 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(179.2 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">VBAT</text><path d="M192.4 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(195.0 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">AIN0</text><path d="M208.2 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(210.8 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">AIN1</text><path d="M224.0 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(226.6 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">AIN2</text><path d="M239.8 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(242.4 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">AIN3</text><path d="M255.6 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(258.2 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">NTC</text><path d="M271.4 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(274.0 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">ISNS</text><path d="M287.2 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(289.8 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">VCC_IO</text><path d="M303.0 64V190" stroke="#262d34"/><text x="0" y="0" transform="translate(305.6 61) rotate(-60)" style="font: 600 7.5px ui-monospace, Menlo, monospace; fill: #9aa8b6">GND</text><path d="M60 70H309.0" stroke="#262d34"/><text x="14" y="73" text-anchor="start" style="font: 600 9px ui-monospace, Menlo, monospace; fill: #c3ccd5">ABUS1</text><path d="M60 108H309.0" stroke="#262d34"/><text x="14" y="111" text-anchor="start" style="font: 600 9px ui-monospace, Menlo, monospace; fill: #c3ccd5">ABUS2</text><path d="M60 146H309.0" stroke="#262d34"/><text x="14" y="149" text-anchor="start" style="font: 600 9px ui-monospace, Menlo, monospace; fill: #c3ccd5">ABUS3</text><path d="M60 184H309.0" stroke="#262d34"/><text x="14" y="187" text-anchor="start" style="font: 600 9px ui-monospace, Menlo, monospace; fill: #c3ccd5">ABUS4</text><g class="xp" data-bind="ui.x0_0"><circle cx="66.0" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_1"><circle cx="81.8" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_2"><circle cx="97.6" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_3"><circle cx="113.4" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_4"><circle cx="129.2" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_5"><circle cx="145.0" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_6"><circle cx="160.8" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_7"><circle cx="176.6" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_8"><circle cx="192.4" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_9"><circle cx="208.2" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_10"><circle cx="224.0" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_11"><circle cx="239.8" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_12"><circle cx="255.6" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_13"><circle cx="271.4" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_14"><circle cx="287.2" cy="70" r="5"/></g><g class="xp" data-bind="ui.x0_15"><circle cx="303.0" cy="70" r="5"/></g><g class="xp" data-bind="ui.x1_0"><circle cx="66.0" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_1"><circle cx="81.8" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_2"><circle cx="97.6" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_3"><circle cx="113.4" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_4"><circle cx="129.2" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_5"><circle cx="145.0" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_6"><circle cx="160.8" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_7"><circle cx="176.6" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_8"><circle cx="192.4" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_9"><circle cx="208.2" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_10"><circle cx="224.0" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_11"><circle cx="239.8" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_12"><circle cx="255.6" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_13"><circle cx="271.4" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_14"><circle cx="287.2" cy="108" r="5"/></g><g class="xp" data-bind="ui.x1_15"><circle cx="303.0" cy="108" r="5"/></g><g class="xp" data-bind="ui.x2_0"><circle cx="66.0" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_1"><circle cx="81.8" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_2"><circle cx="97.6" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_3"><circle cx="113.4" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_4"><circle cx="129.2" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_5"><circle cx="145.0" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_6"><circle cx="160.8" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_7"><circle cx="176.6" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_8"><circle cx="192.4" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_9"><circle cx="208.2" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_10"><circle cx="224.0" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_11"><circle cx="239.8" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_12"><circle cx="255.6" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_13"><circle cx="271.4" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_14"><circle cx="287.2" cy="146" r="5"/></g><g class="xp" data-bind="ui.x2_15"><circle cx="303.0" cy="146" r="5"/></g><g class="xp" data-bind="ui.x3_0"><circle cx="66.0" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_1"><circle cx="81.8" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_2"><circle cx="97.6" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_3"><circle cx="113.4" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_4"><circle cx="129.2" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_5"><circle cx="145.0" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_6"><circle cx="160.8" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_7"><circle cx="176.6" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_8"><circle cx="192.4" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_9"><circle cx="208.2" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_10"><circle cx="224.0" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_11"><circle cx="239.8" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_12"><circle cx="255.6" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_13"><circle cx="271.4" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_14"><circle cx="287.2" cy="184" r="5"/></g><g class="xp" data-bind="ui.x3_15"><circle cx="303.0" cy="184" r="5"/></g></svg></div><style>  .inst { width: min(560px, 100%); margin: 0 auto; }  .inst svg { display: block; width: 100%; height: auto; }  .inst text { font-family: system-ui, sans-serif; }  .dp rect { fill: var(--off); }  .dp.on rect, .dp[data-value=true] rect { fill: var(--on); }  .led circle { fill: #2a2f35; transition: fill .15s; }  .led[data-value=true] circle { fill: var(--led, #38e07a); }  .ann text { fill: var(--off); transition: fill .15s; }  .ann[data-value=true] text { fill: var(--on); }  .d7 rect { fill: var(--off); transition: fill .08s; }  .d7[data-value="0"] :is(.sa, .sb, .sc, .sd, .se, .sf) { fill: var(--on); }  .d7[data-value="1"] :is(.sb, .sc) { fill: var(--on); }  .d7[data-value="2"] :is(.sa, .sb, .sd, .se, .sg) { fill: var(--on); }  .d7[data-value="3"] :is(.sa, .sb, .sc, .sd, .sg) { fill: var(--on); }  .d7[data-value="4"] :is(.sb, .sc, .sf, .sg) { fill: var(--on); }  .d7[data-value="5"] :is(.sa, .sc, .sd, .sf, .sg) { fill: var(--on); }  .d7[data-value="6"] :is(.sa, .sc, .sd, .se, .sf, .sg) { fill: var(--on); }  .d7[data-value="7"] :is(.sa, .sb, .sc) { fill: var(--on); }  .d7[data-value="8"] :is(.sa, .sb, .sc, .sd, .se, .sf, .sg) { fill: var(--on); }  .d7[data-value="9"] :is(.sa, .sb, .sc, .sd, .sf, .sg) { fill: var(--on); }  .d7[data-value="-"] :is(.sg) { fill: var(--on); }  .d7[data-value="E"] :is(.sa, .sd, .se, .sf, .sg) { fill: var(--on); }  .d7[data-value="U"] :is(.sb, .sc, .sd, .se, .sf) { fill: var(--on); }  .d7[data-value="r"] :is(.se, .sg) { fill: var(--on); }  .xp circle { fill: #0d1014; stroke: #3a434c; stroke-width: 1.4; transition: fill .12s, stroke .12s; }  .xp[data-value=true] circle { fill: #38e07a; stroke: #7cf0aa; }</style>

The phase

phases/relay_matrix.py
"""Routes the multimeter through the switch matrix to each test node in turn:ABUS1 on the node, ABUS2 on ground. `ui.x{bus}_{column}` lights the closedcrosspoints. The run records VREF and the 3V3 node."""import timeGND = 15RECORD = {3: "v3v3", 6: "vref"}def scan_nodes(ui, measurements, switch_matrix):    for node in range(15):        switch_matrix.close(0, node)        switch_matrix.close(1, GND)        setattr(ui, f"x0_{node}", True)        setattr(ui, f"x1_{GND}", True)        for _ in range(8):            volts = switch_matrix.read_dc()            time.sleep(0.1)        if node in RECORD:            setattr(measurements, RECORD[node], round(volts, 4))        switch_matrix.open_all()        setattr(ui, f"x0_{node}", False)        setattr(ui, f"x1_{GND}", False)        time.sleep(0.1)    time.sleep(1.5)

The mocked instrument

plugs/switch_matrix.py
"""Mock 4 x 16 crosspoint switch matrix with a multimeter on its analogbuses: ABUS1 goes to the node under test, ABUS2 to ground. Replace it withyour matrix and multimeter drivers."""import mathNODES = ["VIN", "VBUS", "5V0", "3V3", "1V8", "1V2", "VREF", "VBAT", "AIN0", "AIN1", "AIN2", "AIN3", "NTC", "ISNS", "VCC_IO", "GND"]LEVELS = [12.012, 5.021, 4.998, 3.2987, 1.8012, 1.2004, 2.4981, 3.2961, 0.4986, 1.0012, 1.4997, 2.0021, 1.6503, 0.1873, 3.3012]class SwitchMatrix:    def __init__(self):        self.closed = set()        self.k = 0    def close(self, bus, column):        self.closed.add((bus, column))    def open_all(self):        self.closed.clear()    def read_dc(self):        """Volts between ABUS1 and ABUS2."""        self.k += 1        node = next((c for b, c in self.closed if b == 0), None)        return 0.0 if node is None else LEVELS[node] * (1 + 0.00005 * math.sin(self.k * 1.7))

Run your first test in minutes