Skip to content

Commit

Permalink
QDAC2: start_once_on triggers
Browse files Browse the repository at this point in the history
- Additional init is not needed anymore
  • Loading branch information
jpsecher committed Oct 4, 2023
1 parent 7575e0d commit b65ca5c
Show file tree
Hide file tree
Showing 10 changed files with 187 additions and 66 deletions.
136 changes: 131 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.4.0
# Version 1.6.0
#
# Guiding principles for this driver for QDevil QDAC-II
# -----------------------------------------------------
Expand Down Expand Up @@ -198,10 +198,18 @@ def allocate_trigger(self) -> QDac2Trigger_Context:
def start_on(self, trigger: QDac2Trigger_Context) -> None:
pass

@abc.abstractmethod
def start_once_on(self, trigger: QDac2Trigger_Context) -> None:
pass

@abc.abstractmethod
def start_on_external(self, trigger: ExternalInput) -> None:
pass

@abc.abstractmethod
def start_once_on_external(self, trigger: ExternalInput) -> None:
pass

@abc.abstractmethod
def abort(self) -> None:
pass
Expand Down Expand Up @@ -265,6 +273,17 @@ def start_on(self, trigger: QDac2Trigger_Context) -> None:
self._write_channel(f'sour{"{0}"}:dc:trig:sour int{internal}')
self._make_ready_to_start()

def start_once_on(self, trigger: QDac2Trigger_Context) -> None:
"""Attach internal one-shot trigger to DC generator
Args:
trigger (QDac2Trigger_Context): trigger that will start DC
"""
self._trigger = trigger
internal = _trigger_context_to_value(trigger)
self._write_channel(f'sour{"{0}"}:dc:trig:sour int{internal}')
self._make_ready_to_start_once()

def start_on_external(self, trigger: ExternalInput) -> None:
"""Attach external trigger to DC generator
Expand All @@ -275,6 +294,16 @@ def start_on_external(self, trigger: ExternalInput) -> None:
self._write_channel(f'sour{"{0}"}:dc:trig:sour ext{trigger}')
self._make_ready_to_start()

def start_once_on_external(self, trigger: ExternalInput) -> None:
"""Attach external one-shot trigger to DC generator
Args:
trigger (ExternalInput): trigger that will start DC generator
"""
self._trigger = None
self._write_channel(f'sour{"{0}"}:dc:trig:sour ext{trigger}')
self._make_ready_to_start_once()

def abort(self) -> None:
"""Abort any DC running generator on the channel
"""
Expand Down Expand Up @@ -348,7 +377,9 @@ def _start(self, description: str) -> None:

def _make_ready_to_start(self) -> None:
self._write_channel('sour{0}:dc:init:cont on')
self._write_channel('sour{0}:dc:init')

def _make_ready_to_start_once(self) -> None:
self._write_channel('sour{0}:dc:init:cont off')

def _switch_to_immediate_trigger(self) -> None:
self._write_channel('sour{0}:dc:init:cont off')
Expand Down Expand Up @@ -558,11 +589,22 @@ def _start_on(self, trigger: QDac2Trigger_Context, wave_kind: str) -> None:
self._write_channel(f'sour{"{0}"}:{wave_kind}:trig:sour int{internal}')
self._make_ready_to_start(wave_kind)

def _start_once_on(self, trigger: QDac2Trigger_Context, wave_kind: str) -> None:
self._trigger = trigger
internal = _trigger_context_to_value(trigger)
self._write_channel(f'sour{"{0}"}:{wave_kind}:trig:sour int{internal}')
self._make_ready_to_start_once(wave_kind)

def _start_on_external(self, trigger: ExternalInput, wave_kind: str) -> None:
self._trigger = None
self._write_channel(f'sour{"{0}"}:{wave_kind}:trig:sour ext{trigger}')
self._make_ready_to_start(wave_kind)

def _start_once_on_external(self, trigger: ExternalInput, wave_kind: str) -> None:
self._trigger = None
self._write_channel(f'sour{"{0}"}:{wave_kind}:trig:sour ext{trigger}')
self._make_ready_to_start_once(wave_kind)

def _end_marker(self, wave_kind: str) -> QDac2Trigger_Context:
if not self._marker_end:
self._marker_end = self.allocate_trigger()
Expand All @@ -589,7 +631,9 @@ def _period_start_marker(self, wave_kind: str) -> QDac2Trigger_Context:

def _make_ready_to_start(self, wave_kind: str) -> None:
self._write_channel(f'sour{"{0}"}:{wave_kind}:init:cont on')
self._write_channel(f'sour{"{0}"}:{wave_kind}:init')

def _make_ready_to_start_once(self, wave_kind: str) -> None:
self._write_channel(f'sour{"{0}"}:{wave_kind}:init:cont off')

def _switch_to_immediate_trigger(self, wave_kind: str):
self._write_channel(f'sour{"{0}"}:{wave_kind}:init:cont off')
Expand Down Expand Up @@ -723,6 +767,14 @@ def start_on(self, trigger: QDac2Trigger_Context) -> None:
"""
return super()._start_on(trigger, 'squ')

