Metadata-Version: 2.4
Name: keithley2400
Version: 0.2.2
Summary: Auto-discovering Keithley 2400/2450 SMU control library over serial or USB
Author-email: Asaf Ayalon <ayalon.asaf.c0@s.mail.nagoya-u.ac.jp>
License-Expression: MIT
Keywords: keithley,smu,sourcemeter,visa,iv-curve,instrumentation
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Physics
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
Requires-Dist: pyvisa>=1.11.0
Requires-Dist: pyvisa-py>=0.5.2
Requires-Dist: pyserial>=3.4
Requires-Dist: pyusb>=1.2.1
Provides-Extra: dev
Requires-Dist: setuptools; extra == "dev"
Requires-Dist: wheel; extra == "dev"
Requires-Dist: twine; extra == "dev"
Requires-Dist: build; extra == "dev"

# keithley2400

Single-file Python library for **Keithley 2400 and 2450 SourceMeter / SMU** control.

The public API stays simple:
- one import
- one class
- auto-detect model
- auto-detect serial vs USB
- old scripts can keep using `Keithley2400(...)`

## What it supports

- **Keithley 2400** over RS-232 / USB-serial (`ASRL...`)
- **Keithley 2450** over USBTMC / VISA USB (`USB...`)
- stale configured resources with automatic fallback discovery
- one shared high-level API for common operations: source V/I, compliance, read V/I/R, sweep IV, ramp voltage

## Installation

```bash
pip install keithley2400
```

For USB instruments when using the `@py` backend, also make sure the host has a USB backend library such as `libusb` installed.

## Quick start

### Auto-discover everything

```python
from keithley2400 import Keithley2400

with Keithley2400(resource=None) as k:
    print(k.idn())
    print(k.model)
    print(k.resource)
```

### Old code still works

```python
from keithley2400 import Keithley2400

k = Keithley2400(resource="ASRL/dev/cu.usbserial-FTRTKC3X::INSTR")
print(k.idn())
k.close()
```

If that resource is stale, the library tries it first and then falls back to auto-discovery.

### Ramp to bias voltage

```python
from keithley2400 import Keithley2400

with Keithley2400() as k:
    v_meas, i_meas = k.ramp_to_voltage(
        44.5,
        voltage_steps=[0, 10, 20, 30, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 44.5],
        compliance_amps=1e-3,
        high_voltage_threshold_v=35.0,
        high_compliance_amps=5e-3,
        high_compliance_hold_s=5.0,
        stabilize_s=3.0,
        current_range_amps=0.01,
        keep_output_on=True,
    )
    print(v_meas, i_meas)
```

## Compatibility note

The public class name remains `Keithley2400` for backward compatibility, but it now acts as a model-agnostic SMU facade. You can also import the alias `KeithleySMU`.
