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

Upgrade Basel drivers to conform to our standard #4482

Merged
merged 5 commits into from
Aug 23, 2022
Merged
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
1 change: 1 addition & 0 deletions docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ genapi:
sphinx-apidoc -o _auto -d 10 ../qcodes \
../qcodes/instrument_drivers/agilent \
../qcodes/instrument_drivers/AimTTi \
../qcodes/instrument_drivers/basel \
../qcodes/instrument_drivers/HP \
../qcodes/instrument_drivers/ithaco \
../qcodes/instrument_drivers/keysight \
Expand Down
7 changes: 7 additions & 0 deletions docs/drivers_api/Basel.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.. _Basel_api :

Basel Drivers
=============

.. automodule:: qcodes.instrument_drivers.basel
:autosummary:
1 change: 1 addition & 0 deletions docs/make.bat
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ REM for storing drivers, not the lower-case one).
sphinx-apidoc -o _auto -d 10 ..\qcodes ^
..\qcodes\instrument_drivers\agilent\* ^
..\qcodes\instrument_drivers\AimTTi ^
..\qcodes\instrument_drivers\basel ^
..\qcodes\instrument_drivers\HP ^
..\qcodes\instrument_drivers\ithaco ^
..\qcodes\instrument_drivers\Lakeshore ^
Expand Down
79 changes: 79 additions & 0 deletions qcodes/instrument_drivers/basel/BaselSP983.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
from typing import Any, Dict, Optional

from qcodes.instrument import Instrument
from qcodes.parameters import DelegateParameter, Parameter
from qcodes.validators import Enum, Numbers


class BaselSP983(Instrument):
"""
A virtual driver for the Basel SP 983 current to voltage converter.

This driver supports both the SP 983 and SP 983c models. These differ only
in their handling of input offset voltage. It is the responsibility of the
user to capture the input offset, (from the voltage supply) and compensate
that as needed for SP 983. For SP 983c model, 'input_offset_voltage'
argument can be used to set up offset (This doesn't work for SP 983c01
model).

Note that, as this is a purely virtual driver, there is no support
for the remote control interface (SP 983a). It is the responsibility of
the user to ensure that values set here are in accordance with the values
set on the instrument.

Args:
name
input_offset_voltage: (Optional) A source input offset voltage
parameter. The range for input is -10 to 10 Volts and it is
user's responsibility to ensure this. This source parameter is
used to set offset voltage parameter of the preamp and the
source parameter should represent a voltage source that is
connected to the "Offset Input Voltage" connector of the SP983C.
"""

def __init__(
self, name: str, input_offset_voltage: Optional[Parameter] = None, **kwargs: Any
):
super().__init__(name, **kwargs)

self.add_parameter(
"gain",
initial_value=1e8,
label="Gain",
unit="V/A",
get_cmd=None,
set_cmd=None,
vals=Enum(1e09, 1e08, 1e07, 1e06, 1e05),
)

self.add_parameter(
"fcut",
initial_value=1e3,
label="Cutoff frequency",
unit="Hz",
get_cmd=None,
set_cmd=None,
vals=Enum(30.0, 100.0, 300.0, 1e3, 3e3, 10e3, 30e3, 100e3, 1e6),
)

self.add_parameter(
"offset_voltage",
label="Offset Voltage",
unit="V",
vals=Numbers(-0.1, 0.1),
scale=100,
source=input_offset_voltage,
parameter_class=DelegateParameter,
)

def get_idn(self) -> Dict[str, Optional[str]]:
vendor = "Physics Basel"
model = "SP 983"
serial = None
firmware = None
return {
"vendor": vendor,
"model": model,
"serial": serial,
"firmware": firmware,
}
119 changes: 119 additions & 0 deletions qcodes/instrument_drivers/basel/BaselSP983a.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
from typing import Any, Dict, Optional

import numpy as np

from qcodes import validators as vals
from qcodes.instrument import VisaInstrument
from qcodes.parameters import DelegateParameter, Parameter


class BaselSP983a(VisaInstrument):
"""
A driver for Basel Preamp's (SP983a) Remote Instrument - Model SP983a.

Args:
name: name for your instrument driver instance
address: address of the connected remote controller of basel preamp
input_offset_voltage: (Optional) A source input offset voltage
parameter. The range for input is -10 to 10 Volts and it is
user's responsibility to ensure this. This source parameter is
used to set offset voltage parameter of the preamp and the
source parameter should represent a voltage source that is
connected to the "Offset Input Volgate" connector of the SP983C.
"""

def __init__(
self,
name: str,
address: str,
input_offset_voltage: Optional[Parameter] = None,
terminator: str = "\r\n",
**kwargs: Any,
) -> None:
super().__init__(name, address, terminator=terminator, **kwargs)

self.connect_message()

self.add_parameter(
"gain",
label="Gain",
unit="V/A",
set_cmd=self._set_gain,
get_cmd=self._get_gain,
vals=vals.Enum(1e5, 1e6, 1e7, 1e8, 1e9),
)
self.add_parameter(
"fcut",
unit="Hz",
label="Filter Cut-Off Frequency",
get_cmd=self._get_filter,
get_parser=self._parse_filter_value,
set_cmd=self._set_filter,
val_mapping={
30: "30",
100: "100",
300: "300",
1000: "1k",
3000: "3k",
10e3: "10k",
30e3: "30k",
100e3: "100k",
1e6: "FULL",
},
)
self.add_parameter(
"overload_status", label="Overload Status", set_cmd=False, get_cmd="GET O"
)

self.add_parameter(
"offset_voltage",
label="Offset Voltage for SP983C",
unit="V",
vals=vals.Numbers(-0.1, 0.1),
scale=100,
source=input_offset_voltage,
parameter_class=DelegateParameter,
)

