A high-level Hardware Abstraction Layer (HAL) for RF test stations with Digital Twin support.
Project description
Instrumation
A high-level Hardware Abstraction Layer (HAL) for RF test stations, designed to simplify interactions with VISA instruments and Serial control boxes.
About The Project
Instrumation is a Python library that provides a unified interface for controlling hardware test benches. It abstracts away the low-level details of PyVISA and PySerial, allowing you to focus on writing test logic rather than connection code.
It features a Digital Twin mode, enabling you to develop and test your scripts offline using simulated drivers that generate realistic data with noise.
Tech Usage
- Language: Python 3.8+
- Libraries: PyVISA, PySerial
- Architecture: Factory Pattern, Polymorphism
- Standards: SCPI (Standard Commands for Programmable Instruments)
Features
- Auto-Discovery: Automatically scans and identifies connected devices (VISA & Serial).
- Smart Factory: Detects connected hardware (e.g., Keysight vs. Rigol) and loads the correct driver automatically.
- Digital Twin: Simulation mode with realistic Gaussian noise for offline development.
- Unified API: Use the same code for different hardware brands.
- Logging: Built-in CSV logging for test results.
Getting Started
Prerequisites
- Python 3.8 or higher
- Git (optional, if cloning the repository)
Installation
- Download or Clone the repository:
You can download the source code as a ZIP file and extract it, or clone the repository using Git:
git clone https://github.com/yourusername/instrumation.git cd instrumation
- Install the library:
Navigate to the
instrumationproject root directory (wheresetup.pyis located) and install:pip install .
For developers, you might want to install in editable mode:pip install -e .
Setup Guide
Linux / Termux (Android)
If you are running this on Termux (Android) or a Linux machine:
-
Install dependencies:
pkg install python # Add git if you plan to clone the repo
(On standard Linux, use
sudo apt install python3and optionallygit) -
Setup Virtual Environment (Optional but Recommended):
python -m venv .venv source .venv/bin/activate
-
Install the library:
pip install .
Windows
- Open PowerShell as Administrator (for driver installation if needed).
- Install Python: Download from python.org.
- Download or Clone and Install:
# If cloning (requires Git): git clone https://github.com/yourusername/instrumation.git cd instrumation # Or if you downloaded the ZIP and extracted it, navigate to the extracted folder: # cd path\to\instrumation-main pip install .
- VISA Backend: You may need to install NI-VISA or Keysight IO Libraries Suite for physical hardware access.
Usage
1. Real Hardware Mode
Connect your devices and run:
import instrumation
# Auto-connect to first found instrument
sa = instrumation.connect_instrument("USB0::0x2A8D::...")
# Works on ANY supported device (Keysight, Rigol, etc.)
peak_power = sa.get_peak_value()
print(f"Peak Power: {peak_power} dBm")
2. Digital Twin (Simulation) Mode
Develop offline without hardware.
Enable Simulation:
- Linux/Termux:
export INSTRUMATION_MODE=SIM - Windows (PowerShell):
$env:INSTRUMATION_MODE="SIM" - Windows (CMD):
set INSTRUMATION_MODE=SIM
Run Code:
from instrumation.factory import get_driver
# Address is ignored in SIM mode
driver = get_driver("DUMMY_ADDRESS")
driver.connect()
print(f"ID: {driver.get_id()}")
print(f"Voltage: {driver.measure_voltage(1)} V")
| Command | Description |
|---|---|
scan() |
Lists all connected Serial and VISA devices. |
connect() |
Auto-connects to a generic Test Station (Box + Inst). |
connect_instrument(addr) |
Connects to a specific instrument (loading correct driver). |
Development & Testing
If you want to contribute or run the tests, follow these steps to avoid import errors.
-
Install in Editable Mode: This is crucial for tests to find your local changes.
pip install -e .
-
Install Test Dependencies:
pip install pytest flake8
-
Run Tests: Enable simulation mode and run pytest.
# Linux / Termux export INSTRUMATION_MODE=SIM pytest # Windows PowerShell $env:INSTRUMATION_MODE="SIM" pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file instrumation-0.1.1.tar.gz.
File metadata
- Download URL: instrumation-0.1.1.tar.gz
- Upload date:
- Size: 11.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4458b40c64bab4d67ba788c24d4bcac83e642a79baa4ca2212c6bb0e3337522d
|
|
| MD5 |
13016c130fdb4d1619f03ccd79cb6f35
|
|
| BLAKE2b-256 |
adf9a97cd8dbfd0d4df0a70c4e5ea82b643976ffb84d172a338e0d0467de0e3e
|
File details
Details for the file instrumation-0.1.1-py3-none-any.whl.
File metadata
- Download URL: instrumation-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a53f1b951f8581e32b52e06fcad2ea5fb4c8a4df554614b4eb51c1bfcbbf1805
|
|
| MD5 |
14475cf12d67778abf1fa13e1d030b20
|
|
| BLAKE2b-256 |
7ac087f6c0ea277772a9ccf5f8ea61281d124c719d16f560e2693a333629ed88
|