# BK Precision 1900 Series Control
A lightweight Python 3.12 library and CLI for controlling **BK Precision 1900-series programmable DC power supplies**, tested on the **BK 1902B**.
It provides both a **Pythonic context-manager interface** and a simple **command-line tool** for automation or lab use.
## โจ Features
- Safe open/close via context manager
- Set and read output voltage/current
- Enable or disable output
- Query front-panel readings (voltage, current, CV/CC mode)
- Command-line interface (`bk1902b`) for quick manual control
## ๐งฐ Installation
### From PyPI
```bash
pip install bk_precision_1900
```
### From Source
```bash
git clone https://github.com/DephyInc/bk_precision_1900.git
cd bk_precision_1900
pip install -e ".[dev]"
```
## ๐ Command-Line Usage
After installation, a console script `bk1902b` is available.
```bash
# Set output voltage to 12.0 V
bk1902b set-voltage --port /dev/ttyUSB0 12.0
# Set output current to 2.0 A
bk1902b set-current --port /dev/ttyUSB0 2.0
# Turn output on / off
bk1902b output --port /dev/ttyUSB0 on
bk1902b output --port /dev/ttyUSB0 off
# Read front-panel display (voltage, current, mode)
bk1902b read-display --port /dev/ttyUSB0
bk1902b read-display --port /dev/ttyUSB0 --json
```
> Replace `/dev/ttyUSB0` with your serial port (e.g., `COM3` on Windows).
## ๐งโ๐ป Library Usage
```bash
import time
from bk_precision_1900.bk1902b import BK1902B
with BK1902B("/dev/ttyUSB0") as psu:
psu.set_current(0.1)
psu.set_voltage(5.0)
psu.enable_output()
time.sleep(5)
psu.disable_output()
```
## ๐งฉ Demo Script
A minimal example (`bk_precision_1900/bk_demo.py`) is included:
```bash
python -m bk_precision_1900.bk_demo /dev/ttyUSB0
```
It cycles voltages between 1 V and 40 V, reads back live measurements, and prints CV/CC status.
## ๐งช Development
```bash
# Format, lint, and type-check
ruff format .
ruff check .
mypy .
```
Requirements are managed via `pyproject.toml` and use [Ruff](https://docs.astral.sh/ruff) for linting + formatting and [Mypy](https://mypy-lang.org) for static type checking.
## ๐ To Do
- Implement full BK 1900 command set (`GETS`, `SOVP`, `SOCP`, etc.)
- Query limits instead of hard-coding max values
- Add unit tests / mock serial backend
- Automate releases (e.g. GitHub Actions)
## โ๏ธ License
MIT License ยฉ Dephy Inc.
See [https://dephyinc.mit-license.org/](LICENSE) for details.
Raw data
{
"_id": null,
"home_page": null,
"name": "bk-precision-1900",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "B&K, BK Precision, hardware, serial, power-supply",
"author": null,
"author_email": "Carlos Asmat <casmat@dephy.com>",
"download_url": "https://files.pythonhosted.org/packages/14/8c/ec0876f91b76df55ece2c22d7a5ad7ad75a0308e6e8b44a41eba7d33c449/bk_precision_1900-1.1.1.tar.gz",
"platform": null,
"description": "# BK Precision 1900 Series Control\n\nA lightweight Python 3.12 library and CLI for controlling **BK Precision 1900-series programmable DC power supplies**, tested on the **BK 1902B**.\nIt provides both a **Pythonic context-manager interface** and a simple **command-line tool** for automation or lab use.\n\n## \u2728 Features\n\n- Safe open/close via context manager\n- Set and read output voltage/current\n- Enable or disable output\n- Query front-panel readings (voltage, current, CV/CC mode)\n- Command-line interface (`bk1902b`) for quick manual control\n\n## \ud83e\uddf0 Installation\n\n### From PyPI\n\n```bash\npip install bk_precision_1900\n```\n\n### From Source\n\n```bash\ngit clone https://github.com/DephyInc/bk_precision_1900.git\ncd bk_precision_1900\npip install -e \".[dev]\"\n```\n\n## \ud83d\ude80 Command-Line Usage\n\nAfter installation, a console script `bk1902b` is available.\n\n```bash\n# Set output voltage to 12.0 V\nbk1902b set-voltage --port /dev/ttyUSB0 12.0\n\n# Set output current to 2.0 A\nbk1902b set-current --port /dev/ttyUSB0 2.0\n\n# Turn output on / off\nbk1902b output --port /dev/ttyUSB0 on\nbk1902b output --port /dev/ttyUSB0 off\n\n# Read front-panel display (voltage, current, mode)\nbk1902b read-display --port /dev/ttyUSB0\nbk1902b read-display --port /dev/ttyUSB0 --json\n```\n\n> Replace `/dev/ttyUSB0` with your serial port (e.g., `COM3` on Windows).\n\n## \ud83e\uddd1\u200d\ud83d\udcbb Library Usage\n\n```bash\nimport time\nfrom bk_precision_1900.bk1902b import BK1902B\n\nwith BK1902B(\"/dev/ttyUSB0\") as psu:\n psu.set_current(0.1)\n psu.set_voltage(5.0)\n psu.enable_output()\n time.sleep(5)\n psu.disable_output()\n```\n\n## \ud83e\udde9 Demo Script\n\nA minimal example (`bk_precision_1900/bk_demo.py`) is included:\n\n```bash\npython -m bk_precision_1900.bk_demo /dev/ttyUSB0\n```\n\nIt cycles voltages between 1 V and 40 V, reads back live measurements, and prints CV/CC status.\n\n## \ud83e\uddea Development\n\n```bash\n # Format, lint, and type-check\n ruff format .\n ruff check .\n mypy .\n```\n\nRequirements are managed via `pyproject.toml` and use [Ruff](https://docs.astral.sh/ruff) for linting + formatting and [Mypy](https://mypy-lang.org) for static type checking.\n\n## \ud83d\udcdd To Do\n\n- Implement full BK 1900 command set (`GETS`, `SOVP`, `SOCP`, etc.)\n- Query limits instead of hard-coding max values\n- Add unit tests / mock serial backend\n- Automate releases (e.g. GitHub Actions)\n\n## \u2696\ufe0f License\n\nMIT License \u00a9 Dephy Inc.\nSee [https://dephyinc.mit-license.org/](LICENSE) for details.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Control the BK Precision 1900 series power supplies",
"version": "1.1.1",
"project_urls": {
"Homepage": "https://github.com/DephyInc/bk-precision-1900",
"Issues": "https://github.com/DephyInc/bk-precision-1900/issues",
"Repository": "https://github.com/DephyInc/bk-precision-1900"
},
"split_keywords": [
"b&k",
" bk precision",
" hardware",
" serial",
" power-supply"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "49a5a87fef5ca32e4f4badcd0402c45b7ea9a10dd9c312c8a3e13f4ce3fc8437",
"md5": "7daec0e571f33742acba28d9fa5e77c7",
"sha256": "a5cbf3ff9b827fb11a9de8e3f78a35d30d2578c23c8d125a02988ffb3347111d"
},
"downloads": -1,
"filename": "bk_precision_1900-1.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7daec0e571f33742acba28d9fa5e77c7",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 7843,
"upload_time": "2025-10-10T19:52:28",
"upload_time_iso_8601": "2025-10-10T19:52:28.476955Z",
"url": "https://files.pythonhosted.org/packages/49/a5/a87fef5ca32e4f4badcd0402c45b7ea9a10dd9c312c8a3e13f4ce3fc8437/bk_precision_1900-1.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "148cec0876f91b76df55ece2c22d7a5ad7ad75a0308e6e8b44a41eba7d33c449",
"md5": "42d3d3decd2d780e3b46ad7195911a17",
"sha256": "c5eb83fe44a7b05d1a9e24b993b65804fd353ce02ee5cb140e18f17be51f8d0d"
},
"downloads": -1,
"filename": "bk_precision_1900-1.1.1.tar.gz",
"has_sig": false,
"md5_digest": "42d3d3decd2d780e3b46ad7195911a17",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 7169,
"upload_time": "2025-10-10T19:52:29",
"upload_time_iso_8601": "2025-10-10T19:52:29.790324Z",
"url": "https://files.pythonhosted.org/packages/14/8c/ec0876f91b76df55ece2c22d7a5ad7ad75a0308e6e8b44a41eba7d33c449/bk_precision_1900-1.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-10-10 19:52:29",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "DephyInc",
"github_project": "bk-precision-1900",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "bk-precision-1900"
}