Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ADD_GPIB #88

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions basil/HL/hp_e3632a.yaml
Original file line number Diff line number Diff line change
@@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The identifier does not have to be fully matched. So sometimes it is better to not specify minor firmware versions for compatibility. I guess HEWLETT-PACKARD,E3632A could be enough here?

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?




53 changes: 53 additions & 0 deletions basil/TL/PrologixVisa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I see it the only difference to the already existing VISA implementation is the query command. So one could simplify this module to:

class PrologixVisa(Visa):
    def query(self, data):
        self._resource.write("++auto 0")
        self._resource.write(data)
        return self._resource.query("++read eoi")

and it would do the same, no?
I am not sure if the write and read commands also need changes. Did you check?

# ------------------------------------------------------------
# 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")
14 changes: 14 additions & 0 deletions examples/lab_devices/prologix_pyvisa.yaml
Original file line number Diff line number Diff line change
@@ -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