def start_once_on(self, trigger: QDac2Trigger_Context) -> None:
"""Attach internal one-shot trigger to start the square wave generator
Args:
trigger (QDac2Trigger_Context): trigger that will start square wave
"""
return super()._start_once_on(trigger, 'squ')

def start_on_external(self, trigger: ExternalInput) -> None:
"""Attach external trigger to start the square wave generator
Expand All @@ -731,6 +783,14 @@ def start_on_external(self, trigger: ExternalInput) -> None:
"""
return super()._start_on_external(trigger, 'squ')

def start_once_on_external(self, trigger: ExternalInput) -> None:
"""Attach external one-shot trigger to start the square wave generator
Args:
trigger (ExternalInput): external trigger that will start square wave
"""
return super()._start_once_on_external(trigger, 'squ')


class Sine_Context(_Waveform_Context):

Expand Down Expand Up @@ -838,6 +898,14 @@ def start_on(self, trigger: QDac2Trigger_Context) -> None:
"""
return super()._start_on(trigger, 'sine')

def start_once_on(self, trigger: QDac2Trigger_Context) -> None:
"""Attach internal one-shot trigger to start the sine wave generator
Args:
trigger (QDac2Trigger_Context): trigger that will start sine wave
"""
return super()._start_once_on(trigger, 'sin')

def start_on_external(self, trigger: ExternalInput) -> None:
"""Attach external trigger to start the sine wave generator
Expand All @@ -846,6 +914,14 @@ def start_on_external(self, trigger: ExternalInput) -> None:
"""
return super()._start_on_external(trigger, 'sine')

def start_once_on_external(self, trigger: ExternalInput) -> None:
"""Attach external one-shot trigger to start the sine wave generator
Args:
trigger (ExternalInput): external trigger that will start sine wave
"""
return super()._start_once_on_external(trigger, 'sin')


class Triangle_Context(_Waveform_Context):

Expand Down Expand Up @@ -962,6 +1038,14 @@ def start_on(self, trigger: QDac2Trigger_Context) -> None:
"""
return super()._start_on(trigger, 'tri')

def start_once_on(self, trigger: QDac2Trigger_Context) -> None:
"""Attach internal one-shot trigger to start the triangle wave generator
Args:
trigger (QDac2Trigger_Context): trigger that will start triangle wave
"""
return super()._start_once_on(trigger, 'tri')

def start_on_external(self, trigger: ExternalInput) -> None:
"""Attach external trigger to start the triangle wave generator
Expand All @@ -970,6 +1054,14 @@ def start_on_external(self, trigger: ExternalInput) -> None:
"""
return super()._start_on_external(trigger, 'tri')

def start_once_on_external(self, trigger: ExternalInput) -> None:
"""Attach external one-shot trigger to start the triangle wave generator
Args:
trigger (ExternalInput): external trigger that will start triangle wave
"""
return super()._start_once_on_external(trigger, 'tri')


