See also

A Jupyter notebook version of this tutorial can be downloaded here.

Multiplexed sequencing

The Pulsar/Cluster QRM/QCM supports six sequencers. The output of each sequencer is multiplexed, accumulated and connected to the output ports of the instrument as shown in the figure below. Furthermore, input paths 0 and 1 of every sequencer are connected to inputs \(\text{I}^{1}\) and \(\text{I}^{2}\) respectively. In the first part of the tutorial we will connect outputs of multiple sequencers to a single pair of output ports and demonstrate how to multiplex output paths 0 and 1 of these sequencers as well as show how these multiplexed signals are accumulated. In the second part of the tutorial we will demonstrate firstly, how to frequency multiplex the output paths of different sequencers at different unique carrier frequencies on a single pair of output ports and secondly, how to acquire, demodulate and integrate the received frequency multiplexed waveforms. In the third part of the tutorial we will demonstrate “real mode”, where we will control various sequencers to independently output real signals on each output port of the instrument.

We will show this by using a QRM and directly connecting outputs \(\text{O}^{[1-2]}\) to inputs \(\text{I}^{[1-2]}\) respectively. We will then use the QRM’s sequencers to sequence waveforms on the outputs and simultaneously acquire the resulting waveforms on the inputs.

To run this tutorial please make sure you have installed and enabled ipywidgets:

pip install ipywidgets
jupyter nbextension enable --py widgetsnbextension

Setup

First, we are going to import the required packages.

[1]:
# Import ipython widgets
import json
import math
import os

import ipywidgets as widgets
import matplotlib.pyplot
import numpy

# Set up the environment.
import scipy.signal
from IPython.display import display
from ipywidgets import fixed, interact, interact_manual, interactive
from scipy.fft import rfft, rfftfreq
from qcodes import Instrument
from qblox_instruments import Cluster, PlugAndPlay, Pulsar

Scan For Devices

We scan for the available devices connected via ethernet using the Plug & Play functionality of the Qblox Instruments package (see Plug & Play for more info).

[2]:
# Scan for available devices and display
with PlugAndPlay() as p:
    # get info of all devices
    device_list = p.list_devices()

names = {
    dev_id: dev_info["description"]["name"] for dev_id, dev_info in device_list.items()
}
ip_addresses = {
    dev_id: dev_info["identity"]["ip"] for dev_id, dev_info in device_list.items()
}

# create widget for names and ip addresses
connect = widgets.Dropdown(
    options=[(names[dev_id] + " @" + ip_addresses[dev_id], dev_id)
             for dev_id in device_list.keys()],
    description="Select Device",
)
display(connect)
The following widget displays all the existing modules that are connected to your PC which includes the Pulsar modules as well as a Cluster. Select the device you want to run the notebook on.

Connect to Cluster

We now make a connection with the Cluster selected in the dropdown widget. We also define a function to find the modules we’re interested in. We select the readout and control module we want to use.

[ ]:
# Connect to device
dev_id = connect.value
# Close the chosen QCodes instrument as to prevent name clash.
try:
    Instrument.find_instrument(names[dev_id]).close()
except KeyError:
    pass

cluster = Cluster(name=names[dev_id], identifier=ip_addresses[dev_id], debug=True) # TODO remove debug

print(f"{connect.label} connected")
print(cluster.get_system_state())
[ ]:
def select_module_widget(device, select_all=False, select_qrm_type: bool=True, select_rf_type: bool=False):
    """Create a widget to select modules of a certain type

    default is to show only QRM baseband

    Args:
        devices : Cluster we are currently using
        select_all (bool): ignore filters and show all modules
        select_qrm_type (bool): filter QRM/QCM
        select_rf_type (bool): filter RF/baseband
    """
    options = [[None, None]]


    for module in device.modules:
        if module.present():
            if select_all or (module.is_qrm_type == select_qrm_type and module.is_rf_type == select_rf_type):
                options.append(
                    [
                        f"{device.name} "
                        f"{module.short_name} "
                        f"({module.module_type}{'_RF' if module.is_rf_type else ''})",
                        module,
                    ]
                )
    widget = widgets.Dropdown(options=options)
    display(widget)

    return widget
