Skip to main content

A high-level Hardware Abstraction Layer (HAL) for RF test stations with Digital Twin support.

Project description

Instrumation

PyPI version License Python Versions Stars

Example

A high-level Hardware Abstraction Layer (HAL) for RF test stations. Stop wrestling with PyVISA boilerplate — write test logic, not connection code.


Why Instrumation?

RF test bench automation is painful. Every instrument brand has its own quirks, SCPI dialects vary, and testing your scripts requires physical hardware on your desk. Instrumation fixes all three:

  • One API for everything — same code works on Keysight, Rigol, and any other supported brand
  • Digital Twin mode — develop and debug offline with simulated instruments that emit realistic Gaussian noise
  • Smart auto-detection — scans connected devices and loads the right driver automatically, no manual config


Live Data Streaming

Instrumation includes a built-in DataBroadcaster for streaming live readings over UDP. This allows you to build real-time dashboards or loggers with zero external dependencies.

  • Zero-lag — UDP delivery doesn't block your test flow.
  • Zero-config — Broadcast to any host/port as JSON packets.
  • Zero-dep — Built-in with Python standard library.

See examples/broadcast_demo.py and examples/dashboard.py for usage.

Features

  • Auto-Discovery — scans VISA and Serial buses, identifies what's connected
  • Smart Factory — detects instrument brand and loads the correct driver
  • Digital Twin — full simulation mode for offline development and CI pipelines
  • Unified API — write once, run on any supported hardware
  • Built-in CSV logging — test results logged out of the box

Installation

pip install instrumation

Or install from source:

git clone https://github.com/abduznik/instrumation.git
cd instrumation
pip install .

Windows users: You may need NI-VISA or Keysight IO Libraries Suite for physical hardware access.


Quick Start

Real hardware

import instrumation

sa = instrumation.connect_instrument("USB0::0x2A8D::...")

peak_power = sa.get_peak_value()
print(f"Peak Power: {peak_power} dBm")

Digital Twin (no hardware needed)

# Linux/macOS
export INSTRUMATION_MODE=SIM

# Windows PowerShell
$env:INSTRUMATION_MODE="SIM"
from instrumation.factory import get_instrument

# Safer usage with context manager
with get_instrument("DUMMY_ADDRESS", "DMM") as dmm:
    print(dmm.get_id())
    result = dmm.measure_voltage()
    print(f"Voltage: {result}")

Station Manager (TOML)

Manage complex test stations with multiple instruments using a station.toml file.

[instruments.sa_main]
driver = "SA"
address = "USB0::0x2A8D::0x0101::MY12345678::0::INSTR"

[instruments.psu_dut]
driver = "PSU"
address = "TCPIP0::192.168.1.100::inst0::INSTR"

Use it in your code:

from instrumation import Station

station = Station("station.toml")
station.connect()

# Access instruments via dot notation
res = station.instr.sa_main.get_peak_value()
print(f"Peak: {res}")

station.disconnect()

Command Line Interface

Instrumation comes with a powerful CLI for quick interaction and diagnostics.

# Scan for connected hardware
instrumation scan

# Take a quick measurement
instrumation measure USB0::... DMM measure_voltage

# List instruments in your station.toml
instrumation station list

# Measure using a named instrument from your station
instrumation station measure sa_main get_peak_value

API Reference

Command Description
scan() Lists all connected Serial and VISA devices
connect() Auto-connects to a generic Test Station (Box + Instrument)
connect_instrument(addr) Connects to a specific instrument with auto driver detection

Platform Support

Platform Status
Windows Supported
Linux Supported
Termux (Android) Supported
macOS Supported

Development

# Install in editable mode (required for tests to pick up local changes)
pip install -e .
# This project uses pyproject.toml (PEP 517/518). No setup.py is required.


# Install test dependencies
pip install pytest flake8

# Run tests (simulation mode)
export INSTRUMATION_MODE=SIM  # Linux/macOS
pytest

Tech Stack

  • Language: Python 3.7+
  • Libraries: PyVISA, PySerial
  • Architecture: Smart Factory Pattern, Polymorphism
  • Standards: SCPI (Standard Commands for Programmable Instruments)

Support the Project

Instrumation is maintained in my spare time alongside a full-time RF technician job. If it's saved you hours of boilerplate or made your test bench easier to automate, consider supporting:

GitHub Sponsors

Commercial support or custom driver development? Reach out via GitHub Issues or Discussions.


Contributing

PRs and driver contributions are welcome. Open an issue first to discuss larger changes.

License

See LICENSE for details.

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

instrumation-0.2.0.tar.gz (34.2 kB view details)

Uploaded Source

Built Distribution

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

instrumation-0.2.0-py3-none-any.whl (35.2 kB view details)

Uploaded Python 3

File details

Details for the file instrumation-0.2.0.tar.gz.

File metadata

  • Download URL: instrumation-0.2.0.tar.gz
  • Upload date:
  • Size: 34.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for instrumation-0.2.0.tar.gz
Algorithm Hash digest
SHA256 64e33cdb3150298257ac2fcdbe83db7547a6fcdaade6851c222e9100bb4a1d02
MD5 38879ddbf8a109421f96ffc212c76cd7
BLAKE2b-256 cb9f8ad1adaba70e0791357d482cfea266d06da513c392926040acbd82e32aa1

See more details on using hashes here.

File details

Details for the file instrumation-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: instrumation-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 35.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for instrumation-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 280ddfd37420b0e9513933c99c330f102ca3f251d43e4e8d536742638aa9a57e
MD5 e9100128ab6dc8fe49c32d620373144d
BLAKE2b-256 255983b5f57c734dcd5f79e5d6d57a2dff8650d3cb92e566b269b18ff9da65fc

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