class Awg_Context(_Waveform_Context):

Expand Down Expand Up @@ -1061,6 +1153,14 @@ def start_on(self, trigger: QDac2Trigger_Context) -> None:
"""
return super()._start_on(trigger, 'awg')

def start_once_on(self, trigger: QDac2Trigger_Context) -> None:
"""Attach internal one-shot trigger to start the AWG
Args:
trigger (QDac2Trigger_Context): trigger that will start AWG
"""
return super()._start_once_on(trigger, 'awg')

def start_on_external(self, trigger: ExternalInput) -> None:
"""Attach external trigger to start the AWG
Expand All @@ -1069,6 +1169,14 @@ def start_on_external(self, trigger: ExternalInput) -> None:
"""
return super()._start_on_external(trigger, 'awg')

def start_once_on_external(self, trigger: ExternalInput) -> None:
"""Attach external one-shot trigger to start the AWG
Args:
trigger (ExternalInput): external trigger that will start AWG
"""
return super()._start_once_on_external(trigger, 'awg')


class Measurement_Context(_Channel_Context):

Expand Down Expand Up @@ -1105,7 +1213,17 @@ def start_on(self, trigger: QDac2Trigger_Context) -> None:
internal = _trigger_context_to_value(trigger)
self._write_channel(f'sens{"{0}"}:trig:sour int{internal}')
self._write_channel(f'sens{"{0}"}:init:cont on')
self._write_channel(f'sens{"{0}"}:init')

def start_once_on(self, trigger: QDac2Trigger_Context) -> None:
"""Attach internal once-shot trigger to start the current measurement
Args:
trigger (QDac2Trigger_Context): trigger that will start measurement
"""
self._trigger = trigger
internal = _trigger_context_to_value(trigger)
self._write_channel(f'sens{"{0}"}:trig:sour int{internal}')
self._write_channel(f'sens{"{0}"}:init:cont off')

def start_on_external(self, trigger: ExternalInput) -> None:
"""Attach external trigger to start the current measurement
Expand All @@ -1115,7 +1233,15 @@ def start_on_external(self, trigger: ExternalInput) -> None:
"""
self._write_channel(f'sens{"{0}"}:trig:sour ext{trigger}')
self._write_channel(f'sens{"{0}"}:init:cont on')
self._write_channel(f'sens{"{0}"}:init')

def start_once_on_external(self, trigger: ExternalInput) -> None:
"""Attach external one-shot trigger to start the current measurement
Args:
trigger (ExternalInput): trigger that will start measurement
"""
self._write_channel(f'sens{"{0}"}:trig:sour ext{trigger}')
self._write_channel(f'sens{"{0}"}:init:cont off')

def abort(self) -> None:
"""Abort current measurement
Expand Down
4 changes: 2 additions & 2 deletions qcodes_contrib_drivers/tests/QDevil/test_sim_qdac2_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ def test_sync_square_waves(qdac, qdac2): # noqa
assert 'sour1:squ:per 1e-05' in controller_commands
assert 'sour1:squ:span 1' in controller_commands
assert 'sour1:squ:trig:sour ext3' in controller_commands
assert 'sour1:squ:init' in controller_commands
assert 'sour1:squ:init:cont on' in controller_commands
assert 'outp:trig4:sour int1' in controller_commands
listener_commands = qdac2.get_recorded_scpi_commands()
assert 'sour1:squ:per 1e-05' in listener_commands
assert 'sour1:squ:span 1' in listener_commands
assert 'sour1:squ:trig:sour ext3' in listener_commands
assert 'sour1:squ:init' in listener_commands
assert 'sour1:squ:init:cont on' in listener_commands
# -----------------------------------------------------------------------
qdacs.trigger(start_trigger)
# -----------------------------------------------------------------------
Expand Down
33 changes: 28 additions & 5 deletions qcodes_contrib_drivers/tests/QDevil/test_sim_qdac2_awg.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def test_awg_default_values(qdac): # noqa
'sour5:awg:coun 1',
'sour5:awg:trig:sour bus',
'sour5:awg:init:cont on',
'sour5:awg:init',
]