[ ]:
print("Select the readout module from the available modules:")
select_readout_module = select_module_widget(cluster, select_qrm_type=True, select_rf_type=False)
[ ]:
readout_module = select_readout_module.value
print(f"{readout_module} connected")

Reset the Cluster

We reset the Cluster to enter a well-defined state. Note that resetting will clear all stored parameters, so resetting between experiments is usually not desirable.

[ ]:
cluster.reset()
print(cluster.get_system_state())

Generate waveforms

Next, we need to create the gaussian and block waveforms for the sequence.

[4]:
# Waveforms
waveform_len = 1000
waveforms = {
    "gaussian": {
        "data": scipy.signal.gaussian(waveform_len, std=0.133 * waveform_len).tolist(),
        "index": 0,
    },
    "sine": {
        "data": [
            math.sin((2 * math.pi / waveform_len) * i) for i in range(0, waveform_len)
        ],
        "index": 1,
    },
    "sawtooth": {
        "data": [(1.0 / waveform_len) * i for i in range(0, waveform_len)],
        "index": 2,
    },
    "block": {"data": [1.0 for i in range(0, waveform_len)], "index": 3},
}

Let’s plot the waveforms to see what we have created.

[5]:
time = numpy.arange(0, max(map(lambda d: len(d["data"]), waveforms.values())), 1)
fig, ax = matplotlib.pyplot.subplots(1, 1, figsize=(10, 10 / 1.61))

for wf, d in waveforms.items():
    ax.plot(time[: len(d["data"])], d["data"], ".-", linewidth=0.5, label=wf)

ax.legend(loc=4)
ax.yaxis.grid()
ax.xaxis.grid()
ax.set_ylabel("Waveform primitive amplitude")
ax.set_xlabel("Time (ns)")

matplotlib.pyplot.draw()
matplotlib.pyplot.show()
../../_images/tutorials_q1asm_tutorials_multiplexed_sequencing_15_0.png

Specify the acquisitions

We will only use a single bin in this tutorial, so we can keep it simple

[6]:
# Acquisitions
acquisitions = {"scope": {"num_bins": 1, "index": 0}}

Create Q1ASM program and upload the sequence

Now that we have the waveform and acquisition specifications for the sequence, we need a simple Q1ASM program that sequences the waveforms and triggers the acquisitions. In this case we will play a gaussian and a sinosoid wave for path 0 and 1 respectively per sequencer.

[7]:
# Number of sequencers per instrument
num_seq = 6

# Program
program = """
wait_sync 4
play      0,1,4
wait      140
acquire   0,0,16380
stop
"""

# Write sequence to file.
with open("sequence.json", "w", encoding="utf-8") as file:
    json.dump(
        {
            "waveforms": waveforms,
            "weights": waveforms,
            "acquisitions": acquisitions,
            "program": program,
        },
        file,
        indent=4,
    )
    file.close()

# Program sequencers.
for sequencer in readout_module.sequencers:
    sequencer.sequence("sequence.json")

Multiplexed sequencer output control

The output paths of each sequencer are connected to the instrument’s outputs as shown in the figure below. For a QRM, path 0 of each sequencer can only be connected to output \(\text{O}^{1}\) and path 1 only to output \(\text{O}^{2}\) (for a QCM, path 0 can be connected to output \(\text{O}^{1}\) and \(\text{O}^{3}\) and path 1 to \(\text{O}^{2}\) and \(\text{O}^{4}\)), . In order to connect the sequencer output paths to corresponding output ports, we need to configure the sequencer’s channel map by calling sequencerX_channel_map_pathY_outZ_en where X, Y and Z represents sequencer ID, path ID and output port number respectively.

Capture1.PNG

Now lets configure the first sequencer to output its paths on \(\text{O}^{1}\) and \(\text{O}^{2}\). We will scale the amplitude of the signal such that we are able the show what happens when other sequencers are added and eventually output overflow occurs.

[8]:
# Configure the sequencer to trigger the scope acquisition.
readout_module.scope_acq_sequencer_select(0)
readout_module.scope_acq_trigger_mode_path0("sequencer")
readout_module.scope_acq_trigger_mode_path1("sequencer")

