pygpp 0.1.0
A Python abstraction layer for GW-Instek GPP power supplies
Requires Python: >=3.12
Keywords: gpp, gwinstek, power supply, scpi, visa

# pyGPP

![Status](https://img.shields.io/badge/status-early_dev-orange)
![Python](https://img.shields.io/badge/python-3.12%2B-blue)
[![License](https://img.shields.io/badge/license-MIT-green)](./LICENSE)
[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)

_pyGPP_ is a Python Hardware Abstraction Layer (HAL) over SCPI commands using [PyVISA](https://pyvisa.readthedocs.io/en/latest/) for controlling GW-Instek GPP series power supplies.
It simplifies automation, allowing you to focus on your test logic rather than looking up raw SCPI command strings.

**Supported Models:**
- GPP-3060
- GPP-6030
- GPP-3650

### Why this library?
- Type-safe API (`Enums`, `Dataclasses`) instead of magic strings
- Model-aware validation (prevents sending 70V to a 30V channel)
- Auto-disables outputs on exit/error via context manager
- Returns structured data, not CSV strings


## Quick Start
```python
from pygpp import GPP3060, ChannelMode

with GPP3060(address='ASRL3::INSTR') as psu:
    # Example: Using the GPP as an electronic load
    psu.ch1.set_mode(ChannelMode.LOAD_CC)
    psu.ch1.set_current(0.5)  # Sink 0.5A
    psu.ch1.enable()
    data = psu.ch1.measure()
    print(f"Sinking {data.power} W")
```

## Examples
The [`examples/`](examples) directory demonstrates the features in progressive complexity.
The plot below was generated using [`examples/04_python_sequence.py`](examples/04_python_sequence.py) 
to sweep the load on a GPP-3060 and characterize a buck converter:

![See example 04 for a description.](/docs/img/e03_plot_6A.png "Efficiency and load regulation plot.")

## Prerequisites

*   **Hardware**: A supported GW-Instek programmable power supply.
*   **Drivers**:
    *   [GW-Instek USB Driver](https://www.gwinstek.com/en-global/download/index?cate=93&subcate=644&ser=2123&down=62&key=) (not needed in LAN mode)
    *   **VISA Backend** (choose one):
        *   [NI-VISA](https://www.ni.com/en/support/downloads/drivers/download.ni-visa.html) (recommended, full-featured)
        *   [PyVISA-py](https://pyvisa.readthedocs.io/projects/pyvisa-py/en/latest/) (pure Python, no binary install): `pip install pyvisa-py`
*   **Tooling**: [uv](https://docs.astral.sh/uv/) (optional)

## Installation

### As a Dependency (for users)

If you want to use _pyGPP_ in your own project, install it directly from PyPI:

```bash
pip install pygpp
```
 
**Try the examples:**
```bash
git clone https://gitlab.com/samshahrokni/pyGPP.git
cd pyGPP
uv sync --group examples

# Run any example directly:
uv run python -m examples.01_connection_check
```

### For Development (for contributors)

Clone the repository and sync dependencies (automatically fetches Python):

```bash
git clone https://gitlab.com/samshahrokni/pyGPP.git
cd pyGPP
uv sync --all-extras
pre-commit install
```

## Notes

*   **Incomplete Implementation**: Not all SCPI commands are implemented. See the [GPP Series User Manual](https://www.gwinstek.com/en-global/download/downloadFile/21821) for the full command list.