3.4.1.3. qupulse.hardware.awgs.zihdawg

class qupulse.hardware.awgs.zihdawg.ELFManager(awg_module)[source]

Bases: object

This class organizes compiling and uploading of compiled programs. The source code file is named based on the code hash to cache compilation results. This requires that the waveform names are unique.

The compilation and upload itself are done asynchronously by zhinst.ziPython. To avoid spawning a useless thread for updating the status the method compile_and_upload() returns a generator which talks to the undelying library when needed.

class AWGModule(awg_module)[source]

Bases: object

Provide an easily mockable interface to the zhinst AwgModule object

__init__(awg_module)[source]

Provide an easily mockable interface to the zhinst AwgModule object

property compiler_source_file: str
Return type

str

property compiler_start: bool

True if the compiler is running

Return type

bool

property compiler_status: Tuple[int, str]
Return type

Tuple[int, str]

property compiler_upload: bool

auto upload after compiling

Return type

bool

property elf_dir: pathlib.Path
Return type

Path

property elf_file: str
Return type

str

property elf_status: Tuple[int, float]
Return type

Tuple[int, float]

property elf_upload: bool
Return type

bool

property index: int
Return type

int

property src_dir: pathlib.Path
Return type

Path

__init__(awg_module)[source]

This class organizes compiling and uploading of compiled programs. The source code file is named based on the code hash to cache compilation results. This requires that the waveform names are unique.

The compilation and upload itself are done asynchronously by zhinst.ziPython. To avoid spawning a useless thread for updating the status the method compile_and_upload() returns a generator which talks to the undelying library when needed.

clear()[source]

Deletes all files with a SHA512 hash name

compile_and_upload(source_string)[source]

The source code is saved to a file determined by the source hash, compiled and uploaded to the instrument. The function returns a generator that yields the current state of the progress. The generator is empty iff the upload is complete. An exception is raised if there is an error.

To abort send ‘abort’ to the generator.

Example

>>> my_source = 'playWave("my_wave");'
>>> for state in elf_manager.compile_and_upload(my_source):
...     print('Current state:', state)
...     time.sleep(1)
Parameters

source_string (str) – Source code to compile

Return type

Generator[str, str, None]

Returns

Generator object that needs to be consumed

class qupulse.hardware.awgs.zihdawg.HDAWGChannelGroup(group_idx, group_size, identifier, timeout)[source]

Bases: qupulse.hardware.awgs.base.AWG

Represents a channel pair of the Zurich Instruments HDAWG as an independent AWG entity. It represents a set of channels that have to have(hardware enforced) the same control flow and sample rate.

It keeps track of the AWG state and manages waveforms and programs on the hardware.

MIN_WAVEFORM_LEN = 192
WAVEFORM_LEN_QUANTUM = 16
amplitudes()[source]

Query AWG channel amplitude value (not peak to peak).

From manual: The final signal amplitude is given by the product of the full scale output range of 1 V[in this example], the dimensionless amplitude scaling factor 1.0, and the actual dimensionless signal amplitude stored in the waveform memory.

Return type

Tuple[float, …]

arm(name)[source]

Load the program ‘name’ and arm the device for running it. If name is None the awg will “dearm” its current program.

Currently hardware triggering is not implemented. The HDAWGProgramManager needs to emit code that calls waitDigTrigger to do that.

Return type

None

property awg_group_index: int

AWG node group index assuming 4x2 channel grouping. Then 0…3 will give appropriate index of group.

Return type

int

property awg_module: zhinst.ziPython.AwgModule

Each AWG channel group has its own awg module to manage program compilation and upload.

Return type

AwgModule

clear()[source]

Removes all programs and waveforms from the AWG.

Caution: This affects all programs and waveforms on the AWG, not only those uploaded using qupulse!

Return type

None

connect_group(hdawg_device)[source]
property device: qupulse.hardware.awgs.zihdawg.HDAWGRepresentation

Reference to HDAWG representation.

Return type

HDAWGRepresentation

disconnect_group()[source]

Disconnect this group from device so groups of another size can be used

enable(status=None)[source]

Start the AWG sequencer.

Return type

bool

is_connected()[source]
Return type

bool

property num_channels: int

Number of channels

Return type

int

property num_markers: int

Number of marker channels

Return type

int

offsets()[source]
Return type

Tuple[float, …]

property programs: Set[str]

The set of program names that can currently be executed on the hardware AWG.

Return type

Set[str]

remove(name)[source]

Remove a program from the AWG.

Also discards all waveforms referenced only by the program identified by name.

Parameters

name (str) – The name of the program to remove.

Return type

None

run_current_program()[source]

Run armed program.

Return type

None

