Skip to main content

Qt-based framework for controlling scientific instruments over serial ports

Project description

QInstrument

PyPI version Tests Documentation DOI License: GPL v3

A Qt-based framework for controlling scientific instruments over serial ports. Instruments are represented as Qt objects with a uniform property system, automatic UI binding, and JSON-based configuration persistence. Any Qt binding (PyQt5, PyQt6, PySide2, PySide6) is supported via qtpy.

Instruments

IPG Photonics

  • YLR Series: Ytterbium fiber laser

Laser Quantum

  • Opus: Continuous-wave laser

PiezoDrive

  • PDUS210: Piezo transducer driver

Prior Scientific

  • Proscan II/III: Motorized microscope stage controller

Stanford Research Systems

  • DS345: 30 MHz Synthesized Function Generator
  • SR830: 100 kHz Digital Lock-in Amplifier
  • SR844: 200 MHz RF Lock-in Amplifier

Tektronix

  • TDS1000: Digital oscilloscope

Installation

pip install QInstrument
pip install PyQt6          # or PyQt5, PySide2, PySide6

Installing from PyPI also places a qinstrument command on your PATH.

To install from source:

git clone https://github.com/davidgrier/QInstrument
cd QInstrument
python -m venv .qi
source .qi/bin/activate
pip install -e ".[dev]"

Quick start

Rack application

Launch the rack to control multiple instruments at once:

qinstrument DS345 SR830

On subsequent runs, qinstrument with no arguments restores the last-used instrument list automatically. Use the Add instrument… button to add instruments at runtime, or right-click any instrument to remove it.

DS345 Widget

Single instrument widget

Each instrument widget also has a built-in example() entry point:

python -m QInstrument.instruments.DS345.widget

This finds a connected DS345 and opens its control panel. If no instrument is detected it falls back automatically to a simulated (fake) device so the UI is always usable.

Embedding a widget in your application

from qtpy.QtWidgets import QApplication
from QInstrument.instruments import QDS345Widget

app = QApplication([])
widget = QDS345Widget()
widget.show()
app.exec()

Using a simulated instrument

When hardware is not available, pass a fake device directly:

from QInstrument.instruments import QDS345Widget, QFakeDS345

app = QApplication([])
widget = QDS345Widget(device=QFakeDS345())
widget.show()
app.exec()

Architecture

QtCore.QObject
└── QAbstractInstrument      # property/method registry, thread-safe get/set
    └── QSerialInstrument    # holds QSerialInterface; adds open/find/identify
        └── QXxxInstrument   # concrete instrument

QtSerialPort.QSerialPort
└── QSerialInterface         # raw serial I/O (owned by QSerialInstrument)

QWidget
├── QInstrumentWidget        # loads .ui file; auto-binds widgets to properties;
│                            # saves/restores device state via Configure
└── QInstrumentRack          # holds multiple QInstrumentWidgets; runtime
                             # add/remove; saves/restores instrument list

Each instrument lives in instruments/<Name>/ with three files:

File Purpose
instrument.py Serial communication and property registration
fake.py Simulated instrument for UI development without hardware
widget.py Qt widget, .ui file binding, example() entry point

Development

Run the test suite:

source .qi/bin/activate
pytest tests/

Tests run automatically before every git push via a pre-push hook. To install the hook in a fresh clone:

cp hooks/pre-push .git/hooks/pre-push   # if tracked, else set up manually
chmod +x .git/hooks/pre-push

Acknowledgements

Work on this project at New York University is supported by the National Science Foundation of the United States under award number DMR-2438983.

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

qinstrument-2.4.0.tar.gz (109.7 kB view details)

Uploaded Source

Built Distribution

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

qinstrument-2.4.0-py3-none-any.whl (122.2 kB view details)

Uploaded Python 3

File details

Details for the file qinstrument-2.4.0.tar.gz.

File metadata

  • Download URL: qinstrument-2.4.0.tar.gz
  • Upload date:
  • Size: 109.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qinstrument-2.4.0.tar.gz
Algorithm Hash digest
SHA256 5770d3bebcf79e8a834a7685e290e12b35ff1af4dcf098795e4335caa96f654e
MD5 f17f6b08d984cf72148cee20389a9377
BLAKE2b-256 4c616b99fb57df78438fa4c7a6076dffa578c8a4d2fd5cdae1fdab5747f50570

See more details on using hashes here.

Provenance

The following attestation bundles were made for qinstrument-2.4.0.tar.gz:

Publisher: publish.yml on davidgrier/QInstrument

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file qinstrument-2.4.0-py3-none-any.whl.

File metadata

  • Download URL: qinstrument-2.4.0-py3-none-any.whl
  • Upload date:
  • Size: 122.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for qinstrument-2.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6838a22098f9e12b10c7807f44b75080fce096bebfa773a0d9b9a8a352f80321
MD5 5a97f9be876e9f92674451d78510e9ed
BLAKE2b-256 b7b134d3e0a41b7752e392775d74dc9311ebc18341f36544e17c1d0777b1952c

See more details on using hashes here.

Provenance

The following attestation bundles were made for qinstrument-2.4.0-py3-none-any.whl:

Publisher: publish.yml on davidgrier/QInstrument

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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