Skip to main content

Keysight B1500A + Thorlabs PM100D synchronized LIV sweep with automatic optical rollover detection (CUSUM, EWMA, rolling average, regression)

Project description

b1500_powermeter_rollover

PyPI Python License: MIT

Synchronized Keysight B1500 + Thorlabs power-meter IV sweep with four-algorithm rollover detection.

© Veronica Gao Zhan – May 2026


Features

Feature Detail
IV sweep Point-by-point sourcing via B1500 SMU (IV or VI mode)
Optical power Real-time Thorlabs PM100D / PM400 readout per point
Rollover detection 4 algorithms: CUSUM (default), EWMA, Rolling Average, Regression (sklearn)
GUI PyQt5 scrollable control panel + live 2×2 matplotlib canvas
CLI Full headless operation with argparse
CSV export Timestamped file per sweep with rollover summary header

Package Structure

b1500_powermeter_rollover/
├── __init__.py            ← public API re-exports
├── __main__.py            ← python -m b1500_powermeter_rollover
├── config.py              ← SweepConfig, MeasurementPoint, RolloverResult
├── b1500_controller.py    ← thread-safe VISA driver for Keysight B1500
├── powermeter_controller.py ← thread-safe VISA driver for Thorlabs PM100D/PM400
├── rollover_detector.py   ← instrument-agnostic online rollover detector
├── engine.py              ← SynchronizedMeasurementEngine (no GUI dependency)
├── cli.py                 ← build_parser() + run_cli()
├── gui/
│   ├── __init__.py
│   ├── worker.py          ← MeasurementWorker (QThread)
│   └── main_window.py     ← SynchronizedMeasurementGUI (QMainWindow)
├── requirements.txt
└── pyproject.toml

Installation

# From the B1500/ folder (editable install)
pip install -e ".[all]"

# Or install only the core (no GUI, no ML)
pip install -e .

# Or manually
pip install pyvisa pyvisa-py pyusb numpy PyQt5 matplotlib scikit-learn

Quick Start

GUI (interactive)

python -m b1500_powermeter_rollover

CLI (headless / automated)

# List connected instruments
python -m b1500_powermeter_rollover --list

# Run an IV sweep with CUSUM rollover detection
python -m b1500_powermeter_rollover \
    --b1500 GPIB0::17::INSTR \
    --pm    USB0::0x1313::0x8078::INSTR \
    --start 0 --stop 2.5 --steps 26 \
    --compliance 0.5 --dwell 0.1 \
    --rollover --method cusum --threshold 90 \
    --output ./results --name MyLaser

Python API

from b1500_powermeter_rollover import (
    SweepConfig,
    B1500Controller,
    ThorlabsPowerMeterController,
    SynchronizedMeasurementEngine,
)

b  = B1500Controller()
pm = ThorlabsPowerMeterController()
b.connect("GPIB0::17::INSTR")
pm.connect("USB0::0x1313::0x8078::INSTR")

cfg = SweepConfig(
    mode="iv", start=0, stop=2.5, steps=26,
    enable_rollover=True, rollover_method="cusum",
)
eng = SynchronizedMeasurementEngine(b, pm, cfg)
eng.on_log = print
data = eng.run()

r = eng.rollover_result
print(f"Peak power {r.peak_power:.4e} W at {r.peak_voltage:.4f} V")

Standalone rollover detector (no instruments)

from b1500_powermeter_rollover import SweepConfig, RolloverDetector

cfg = SweepConfig(rollover_method="cusum", rollover_threshold=0.90)
det = RolloverDetector(cfg)

peak = 0.0
for power in my_power_readings:
    peak = max(peak, power)
    triggered, info = det.update(power, peak)
    if triggered:
        print("Rollover detected!", info)
        break

Detection Algorithms

Method Latency Notes
cusum (default) 1–3 pts Lower-sided CUSUM (Page 1954). Scale-invariant. O(1)/sample
ewma ~window/2 Exponential moving average. Tunable with --alpha
rolling_avg window pts Classic windowed mean. Robust to impulse noise
regression window pts sklearn LinearRegression (batch) + SGDRegressor (online)

Acknowledgements

This project was developed using vibe coding — an AI-assisted development workflow powered by GitHub Copilot. The architecture, code structure, and implementation were generated through iterative natural-language prompting and human review.

License

© Veronica Gao ZHan

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

b1500_powermeter_rollover-1.0.1.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

b1500_powermeter_rollover-1.0.1-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file b1500_powermeter_rollover-1.0.1.tar.gz.

File metadata

File hashes

Hashes for b1500_powermeter_rollover-1.0.1.tar.gz
Algorithm Hash digest
SHA256 199361dacb37e343a02c2089f8a9ef63c2de65eb31b396d34b166b8ade51ec90
MD5 60733ffab54a51b0bc8af805eb2fd9ec
BLAKE2b-256 c987464df2a452680b41997524f308ca0853c0ae3249214a8061444904bfbfe8

See more details on using hashes here.

File details

Details for the file b1500_powermeter_rollover-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for b1500_powermeter_rollover-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e5491c1d851acecfefdbd2eb6281b0369391cf2e6dca5cd61288726be86d1e40
MD5 9d7c15256098f3e3f369beaa9accf6dc
BLAKE2b-256 811b2e0175b938e46d76e5153c33ca11829f0e9e754f32d596e2d7f0c6d10691

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