property sample_rate: qupulse.utils.types.TimeType

The default sample rate of the AWG channel group.

Return type

TimeType

set_volatile_parameters(program_name, parameters)[source]

Set the values of parameters which were marked as volatile on program creation.

upload(name, program, channels, markers, voltage_transformation, force=False)[source]

Upload a program to the AWG.

Physically uploads all waveforms required by the program - excluding those already present - to the device and sets up playback sequences accordingly. This method should be cheap for program already on the device and can therefore be used for syncing. Programs that are uploaded should be fast(~1 sec) to arm.

Parameters
  • name (str) – A name for the program on the AWG.

  • program (Loop) – The program (a sequence of instructions) to upload.

  • channels (Tuple[Union[str, int, None], …]) – Tuple of length num_channels that ChannelIDs of in the program to use. Position in the list

  • to the AWG channel (corresponds) –

  • markers (Tuple[Union[str, int, None], …]) – List of channels in the program to use. Position in the List in the list corresponds to

  • AWG channel (the) –

  • voltage_transformation (Tuple[Callable, …]) – transformations applied to the waveforms extracted rom the program. Position

  • the list corresponds to the AWG channel (in) –

  • force (bool) – If a different sequence is already present with the same name, it is overwritten if force is set to True. (default = False)

Known programs are handled in host memory most of the time. Only when uploading the device memory is touched at all.

Returning from setting user register in seqc can take from 50ms to 60 ms. Fluctuates heavily. Not a good way to have deterministic behaviour “setUserReg(PROG_SEL, PROG_IDLE);”.

Return type

None

property user_directory: str

“awg/src” (seqc sourcefiles), “awg/elf” (compiled AWG binaries), “awag/waves” (user defined csv waveforms).

Type

LabOne user directory with subdirectories

Return type

str

user_register(reg, value=None)[source]

Query user registers (1-16) and optionally set it.

Parameters
  • reg (UserRegister) – User register. If it is an int, a warning is raised and it is interpreted as a one based index

  • value (Optional[int]) – Value to set

Return type

int

Returns

User Register value after setting it

was_current_program_finished()[source]

Return true if the current program has finished at least once

Return type

bool

class qupulse.hardware.awgs.zihdawg.HDAWGChannelGrouping(value)[source]

Bases: enum.Enum

How many independent sequencers should run on the AWG and how the outputs should be grouped by sequencer.

CHAN_GROUP_1x8 = 2
CHAN_GROUP_2x4 = 1
CHAN_GROUP_4x2 = 0
group_size()[source]
Return type

int

exception qupulse.hardware.awgs.zihdawg.HDAWGCompilationException(msg)[source]

Bases: qupulse.hardware.awgs.zihdawg.HDAWGException

exception qupulse.hardware.awgs.zihdawg.HDAWGException[source]

Bases: Exception

Base exception class for HDAWG errors.

exception qupulse.hardware.awgs.zihdawg.HDAWGIOError[source]

Bases: qupulse.hardware.awgs.zihdawg.HDAWGException, OSError

class qupulse.hardware.awgs.zihdawg.HDAWGModulationMode(value)[source]

Bases: enum.Enum

Modulation mode of waveform generator.

ADVANCED = 5
FG_1 = 3
FG_2 = 4
OFF = 0
SINE_1 = 1
SINE_2 = 2
class qupulse.hardware.awgs.zihdawg.HDAWGRepresentation(device_serial=None, device_interface='1GbE', data_server_addr='localhost', data_server_port=8004, api_level_number=6, reset=False, timeout=20, grouping=None)[source]

Bases: object

HDAWGRepresentation represents an HDAWG8 instruments and manages a LabOne data server api session. A data server must be running and the device be discoverable. Channels are per default grouped into pairs.

Parameters
  • device_serial (Optional[str]) – Device serial that uniquely identifies this device to the LabOne data server

  • device_interface (str) – Either ‘1GbE’ for ethernet or ‘USB’

  • data_server_addr (str) – Data server address. Must be already running. Default: localhost

  • data_server_port (int) – Data server port. Default: 8004 for HDAWG, MF and UHF devices

  • api_level_number (int) – Version of API to use for the session, higher number, newer. Default: 6 most recent

  • reset (bool) – Reset device before initialization

  • timeout (float) – Timeout in seconds for uploading

__init__(device_serial=None, device_interface='1GbE', data_server_addr='localhost', data_server_port=8004, api_level_number=6, reset=False, timeout=20, grouping=None)[source]
Parameters
  • device_serial (Optional[str]) – Device serial that uniquely identifies this device to the LabOne data server

  • device_interface (str) – Either ‘1GbE’ for ethernet or ‘USB’

  • data_server_addr (str) – Data server address. Must be already running. Default: localhost

  • data_server_port (int) – Data server port. Default: 8004 for HDAWG, MF and UHF devices

  • api_level_number (int) – Version of API to use for the session, higher number, newer. Default: 6 most recent

  • reset (bool) – Reset device before initialization

  • timeout (float) – Timeout in seconds for uploading