# Configure sequencer
readout_module.sequencer0.sync_en(True)
readout_module.sequencer0.gain_awg_path0(
    1.1 / num_seq
)  # The output range is 1.0 to -1.0, but we want to show what happens when the signals go out of range.
readout_module.sequencer0.gain_awg_path1(1.1 / num_seq)
readout_module.sequencer0.channel_map_path0_out0_en(True)
readout_module.sequencer0.channel_map_path1_out1_en(True)

# Start the sequence
readout_module.arm_sequencer(0)
readout_module.start_sequencer()

# Wait for the sequencer to stop
readout_module.get_acquisition_state(0, 1)

# Get acquisition data
readout_module.store_scope_acquisition(0, "scope")
acq = readout_module.get_acquisitions(0)

# Plot the results
fig, ax = matplotlib.pyplot.subplots(1, 1, figsize=(15, 15 / 2 / 1.61))

ax.plot(acq["scope"]["acquisition"]["scope"]["path0"]["data"][0:waveform_len])
ax.plot(acq["scope"]["acquisition"]["scope"]["path1"]["data"][0:waveform_len])
ax.set_xlabel("Time (ns)")
ax.set_ylabel("Relative amplitude")

matplotlib.pyplot.show()
../../_images/tutorials_q1asm_tutorials_multiplexed_sequencing_23_0.png

Let’s add the second sequencer.

[9]:
# Configure the sequencer
readout_module.sequencer1.sync_en(True)
readout_module.sequencer1.gain_awg_path0(1.1 / num_seq)
readout_module.sequencer1.gain_awg_path1(1.1 / num_seq)
readout_module.sequencer1.channel_map_path0_out0_en(True)
readout_module.sequencer1.channel_map_path1_out1_en(True)

# Start the sequencers
for seq in range(0, 2):
    readout_module.arm_sequencer(seq)
readout_module.start_sequencer()

# Wait for sequencers to stop
for seq in range(0, 2):
    readout_module.get_acquisition_state(seq, 1)

# Get acquisition data
readout_module.store_scope_acquisition(0, "scope")
acq = readout_module.get_acquisitions(0)

# Plot the results
fig, ax = matplotlib.pyplot.subplots(1, 1, figsize=(15, 15 / 2 / 1.61))

ax.plot(acq["scope"]["acquisition"]["scope"]["path0"]["data"][0:waveform_len])
ax.plot(acq["scope"]["acquisition"]["scope"]["path1"]["data"][0:waveform_len])
ax.set_xlabel("Time (ns)")
ax.set_ylabel("Relative amplitude")

matplotlib.pyplot.show()
../../_images/tutorials_q1asm_tutorials_multiplexed_sequencing_25_0.png

Let’s add the third sequencer.

[10]:
# Configure the sequencer
readout_module.sequencer2.sync_en(True)
readout_module.sequencer2.gain_awg_path0(1.1 / num_seq)
readout_module.sequencer2.gain_awg_path1(1.1 / num_seq)
readout_module.sequencer2.channel_map_path0_out0_en(True)
readout_module.sequencer2.channel_map_path1_out1_en(True)

# Start the sequencers
for seq in range(0, 3):
    readout_module.arm_sequencer(seq)
readout_module.start_sequencer()

# Wait for sequencers to stop
for seq in range(0, 3):
    readout_module.get_acquisition_state(seq, 1)

# Get acquisition data
readout_module.store_scope_acquisition(0, "scope")
acq = readout_module.get_acquisitions(0)

# Plot the results
fig, ax = matplotlib.pyplot.subplots(1, 1, figsize=(15, 15 / 2 / 1.61))

ax.plot(acq["scope"]["acquisition"]["scope"]["path0"]["data"][0:waveform_len])
ax.plot(acq["scope"]["acquisition"]["scope"]["path1"]["data"][0:waveform_len])
ax.set_xlabel("Time (ns)")
ax.set_ylabel("Relative amplitude")

matplotlib.pyplot.show()
../../_images/tutorials_q1asm_tutorials_multiplexed_sequencing_27_0.png

Let’s add the fourth sequencer.

[11]:
# Configure the sequencer
readout_module.sequencer3.sync_en(True)
readout_module.sequencer3.gain_awg_path0(1.1 / num_seq)
readout_module.sequencer3.gain_awg_path1(1.1 / num_seq)
readout_module.sequencer3.channel_map_path0_out0_en(True)
readout_module.sequencer3.channel_map_path1_out1_en(True)

