This page was generated from docs/examples/driver_examples/Qcodes+broadbean example with Tektronix AWG5208.ipynb. Interactive online version: Binder badge.

QCoDeS+Broadbean Example with Tektronix AWG5208

%matplotlib notebook
import broadbean as bb

from qcodes.instrument_drivers.tektronix import TektronixAWG5208

ramp = bb.PulseAtoms.ramp
sine = bb.PulseAtoms.sine

Part 1: Make a complicated sequence

Keeping in mind that no waveform can be shorter than 2400 points (hardware limitation).

We have an element corresponding to a measurement that we’d like to repeat N times followed by a “reset” element. The master sequence should then repeat that whole thing with different measurement frequencies. We therefore make the measurement into a subsequence.

# First we form the measurement sequence

SR = 1e9
N = 3  # the number of times we repeat the first part
measurement_freqs = [5e4, 1e5, 2e5]

meas_bp_ch1 = bb.BluePrint()
meas_bp_ch1.insertSegment(0, sine, (1e5, 0.1, 0, 0), dur=200e-6)
meas_bp_ch1.insertSegment(-1, ramp, (0, 0), dur=40e-6)

meas_bp_ch2 = bb.BluePrint()
meas_bp_ch2.insertSegment(0, ramp, (0, 0), dur=200e-6)
meas_bp_ch2.insertSegment(-1, ramp, (0.1, 0.1), dur=20e-6)
meas_bp_ch2.insertSegment(-1, ramp, (0, 0), dur=20e-6)

meas_elem = bb.Element()
meas_elem.addBluePrint('signal_channel', meas_bp_ch1)
meas_elem.addBluePrint('trigger_channel', meas_bp_ch2)

reset_bp = bb.BluePrint()
reset_bp.insertSegment(0, ramp, (0, 0.05), dur=120e-6)
reset_bp.insertSegment(1, ramp, (0.05, 0), dur=120e-6)

reset_elem = bb.Element()
reset_elem.addBluePrint('signal_channel', reset_bp)
reset_elem.addBluePrint('trigger_channel', reset_bp)

measureseq = bb.Sequence()
measureseq.addElement(1, meas_elem)
measureseq.addElement(2, reset_elem)
measureseq.setSequencingNumberOfRepetitions(1, N)

# And then we turn that into a master sequence

mainseq = bb.Sequence()

for pos, freq in enumerate(measurement_freqs):
    subseq = measureseq.copy()
    subseq.element(1).changeArg('signal_channel', 'sine',
                                'freq', freq)
    mainseq.addSubSequence(pos+1, subseq)


# The visualisation is not terribly helpful in this case, but
# we see that three subsequences are present

Part 2: Get the sequence onto the instrument

# Connect

awg = TektronixAWG5208('awg', 'TCPIP0::')
Connected to: TEKTRONIX AWG5208 (serial:B020203, firmware:FV:6.0.0242.0) in 0.30s
# forge the sequence
fs = mainseq.forge()

# send it to the instrument
seqname = 'mytestseq'
amplitudes = [ch.awg_amplitude() for ch in awg.channels][:2]
channel_mapping = {'trigger_channel': 2, 'signal_channel': 1}
seqx_file = TektronixAWG5208.makeSEQXFileFromForgedSequence(fs,

# load it and assign its tracks to the channels
filename = 'mainplussub.seqx'

awg.sendSEQXFile(seqx_file, filename=filename)
awg.ch1.setSequenceTrack(seqname, 1)
awg.ch2.setSequenceTrack(seqname, 2)

Part 3: Play it and capture it on a scope

Pending… Manually verified.