Expand All @@ -117,7 +116,6 @@ def test_awg_parameters(qdac): # noqa
'sour5:awg:coun 10',
'sour5:awg:trig:sour bus',
'sour5:awg:init:cont on',
'sour5:awg:init',
]


Expand Down Expand Up @@ -224,7 +222,6 @@ def test_awg_start_trigger_fires(qdac): # noqa
# -----------------------------------------------------------------------
assert qdac.get_recorded_scpi_commands() == [
'sour5:awg:init:cont on',
'sour5:awg:init',
f'tint {trigger.value}'
]

Expand Down Expand Up @@ -296,7 +293,20 @@ def test_awg_trigger_on_internal(qdac): # noqa
assert qdac.get_recorded_scpi_commands() == [
f'sour5:awg:trig:sour int{trigger.value}',
f'sour5:awg:init:cont on',
'sour5:awg:init'
]


def test_awg_trigger_once_on_internal(qdac): # noqa
trace = qdac.allocate_trace('my-trace', 6)
awg = qdac.ch05.arbitrary_wave(trace.name)
trigger = qdac.allocate_trigger()
qdac.start_recording_scpi()
# -----------------------------------------------------------------------
awg.start_once_on(trigger)
# -----------------------------------------------------------------------
assert qdac.get_recorded_scpi_commands() == [
f'sour5:awg:trig:sour int{trigger.value}',
f'sour5:awg:init:cont off',
]


Expand All @@ -311,5 +321,18 @@ def test_awg_trigger_on_external(qdac): # noqa
assert qdac.get_recorded_scpi_commands() == [
f'sour5:awg:trig:sour ext{trigger}',
f'sour5:awg:init:cont on',
'sour5:awg:init'
]


def test_awg_trigger_once_on_external(qdac): # noqa
trace = qdac.allocate_trace('my-trace', 6)
awg = qdac.ch05.arbitrary_wave(trace.name)
trigger = ExternalInput(1)
qdac.start_recording_scpi()
# -----------------------------------------------------------------------
awg.start_once_on_external(trigger)
# -----------------------------------------------------------------------
assert qdac.get_recorded_scpi_commands() == [
f'sour5:awg:trig:sour ext{trigger}',
f'sour5:awg:init:cont off',
]
28 changes: 26 additions & 2 deletions qcodes_contrib_drivers/tests/QDevil/test_sim_qdac2_current.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,19 @@ def test_measurement_trigger_on_internal(qdac): # noqa
assert qdac.get_recorded_scpi_commands() == [
f'sens2:trig:sour int{trigger.value}',
f'sens2:init:cont on',
'sens2:init'
]


def test_measurement_trigger_once_on_internal(qdac): # noqa
measurement = qdac.ch02.measurement()
trigger = qdac.allocate_trigger()
qdac.start_recording_scpi()
# -----------------------------------------------------------------------
measurement.start_once_on(trigger)
# -----------------------------------------------------------------------
assert qdac.get_recorded_scpi_commands() == [
f'sens2:trig:sour int{trigger.value}',
f'sens2:init:cont off',
]


Expand All @@ -96,7 +108,19 @@ def test_measurement_trigger_on_external(qdac): # noqa
assert qdac.get_recorded_scpi_commands() == [
f'sens2:trig:sour ext{trigger}',
f'sens2:init:cont on',
'sens2:init'
]


def test_measurement_trigger_once_on_external(qdac): # noqa
measurement = qdac.ch02.measurement()
trigger = ExternalInput(1)
qdac.start_recording_scpi()
# -----------------------------------------------------------------------
measurement.start_once_on_external(trigger)
# -----------------------------------------------------------------------
assert qdac.get_recorded_scpi_commands() == [
f'sens2:trig:sour ext{trigger}',
f'sens2:init:cont off',
]


Expand Down
Loading

0 comments on commit b65ca5c

Please sign in to comment.