Skip to content

Commit

Permalink
Merge pull request #282 from QDevil/qdac2
Browse files Browse the repository at this point in the history
QDAC2: Sweep generator and snapshot bugfixes
  • Loading branch information
astafan8 authored Jan 3, 2024
2 parents 49ba5e6 + ff0ac4b commit 27abe4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
5 changes: 3 additions & 2 deletions docs/examples/QDevil/QDAC2/Sweep.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
"source": [
"dc_sweep = qdac.ch03.dc_sweep(\n",
" repetitions=2,\n",
" stepped=True,\n",
" start_V=-1,\n",
" stop_V=1,\n",
" points=11,\n",
Expand Down Expand Up @@ -247,7 +248,7 @@
],
"metadata": {
"kernelspec": {
"display_name": "qcodespip311",
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
Expand All @@ -261,7 +262,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.0 | packaged by conda-forge | (main, Jan 16 2023, 14:12:30) [MSC v.1916 64 bit (AMD64)]"
"version": "3.10.12"
},
"nbsphinx": {
"execute": "never"
Expand Down
28 changes: 13 additions & 15 deletions qcodes_contrib_drivers/drivers/QDevil/QDAC2.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
from pyvisa.errors import VisaIOError
from qcodes.utils import validators
from typing import NewType, Tuple, Sequence, List, Dict, Optional
from packaging.version import Version, parse
from packaging.version import parse
import abc

# Version 1.8.0
# Version 1.10.0
#
# Guiding principles for this driver for QDevil QDAC-II
# -----------------------------------------------------
Expand All @@ -28,9 +28,9 @@
#
# qdac.n_channels()
#
# 3. Allocation of resources should be automated as much as possible, preferably
# by python context managers that automatically clean up on exit. Such
# context managers have a name with a '_Context' suffix.
# 3. Allocation of resources should be automated as much as possible,
# preferably by python context managers that automatically clean up on exit.
# Such context managers have a name with a '_Context' suffix.
#
# 4. Any generator should by default be set to start on the BUS trigger
# (*TRG) so that it is possible to synchronise several generators without
Expand Down Expand Up @@ -139,14 +139,12 @@ def __init__(self, parent: 'QDac2', name: str, external: int):
name='source_from_input',
# Route external input to external output
set_cmd='outp:trig{0}:sour ext{1}'.format(external, '{}'),
get_parser=int
)
self.add_parameter(
name='source_from_trigger',
# Route internal trigger to external output
set_parser=_trigger_context_to_value,
set_cmd='outp:trig{0}:sour int{1}'.format(external, '{}'),
get_parser=int
)
self.add_parameter(
name='width_s',
Expand Down Expand Up @@ -400,7 +398,7 @@ def __init__(self, channel: 'QDac2Channel', start_V: float, stop_V: float,
channel.write_channel('sour{0}:volt:mode swe')
self._set_voltages(start_V, stop_V)
channel.write_channel(f'sour{"{0}"}:swe:poin {points}')
self._set_trigger_mode(stepped)
self._set_generation_mode(stepped)
channel.write_channel(f'sour{"{0}"}:swe:dwel {dwell_s}')
super()._set_delay(delay_s)
self._set_direction(backwards)
Expand All @@ -411,10 +409,10 @@ def _set_voltages(self, start_V: float, stop_V: float):
self._write_channel(f'sour{"{0}"}:swe:star {start_V}')
self._write_channel(f'sour{"{0}"}:swe:stop {stop_V}')

def _set_trigger_mode(self, stepped: bool) -> None:
def _set_generation_mode(self, stepped: bool) -> None:
if stepped:
return self._write_channel('sour{0}:swe:gen step')
self._write_channel('sour{0}:swe:gen auto')
self._write_channel('sour{0}:swe:gen anal')

def _set_direction(self, backwards: bool) -> None:
if backwards:
Expand Down Expand Up @@ -1578,7 +1576,7 @@ def dc_sweep(self, start_V: float, stop_V: float, points: int,
dwell_s (float, optional): Seconds between each voltage (default 1ms)
delay_s (float, optional): Seconds of delay after receiving a trigger (default 0)
backwards (bool, optional): Sweep in reverse (default is forward)
stepped (bool, optional): True means that each step needs to be triggered (default False)
stepped (bool, optional): True means discrete steps (default True)
Returns:
Sweep_Context: context manager
Expand Down Expand Up @@ -2058,7 +2056,7 @@ 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.ask('*stb?')
self._qdac.write(f'sens:nplc {nplc},{channels_suffix}')
# Wait for the current sensors to stabilize and then read
slowest_line_freq_Hz = 50
Expand Down Expand Up @@ -2219,9 +2217,9 @@ def _calculate_detune_values(self, contacts: Sequence[str], start_V: Sequence[fl
def leakage(self, modulation_V: float, nplc: int = 2) -> np.ndarray:
"""Run a simple leakage test between the contacts
Each contact is changed in turn and the resulting change in current from
steady-state is recorded. The resulting resistance matrix is calculated
as modulation_voltage divided by current_change.
Each contact is changed in turn and the resulting change in current
from steady-state is recorded. The resulting resistance matrix is
calculated as modulation_voltage divided by current_change.
Args:
modulation_V (float): Virtual voltage added to each contact
Expand Down

0 comments on commit 27abe4e

Please sign in to comment.