ug_gpib
A Python3 pyUSB driver for the LQ Electronics Corp UGPlus USB to GPIB Controller.
Tested using Linux, should work for Mac OSX, Windows and any OS with Python pyUSB support.
:warning: The device must be IEEE 488.1 compliant. It must assert the EOI line to signal the end of a line. If this is not the case, the controller cannot be used. Older devices, typically only send CR, LF, or CR-LF.
The UGPlus is a fairly cheap controller, that supports simple GPIB read and write operations only. It does not support advanced GPIB features like serial polling for example, and it does not have line drivers to support long cables and lots of devices on the bus.
The UGPlus does have several firmware bugs, I have tried to mitigate them to the best of my knowledge. See below for details.
If you are looking for advanced features I suggest buying either a Prologix GPIB adapter or one of the NI USB adapters. I can recommend the following libraries for both Prologix GPIB adapter and Linux GPIB.
The library is fully type-hinted.
Setup
To install the library in a virtual environment (always use venvs with every project):
virtualenv env # virtual environment, optional
source env/bin/activate
pip install ug-gpib
Linux
To access the raw usb port in Linux, root privileges are required. It is possible to use udev to change ownership of the usb port on creation. This can be done via a rules file.
sudo cp 98-ugsimple.rules /etc/udev/rules.d/.
sudo udevadm control --reload-rules
Usage
Initialize UGSimpleGPIB
from ug_gpib import UGPlusGpib
gpib_controller = UGPlusGpib()
Writing "*IDN?" a command to address 0x02. Do note the GPIB commands must be byte strings.
gpib_controller.write(2, b"*IDN?\n")
Reading from address 0x02 and decoding the byte string to a unicode string.
data = gpib_controller.read(2)
print(data.decode())
See examples/ for more working examples. Including an example that shows how to use the library from the command line.
Firmware Bugs
There are several bugs in the firmware of the UGPlus most of those are off-by-one errors and consequently out-of-bounds reads. I documented them here. Some of these bugs are also evident when using the software supplied by the manufacturer. The most obvious ones are the following:
- Out-of-bounds read when reading the firmware version. The controller sends one more byte than requested.
- Out-of-bounds read when discovering GPIB devices. The controller sends one more byte than requested.
- Out-of-bounds read when the GPIB device does not return any data. The controller sends one more byte than requested.
Versioning
I use SemVer for versioning. For the versions available, see the tags on this repository.
Documentation
I use the Numpydoc style for documentation.
Authors
- Jacob Alexander - Initial work for the UGSimple Jacob Alexander
- Patrick Baus - Complete rewrite for the UGPlus - PatrickBaus
License
This project is licensed under the GPL v3 license - see the LICENSE file for details
Metadata
Release files for ug-gpib 1.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ug_gpib-1.2.2.tar.gz | 23.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ug_gpib-1.2.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 44.7 kB
Release files / ug_gpib-1.2.2.tar.gz
| Download URL | ug_gpib-1.2.2.tar.gz |
|---|---|
| Size | 23.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d919d12c430286e7d952813f15eebcfb1a95e64504699b988ddae2c010da6b0f
|
|
BLAKE2b-256 checksum How to use checksums |
f26c641fa528fc78c5b0f77f388201dc0803fd6a4737ae7d9ba0edef4515cce8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|
Release files / ug_gpib-1.2.2-py3-none-any.whl
| Download URL | ug_gpib-1.2.2-py3-none-any.whl |
|---|---|
| Size | 21.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
434008a04d92dc0198fe294b44fe3fa4a12e3f13a2d30d33341d6ba3fa83eb57
|
|
BLAKE2b-256 checksum How to use checksums |
07df865b80ce03ff60963a639df4c17313ba5984b1ce2e1fe51c372a5ea3f81a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.12.4
|