property api_session: zhinst.ziPython.ziDAQServer
Return type

ziDAQServer

property channel_grouping: qupulse.hardware.awgs.zihdawg.HDAWGChannelGrouping
Return type

HDAWGChannelGrouping

property channel_pair_AB: qupulse.hardware.awgs.zihdawg.HDAWGChannelGroup
Return type

HDAWGChannelGroup

property channel_pair_CD: qupulse.hardware.awgs.zihdawg.HDAWGChannelGroup
Return type

HDAWGChannelGroup

property channel_pair_EF: qupulse.hardware.awgs.zihdawg.HDAWGChannelGroup
Return type

HDAWGChannelGroup

property channel_pair_GH: qupulse.hardware.awgs.zihdawg.HDAWGChannelGroup
Return type

HDAWGChannelGroup

property channel_tuples: Tuple[qupulse.hardware.awgs.zihdawg.HDAWGChannelGroup, ...]
Return type

Tuple[HDAWGChannelGroup, …]

get_status_table()[source]

Return node tree of instrument with all important settings, as well as each channel group as tuple.

group_name(group_idx, group_size)[source]
Return type

str

offset(channel, voltage=None)[source]

Query channel offset voltage and optionally set it.

Return type

float

output(channel, status=None)[source]

Query channel signal output status (enabled/disabled) and optionally set it. Corresponds to front LED.

Return type

bool

range(channel, voltage=None)[source]

Query channel voltage range and optionally set it. The instruments selects the next higher available range. This is the one-sided range Vp. Total range: -Vp…Vp

Return type

float

reset()[source]
Return type

None

property serial: str
Return type

str

property waveform_file_system: qupulse._program.seqc.WaveformFileSystem
Return type

WaveformFileSystem

exception qupulse.hardware.awgs.zihdawg.HDAWGRuntimeError[source]

Bases: qupulse.hardware.awgs.zihdawg.HDAWGException, RuntimeError

exception qupulse.hardware.awgs.zihdawg.HDAWGTimeoutError[source]

Bases: qupulse.hardware.awgs.zihdawg.HDAWGException, TimeoutError

class qupulse.hardware.awgs.zihdawg.HDAWGTriggerOutSource(value)[source]

Bases: enum.Enum

Assign a signal to a marker output. This is per AWG Core.

AWG_TRIG_1 = 0
AWG_TRIG_2 = 1
AWG_TRIG_3 = 2
AWG_TRIG_4 = 3
HIGH = 17
LOW = 18
OUT_1_MARK_1 = 4
OUT_1_MARK_2 = 5
OUT_2_MARK_1 = 6
OUT_2_MARK_2 = 7
TRIG_IN_1 = 8
TRIG_IN_2 = 9
TRIG_IN_3 = 10
TRIG_IN_4 = 11
TRIG_IN_5 = 12
TRIG_IN_6 = 13
TRIG_IN_7 = 14
TRIG_IN_8 = 15
exception qupulse.hardware.awgs.zihdawg.HDAWGTypeError[source]

Bases: qupulse.hardware.awgs.zihdawg.HDAWGException, TypeError

exception qupulse.hardware.awgs.zihdawg.HDAWGUploadException[source]

Bases: qupulse.hardware.awgs.zihdawg.HDAWGException

exception qupulse.hardware.awgs.zihdawg.HDAWGValueError[source]

Bases: qupulse.hardware.awgs.zihdawg.HDAWGException, ValueError

class qupulse.hardware.awgs.zihdawg.HDAWGVoltageRange(value)[source]

Bases: enum.Enum

All available voltage ranges for the HDAWG wave outputs. Define maximum output voltage.

RNG_1V = 1
RNG_200mV = 0.2
RNG_2V = 2
RNG_3V = 3
RNG_400mV = 0.4
RNG_4V = 4
RNG_5V = 5
RNG_600mV = 0.6
RNG_800mV = 0.8
qupulse.hardware.awgs.zihdawg.example_upload(hdawg_kwargs, channels, markers)[source]
qupulse.hardware.awgs.zihdawg.get_group_for_channels(hdawg, channels)[source]
Return type

HDAWGChannelGroup

qupulse.hardware.awgs.zihdawg.valid_channel(function_object)[source]

Check if channel is a valid AWG channels. Expects channel to be 2nd argument after self.