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.6.tar.gz (20.9 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.6-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: instrumation-0.1.6.tar.gz
  • Upload date:
  • Size: 20.9 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.6.tar.gz
Algorithm Hash digest
SHA256 111f19be0a6f6bcfe4b0c933f0a8c0ad11c17c3e45047627c8ef0202939c0c7d
MD5 abae7605669ccd4c7d3ba7436181c829
BLAKE2b-256 59991b8f5e9023b5d16196814a8f12abb192ee2b455b08014639863d6ed4ef16

See more details on using hashes here.

File details

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

File metadata

  • Download URL: instrumation-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 19.9 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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 bb9ea6b2fc2729c104abd153ad688042968d2af03e82155add57645f400ce371
MD5 9c821febe193986f41c228d77c395603
BLAKE2b-256 b9f42295a701d736f65b2f345ad5ad8af148c0837820d1dff48746396eaf5fab

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