From e1321edaddb4ef637c4561128c624e80751c00b6 Mon Sep 17 00:00:00 2001 From: Mark Standke Date: Tue, 3 Jul 2018 23:24:51 +0200 Subject: [PATCH] ADD: This commit adds support of the prologix USB to GPIB controller as described here: http://prologix.biz/downloads/PrologixGpibUsbManual-4.2.pdf This enables GPIB usage with basil. --- basil/HL/hp_e3632a.yaml | 20 +++++++++ basil/TL/PrologixVisa.py | 53 +++++++++++++++++++++++ examples/lab_devices/prologix_pyvisa.yaml | 14 ++++++ 3 files changed, 87 insertions(+) create mode 100644 basil/HL/hp_e3632a.yaml create mode 100644 basil/TL/PrologixVisa.py create mode 100644 examples/lab_devices/prologix_pyvisa.yaml diff --git a/basil/HL/hp_e3632a.yaml b/basil/HL/hp_e3632a.yaml new file mode 100644 index 000000000..944b6be7c --- /dev/null +++ b/basil/HL/hp_e3632a.yaml @@ -0,0 +1,20 @@ +# Device description for HP E3632A Powersupply. +# set_ function expect a parameter, get_ function return a parameter. +# Just the very basic commands are imlemented here. +identifier : HEWLETT-PACKARD,E3632A,0,1.1-5.0-1.0 +on : OUTP ON +off : OUTP OFF +disp_on : DISP 1 +disp_off : DISP 0 +get_current : MEAS:CURR? +set_current : SOUR:CURR +set_voltage : SOUR:VOLT +get_voltage : MEAS:VOLT? +set_current_limit : CURR:PROT +get_current_limit : CURR:PROT? +set_voltage_limit : VOLT:PROT +get_voltage_limit : VOLT:PROT? + + + + diff --git a/basil/TL/PrologixVisa.py b/basil/TL/PrologixVisa.py new file mode 100644 index 000000000..085e3559b --- /dev/null +++ b/basil/TL/PrologixVisa.py @@ -0,0 +1,53 @@ +# +# ------------------------------------------------------------ +# Copyright (c) All rights reserved +# SiLab, Institute of Physics, University of Bonn +# ------------------------------------------------------------ +# +import visa +import logging + +from basil.TL.TransferLayer import TransferLayer + +logger = logging.getLogger(__name__) + + +class PrologixVisa(TransferLayer): + '''Transfer layer for a Virtual Instrument Software Architecture (VISA) provided by pyVisa. + Several interfaces are available (GPIB, RS232, USB, Ethernet). To be able to use pyVisa without + the proprietary NI-VISA driver a pyVisa backend pyVisa-py can be used. + GPIB under linux is not supported via pyVisa-py right now. + ''' + + def __init__(self, conf): + super(PrologixVisa, self).__init__(conf) + self._resource = None + + def init(self): + ''' + Initialize the device. + Parameters of visa.ResourceManager().open_resource() + ''' + super(PrologixVisa, self).init() + backend = self._init.get('backend', '') # Empty string means std. backend (NI VISA) + rm = visa.ResourceManager(backend) + try: + logger.info('BASIL VISA TL with %s backend found the following devices: %s', backend, ", ".join(rm.list_resources())) + except NotImplementedError: # some backends do not always implement the list_resources function + logger.info('BASIL VISA TL with %s backend', backend) + self._resource = rm.open_resource(**{key: value for key, value in self._init.items() if key not in ("backend",)}) + + def close(self): + super(PrologixVisa, self).close() + self._resource.close() + + def write(self, data): + self._resource.write(data) + + def read(self): + self._resource.read() + + def query(self, data): + self._resource.write("++auto 0") + self._resource.write(data) + return self._resource.query("++read eoi") diff --git a/examples/lab_devices/prologix_pyvisa.yaml b/examples/lab_devices/prologix_pyvisa.yaml new file mode 100644 index 000000000..220791f69 --- /dev/null +++ b/examples/lab_devices/prologix_pyvisa.yaml @@ -0,0 +1,14 @@ +transfer_layer: + - name : PrologixVisa + type : PrologixVisa + init : + resource_name : ASRL::INSTR + read_termination : "\n" + backend : "@py" + +hw_drivers: + - name : Powersupply + type : scpi + interface : PrologixVisa + init : + device : hp e3632a \ No newline at end of file