# Start the sequencers
for seq in range(0, 4):
    readout_module.arm_sequencer(seq)
readout_module.start_sequencer()

# Wait for sequencers to stop
for seq in range(0, 4):
    readout_module.get_acquisition_state(seq, 1)

# Get acquisition data
readout_module.store_scope_acquisition(0, "scope")
acq = readout_module.get_acquisitions(0)

# Plot the results
fig, ax = matplotlib.pyplot.subplots(1, 1, figsize=(15, 15 / 2 / 1.61))

ax.plot(acq["scope"]["acquisition"]["scope"]["path0"]["data"][0:waveform_len])
ax.plot(acq["scope"]["acquisition"]["scope"]["path1"]["data"][0:waveform_len])
ax.set_xlabel("Time (ns)")
ax.set_ylabel("Relative amplitude")

matplotlib.pyplot.show()
../../_images/tutorials_q1asm_tutorials_multiplexed_sequencing_29_0.png

Let’s add the fifth sequencer.

[12]:
# Configure the sequencer
readout_module.sequencer4.sync_en(True)
readout_module.sequencer4.gain_awg_path0(1.1 / num_seq)
readout_module.sequencer4.gain_awg_path1(1.1 / num_seq)
readout_module.sequencer4.channel_map_path0_out0_en(True)
readout_module.sequencer4.channel_map_path1_out1_en(True)

# Start the sequencers
for seq in range(0, 5):
    readout_module.arm_sequencer(seq)
readout_module.start_sequencer()

# Wait for sequencers to stop
for seq in range(0, 5):
    readout_module.get_acquisition_state(seq, 1)

# Get acquisition data
readout_module.store_scope_acquisition(0, "scope")
acq = readout_module.get_acquisitions(0)

# Plot the results
fig, ax = matplotlib.pyplot.subplots(1, 1, figsize=(15, 15 / 2 / 1.61))

ax.plot(acq["scope"]["acquisition"]["scope"]["path0"]["data"][0:waveform_len])
ax.plot(acq["scope"]["acquisition"]["scope"]["path1"]["data"][0:waveform_len])
ax.set_xlabel("Time (ns)")
ax.set_ylabel("Relative amplitude")

matplotlib.pyplot.show()
../../_images/tutorials_q1asm_tutorials_multiplexed_sequencing_31_0.png

Let’s add the sixth sequencer.

[13]:
# Configure the sequencer
readout_module.sequencer5.sync_en(True)
readout_module.sequencer5.gain_awg_path0(1.1 / num_seq)
readout_module.sequencer5.gain_awg_path1(1.1 / num_seq)
readout_module.sequencer5.channel_map_path0_out0_en(True)
readout_module.sequencer5.channel_map_path1_out1_en(True)

# Start the sequencers
for seq in range(0, 6):
    readout_module.arm_sequencer(seq)
readout_module.start_sequencer()

# Wait for sequencers to stop
for seq in range(0, 6):
    readout_module.get_acquisition_state(seq, 1)

# Get acquisition data
readout_module.store_scope_acquisition(0, "scope")
acq = readout_module.get_acquisitions(0)

# Plot the results
fig, ax = matplotlib.pyplot.subplots(1, 1, figsize=(15, 15 / 2 / 1.61))

ax.plot(acq["scope"]["acquisition"]["scope"]["path0"]["data"][0:waveform_len])
ax.plot(acq["scope"]["acquisition"]["scope"]["path1"]["data"][0:waveform_len])
ax.set_xlabel("Time (ns)")
ax.set_ylabel("Relative amplitude")

matplotlib.pyplot.show()
../../_images/tutorials_q1asm_tutorials_multiplexed_sequencing_33_0.png

Note that now the outputs overflow and the output signal is clipped as intended. Also note that the output range of a QRM is 1 Vpp, while it’s input range is 2 Vpp. This causes the signal in the figure to be clipped at 0.5 and -0.5.

Frequency multiplexing

