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.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

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: instrumation-0.1.2.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for instrumation-0.1.2.tar.gz
Algorithm Hash digest
SHA256 e4c642c22f2854e2038c5fe0469d07aa1e7f17951984960ce5732e6cdd9f112e
MD5 c7084ca8e967a20ec9c6f21e061d9ab5
BLAKE2b-256 f3e1a658ad3d55bc2776aade71d2e4500cbe329b96430c6dfcc36d6c9d7f7d06

See more details on using hashes here.

File details

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

File metadata

  • Download URL: instrumation-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for instrumation-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a388509fb164a67e3bf9b5a59667851a936329032ede1b57dba4758f4e8e9c25
MD5 0565aacdc5514a554685d897c39bcf8a
BLAKE2b-256 711b3eebb2afac0b4ef940ec8a99463ac5217ac6076b96ae6c10527b9cb80331

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