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

Example

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.7+
  • 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.7 or higher
  • Git (optional, if cloning the repository)

Installation

  1. 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
    
  2. Install the library: Navigate to the instrumation project root directory (where setup.py is 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:

  1. Install dependencies:

    pkg install python # Add git if you plan to clone the repo
    

    (On standard Linux, use sudo apt install python3 and optionally git)

  2. Setup Virtual Environment (Optional but Recommended):

    python -m venv .venv
    source .venv/bin/activate
    
  3. Install the library:

    pip install .
    

Windows

  1. Open PowerShell as Administrator (for driver installation if needed).
  2. Install Python: Download from python.org.
  3. 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 .
    
  4. 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.

  1. Install in Editable Mode: This is crucial for tests to find your local changes.

    pip install -e .
    
  2. Install Test Dependencies:

    pip install pytest flake8
    
  3. Run Tests: Enable simulation mode and run pytest.

    # Linux / Termux
    export INSTRUMATION_MODE=SIM
    pytest
    
    # Windows PowerShell
    $env:INSTRUMATION_MODE="SIM"
    pytest
    

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.1.5.tar.gz (17.7 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.1.5-py3-none-any.whl (17.2 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for instrumation-0.1.5.tar.gz
Algorithm Hash digest
SHA256 ec6ac6d6686a3dd4e7bfa5278f5aae03bd933fd36a53b6a0d20bde3ce3c299e0
MD5 1ca16eab5221905024cb41670308232a
BLAKE2b-256 f41a17c157efa05d490fa3f852e23701443639ac09dc384f413f8e6106c03cf6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for instrumation-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 d3d5ceb464b31bac0b15a5217f56f2e3d25716b1e2b4c5d4295cb37e460eeba3
MD5 ed91d86adba32df60d2a56e91219f05e
BLAKE2b-256 76537cb1014b5ecd3acaed9078edac502db0840b4a6eecc6a0c9e784d8fce05a

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