Next, we will show frequency multiplexing. We will connect the outputs of various sequencers to a single output port pair, modulate their waveforms on unique carrier frequencies and in turn acquire, demodulate and integrate the results fed back into the inputs to validate the acquired signals. In this case, for simplicity, we will modulate a square wave pulse on each sequencer and we will play with the output gain. In order to visualise the frequency multiplexing, we will preform an FFT over the acquired scope acquisitions.

[14]:
# Reset
if cluster:
    cluster.reset()
else:
    readout_module.reset()
# Program
program = """
      wait_sync 4
loop: play      3,3,4
      wait      140
      acquire   0,0,16380
      stop
"""

# Write sequence to file
with open("sequence.json", "w", encoding="utf-8") as file:
    json.dump(
        {
            "waveforms": waveforms,
            "weights": waveforms,
            "acquisitions": acquisitions,
            "program": program,
        },
        file,
        indent=4,
    )
    file.close()

Lets start with a single sequencer with an AWG gain of 1.0 (only on path 0 to create a “real” pulse). Let’s modulate it’s output with a carrier frequency of 20MHz.

[15]:
# Program sequencer
readout_module.sequencer0.sequence("sequence.json")

# Configure the channel map
readout_module.sequencer0.channel_map_path0_out0_en(True)
readout_module.sequencer0.channel_map_path1_out1_en(True)

# Configure sequencer
readout_module.sequencer0.sync_en(True)
readout_module.sequencer0.gain_awg_path0(1.0)
readout_module.sequencer0.gain_awg_path1(0.0)
readout_module.sequencer0.nco_freq(20e6)
readout_module.sequencer0.mod_en_awg(True)
readout_module.sequencer0.demod_en_acq(True)
readout_module.sequencer0.integration_length_acq(waveform_len)
[16]:
# Start the sequencer
readout_module.arm_sequencer(0)
readout_module.start_sequencer(0)

# Wait for the sequencer to stop
readout_module.get_acquisition_state(0, 1)

# Get acquisition data
readout_module.store_scope_acquisition(0, "scope")
acq = readout_module.get_acquisitions(0)

Now lets have a look at the FFT of the scope acquisition to verify the presence of one tone at 20MHz.

[17]:
# Plot the FFT
fig, bx = matplotlib.pyplot.subplots(1, 1, figsize=(15, 15 / 2 / 1.61))
yf = abs(rfft(acq["scope"]["acquisition"]["scope"]["path0"]["data"][0:waveform_len]))
xf = rfftfreq(1000, 1 / 1e3)
norm_fact = readout_module.sequencer0.gain_awg_path0() / 2 / numpy.max(yf)
bx.plot(xf[0:100], yf[0:100] * norm_fact)
bx.set_xlabel("Frequency (MHz)")
bx.set_ylabel("Amplitude")
matplotlib.pyplot.show()
../../_images/tutorials_q1asm_tutorials_multiplexed_sequencing_41_0.png

Now let’s have a look at the hardware demodulated and integrated results and check if it matches our expectations. Don’t forget that we need to divide the integration results by the integration length. In this case, the integration length is the same as the waveform length.

[18]:
bins = acq["scope"]["acquisition"]["bins"]
I = bins["integration"]["path0"][0] / waveform_len
Q = bins["integration"]["path1"][0] / waveform_len
print("Integeration results:")
print("I = {}".format(I))
print("Q = {}".format(Q))
print("R = sqrt(I^2 + Q^2) = {}".format(math.sqrt(I**2 + Q**2)))
Integeration results:
I = -0.008239863214460186
Q = -0.00370200293111871
R = sqrt(I^2 + Q^2) = 0.009033281324913206

The pulse acquired at the inputs is automatically demodulated at 20MHz, but due to phase rotation caused by output-to-input latency the result is not purely real. However the amplitude of the IQ vector is 0.5 as expected because: 1Vpp output range / 2Vpp input range = 0.5.

Now lets increase the number of sequencers to three, each with a slightly different AWG gain. We will modulate the signals of sequencer 0 to 2 with a carrier frequencies at 20MHz, 30MHz and 40MHz respectively.

