Python

Your instruments, as Python objects.

Set an instrument up once in Muxit: connection, commands, units, limits. Then use it from any Python script or Jupyter notebook as psu.voltage = 3. The computer that runs Python needs no VISA, no SCPI strings and no COM ports, and the dashboard shows what your script does while it runs.

Download MuxitPython guidepip install muxit · every plan, Free included
01 · Start

A measurement in a dozen lines.

quickstart.py
import muxit

m = muxit.connect()        # or connect("192.168.1.20")
psu = m.connector("psu")   # names from Muxit
dmm = m.connector("dmm")

psu.voltage = 3.0          # write
print(dmm.current)         # read
psu.output = False

rec = m.record(["psu.voltage", "dmm.current"],
               seconds=5, every=0.1)
rec.to_csv("run.csv")      # or .to_pandas(), .plot()

psu and dmm are connectors: the names you gave your instruments in Muxit. Every property and action of that connector is there. Press Tab in Jupyter and you see them all.

A typo fails before anything is sent (Did you mean 'voltage'?), and so does a write to a read-only value. m.record() samples the values Muxit already polls, so a log over time is one call and goes straight into pandas.

The same client reads camera frames, waits for a barcode scan, starts Muxit scripts and asks the AI about an image. Everything it does →

02 · Why

Why not just PyVISA?

PyVISA, PyMeasure and vendor SDKs work, and they are free. Muxit adds what comes from having a server between your code and the instrument:

Muxit + PythonPyVISAPyMeasureVendor SDK
On the Python computerpip install muxitPyVISA and a VISA backendPyMeasure and a VISA backendThe vendor's package and drivers
Setting a voltagepsu.voltage = 3, any brandwrite("VOLT 3"), in each vendor's dialectA property, if your model has a classThe vendor's API
Dashboard and colleagues on the same instrument while your script runsYes, through the serverNo; a serial or USB port is open in one program at a timeNoRarely
Robots, cameras, MQTT sensorsSame syntaxNoSomeOne SDK per vendor
Limits your code can't write pastPer-connector safety limits NoNoSometimes, in firmware
Python on another computerYes, over the networkFor LAN instrumentsFor LAN instrumentsDepends
03 · Two languages

Python where you work, JavaScript where the station runs.

Every script on this site has a JavaScript and a Python tab, and both run as written. They use the same instrument names, the same events and the same safety limits. What differs is where each one runs. A JavaScript script runs inside Muxit, so it starts from a dashboard button, an operator station or at boot, and keeps going when your laptop closes. Python runs wherever you work, next to numpy, pandas and your own code.

runs inside Muxitruns on your computer · pip install muxit
led-iv.js
// led-iv.js: LED I/V curve, one CSV row per step
const psu = connector("psu");
const dmm = connector("dmm");
const csv = connector("fileaccess").openText("runs/led-iv.csv");

csv.write("v_set,i_measured\n");
psu.current_limit = 0.05;
psu.output = true;

for (let v = 0; v <= 3.2; v += 0.05) {
  psu.voltage = v;
  delay(200);
  csv.append([v.toFixed(2), dmm.current]);
}

psu.output = false;
log.info("Saved runs/led-iv.csv");
led_iv.py
# led_iv.py: LED I/V curve, one CSV row per step
import csv, time
import muxit

m = muxit.connect()
psu = m.connector("psu")
dmm = m.connector("dmm")

psu.current_limit = 0.05
psu.output = True
with open("led-iv.csv", "w", newline="") as f:
    out = csv.writer(f)
    out.writerow(["v_set", "i_measured"])
    for step in range(65):             # 0 to 3.2 V
        v = step * 0.05
        psu.voltage = v
        time.sleep(0.2)
        out.writerow([f"{v:.2f}", dmm.current])

psu.output = False
print("Saved led-iv.csv")

They work together. Here the station runs a script inside Muxit, and an analysis in Python hands it the verdict through an event:

analyse.py · on your computer
# analyse.py: measure in Python, hand the verdict to the station script
import numpy as np
import muxit

m = muxit.connect()

while True:
    serial = m.events.wait("connector:scanner.scan")
    rec = m.record("dmm.current", seconds=2, every=0.05)
    noise = float(np.std(rec["dmm.current"]))
    m.events.emit("analysis-done",
                  {"serial": serial, "pass": noise < 0.001, "noise": noise})
scripts/operator/station.js · inside Muxit
// station.js: runs on the station, waits for the verdict from Python
const station = connector("station");

while (true) {
  const r = waitFor("analysis-done");
  station.status = r.pass ? "PASS" : "FAIL";
  log.info(`${r.serial}: noise ${r.noise.toFixed(5)} A`);
}
04 · Limits

When Python through Muxit is the wrong tool.

  • Fast control loops. Each read or write is a round trip to the server, about a millisecond on the same computer plus the instrument's own time, and by default 50 calls a second per connection. Fine for setpoints and measurements; not for a kHz loop.
  • Bulk waveform capture. Millions of samples a second belong in the vendor's acquisition software or an FPGA.
  • A lab that already runs a mature QCoDeS or Bluesky setup. Keep it.
  • A station that has to run on its own. Use the JavaScript version of the script, so it runs inside Muxit.
05 · Try it

No hardware needed.

pip install muxit
python -m muxit doctor
python -m muxit demo

With Muxit running, doctor checks the connection and demo reads and writes the test device that every new workspace has.

Then open a notebook: a first look on the test device, or an LED I-V curve with your own supply and meter. In the Muxit window, the Py button on a connector copies a snippet with its real names.

06 · Questions

Questions.

Which plan do I need?

Any. The Python client is in every plan, Free included. Free runs three connectors; per-connector safety limits are Lab.

Can a dashboard button start a Python script?

Not yet: a dashboard starts scripts that run inside Muxit, which are JavaScript. A running Python program can wait for a dashboard button with m.events.wait("dashboard:start").

Does my Python have to run on the Muxit computer?

No. On the same computer it needs no setup. From another computer, turn on remote access in Muxit and pass the password.

Do the safety limits apply to Python?

Yes. Calls from Python go through the same safety gate as everything else, and appear in the audit log as client:python (Lab). On the Observe level writes are simulated, and the client warns you that nothing reached the instrument.

Which Python versions?

3.9 or newer, on Windows, macOS and Linux. The only dependency is websockets.

Does the client send data anywhere?

Only to the Muxit server you point it at. The client is open source, MIT licensed.

Set one instrument up, then open a notebook.

Install Muxit on the computer the instruments are on, add a connector, and pip install muxit wherever you write Python.