Library and CLI for the Hanmatek Power supply units (PSU) of the HM3xxP series.
Project description
Hanmatek HM3xxP PSU control library and CLI
Unifying library and CLI for the popular and low-cost digital lab power supplies HM305P and
HM310P.
The library provides an (almost) complete, easy to use interface to all known functions of the device. This project is different to the below mentioned ones, in that it provides a minimal, but complete interface to the device and also keeps the dependencies low.
This project is based on the work done in https://github.com/notkevinjohn/HM310P, which uses the
minimalmodbus library for device communication. Other related projects were providing
useful register definition and hints:
- https://github.com/JackDoan/hm305_ctrl/tree/master/hm305
- https://github.com/hobbyquaker/hanmatek-hm310p
- https://sigrok.org/wiki/ETommens_eTM-xxxxP_Series#Protocol
Installation
pip install hanmatek-psu
If users are in the plugdev user group, Hanmatek devices are accessible via /dev/ttyUSBx without
privileges. Adding the following udev rule will create a symlink /dev/ttyHM3xxP when a Hanmatek
PSU device is plugged in via USB. This symlink is used by default by the hanmatek-cli to find
devices:
echo 'SUBSYSTEM=="tty", ATTRS{idVendor}=="1a86", ATTRS{idProduct}=="7523", SYMLINK+="ttyHM3xxP", MODE="0666", GROUP="plugdev"' | sudo tee "/etc/udev/rules.d/99-hanmatek.rules" > /dev/null
Usage
CLI Usage
hanmatek-cli -h
hanmatek-cli --discover # find devices
hanmatek-cli # show default device info
hanmatek-cli --device /dev/ttyUSB0 # specific device
hanmatek-cli voltage:set 3.0 # set voltage
hanmatek-cli current:set 0.1 # set current limit
hanmatek-cli output on
hanmatek-cli current # read current
hanmatek-cli power # read power
hanmatek-cli output off
hanmatek-cli --list # list all commands/registers
Library Usage
from hanmatek import HM3xxP
device = HM3xxP("/dev/ttyHM3xxP")
print(device.info())
device.write("voltage:set", 3.0)
device.write("current:set", 3.0)
device.write("output", True)
print(device.read("current"))
print(device.read("power"))
device.write("output", False)
Development
The following tools are used to provide clean and quality software, and made available through a
tox configuration: flake8 for linting, black for code formatting and checking, mypy for
type checking and pytest for unit tests. Use as:
pip install "tox<=4" tox-poetry
(we're using tox-poetry, so that tox reads dependencies
from pyproject.toml)
(note that tox-poetry requires tox<4.x, see https://github.com/tkukushkin/tox-poetry/issues/15).
tox -a # show test environments
tox # run all
tox -e test # run unit tests
tox -e lint # run lint
tox -e type # run type checker
(we're using pyproject-flake8, so that the flake8
configuration can live in pyproject.toml - within tox we then run pflake8 instead of
flake8.)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hanmatek_psu-1.1.0.tar.gz.
File metadata
- Download URL: hanmatek_psu-1.1.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.4.109+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de59bdac2edb9a869b10b0a1dd90f9821550cd553a2f0c937685b2a39dd15a1d
|
|
| MD5 |
be09c4f897579d6a8856a8def0baad6e
|
|
| BLAKE2b-256 |
8b64c6ed7182256c359a910092bc9183c35fe959e386a7a5f56095ecc1fc8e2c
|
File details
Details for the file hanmatek_psu-1.1.0-py3-none-any.whl.
File metadata
- Download URL: hanmatek_psu-1.1.0-py3-none-any.whl
- Upload date:
- Size: 8.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.3.1 CPython/3.11.1 Linux/5.4.109+
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
88943d4703fc9efe60c4e5e2cff06cad03c6e6285cab5896bec33f1ed7dd06ce
|
|
| MD5 |
16a120659a95c68f0465fbcd477df3b6
|
|
| BLAKE2b-256 |
f52f0ebe248981334836278ee648de6306e9fa6db8857aeb5e98d7c82260e07e
|