[19]:
num_seq = 3
for seq in range(0, num_seq):
    # Program sequencers
    readout_module.sequencers[seq].sequence("sequence.json")

    # Configure the channel map
    readout_module.sequencers[seq].channel_map_path0_out0_en(True)
    readout_module.sequencers[seq].channel_map_path1_out1_en(True)

    # Configure the sequencers
    readout_module.sequencers[seq].sync_en(True)
    readout_module.sequencers[seq].mod_en_awg(True)
    readout_module.sequencers[seq].demod_en_acq(True)
    readout_module.sequencers[seq].integration_length_acq(waveform_len)

# Set the gains
readout_module.sequencer0.gain_awg_path0(0.5)
readout_module.sequencer0.gain_awg_path1(0.0)
readout_module.sequencer1.gain_awg_path0(0.25)
readout_module.sequencer1.gain_awg_path1(0.0)
readout_module.sequencer2.gain_awg_path0(0.125)
readout_module.sequencer2.gain_awg_path1(0.0)

# Set the frequencies
readout_module.sequencer0.nco_freq(20e6)
readout_module.sequencer1.nco_freq(30e6)
readout_module.sequencer2.nco_freq(40e6)
[20]:
# Start the sequencers
for seq in range(0, 3):
    readout_module.arm_sequencer(seq)
readout_module.start_sequencer()

# Wait for sequencers to stop
for seq in range(0, 3):
    readout_module.get_acquisition_state(seq, 1)

# Get acquisition data
readout_module.store_scope_acquisition(0, "scope")
acq = readout_module.get_acquisitions(0)

Now lets have a look at the FFT of the scope acquisition to verify the presence of three tones at 20MHz, 30Mhz and 40MHz.

[21]:
# Plot the FFT
fig, bx = matplotlib.pyplot.subplots(1, 1, figsize=(15, 15 / 2 / 1.61))
yf = abs(rfft(acq["scope"]["acquisition"]["scope"]["path0"]["data"][0:waveform_len]))
xf = rfftfreq(1000, 1 / 1e3)
bx.plot(xf[0:100], yf[0:100] * norm_fact)
bx.set_xlabel("Frequency (MHz)")
bx.set_ylabel("Amplitude")
matplotlib.pyplot.show()
../../_images/tutorials_q1asm_tutorials_multiplexed_sequencing_48_0.png

Now let’s check if the hardware demodulated and integrated results match our expectations.

[22]:
for seq in range(0, num_seq):
    readout_module.store_scope_acquisition(seq, "scope")
    acq = readout_module.get_acquisitions(seq)
    bins = acq["scope"]["acquisition"]["bins"]
    I = bins["integration"]["path0"][0] / waveform_len
    Q = bins["integration"]["path1"][0] / waveform_len
    print("Sequencer {}".format(seq))
    print("Integeration results:")
    print("I = {}".format(I))
    print("Q = {}".format(Q))
    print("R = sqrt(I^2 + Q^2) = {}".format(math.sqrt(I**2 + Q**2)))
    print(
        "---------------------------------------------------------------------------------"
    )
Sequencer 0
Integeration results:
I = -0.0046311675622862725
Q = -0.0015676599902296042
R = sqrt(I^2 + Q^2) = 0.0048893016715006715
---------------------------------------------------------------------------------
Sequencer 1
Integeration results:
I = -0.0034816805080605767
Q = 0.00247923790913532
R = sqrt(I^2 + Q^2) = 0.0042741922944929175
---------------------------------------------------------------------------------
Sequencer 2
Integeration results:
I = -0.002084513922813874
Q = 0.0004640937957987298
R = sqrt(I^2 + Q^2) = 0.002135551766102559
---------------------------------------------------------------------------------

Again, the acquired signals on the input are automatically demodulated at 20MHz, 30MHz and 40MHz and we see that the amplitude of the IQ vectors match the gain values we set divided by two, which matches our expectations.

Now, let’s try it one final time with six sequencers, each with 0.15 AWG gain. We will modulate the outputs of sequencer 0 to 5 with carrier frequencies at 20MHz, 30Mhz, 40MHz, 50MHz, 60MHz and 70MHz respectivey.

