Run It
Every instrument is mocked, so the example runs without hardware.
bash
git clone https://github.com/tofupilot/panelscd panelstofupilot run triple-power-supplyThe procedure
procedure.yaml
name: Triple-Output Power Supplyversion: 1.0.0plugs: - key: supply name: Triple-output power supply python: plugs.power_supply_3ch:TripleSupplymain: - key: power name: Power up python: phases.triple_power_supply:power_up measurements: - key: vbus_current name: VBUS current unit: "A" validators: - operator: ">=" expected_value: 0.08 - operator: "<=" expected_value: 0.2 - key: usb1_load_current name: USB1 load current unit: "A" validators: - operator: ">=" expected_value: 0.45 - operator: "<=" expected_value: 0.55 ui: panel: panels/supply.htmlThe panel
panels/supply.html
<div class="inst"><svg viewBox="0 0 320 210" role="img"><rect x="1" y="1" width="318" height="208" rx="10" fill="#0b0f14" stroke="#20262c" stroke-width="1.5"/><g class="tile" data-bind="ui.m1"><rect x="8" y="10" width="98" height="190" rx="4" fill="#111821" stroke="#f5d90a" stroke-opacity=".45"/><rect x="8" y="10" width="98" height="18" rx="4" fill="#f5d90a"/></g><text x="14" y="23" text-anchor="start" style="font: 700 10px system-ui, sans-serif; letter-spacing: .06em; fill: #0b0f14">CH1</text><text x="100" y="23" text-anchor="end" style="font: 700 7px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #0b0f14">VBUS IN</text><text x="14" y="42" text-anchor="start" style="font: 500 7px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #7d8791">SET 5.00 V 0.50 A</text><text x="100" y="80" text-anchor="end" data-bind="ui.v1" style="font: 600 25px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #f5d90a">0.000</text><text x="100" y="93" text-anchor="end" style="font: 600 8px system-ui, sans-serif; letter-spacing: 0; fill: #7d8791">V</text><text x="100" y="128" text-anchor="end" data-bind="ui.a1" style="font: 600 25px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #f5d90a">0.000</text><text x="100" y="141" text-anchor="end" style="font: 600 8px system-ui, sans-serif; letter-spacing: 0; fill: #7d8791">A</text><text x="100" y="166" text-anchor="end" data-bind="ui.w1" style="font: 600 12px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #c3ccd5">0.000 W</text><g class="mode" data-bind="ui.m1"><rect x="14" y="178" width="30" height="14" rx="3"/></g><text x="29" y="188.5" text-anchor="middle" data-bind="ui.m1" style="font: 700 8px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #0b0f14">OFF</text><g class="tile" data-bind="ui.m2"><rect x="111" y="10" width="98" height="190" rx="4" fill="#111821" stroke="#22d3ee" stroke-opacity=".45"/><rect x="111" y="10" width="98" height="18" rx="4" fill="#22d3ee"/></g><text x="117" y="23" text-anchor="start" style="font: 700 10px system-ui, sans-serif; letter-spacing: .06em; fill: #0b0f14">CH2</text><text x="203" y="23" text-anchor="end" style="font: 700 7px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #0b0f14">USB1 LOAD</text><text x="117" y="42" text-anchor="start" style="font: 500 7px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #7d8791">SET 5.00 V 0.60 A</text><text x="203" y="80" text-anchor="end" data-bind="ui.v2" style="font: 600 25px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #22d3ee">0.000</text><text x="203" y="93" text-anchor="end" style="font: 600 8px system-ui, sans-serif; letter-spacing: 0; fill: #7d8791">V</text><text x="203" y="128" text-anchor="end" data-bind="ui.a2" style="font: 600 25px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #22d3ee">0.000</text><text x="203" y="141" text-anchor="end" style="font: 600 8px system-ui, sans-serif; letter-spacing: 0; fill: #7d8791">A</text><text x="203" y="166" text-anchor="end" data-bind="ui.w2" style="font: 600 12px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #c3ccd5">0.000 W</text><g class="mode" data-bind="ui.m2"><rect x="117" y="178" width="30" height="14" rx="3"/></g><text x="132" y="188.5" text-anchor="middle" data-bind="ui.m2" style="font: 700 8px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #0b0f14">OFF</text><g class="tile" data-bind="ui.m3"><rect x="214" y="10" width="98" height="190" rx="4" fill="#111821" stroke="#e879f9" stroke-opacity=".45"/><rect x="214" y="10" width="98" height="18" rx="4" fill="#e879f9"/></g><text x="220" y="23" text-anchor="start" style="font: 700 10px system-ui, sans-serif; letter-spacing: .06em; fill: #0b0f14">CH3</text><text x="306" y="23" text-anchor="end" style="font: 700 7px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #0b0f14">TARGET</text><text x="220" y="42" text-anchor="start" style="font: 500 7px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #7d8791">SET 3.30 V 0.10 A</text><text x="306" y="80" text-anchor="end" data-bind="ui.v3" style="font: 600 25px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #e879f9">0.000</text><text x="306" y="93" text-anchor="end" style="font: 600 8px system-ui, sans-serif; letter-spacing: 0; fill: #7d8791">V</text><text x="306" y="128" text-anchor="end" data-bind="ui.a3" style="font: 600 25px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #e879f9">0.000</text><text x="306" y="141" text-anchor="end" style="font: 600 8px system-ui, sans-serif; letter-spacing: 0; fill: #7d8791">A</text><text x="306" y="166" text-anchor="end" data-bind="ui.w3" style="font: 600 12px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #c3ccd5">0.000 W</text><g class="mode" data-bind="ui.m3"><rect x="220" y="178" width="30" height="14" rx="3"/></g><text x="235" y="188.5" text-anchor="middle" data-bind="ui.m3" style="font: 700 8px ui-monospace, Menlo, monospace; letter-spacing: 0; fill: #0b0f14">OFF</text></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); } .mode rect { fill: #3a4048; transition: fill .15s; } .mode[data-value=CV] rect { fill: #38e07a; } .mode[data-value=CC] rect { fill: #ff5a3d; } .tile { transition: opacity .2s; } .tile[data-value=OFF] { opacity: .5; }</style>The phase
phases/triple_power_supply.py
"""Switches the supply's three outputs on one after the other and reads themback. `ui.v1` to `ui.w3` are the readouts, `ui.m1` to `ui.m3` each channel'smode: CV, CC once its current limit is reached, or OFF. The run records theVBUS current and the USB1 load current."""import timeSWITCH_ON = {1: 5, 2: 15, 3: 25} # read index at which each output comes ondef power_up(ui, measurements, supply): for n in range(160): for channel, at in SWITCH_ON.items(): if n == at: supply.output(channel, True) for channel in (1, 2, 3): volts, amps, mode = supply.read(channel) setattr(ui, f"v{channel}", f"{volts:.3f}") setattr(ui, f"a{channel}", f"{amps:.3f}") setattr(ui, f"w{channel}", f"{volts * amps:.3f} W") setattr(ui, f"m{channel}", mode) time.sleep(0.1) measurements.vbus_current = round(supply.read(1)[1], 3) measurements.usb1_load_current = round(supply.read(2)[1], 3) time.sleep(1.5)The mocked instrument
plugs/power_supply_3ch.py
"""Mock triple-output supply: CH1 is VBUS into the board's USB0, CH2 feeds anelectronic load on its USB1 host port, CH3 an external target whose currentlimit is set too low. Replace it with your supply's driver."""import mathCHANNELS = [ # set volts, current limit, load ohms (5.0, 0.5, 42.0), (5.0, 0.6, 10.0), (3.3, 0.1, 10.2),]class TripleSupply: def __init__(self): self.k = 0 self.on = [False, False, False] def output(self, channel, on): self.on[channel - 1] = on def read(self, channel): """[volts, amps, 'CV' | 'CC' | 'OFF'] of one channel.""" self.k += 1 if not self.on[channel - 1]: return [0.0, 0.0, "OFF"] vset, ilim, load = CHANNELS[channel - 1] wobble = math.sin(self.k * 0.37 + channel) if vset / load > ilim: return [ilim * load * (1 + 0.0002 * wobble), ilim * (1 + 0.002 * wobble), "CC"] return [vset * (1 + 0.0002 * wobble), vset / load * (1 + 0.002 * wobble), "CV"]