Skip to content

Commit

Permalink
Merge #4342
Browse files Browse the repository at this point in the history
4342: fix option detection on Keysight N51x1 driver r=jenshnielsen a=simonzihlmann

make frequency option detection compatible with multiple options installed on device. The old version of the driver resulted in a `KeyError` if multiple options were installed on the device.

I was unable to figure out from the manual / spec sheet if the frequency option will always be the first one in the string returned by the instrument. For the moment, all other options are ignored.


Co-authored-by: Simon Zihlmann <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Jens H. Nielsen <[email protected]>
  • Loading branch information
4 people authored Jul 4, 2022
2 parents 42dfe86 + d3fc2fe commit c42d7b9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/changes/newsfragments/4342.improved_driver
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Improved Keysight N51x1 driver: make frequency option detection compatible with multiple options installed on device.
25 changes: 21 additions & 4 deletions qcodes/instrument_drivers/Keysight/N51x1.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,27 @@ class N51x1(VisaInstrument):
def __init__(self, name: str, address: str, min_power: int = -144, max_power: int = 19, **kwargs: Any):
super().__init__(name, address, terminator='\n', **kwargs)

self._options = self.ask("*OPT?")
# Determine installed frequency option
freq_dict = {
"501": 1e9,
"503": 3e9,
"506": 6e9,
"513": 13e9,
"520": 20e9,
"532": 31.8e9,
"540": 40e9,
}

frequency_option = None
for f_option in freq_dict.keys():
if f_option in self._options:
frequency_option = f_option
if frequency_option is None:
raise RuntimeError("Could not determine the frequency option")

max_freq = freq_dict[frequency_option]

self.add_parameter('power',
label='Power',
get_cmd='SOUR:POW?',
Expand All @@ -21,10 +42,6 @@ def __init__(self, name: str, address: str, min_power: int = -144, max_power: in
unit='dBm',
vals=Numbers(min_value=min_power,max_value=max_power))

# Query the instrument to see what frequency range was purchased
freq_dict = {'501':1e9, '503':3e9, '506':6e9, '513': 13e9, '520':20e9, '532': 31.8e9, '540': 40e9}

max_freq = freq_dict[self.ask('*OPT?')] # TODO: use .split(',') to detect other options
self.add_parameter('frequency',
label='Frequency',
get_cmd='SOUR:FREQ?',
Expand Down

0 comments on commit c42d7b9

Please sign in to comment.