[23]:
num_seq = 6
for seq in range(0, num_seq):
    # Program sequencers
    readout_module.sequencers[seq].sequence("sequence.json")

    # Configure the channel map
    readout_module.sequencers[seq].channel_map_path0_out0_en(True)
    readout_module.sequencers[seq].channel_map_path1_out1_en(True)

    # Configure the sequencers
    readout_module.sequencers[seq].sync_en(True)
    readout_module.sequencers[seq].gain_awg_path0(0.15)
    readout_module.sequencers[seq].gain_awg_path1(0.0)
    readout_module.sequencers[seq].mod_en_awg(True)
    readout_module.sequencers[seq].demod_en_acq(True)
    readout_module.sequencers[seq].integration_length_acq(waveform_len)

# Set the frequencies
readout_module.sequencer0.nco_freq(20e6)
readout_module.sequencer1.nco_freq(30e6)
readout_module.sequencer2.nco_freq(40e6)
readout_module.sequencer3.nco_freq(50e6)
readout_module.sequencer4.nco_freq(60e6)
readout_module.sequencer5.nco_freq(70e6)
[24]:
# Start the sequencers
for seq in range(0, 6):
    readout_module.arm_sequencer(seq)
readout_module.start_sequencer()

# Wait for sequencers to stop
for seq in range(0, 6):
    readout_module.get_acquisition_state(seq, 1)

# Get acquisition data
readout_module.store_scope_acquisition(0, "scope")
acq = readout_module.get_acquisitions(0)

Now lets have a look at the FFT of the scope acquisition to verify the presence of six tones at 20MHz, 30Mhz, 40MHz, 50MHz, 60MHz and 70MHz

[25]:
# Plot the FFT
fig, bx = matplotlib.pyplot.subplots(1, 1, figsize=(15, 15 / 2 / 1.61))
yf = abs(rfft(acq["scope"]["acquisition"]["scope"]["path0"]["data"][0:waveform_len]))
xf = rfftfreq(1000, 1 / 1e3)
bx.plot(xf[0:100], yf[0:100] * norm_fact)
bx.set_xlabel("Frequency (MHz)")
bx.set_ylabel("Amplitude")
matplotlib.pyplot.show()
../../_images/tutorials_q1asm_tutorials_multiplexed_sequencing_55_0.png

Note that we lose a little bit of power over the frequency range, but that is to be expected due to frequency dependant components in the output and input path. Now let’s check if the hardware demodulated and integrated results match our expectations.

[26]:
for seq in range(0, num_seq):
    readout_module.store_scope_acquisition(seq, "scope")
    acq = readout_module.get_acquisitions(seq)
    bins = acq["scope"]["acquisition"]["bins"]
    I = bins["integration"]["path0"][0] / waveform_len
    Q = bins["integration"]["path1"][0] / waveform_len
    print("Sequencer {}".format(seq))
    print("Integeration results:")
    print("I = {}".format(I))
    print("Q = {}".format(Q))
    print("R = sqrt(I^2 + Q^2) = {}".format(math.sqrt(I**2 + Q**2)))
    print(
        "---------------------------------------------------------------------------------"
    )
Sequencer 0
Integeration results:
I = -0.001826086956521739
Q = -0.0006306790425012213
R = sqrt(I^2 + Q^2) = 0.0019319289913009444
---------------------------------------------------------------------------------
Sequencer 1
Integeration results:
I = -0.0015329750854909622
Q = 0.0002892037127503664
R = sqrt(I^2 + Q^2) = 0.001560016474337569
---------------------------------------------------------------------------------
Sequencer 2
Integeration results:
I = -0.0012208109428431852
Q = 0.0026722032242305813
R = sqrt(I^2 + Q^2) = 0.0029378647739053583
---------------------------------------------------------------------------------
Sequencer 3
Integeration results:
I = 0.001172447484123107
Q = 0.002017098192476795
R = sqrt(I^2 + Q^2) = 0.002333091987282061
---------------------------------------------------------------------------------
Sequencer 4
Integeration results:
I = 0.003261846604787494
Q = 0.0005994137762579385
R = sqrt(I^2 + Q^2) = 0.0033164650078557293
---------------------------------------------------------------------------------
Sequencer 5
Integeration results:
I = 0.0027655105031753786
Q = -0.0032325354176844165
R = sqrt(I^2 + Q^2) = 0.0042540960931504
---------------------------------------------------------------------------------

