bendev - Python module to control Bentham SCPI devices

bendev

BENDEV is an open source crossplatform python package for communicating with the USB/SCPI-enabled Bentham Instruments hardware devices such as the TLS120Xe. The package uses hidapi to send and receive text based commands and replies using the USB HID protocol. It is available under the permissive MIT license.

Read more on this project's PyPI page, or view the source code on github, including the license.

Installation

bendev can be installed with pip. To do so, run this pip command:

 

pip install bendev

 

No hardware drivers should be required.

Usage

bendev can be imported like any other python module, and can be used as a context manager. In the below example, no arguments are given to bendev.Device() and as a result it connects to the first Bentham device found.

 

>>> import bendev
>>> with bendev.Device() as dev:
...     print(dev.query("*IDN?"))
"Bentham Instruments Ltd.","MSH150_RD_Direct","99999/9","1.2.53"

Basic Usage

bendev devices can be instantiated in context managers:

 

>>> import bendev
>>> with bendev.Device() as dev:
...     print(dev.query("*IDN?"))
"Bentham Instruments Ltd.","MSH150_RD_Direct","99999/9","1.2.53"

 

or normally:

 

>>> import bendev
>>> my_tls = bendev.Device()
>>> my_tls.write("SYSTEM:REMOTE")
>>> my_tls.query("MONO:GOTO? 555")
"1"

 

Devices can be opened by serial number, product string or manufacturer string:

 

>>> import bendev
>>> device_a = bendev.Device(serial_number="99999/9")
>>> device_b = bendev.Device(product_string="TLS120Xe")
>>> device_c = bendev.Device(manufacturer_string="Bentham")

 

For product_string and manufacturer_string, it is sufficient if the given substring is present in the device descriptor. The serial_number has to be exact. manufacturer_string defaults to "Bentham".

The package can also tell you what devices are connected:

 

>>> import bendev
>>> devs=bendev.list_connected_devices(verbose=True)
Connected Devices:
Device 18: Bentham Instruments, TLS120Xe, ...

 

For the precise commands to send, please refer to your product's communication manual.

Further usage information is built into the package and can be viewed in the python console using the command:

 

>>> import bendev
>>> help(bendev)

Specifications

Requirements

Hardware

USB port

Host Operating System

Windows, Mac, Linux

Python version

>= 3.8

bendev License

MIT License

Copyright (c) 2022 Bentham Instruments

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 

Share this:

The Bentham Standard

We’re with you from the first call to the final result

Call us on +44 118 975 1355 or email us