97 lines
2.8 KiB
Markdown
97 lines
2.8 KiB
Markdown
# HPCS 6500 — Open-Source Driver
|
|
|
|
Python driver and CLI for the HPCS 6500 spectrophotometer / integrating sphere.
|
|
|
|
Communicates directly with the instrument over USB serial, replacing the
|
|
vendor software for measurement automation and data extraction.
|
|
|
|
## What This Does
|
|
|
|
- **Measure**: Luminous flux (lm), CCT (K), CRI (Ra, R1-R15), chromaticity
|
|
(CIE xy, uv, u'v'), radiometric flux, spectrum 380-1050 nm
|
|
- **Electrical**: Voltage, current, power, power factor, frequency
|
|
- **Harmonics**: 50-harmonic voltage/current analysis, UThd, AThd, waveforms
|
|
- **Power supply**: Control the built-in AC (100-240V, 50/60Hz) and DC
|
|
(1-60V, 0-5A) power supply
|
|
- **Export**: CSV output for data logging
|
|
|
|
## Quick Start
|
|
|
|
```bash
|
|
# Install
|
|
uv sync
|
|
|
|
# Single measurement (auto-detects device, turns PSU on/off)
|
|
uv run hpcs6500.py
|
|
|
|
# Continuous measurements
|
|
uv run hpcs6500.py --continuous
|
|
|
|
# Quick test (lumen + CCT only)
|
|
uv run hpcs6500.py --quick
|
|
uv run hpcs6500.py --quick --continuous
|
|
|
|
# Show full spectrum + harmonics
|
|
uv run hpcs6500.py --spectrum --harmonics
|
|
|
|
# Save to CSV
|
|
uv run hpcs6500.py --continuous --csv output.csv
|
|
```
|
|
|
|
## Power Supply Control
|
|
|
|
```bash
|
|
# Read current PSU settings
|
|
uv run hpcs6500.py --psu-status
|
|
|
|
# Set AC mode, 230V 50Hz
|
|
uv run hpcs6500.py --mode ac --voltage 230 --frequency 50
|
|
|
|
# Set DC mode, 12V with 1A current limit
|
|
uv run hpcs6500.py --mode dc --voltage 12 --current 1.0
|
|
|
|
# Manual PSU on/off
|
|
uv run hpcs6500.py --psu-on
|
|
uv run hpcs6500.py --psu-off
|
|
|
|
# Set integration time (ms)
|
|
uv run hpcs6500.py --integration 500
|
|
```
|
|
|
|
## Offline Parsing
|
|
|
|
Parse previously captured USB traffic (pcap files from USBPcap):
|
|
|
|
```bash
|
|
uv run hpcs6500.py --parse captures/some_capture.pcap
|
|
uv run hpcs6500.py --parse captures/some_capture.pcap --quick
|
|
```
|
|
|
|
## Files
|
|
|
|
| File | Description |
|
|
|------------------|----------------------------------------------------|
|
|
| `hpcs6500.py` | Driver class (`HPCS6500`) and CLI |
|
|
| `usb_capture.py` | USB traffic capture tool (requires USBPcap) |
|
|
| `PROTOCOL.md` | Complete protocol reference (byte-level) |
|
|
| `pyproject.toml` | Project metadata and dependencies |
|
|
|
|
## Hardware
|
|
|
|
- **Device**: HPCS 6500 spectrophotometer / integrating sphere
|
|
- **USB**: STM32 Virtual COM Port (VID `0483`, PID `5741`)
|
|
- **Protocol**: Custom binary over serial, documented in [PROTOCOL.md](PROTOCOL.md)
|
|
|
|
## Dependencies
|
|
|
|
- Python 3.11+
|
|
- `pyserial` (serial communication)
|
|
- USBPcap (only for `usb_capture.py`, not needed for normal operation)
|
|
|
|
## Protocol
|
|
|
|
The binary protocol is fully documented in [PROTOCOL.md](PROTOCOL.md),
|
|
including all command bytes, data block layouts, field offsets, and the
|
|
complete measurement sequence. This was reverse-engineered from USB
|
|
packet captures of the vendor software.
|