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

QDAC2: Improved waiting for settlement before reading currents #233

Merged
merged 3 commits into from
Aug 24, 2023
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
9 changes: 4 additions & 5 deletions qcodes_contrib_drivers/drivers/QDevil/QDAC2.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from packaging.version import Version, parse
import abc

# Version 1.2.0
# Version 1.3.0
#
# Guiding principles for this driver for QDevil QDAC-II
# -----------------------------------------------------
Expand Down Expand Up @@ -1856,12 +1856,11 @@ def currents_A(self, nplc: int = 1, current_range: str = "low") -> Sequence[floa
"""
channels_suffix = self._all_channels_as_suffix()
self._qdac.write(f'sens:rang {current_range},{channels_suffix}')
# Wait for relays to finish switching by doing a query
self._qdac.ask(f'*stb?')
self._qdac.write(f'sens:nplc {nplc},{channels_suffix}')
# Discard first reading because of possible output-capacitor effects, etc
# Wait for the current sensors to stabilize and then read
slowest_line_freq_Hz = 50
sleep_s(1 / slowest_line_freq_Hz)
self._qdac.ask(f'read? {channels_suffix}')
# Then make a proper reading
sleep_s((nplc + 1) / slowest_line_freq_Hz)
currents = self._qdac.ask(f'read? {channels_suffix}')
return comma_sequence_to_list_of_floats(currents)
Expand Down
11 changes: 5 additions & 6 deletions qcodes_contrib_drivers/drivers/QDevil/QDAC2_Array.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,14 @@ def currents_A(self, nplc: int = 1, current_range: str = "low") -> Sequence[floa
arrangement = self._arrangements[qdac]
channels_suffix = arrangement._all_channels_as_suffix()
arrangement._qdac.write(f'sens:rang {current_range},{channels_suffix}')
arrangement._qdac.write(f'sens:nplc {nplc},{channels_suffix}')
# Discard first reading because of possible output-capacitor effects, etc
slowest_line_freq_Hz = 50
sleep_s(1 / slowest_line_freq_Hz)
for qdac in self.qdac_names():
arrangement = self._arrangements[qdac]
channels_suffix = arrangement._all_channels_as_suffix()
arrangement._qdac.ask(f'read? {channels_suffix}')
# Then make a proper reading on all instruments
# Wait for relays to finish switching by doing a query
arrangement._qdac.ask(f'*stb?')
arrangement._qdac.write(f'sens:nplc {nplc},{channels_suffix}')
# Wait for the current sensors to stabilize and then read
slowest_line_freq_Hz = 50
sleep_s((nplc + 1) / slowest_line_freq_Hz)
values: List[float] = list()
for qdac in self.qdac_names():
Expand Down
25 changes: 11 additions & 14 deletions qcodes_contrib_drivers/tests/QDevil/test_sim_qdac2_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,24 +190,21 @@ def test_sync_steady_state(qdac, qdac2, mocker): # noqa
controller_commands = qdac.get_recorded_scpi_commands()
assert controller_commands == [
'sens:rang low,(@2,1)',
'*stb?',
'sens:nplc 2,(@2,1)',
# (Sleep 1 PLC)
'read? (@2,1)',
# (Sleep NPLC / line_freq)
'read? (@2,1)',
]
listener_commands = qdac2.get_recorded_scpi_commands()
assert listener_commands == [
'sens:rang low,(@3)',
'*stb?',
'sens:nplc 2,(@3)',
# (Sleep 1 PLC)
'read? (@3)',
# (Sleep NPLC / line_freq)
'read? (@3)',
]
discard_s = 1 / 50
measure_s = (nplc + 1) / 50
sleep_s.assert_has_calls([call(discard_s), call(measure_s)])
sleep_s.assert_has_calls([call(measure_s)])


def test_sync_leakage(qdac, qdac2, mocker): # noqa
Expand All @@ -229,49 +226,49 @@ def test_sync_leakage(qdac, qdac2, mocker): # noqa
assert controller_commands == [
# Steady-state reading
'sens:rang low,(@3)',
'*stb?',
'sens:nplc 2,(@3)',
'read? (@3)',
'read? (@3)',
# First modulation
'sour3:volt:mode fix',
'sour3:volt 0.302',
'sens:rang low,(@3)',
'*stb?',
'sens:nplc 2,(@3)',
'read? (@3)',
'read? (@3)',
'sour3:volt:mode fix',
'sour3:volt 0.3',
# Second modulation
'sens:rang low,(@3)',
'*stb?',
'sens:nplc 2,(@3)',
'read? (@3)',
'read? (@3)',
# Third modulation
'sens:rang low,(@3)',
'*stb?',
'sens:nplc 2,(@3)',
'read? (@3)',
'read? (@3)'
]
assert listener_commands == [
# Steady-state reading
'sens:rang low,(@1,2)',
'*stb?',
'sens:nplc 2,(@1,2)',
'read? (@1,2)',
'read? (@1,2)',
# First modulation
'sens:rang low,(@1,2)',
'*stb?',
'sens:nplc 2,(@1,2)',
'read? (@1,2)',
'read? (@1,2)',
# Second modulation
'sour1:volt:mode fix',
'sour1:volt 0.202',
'sour2:volt:mode fix',
'sour2:volt 0.0',
'sens:rang low,(@1,2)',
'*stb?',
'sens:nplc 2,(@1,2)',
'read? (@1,2)',
'read? (@1,2)',
'sour1:volt:mode fix',
'sour1:volt 0.2',
'sour2:volt:mode fix',
Expand All @@ -282,9 +279,9 @@ def test_sync_leakage(qdac, qdac2, mocker): # noqa
'sour2:volt:mode fix',
'sour2:volt 0.002',
'sens:rang low,(@1,2)',
'*stb?',
'sens:nplc 2,(@1,2)',
'read? (@1,2)',
'read? (@1,2)',
'sour1:volt:mode fix',
'sour1:volt 0.2',
'sour2:volt:mode fix',
Expand Down
15 changes: 6 additions & 9 deletions qcodes_contrib_drivers/tests/QDevil/test_sim_qdac2_leakage.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,13 @@ def test_arrangement_steady_state(qdac, mocker):
commands = qdac.get_recorded_scpi_commands()
assert commands == [
'sens:rang low,(@1,2,3)',
'*stb?',
'sens:nplc 2,(@1,2,3)',
# (Sleep 1 PLC)
'read? (@1,2,3)',
# (Sleep NPLC / line_freq)
'read? (@1,2,3)',
]
discard_s = 1 / 50
measure_s = (nplc + 1) / 50
sleep_s.assert_has_calls([call(discard_s), call(measure_s)])
sleep_s.assert_has_calls([call(measure_s)])


def test_arrangement_leakage(qdac, mocker): # noqa
Expand All @@ -52,9 +50,8 @@ def test_arrangement_leakage(qdac, mocker): # noqa
commands = qdac.get_recorded_scpi_commands()
assert commands == [
'sens:rang low,(@1,2,3)',
'*stb?',
'sens:nplc 2,(@1,2,3)',
# Discard first reading
'read? (@1,2,3)',
# Steady-state reading
'read? (@1,2,3)',
# First modulation
Expand All @@ -65,9 +62,9 @@ def test_arrangement_leakage(qdac, mocker): # noqa
'sour3:volt:mode fix',
'sour3:volt 0.4',
'sens:rang low,(@1,2,3)',
'*stb?',
'sens:nplc 2,(@1,2,3)',
'read? (@1,2,3)',
'read? (@1,2,3)',
'sour1:volt:mode fix',
'sour1:volt 0.3',
'sour2:volt:mode fix',
Expand All @@ -82,9 +79,9 @@ def test_arrangement_leakage(qdac, mocker): # noqa
'sour3:volt:mode fix',
'sour3:volt 0.4',
'sens:rang low,(@1,2,3)',
'*stb?',
'sens:nplc 2,(@1,2,3)',
'read? (@1,2,3)',
'read? (@1,2,3)',
'sour1:volt:mode fix',
'sour1:volt 0.3',
'sour2:volt:mode fix',
Expand All @@ -99,9 +96,9 @@ def test_arrangement_leakage(qdac, mocker): # noqa
'sour3:volt:mode fix',
'sour3:volt 0.405',
'sens:rang low,(@1,2,3)',
'*stb?',
'sens:nplc 2,(@1,2,3)',
'read? (@1,2,3)',
'read? (@1,2,3)',
'sour1:volt:mode fix',
'sour1:volt 0.3',
'sour2:volt:mode fix',
Expand Down