See also
A Jupyter notebook version of this tutorial can be downloaded here
.
Multiplexed sequencing
The Cluster QRM/QCM supports six sequencers. The output of each sequencer is multiplexed, accumulated and connected to the output ports of the instrument.
In the first part of the tutorial we will demonstrate how to connect multiple sequencers to a single pair of output ports.
In the second part of the tutorial we will demonstrate frequency multiplexing by assigning different unique modulation frequencies (frequency of the carrier) to the sequencers. We will then show 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 output real signals on each individual output port of the instrument.
We will show this by using a QRM and 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 (using the same sequencers).
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 as plt
import numpy as np
# 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
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)
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.windows.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 = np.arange(0, max(map(lambda d: len(d["data"]), waveforms.values())), 1)
fig, ax = plt.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.grid(alpha=1/10)
ax.set_ylabel("Waveform primitive amplitude")
ax.set_xlabel("Time (ns)")
plt.draw()
plt.show()
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
Each sequencer has two output paths. The output paths of each sequencer are physically connected to the instrument’s outputs. It is possible to map any sequencer output path to any output port by using the sequencer’s channel map.
We can do so by calling sequencerX.connect_outY(Z)
where X
, Y
and Z
represents sequencer ID \(\in[0,..,5]\), output port number, and Z
\(\in \{\)"off"
, "I"
, "Q"
\(\}\).
For most common sequencer configurations, the convenience function sequencerX.connect_sequencer(config)
can be used to easily set the channel map. Some examples:
Multiplexed sequencers on a QRM baseband
instrument.disconnect_inputs()
instrument.disconnect_outputs()
for seq in instrument.sequencers:
seq.connect_sequencer("io0_1")
Multiplexed sequencers on a QRM-RF
instrument.disconnect_inputs()
instrument.disconnect_outputs()
for seq in instrument.sequencers:
seq.connect_sequencer("io0")
Sequencers 1:1 on a QCM baseband
instrument.disconnect_outputs()
for idx in range(4):
instrument[f"sequencer{idx}"].connect_sequencer(f"out{idx}")
Sequencers 1:1 on a QCM-RF
instrument.disconnect_outputs()
for idx in range(2):
instrument[f"sequencer{idx}"].connect_sequencer(f"out{idx}")
For the sake of this tutorial we will map the in-phase path of each sequencer to the ports with the even output port numbers (indexed from 0) and the quadrature path of each sequencer to the ports with the odd output port numbers, like is shown in the figure below. Note that this figure is for the QCM, so it has 4 outputs.
Now lets configure the first sequencer to output its in-phase and quadrature paths on \(\text{O}^{1}\) and \(\text{O}^{2}\) respectively. 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.
We will also configure the channel map so that inputs \(\text{I}^{[1-2]}\) of the QRM are mapped to the in-phase and quadrature input paths of the same sequencer.
[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.disconnect_outputs()
readout_module.disconnect_inputs()
# connect output paths of the sequencer
readout_module.sequencer0.connect_out0("I")
readout_module.sequencer0.connect_out1("Q")
# connect input paths of the same sequencer.
readout_module.sequencer0.connect_acq_I('in0')
readout_module.sequencer0.connect_acq_Q('in1')
# 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 = plt.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")
plt.show()
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.connect_out0("I")
readout_module.sequencer1.connect_out1("Q")
# connect input paths of the same sequencer.
readout_module.sequencer1.connect_acq_I('in0')
readout_module.sequencer1.connect_acq_Q('in1')
# 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 = plt.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")
plt.show()
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.connect_out0("I")
readout_module.sequencer2.connect_out1("Q")
# connect input paths of the same sequencer.
readout_module.sequencer2.connect_acq_I('in0')
readout_module.sequencer2.connect_acq_Q('in1')
# 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 = plt.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")
plt.show()
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.connect_out0("I")
readout_module.sequencer3.connect_out1("Q")
# connect input paths of the same sequencer.
readout_module.sequencer3.connect_acq_I('in0')
readout_module.sequencer3.connect_acq_Q('in1')
# 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 = plt.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")
plt.show()
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.connect_out0("I")
readout_module.sequencer4.connect_out1("Q")
# connect input paths of the same sequencer.
readout_module.sequencer4.connect_acq_I('in0')
readout_module.sequencer4.connect_acq_Q('in1')
# 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 = plt.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")
plt.show()
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.connect_out0("I")
readout_module.sequencer5.connect_out1("Q")
# connect input paths of the same sequencer.
readout_module.sequencer5.connect_acq_I('in0')
readout_module.sequencer5.connect_acq_Q('in1')
# 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 = plt.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")
plt.show()
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 visualize 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")
readout_module.disconnect_outputs()
readout_module.disconnect_inputs()
# connect output paths of the sequencer
readout_module.sequencer0.connect_out0("I")
readout_module.sequencer0.connect_out1("Q")
# connect input paths of the same sequencer.
readout_module.sequencer0.connect_acq_I('in0')
readout_module.sequencer0.connect_acq_Q('in1')
# 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 = plt.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 / np.max(yf)
bx.plot(xf[0:100], yf[0:100] * norm_fact)
bx.set_xlabel("Frequency (MHz)")
bx.set_ylabel("Amplitude")
plt.show()
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("Integration 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].connect_out0("I")
readout_module.sequencers[seq].connect_out1("Q")
# Connect input paths of the same sequencer.
readout_module.sequencers[seq].connect_acq_I('in0')
readout_module.sequencers[seq].connect_acq_Q('in1')
# 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, timeout=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 = plt.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")
plt.show()
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("Integration 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 respectively.
[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].connect_out0("I")
readout_module.sequencers[seq].connect_out1("Q")
# Connect input paths of the same sequencer.
readout_module.sequencers[seq].connect_acq_I('in0')
readout_module.sequencers[seq].connect_acq_Q('in1')
# 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, timeout=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 = plt.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")
plt.show()
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("Integration 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 independently 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 independently 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
cluster.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.connect_out0("I")
readout_module.sequencer0.connect_acq_I("in0")
readout_module.sequencer1.connect_out1("I")
readout_module.sequencer1.connect_acq_I("in1")
# 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 visualize 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, timeout=1)
readout_module.get_acquisition_state(0, timeout=1)
# Get acquisition
readout_module.store_scope_acquisition(0, "scope")
acq = readout_module.get_acquisitions(0)
# Plot result
fig, ax = plt.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")
plt.show()
As expected, we see a sine and sawtooth that are independently 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 all QCoDeS Instrument instances.
Instrument.close_all()