diff --git a/docs/changes/newsfragments/6723.improved_driver b/docs/changes/newsfragments/6723.improved_driver new file mode 100644 index 000000000000..0f2b86f36ce5 --- /dev/null +++ b/docs/changes/newsfragments/6723.improved_driver @@ -0,0 +1,2 @@ +The Keysight 344xxA drivers have been updated to ensure that ``NPLC``, ``autorange``, ``autozero``, ``apature_time`` and ```apature_mode`` +parameters use the correct instrument commends for the sense mode selected by the ``sense_function`` parameter. diff --git a/src/qcodes/instrument/sims/Keysight_34465A.yaml b/src/qcodes/instrument/sims/Keysight_34465A.yaml index 1d5170dca554..8caf02abe68d 100644 --- a/src/qcodes/instrument/sims/Keysight_34465A.yaml +++ b/src/qcodes/instrument/sims/Keysight_34465A.yaml @@ -108,17 +108,7 @@ devices: r: "{}" setter: q: "SAMPle:TIMer {}" - dc_autorange: - default: 0 - getter: - q: "SENSe:VOLTage:DC:RANGe:AUTO?" - r: "{}" - setter: - q: "SENSe:VOLTage:DC:RANGe:AUTO {}" - specs: - valid: [0, 1] - type: int - dc_range: + voltage_dc_range: default: 1 getter: q: "SENSe:VOLTage:DC:RANGe?" @@ -131,44 +121,260 @@ devices: 10000, 100000, 1000000, 10000000, 100000000, 1000000000] type: float - NPLC: + voltage_dc_resolution: + default: +3.00000000E-05 + getter: + q: "SENSe:VOLTage:DC:RESolution?" + r: "{}" + setter: + q: "SENSe:VOLTage:DC:RESolution {}" + current_ac_autorange: + default: 0 + getter: + q: "SENSe:CURR:AC:RANGe:AUTO?" + r: "{}" + setter: + q: "SENSe:CURR:AC:RANGe:AUTO {}" + specs: + valid: [0, 1] + type: int + current_dc_autorange: + default: 0 + getter: + q: "SENSe:CURR:RANGe:AUTO?" + r: "{}" + setter: + q: "SENSe:CURR:RANGe:AUTO {}" + specs: + valid: [0, 1] + type: int + fresistance_autorange: + default: 0 + getter: + q: "SENSe:FRES:RANGe:AUTO?" + r: "{}" + setter: + q: "SENSe:FRES:RANGe:AUTO {}" + specs: + valid: [0, 1] + type: int + resistance_autorange: + default: 0 + getter: + q: "SENSe:RES:RANGe:AUTO?" + r: "{}" + setter: + q: "SENSe:RES:RANGe:AUTO {}" + specs: + valid: [0, 1] + type: int + voltage_ac_autorange: + default: 0 + getter: + q: "SENSe:VOLT:AC:RANGe:AUTO?" + r: "{}" + setter: + q: "SENSe:VOLT:AC:RANGe:AUTO {}" + specs: + valid: [0, 1] + type: int + voltage_dc_autorange: + default: 0 + getter: + q: "SENSe:VOLT:RANGe:AUTO?" + r: "{}" + setter: + q: "SENSe:VOLT:RANGe:AUTO {}" + specs: + valid: [0, 1] + type: int + current_ac_autozero: + default: 0 + getter: + q: "SENSe:CURR:AC:ZERO:AUTO?" + r: "{}" + setter: + q: "SENSe:CURR:AC:ZERO:AUTO {}" + current_dc_autozero: + default: 0 + getter: + q: "SENSe:CURR:ZERO:AUTO?" + r: "{}" + setter: + q: "SENSe:CURR:ZERO:AUTO {}" + fresistance_autozero: + default: 0 + getter: + q: "SENSe:FRES:ZERO:AUTO?" + r: "{}" + setter: + q: "SENSe:FRES:ZERO:AUTO {}" + resistance_autozero: + default: 0 + getter: + q: "SENSe:RES:ZERO:AUTO?" + r: "{}" + setter: + q: "SENSe:RES:ZERO:AUTO {}" + voltage_ac_autozero: + default: 0 + getter: + q: "SENSe:VOLT:AC:ZERO:AUTO?" + r: "{}" + setter: + q: "SENSe:VOLT:AC:ZERO:AUTO {}" + voltage_dc_autozero: + default: 0 + getter: + q: "SENSe:VOLT:ZERO:AUTO?" + r: "{}" + setter: + q: "SENSe:VOLT:ZERO:AUTO {}" + current_ac_NPLC: + default: 10.0 + getter: + q: "SENSe:CURR:AC:NPLC?" + r: "{}" + setter: + q: "SENSe:CURR:AC:NPLC {}" + specs: + valid: [0.001, 0.002, 0.006, 0.02, 0.06, 0.2, 1, 10, 100] + type: float + current_dc_NPLC: default: 10.0 getter: - q: "SENSe:VOLTage:DC:NPLC?" + q: "SENSe:CURR:NPLC?" r: "{}" setter: - q: "SENSe:VOLTage:DC:NPLC {}" + q: "SENSe:CURR:NPLC {}" specs: - valid: [0.001, 0.002, 0.006, 0.02, 0.06, .2, 1, 10, 100] + valid: [0.001, 0.002, 0.006, 0.02, 0.06, 0.2, 1, 10, 100] type: float - resolution: - default: +3.00000000E-05 + fresistance_NPLC: + default: 10.0 getter: - q: "SENSe:VOLTage:DC:RESolution?" + q: "SENSe:FRES:NPLC?" r: "{}" setter: - q: "SENSe:VOLTage:DC:RESolution {}" - apterture_enabled: + q: "SENSe:FRES:NPLC {}" + specs: + valid: [0.001, 0.002, 0.006, 0.02, 0.06, 0.2, 1, 10, 100] + type: float + resistance_NPLC: + default: 10.0 + getter: + q: "SENSe:RES:NPLC?" + r: "{}" + setter: + q: "SENSe:RES:NPLC {}" + specs: + valid: [0.001, 0.002, 0.006, 0.02, 0.06, 0.2, 1, 10, 100] + type: float + voltage_ac_NPLC: + default: 10.0 + getter: + q: "SENSe:VOLT:AC:NPLC?" + r: "{}" + setter: + q: "SENSe:VOLT:AC:NPLC {}" + specs: + valid: [0.001, 0.002, 0.006, 0.02, 0.06, 0.2, 1, 10, 100] + type: float + voltage_dc_NPLC: + default: 10.0 + getter: + q: "SENSe:VOLT:NPLC?" + r: "{}" + setter: + q: "SENSe:VOLT:NPLC {}" + specs: + valid: [0.001, 0.002, 0.006, 0.02, 0.06, 0.2, 1, 10, 100] + type: float + current_ac_aperture_enabled: + default: 0 + getter: + q: "SENSe:CURR:AC:APERture:ENABled?" + r: "{}" + setter: + q: "SENSe:CURR:AC:APERture:ENABled {}" + current_dc_aperture_enabled: + default: 0 + getter: + q: "SENSe:CURR:APERture:ENABled?" + r: "{}" + setter: + q: "SENSe:CURR:APERture:ENABled {}" + fresistance_aperture_enabled: + default: 0 + getter: + q: "SENSe:FRES:APERture:ENABled?" + r: "{}" + setter: + q: "SENSe:FRES:APERture:ENABled {}" + resistance_aperture_enabled: + default: 0 + getter: + q: "SENSe:RES:APERture:ENABled?" + r: "{}" + setter: + q: "SENSe:RES:APERture:ENABled {}" + voltage_ac_aperture_enabled: + default: 0 + getter: + q: "SENSe:VOLT:AC:APERture:ENABled?" + r: "{}" + setter: + q: "SENSe:VOLT:AC:APERture:ENABled {}" + voltage_dc_aperture_enabled: + default: 0 + getter: + q: "SENSe:VOLT:APERture:ENABled?" + r: "{}" + setter: + q: "SENSe:VOLT:APERture:ENABled {}" + + current_ac_aperture_time: + default: 0 + getter: + q: "SENSe:CURR:AC:APERture?" + r: "{}" + setter: + q: "SENSe:CURR:AC:APERture {}" + current_dc_aperture_time: + default: 0 + getter: + q: "SENSe:CURR:APERture?" + r: "{}" + setter: + q: "SENSe:CURR:APERture {}" + fresistance_aperture_time: + default: 0 + getter: + q: "SENSe:FRES:APERture?" + r: "{}" + setter: + q: "SENSe:FRES:APERture {}" + resistance_aperture_time: default: 0 getter: - q: "SENSe:VOLTage:DC:APERture:ENABled?" + q: "SENSe:RES:APERture?" r: "{}" setter: - q: "SENSe:VOLTage:DC:APERture:ENABled {}" - apterture_time: + q: "SENSe:RES:APERture {}" + voltage_ac_aperture_time: default: 0 getter: - q: "SENSe:VOLTage:DC:APERture?" + q: "SENSe:VOLT:AC:APERture?" r: "{}" setter: - q: "SENSe:VOLTage:DC:APERture {}" - autozero: + q: "SENSe:VOLT:AC:APERture {}" + voltage_dc_aperture_time: default: 0 getter: - q: "SENSe:VOLTage:DC:ZERO:AUTO?" + q: "SENSe:VOLT:APERture?" r: "{}" setter: - q: "SENSe:VOLTage:DC:ZERO:AUTO {}" + q: "SENSe:VOLT:APERture {}" licenses: default: "DIG" getter: diff --git a/src/qcodes/instrument_drivers/Keysight/private/Keysight_344xxA_submodules.py b/src/qcodes/instrument_drivers/Keysight/private/Keysight_344xxA_submodules.py index 2a2f53d35266..e2b672c39c57 100644 --- a/src/qcodes/instrument_drivers/Keysight/private/Keysight_344xxA_submodules.py +++ b/src/qcodes/instrument_drivers/Keysight/private/Keysight_344xxA_submodules.py @@ -26,7 +26,7 @@ ) if TYPE_CHECKING: - from collections.abc import Sequence + from collections.abc import Callable, Sequence from typing_extensions import Unpack @@ -748,7 +748,7 @@ def __init__( self.NPLC: Parameter = self.add_parameter( "NPLC", - get_cmd="SENSe:VOLTage:DC:NPLC?", + get_cmd=self._get_with_sense_function("NPLC"), get_parser=float, set_cmd=self._set_NPLC, vals=vals.Enum(*self.NPLC_list), @@ -836,8 +836,8 @@ def __init__( self.autorange: Parameter = self.add_parameter( "autorange", label="Autorange", - set_cmd="SENSe:VOLTage:DC:RANGe:AUTO {}", - get_cmd="SENSe:VOLTage:DC:RANGe:AUTO?", + set_cmd=self._set_with_sense_function("RANGe:AUTO"), + get_cmd=self._get_with_sense_function("RANGe:AUTO"), val_mapping={"ON": 1, "OFF": 0}, vals=vals.Enum("ON", "OFF"), ) @@ -846,8 +846,8 @@ def __init__( self.autozero: Parameter = self.add_parameter( "autozero", label="Autozero", - set_cmd="SENSe:VOLTage:DC:ZERO:AUTO {}", - get_cmd="SENSe:VOLTage:DC:ZERO:AUTO?", + set_cmd=self._set_with_sense_function("ZERO:AUTO"), + get_cmd=self._get_with_sense_function("ZERO:AUTO"), val_mapping={"ON": 1, "OFF": 0, "ONCE": "ONCE"}, vals=vals.Enum("ON", "OFF", "ONCE"), docstring=textwrap.dedent( @@ -932,8 +932,8 @@ def __init__( self.aperture_mode: Parameter = self.add_parameter( "aperture_mode", label="Aperture mode", - set_cmd="SENSe:VOLTage:DC:APERture:ENABled {}", - get_cmd="SENSe:VOLTage:DC:APERture:ENABled?", + set_cmd=self._set_with_sense_function("APERture:ENABled"), + get_cmd=self._get_with_sense_function("APERture:ENABled"), val_mapping={"ON": 1, "OFF": 0}, vals=vals.Enum("ON", "OFF"), docstring=textwrap.dedent( @@ -953,7 +953,7 @@ def __init__( "aperture_time", label="Aperture time", set_cmd=self._set_apt_time, - get_cmd="SENSe:VOLTage:DC:APERture?", + get_cmd=self._get_with_sense_function("APERture"), get_parser=float, vals=vals.Numbers(*apt_times[self.model]), docstring=textwrap.dedent( @@ -1212,14 +1212,42 @@ def read(self) -> np.ndarray: raw_vals: str = self.ask("READ?") return _raw_vals_to_array(raw_vals) + def _ask_with_sense_function(self, cmd: str) -> str: + # cache.raw_value currently lacks a way to trigger an update + # force this by calling get on the cache first which will trigger + # the update if required + self.sense_function.cache.get(get_if_invalid=True) + function = self.sense_function.cache.raw_value.strip('"') + return self.ask(f"SENSe:{function}:{cmd}?") + + def _write_with_sense_function(self, cmd: str, value: str) -> None: + # cache.raw_value currently lacks a way to trigger an update + # force this by calling get on the cache first which will trigger + # the update if required + self.sense_function.cache.get(get_if_invalid=True) + function = self.sense_function.cache.raw_value.strip('"') + self.write(f"SENSe:{function}:{cmd} {value}") + + def _get_with_sense_function(self, cmd: str) -> "Callable[[], str]": + def func() -> str: + return self._ask_with_sense_function(cmd) + + return func + + def _set_with_sense_function(self, cmd: str) -> "Callable[[str], None]": + def func(value: str) -> None: + self._write_with_sense_function(cmd, value) + + return func + def _set_apt_time(self, value: float) -> None: - self.write(f"SENSe:VOLTage:DC:APERture {value:f}") + self._write_with_sense_function("APERture", f"{value:f}") # setting aperture time switches aperture mode ON self.aperture_mode.get() def _set_NPLC(self, value: float) -> None: - self.write(f"SENSe:VOLTage:DC:NPLC {value:f}") + self._write_with_sense_function("NPLC", f"{value:f}") # resolution settings change with NPLC self.resolution.get()