See also
A Jupyter notebook version of this tutorial can be downloaded here.
Net-zero pulse compensation#
In this tutorial we show how to use the net-zero pulse compensation at runtime, present in the QCM. The tutorial will showcase:
Configuring and executing a net-zero pulse compensation at runtime with Qblox-instruments (QBI) API and Q1ASM.
Extend the pulse sequence in order to execute long net-zero pulse compensation at runtime.
For more details regarding the net-zero pulse compensation, see the net-zero pulse compensation user guide.
Setup#
First, we are going to import the required packages.
[1]:
from __future__ import annotations
from qcodes.instrument import find_or_create_instrument
from qblox_instruments import Cluster, ClusterType
Scan For Clusters#
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).
!qblox-pnp list
[2]:
cluster_ip = "10.10.200.42"
cluster_name = "cluster0"
Connect to Cluster#
We now make a connection with the Cluster.
[3]:
cluster: Cluster = find_or_create_instrument(
Cluster,
recreate=True,
name=cluster_name,
identifier=cluster_ip,
dummy_cfg=(
{
2: ClusterType.CLUSTER_QCM,
4: ClusterType.CLUSTER_QRM,
6: ClusterType.CLUSTER_QCM_RF,
8: ClusterType.CLUSTER_QRM_RF,
10: ClusterType.CLUSTER_QTM,
12: ClusterType.CLUSTER_QRC,
16: ClusterType.CLUSTER_QSM,
}
if cluster_ip is None
else None
),
)
cluster.reset()
print(cluster.get_system_status())
Status: OKAY, Flags: NONE, Slot flags: NONE
Get connected modules#
[4]:
# QCM baseband modules
modules = cluster.get_connected_modules(lambda mod: mod.is_qcm_type and not mod.is_rf_type)
# This uses the module of the correct type with the lowest slot index
module = list(modules.values())[0]
Configuring net-zero pulse parameters#
As mentioned in the user guide, we start by configuring the net-zero pulse parameters. Here, the pulse sequence, that includes a pulse train followed by a net-zero pulse, will be played from out0 i.e. QCM O1. Therefore, the net-zero pulse parameters are configured for QCM O1.
[5]:
module.disconnect_outputs() # Disconnect outputs to reconfigure the channel mapping between sequencer and output.
module.sequencer0.connect_sequencer("out0") # Connect sequencer 0 to output 0.
module.out0_net_zero_pulse_amplitude(0.5) # Set the amplitude to 0.5 -> 0.5*2.5 = 1.25 V.
module.out0_net_zero_pulse_slew_rate(2e6) # Set the slew rate to 2e6 (1/s).
module.out0_net_zero_pulse_en(True) # Enable the net-zeroing on QCM O1.
Upload sequence#
With the net-zero pulse parameters configured, we will next define our Q1ASM program. The program will include our pulse train which in this example consists of changing offsets with varying duration followed by the net-zero pulse, executed by the play_netzero instruction. The offsets for the pulse train are chosen arbitrarily in this tutorial.
[6]:
q1_prog = """
set_awg_offs 16384, 16384 # Set voltage to half of the total dynamic range of the DAC (0.5 x 2.5 = 1.25)
upd_param 1500 # Update the offset to 1.25 V and wait for 1.5 us
set_awg_offs -8300, -8300 # Set the voltage to -0.63 V
upd_param 1000 # Update the offset to -0.63 V and wait for 1 us
set_awg_offs 5000, 5000 # Set the voltage to 0.38 V
upd_param 3000 # Update the offset to 0.38 V and wait for 3 us
set_awg_offs 0, 0 # Set the voltage to 0 V
upd_param 1000 # Update the offset to 0 V and wait for 1 us
play_netzero 3000, 3000 # Play a net-zero pulse on the previous set offsets with a compensation length of 3 us and wait for 3 us.
stop
"""
# Configure the sequence
sequence = {
"waveforms": {},
"weights": {},
"acquisitions": {},
"program": q1_prog,
}
The sequence which contains our program, will be uploaded to the first sequencer sequencer0 as sequencer0 has been previously connected to out0.
[7]:
module.sequencer0.sequence(sequence) # Upload sequence to sequencer 0.
With the sequence being uploaded, we can go ahead and connect the QCM O1 to the oscilloscope in order to observe the signal once the sequencer is armed and started. Ensure to configure the trigger for the proper input channel on the oscilloscope in order to observe the output.
[8]:
# Arm and start the sequencer
module.arm_sequencer(0)
module.start_sequencer()
We may also check the status of the sequencer and the status of the net-zero pulse after arming and starting the sequencer.
[9]:
# Print status of the sequencer and the net-zero pulse.
print(
module.get_sequencer_status(0, timeout=1)
) # Ensure that the program is finished before retrieving the status.
print(module.get_out0_net_zero_pulse_status())
Status: OKAY, State: STOPPED, Exit Code: 0, Info Flags: NONE, Warning Flags: NONE, Error Flags: NONE, Log: []
{'error_overflow': False, 'operation_status': False, 'warning_re_triggered': False}
By executing our Q1ASM program, we observe the following on the oscilloscope:
Figure 1. Output of QCM O1 which contains the initial pulse train followed by a net-zero pulse.
As seen in figure 1, the net-zero pulse is created after the pulse sequence which specifies a maximum compensation length of 3 us. The effective compensation length used by the net-zero block is ~2.2 us long which means that the rest of the net-zero pulse will be played at 0 V for the remainder of the real-time duration.
The reason for choosing 3 us is based on the parameters and accumulated area. By calculating the accumulated area i.e. 954.5 A*ns (0.5 x 1500 + (-0.2533) x 1000 + 0.1526 x 3000) and with the net-zero pulse amplitude chosen as 0.5, the maxt should be at least 1909 ns. As mentioned in choice of net-zero pulse parameters we also want to add a margin to ensure that the net-zero
pulse gets created. Here an added margin of ~1 us was chosen (maxt = 3 us) as it is the same order of magnitude as the initial pulses within the pulse train. Note that the calculation of the area mentioned above is to give an idea on how to choose the maximum compensation length. The main idea of the net-zero pulse is to choose the parameters such that sufficient area is accumulated without the need of exact calculation for ease of use.
The flags from the net-zero pulse reports that each flag is set to False. This is expected after a net-zero pulse is successfully generated from the net-zero block. The flags signify that the net-zero block is done compensating (operation_status: False), no other net-zero pulse compensation took place while the play_netzero was executed (warning_re_triggered: False) and finally no overflow occurred based on the generated net-zero pulse (error_overflow: False).
Long net-zero pulses#
In this part of the tutorial, we will expand the pulse duration to showcase how one may use longer maximum compensation lengths (up to 4,294,967,295 ns) to do net-zero pulse compensation with the play_netzero instruction.
Configuring net-zero pulse parameters for long net-zero pulses#
As mentioned in the user guide, longer maximum compensation length of the net-zero pulse can be achieved by utilizing a wait loop to hold off for equal amount of time in real-time duration, up to or longer than the specified maximum compensation length. For this example, a 20 ms long pulse is to be compensated with by choosing a maximum compensation length of 25 ms. The extra 5 ms is margin, so the block certainly has enough time to finish compensating.
Since the pulse we are compensating is now longer compared to the previous example, we will also reconfigure the net-zero pulse slew rate to set slower voltage transitions to occur on our net-zero pulse. The amplitude will be kept the same as previously since the initial pulse amplitude is at 1.25 V (A = 0.5 -> V = 1.25 V). There is also no need to enable the net-zero pulse, as it was already enabled for that output from the previous example (module.out0_net_zero_pulse_en(True)).
[10]:
# Configure the net-zero pulse slew rate parameter
module.out0_net_zero_pulse_slew_rate(5e2) # Update to a slower slew rate, in this case 5e2 (1/s).
[11]:
long_nz_prog = f"""
move 999, R0 # Iterator for the wait loop (first pulse).
move 999, R1 # Iterator for the wait loop (second pulse).
move 2499, R2 # Iterator for the wait loop (net-zero pulse).
set_awg_offs 16384, 16384 # Set a positive offset. In this case half of the total dynamic range of the DAC is chosen (1.25 V).
upd_param 10000 # Execute the set offset and wait for 10 us.
first_wait_loop: # Wait loop to hold off the 1.25 V offset for 10 ms in duration (10 us + 10 us x 999).
wait 10000
sub R0, 1, R0
jnz @first_wait_loop
set_awg_offs 0, 0 # Set offset to 0 V.
upd_param 10000 # Execute the set offset and wait for 10 us.
second_wait_loop: # Wait loop to hold off the 0 V offset for 10 ms in duration.
wait 10000
sub R1, 1, R1
jnz @second_wait_loop
play_netzero {int(25e6)}, 10000 # Play a net-zero pulse on the previous set offsets with a compensation length of 25 ms and wait for 10 us.
third_wait_loop: # Wait loop to hold off the net-zero pulse for 25 ms (10 us + 10 us x 2499).
wait 10000
sub R2, 1, R2
jnz @third_wait_loop
stop
"""
# Configure the sequence
sequence = {
"waveforms": {},
"weights": {},
"acquisitions": {},
"program": long_nz_prog,
}
Note: The Q1ASM for the long net-zero pulse is written in a linear form for readability. With increasing number of pulses and since the wait loop is repeated, one may also introduce the wait loop as a subroutine as seen in the following Q1ASM example which uses a register (in this case R1) is used as return-address register. The subroutine program achieves the same outcome as the Q1ASM program seen above.
Similarly to the previous example, we upload the sequence to the first sequencer which is already connected to out0 from the previous example.
[12]:
module.sequencer0.sequence(sequence) # Upload sequence to sequencer 0
[13]:
# Arm and start the sequencer
module.arm_sequencer(0)
module.start_sequencer()
# Print status of the sequencer and the net-zero pulse
print(
module.get_sequencer_status(0, timeout=1)
) # Ensure that the program is finished before retrieving the status.
print(module.get_out0_net_zero_pulse_status())
Status: WARNING, State: STOPPED, Exit Code: 0, Info Flags: NONE, Warning Flags: OUTPUT_OVERFLOW, Error Flags: NONE, Log: []
{'error_overflow': False, 'operation_status': False, 'warning_re_triggered': False}
By executing the long net-zero pulse at runtime we get the following on the oscilloscope:
Figure 2. Output of QCM O1 which contains the initial pulse train followed by a long net-zero pulse.
From figure 2, we observe that a long net-zero pulse of ~12 ms was created to compensate for our initial pulse sequence of 20 ms. How much of the maximum compensation length the net-zero block actually uses depends on the chosen net-zero pulse amplitude and net-zero pulse slew rate. For example, if a lesser net-zero pulse amplitude was chosen, a longer maximum compensation length may have been needed. Therefore, whenever you choose the parameters for the net-zero pulse, follow the net-zero user guide regarding the choice of net-zero pulse parameters.
Similar to the previous example, the status of the long net-zero pulse reports each flag as False.
Important: For the experimental use cases, the net-zero pulse compensation shown above is intended to work in tandem with the inverse high-pass (IHP) filter on the output path of the QCM to counteract the signal imperfections introduced by the bias tee. To understand how the IHP filter works, please visit the real-time predistortions page such that the two functionalities are properly utilized for your experiments.
Lastly, we stop the sequencer via
[14]:
module.stop_sequencer()