μ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()
```
Metadata
Release files for usmu-py 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| usmu_py-1.0.0.tar.gz | 4.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| usmu_py-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 11.2 kB
Release files / usmu_py-1.0.0.tar.gz
| Download URL | usmu_py-1.0.0.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
39aca1ffc694026d03ad12708df4333df5eaf745fe898afd2910ab40aaa2e251
|
|
BLAKE2b-256 checksum How to use checksums |
5226eee8127f13a7be642a1705f078e622bfe01a0155a0196d94c014587f1582
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Release files / usmu_py-1.0.0-py3-none-any.whl
| Download URL | usmu_py-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c8bbc7c839cc02152de7f5ac0ad2ad073a378156824f25aaae62ca7f7631b6a9
|
|
BLAKE2b-256 checksum How to use checksums |
da28f5cdf7ba046db07eb06cce9960227781c3abb5704b2ab17075a64df47ed3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|