Skip to main content

A simple Python library for controlling the uSMU source-measure unit

Project description

μSMU Python Library

A lightweight Python library for controlling a the μSMU source-measure unit device over a Virtual COM Port (VCP). This library provides a simple Python interface to send commands and read measurements from the μSMU, making it easy to automate I–V sweeps, data logging, and more.

Features

  • Communicate with a USB SMU via a serial (VCP) interface using PySerial.
  • Set output voltage, current limit, oversampling rate, DAC values, and other SMU settings.
  • Measure voltage and current (I–V) in a single command.
  • Perform scripted sweeps (e.g., from a negative voltage to a positive voltage).
  • Automatically insert a configurable delay (e.g., 50 ms) between commands.
  • Installation

You can install this package directly from PyPI (once published):

pip install usmu_py

If you're developing locally or have cloned this repo, install it in editable mode:

cd path/to/your/usmu_py
pip install -e .

Ensure PySerial and other dependencies are installed. If plotting is desired, also install Matplotlib and NumPy.

pip install pyserial numpy matplotlib

Basic Usage Example

Below is a minimal script demonstrating how to initialize the SMU, set voltage, measure it, and then close the session.

from usmu_py.smu import USMU

def main():
    # Open SMU on the specified port (e.g., 'COM3' or '/dev/ttyUSB0')
    smu = USMU(port="COM3", baudrate=9600, command_delay=0.05)
    try:
        # Identify the SMU
        idn = smu.read_idn()
        print("IDN:", idn)

        # Enable output and configure current limit
        smu.enable_output()
        smu.set_current_limit(20.0)  # 20 mA current limit

        # Set voltage and measure
        voltage, current = smu.set_voltage_and_measure(1.0)
        print(f"Set voltage: 1.0 V | Measured Voltage: {voltage:.3f} V, Current: {current:.6f} A")

        # Disable output after testing
        smu.disable_output()
    finally:
        smu.close()

if __name__ == "__main__":
    main()

Example I–V Sweep

Below is a snippet showing how to perform a simple I–V sweep, measuring voltage and current at each step, and then plotting the results:

import numpy as np
import matplotlib.pyplot as plt
from usmu_py.smu import USMU

def iv_sweep_example():
    port = "COM3"
    start_voltage = -1.0
    end_voltage = +1.0
    points = 10

    voltages = np.linspace(start_voltage, end_voltage, points)
    measurements = []

    with USMU(port=port, baudrate=9600, command_delay=0.05) as smu:
        print("IDN:", smu.read_idn())
        smu.enable_output()
        smu.set_current_limit(20.0)
        smu.set_oversample_rate(25)

        for v in voltages:
            voltage, current = smu.measure_iv_point(v)
            measurements.append((voltage, current))
            print(f"{voltage:.3f} V, {current:.6e} A")

        smu.disable_output()

    # Plot the resulting I–V curve
    vs = [m[0] for m in measurements]
    is_ = [m[1] for m in measurements]
    plt.figure()
    plt.plot(vs, is_, 'o-')
    plt.xlabel("Voltage (V)")
    plt.ylabel("Current (A)")
    plt.title("I–V Sweep")
    plt.grid(True)
    plt.show()

if __name__ == "__main__":
    iv_sweep_example()
	```

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

usmu_py-1.0.0.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

usmu_py-1.0.0-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file usmu_py-1.0.0.tar.gz.

File metadata

  • Download URL: usmu_py-1.0.0.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for usmu_py-1.0.0.tar.gz
Algorithm Hash digest
SHA256 39aca1ffc694026d03ad12708df4333df5eaf745fe898afd2910ab40aaa2e251
MD5 1182c0f0019fa198e1928d91571d17ec
BLAKE2b-256 5226eee8127f13a7be642a1705f078e622bfe01a0155a0196d94c014587f1582

See more details on using hashes here.

File details

Details for the file usmu_py-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: usmu_py-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.12.8

File hashes

Hashes for usmu_py-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c8bbc7c839cc02152de7f5ac0ad2ad073a378156824f25aaae62ca7f7631b6a9
MD5 fec347a8bb63c9c71170a2aa33f02b40
BLAKE2b-256 da28f5cdf7ba046db07eb06cce9960227781c3abb5704b2ab17075a64df47ed3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page