def get_idn(self) -> Dict[str, Optional[str]]:
vendor = "Physics Basel"
model = "SP 983A"
serial = None
firmware = None
return {
"vendor": vendor,
"model": model,
"serial": serial,
"firmware": firmware,
}

def _set_gain(self, value: float) -> None:
r = self.ask(f"SET G 1E{int(np.log10(value))}")
if r != "OK":
raise ValueError(f"Expected OK return but got: {r}")

def _get_gain(self) -> float:
s = self.ask("GET G")
r = s.split("Gain: ")[1]
return float(r)

def _set_filter(self, value: str) -> None:
r = self.ask(f"SET F {value}")
if r != "OK":
raise ValueError(f"Expected OK return but got: {r}")

def _get_filter(self) -> str:
s = self.ask("GET F")
return s.split("Filter: ")[1]

@staticmethod
def _parse_filter_value(val: str) -> str:
if val.startswith("F"):
return "FULL"
elif val[-3::] == "kHz":
return str(int(val[0:-3])) + "k"

elif val[-2::] == "Hz":
return str(int(val[0:-2]))
else:
raise ValueError(f"Could not interpret result. Got: {val}")
42 changes: 42 additions & 0 deletions qcodes/instrument_drivers/basel/BaselSP983c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from typing import Dict, Optional

from .BaselSP983 import BaselSP983


class BaselSP983c(BaselSP983):
"""
A virtual driver for the Basel SP 983c current to voltage converter.

This driver supports both the SP 983 and SP 983c models. These differ only
in their handling of input offset voltage. It is the responsibility of the
user to capture the input offset, (from the voltage supply) and compensate
that as needed for SP 983. For SP 983c model, 'input_offset_voltage'
argument can be used to set up offset (This doesn't work for SP 983c01
model).

Note that, as this is a purely virtual driver, there is no support
for the remote control interface (SP 983a). It is the responsibility of
the user to ensure that values set here are in accordance with the values
set on the instrument.

Args:
name
input_offset_voltage: (Optional) A source input offset voltage
parameter. The range for input is -10 to 10 Volts and it is
user's responsibility to ensure this. This source parameter is
used to set offset voltage parameter of the preamp and the
source parameter should represent a voltage source that is
connected to the "Offset Input Voltage" connector of the SP983C.
"""

def get_idn(self) -> Dict[str, Optional[str]]:
vendor = "Physics Basel"
model = "SP 983c"
serial = None
firmware = None
return {
"vendor": vendor,
"model": model,
"serial": serial,
"firmware": firmware,
}
5 changes: 5 additions & 0 deletions qcodes/instrument_drivers/basel/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from .BaselSP983 import BaselSP983
from .BaselSP983a import BaselSP983a
from .BaselSP983c import BaselSP983c

__all__ = ["BaselSP983a", "BaselSP983c", "BaselSP983"]
77 changes: 15 additions & 62 deletions qcodes/instrument_drivers/basel/sp983c.py
Original file line number Diff line number Diff line change
@@ -1,69 +1,22 @@
from typing import Any, Dict, Optional
"""
Legacy module kept around for backwards compatibility reasons.
Will eventually be deprecated and removed

from qcodes.instrument.base import Instrument
from qcodes.parameters import DelegateParameter, Parameter
from qcodes.validators import Enum, Numbers
"""
from typing import Dict, Optional

from .BaselSP983c import BaselSP983c

class SP983C(Instrument):
"""
A virtual driver for the Basel SP 983 and SP 983C current to voltage
converter.

This driver supports both the SP 983 and SP 983C models. These differ only
in their handling of input offset voltage. It is the responsibility of the
user to capture the input offset, (from the voltage supply) and compensate
that as needed for SP 983. For SP 983C model, 'input_offset_voltage'
argument can be used to set up offset (This doesn't work for SP 983c01
model).

Note that, as this is a purely virtual driver, there is no support
for the the remote control interface (SP 983a). It is the responsibility of
the user to ensure that values set here are in accordance with the values
set on the instrument.

Args:
name
input_offset_voltage: (Optional) A source input offset voltage
parameter. The range for input is -10 to 10 Volts and it is
user's responsibility to ensure this. This source parameter is
used to set offset voltage parameter of the preamp and the
source parameter should represent a voltage source that is
connected to the "Offset Input Volgate" connector of the SP983C.
"""

def __init__(self, name: str,
input_offset_voltage: Optional[Parameter] = None,
**kwargs: Any):
super().__init__(name, **kwargs)

self.add_parameter('gain',
initial_value=1e8,
label='Gain',
unit='V/A',
get_cmd=None, set_cmd=None,
vals=Enum(1e09, 1e08, 1e07, 1e06, 1e05))

self.add_parameter('fcut',
initial_value=1e3,
label='Cutoff frequency',
unit='Hz',
get_cmd=None, set_cmd=None,
vals=Enum(30., 100., 300., 1e3, 3e3, 10e3, 30e3,
100e3, 1e6))

self.add_parameter('offset_voltage',
label="Offset Voltage",
unit='V',
vals=Numbers(-0.1, 0.1),
scale=100,
source=input_offset_voltage,
parameter_class=DelegateParameter)

class SP983C(BaselSP983c):
def get_idn(self) -> Dict[str, Optional[str]]:
vendor = 'Physics Basel'
model = 'SP 983(c)'
vendor = "Physics Basel"
model = "SP 983(c)"
serial = None
firmware = None
return {'vendor': vendor, 'model': model,
'serial': serial, 'firmware': firmware}
return {
"vendor": vendor,
"model": model,
"serial": serial,
"firmware": firmware,
}
Loading