Taking the power loss over frequency into account, the amplitudes of the IQ vectors match our expectations again.

Real mode

Many applications require multiple outputs to be controlled independantly and only output real signals instead of a modulated IQ pair. To achieve this we will connect one sequencer to each output and only use path 0 to control an even numbered output and path 1 to control an odd numbered output. To demonstrate this, we will simply output an independantly timed sine on output \(\text{O}^{1}\) and a sawtooth on output \(\text{O}^{2}\), which we will then acquire on the inputs.

Lets create a Q1ASM program to sequence the waveforms for sequencer 0.

[27]:
# Reset
if cluster:
    # reset entire cluster
    cluster.reset()
else:
    # reset the pulsar module
    readout_module.reset()
# Program
program = """
wait_sync 4
play      1,1,4
wait      140
acquire   0,0,16380
stop
"""

# Write sequence to file
with open("sequence0.json", "w", encoding="utf-8") as file:
    json.dump(
        {
            "waveforms": waveforms,
            "weights": waveforms,
            "acquisitions": acquisitions,
            "program": program,
        },
        file,
        indent=4,
    )
    file.close()

Lets create a Q1ASM program to sequence the waveforms for sequencer 1.

[28]:
# Program
program = """
wait_sync 4
wait      500
play      2,2,1000
stop
"""

# Write sequence to file
with open("sequence1.json", "w", encoding="utf-8") as file:
    json.dump(
        {
            "waveforms": waveforms,
            "weights": waveforms,
            "acquisitions": acquisitions,
            "program": program,
        },
        file,
        indent=4,
    )
    file.close()

Let’s configure both sequencers and connect them to their respective outputs.

[29]:
# Configure scope mode
readout_module.scope_acq_sequencer_select(0)
readout_module.scope_acq_trigger_mode_path0("sequencer")
readout_module.scope_acq_trigger_mode_path1("sequencer")

# Program sequencer
num_seq = 2
for seq in range(0, num_seq):
    readout_module.sequencers[seq].sequence("sequence{}.json".format(seq))

# Configure the channel map
readout_module.sequencer0.channel_map_path0_out0_en(True)
readout_module.sequencer1.channel_map_path1_out1_en(True)

# Configure sequencer
for seq in range(0, num_seq):
    readout_module.sequencers[seq].sync_en(True)
    readout_module.sequencers[seq].mod_en_awg(False)

readout_module.sequencer0.gain_awg_path1(
    0.0
)  # Disable sequencer 0 path 1, because we will not use it.
readout_module.sequencer1.gain_awg_path0(
    0.0
)  # Disable sequencer 1 path 0, because we will not use it.

Now, let start the sequencers and visualise the resulting sequence.

[30]:
# Start sequencers
for seq in range(0, num_seq):
    readout_module.arm_sequencer(seq)
readout_module.start_sequencer()

# Wait for sequencers to stop (only sequencer 0 will acquire)
for seq in range(0, num_seq):
    readout_module.get_sequencer_state(seq, 1)
readout_module.get_acquisition_state(0, 1)

# Get acquisition
readout_module.store_scope_acquisition(0, "scope")
acq = readout_module.get_acquisitions(0)

# Plot result
fig, ax = matplotlib.pyplot.subplots(1, 1, figsize=(15, 15 / 2 / 1.61))
ax.plot(acq["scope"]["acquisition"]["scope"]["path0"]["data"][0:2000])
ax.plot(acq["scope"]["acquisition"]["scope"]["path1"]["data"][0:2000])
ax.set_xlabel("Time (ns)")
ax.set_ylabel("Relative amplitude")
matplotlib.pyplot.show()
../../_images/tutorials_q1asm_tutorials_multiplexed_sequencing_66_0.png

As expected, we see a sine and sawtooth that are independantly sequenced on the outputs.

Stop

Finally, let’s close the instrument connection. One can also display a detailed snapshot containing the instrument parameters before closing the connection by uncommenting the corresponding lines.

[ ]:
# Uncomment the following to print an overview of the instrument parameters.
# Print an overview of the instrument parameters.
# print("Snapshot:")
# readout_module.print_readable_snapshot(update=True)

# Close the instrument connection.
# Close the instrument connection.
Pulsar.close_all()
Cluster.close_all()