Skip to main content

Standalone Red Pitaya analog-output voltage driver, built on pyrpl

Project description

pyrpl-voltage-driver

A small standalone driver that turns a Red Pitaya (STEMlab 125-10 / 125-14) analog output into a held DC voltage source via pyrpl. Configures pyrpl's arbitrary signal generator (ASG) as a dc waveform with amplitude=0, so offset is the only knob that drives the SMA — set_voltage() is then a single FPGA register write.

Designed to drop into any project that needs a positive, unipolar voltage actuator on a networked Red Pitaya — independent of any larger control framework.

Install

PyPI's pyrpl is stuck at 0.9.3.6 (2017). The maintained fork lives on GitHub, so install it from there first, then install this package:

pip install git+https://github.com/pyrpl-fpga/pyrpl
pip install pyrpl-voltage-driver

If you use uv:

uv add git+https://github.com/pyrpl-fpga/pyrpl
uv add pyrpl-voltage-driver

Usage

from pyrpl_voltage_driver import RedPitayaPyrplDAC

dac = RedPitayaPyrplDAC(
    hostname="rp-f0aabb.local",  # or static IP
    output="out1",
    vmax=0.5,                    # clamp output to 0..0.5 V
)

dac.connect()                    # 10-30 s on first call: SSH + bitstream upload
try:
    dac.set_voltage(0.2)
    # ... do stuff ...
    dac.set_voltage(0.0)
finally:
    dac.disconnect()             # parks the output at 0 V and turns it off

set_voltage(v) clamps v to [0, vmax]. Calling set_voltage() before connect() raises NotConnectedError.

Wrapping this driver to fit an existing host application's interface (VoltageDriver Protocol, pydantic YAML config, async, custom error hierarchy, ...)? See docs/integration.md.

Constructor parameters

Parameter Default Notes
hostname (required) Red Pitaya hostname or IP, e.g. rp-f0aabb.local.
output "out1" "out1" or "out2" — which SMA the ASG is wired to.
asg "asg0" "asg0" or "asg1" — which on-FPGA ASG channel to use.
vmax 1.0 Upper bound on the output in volts. Must be in (0, 1.0]. The SMA itself is bipolar ±1 V.
config_name "pyrpl_voltage_driver" Name of pyrpl's per-instrument YAML file under ~/.pyrpl/. Use distinct names per device.
user None SSH user. Defaults to pyrpl's choice (typically root).
password None SSH password. Defaults to pyrpl's choice (typically root).
park_on_disconnect True On disconnect(), zero the output and turn output_direct off.
force_qt_offscreen True Set QT_QPA_PLATFORM=offscreen before importing pyrpl. Disable if you run with a display.

Headless / Qt note

pyrpl imports PyQt at top level, which tries to open an X display. By default this driver sets QT_QPA_PLATFORM=offscreen before importing pyrpl, so it works on headless servers. If you're already exporting your own QT_QPA_PLATFORM (e.g. running with a real display), pass force_qt_offscreen=False.

First-connect cost

connect() opens an SSH session to the Red Pitaya, pushes pyrpl's bitstream, and starts the FPGA monitor server. Expect 10-30 seconds. Subsequent connect() calls in the same Python process are no-ops.

Development

uv sync --extra test
uv run pytest tests/unit -v

The unit tests are fully mocked — no Red Pitaya required.

Opt-in hardware integration test (skipped unless REDPITAYA_HOST is set):

REDPITAYA_HOST=rp-f0aabb.local uv run pytest tests/integration -v

Releasing (maintainers)

Cutting and publishing PyPI releases is documented in docs/releasing.md — covers one-time PyPI setup, the first-version flow, subsequent versions, and recovering from a broken upload.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyrpl_voltage_driver-0.1.0.tar.gz (21.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyrpl_voltage_driver-0.1.0-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file pyrpl_voltage_driver-0.1.0.tar.gz.

File metadata

  • Download URL: pyrpl_voltage_driver-0.1.0.tar.gz
  • Upload date:
  • Size: 21.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for pyrpl_voltage_driver-0.1.0.tar.gz
Algorithm Hash digest
SHA256 d32020a2261acfc1f011d24d20a5b17b1e6ab0a10dc1c3866d053e66734c3e1c
MD5 e6d2a0807431fa7176de6298bcd6be05
BLAKE2b-256 cb1b9a1f39c5af937d95bfe6de425c1b4c1100d71c0542a4485e97c59e668c9e

See more details on using hashes here.

File details

Details for the file pyrpl_voltage_driver-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pyrpl_voltage_driver-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7d3aba81cf5debec9d88bf9c0ab195ddab75ddf3e393e3d6823e033df76ba6e8
MD5 201607b28ea20be6b70b670f44ed1774
BLAKE2b-256 4b598fbdd92664e5d8ac32e1215151e2afa72f81a16541367237af77d8f69e7e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page