2014-10-04 09:55:53 +08:00
|
|
|
import numpy as np
|
|
|
|
|
|
|
|
from artiq import *
|
|
|
|
|
|
|
|
|
2014-12-03 18:20:30 +08:00
|
|
|
# data is usually precomputed offline
|
|
|
|
transport_data = dict(
|
|
|
|
t=np.linspace(0, 10, 101), # waveform time
|
|
|
|
u=np.random.randn(101, 4*3*3), # waveform data,
|
|
|
|
# 4 devices, 3 board each, 3 dacs each
|
|
|
|
)
|
|
|
|
|
2014-10-04 09:55:53 +08:00
|
|
|
class Transport(AutoContext):
|
2014-12-02 17:19:05 +08:00
|
|
|
bd = Device("dds")
|
2014-12-03 18:20:30 +08:00
|
|
|
bdd = Device("dds")
|
2014-12-02 17:19:05 +08:00
|
|
|
pmt = Device("ttl_in")
|
|
|
|
electrodes = Device("pdq")
|
2014-12-03 18:20:30 +08:00
|
|
|
|
|
|
|
repeats = Parameter(100)
|
|
|
|
nbins = Parameter(100)
|
|
|
|
wait_at_stop = Parameter(100*us)
|
|
|
|
speed = Parameter(1.5)
|
2014-10-19 13:09:10 +08:00
|
|
|
|
2014-10-04 09:55:53 +08:00
|
|
|
def prepare(self, stop):
|
2014-12-03 18:20:30 +08:00
|
|
|
t = transport_data["t"][:stop]*self.speed
|
|
|
|
u = transport_data["u"][:stop]
|
2014-10-17 00:04:30 +08:00
|
|
|
# start a new frame
|
|
|
|
self.tf = self.electrodes.create_frame()
|
2014-10-04 09:55:53 +08:00
|
|
|
# interpolates t and u and appends the (t, u) segment to the frame
|
|
|
|
# adds wait-for-trigger to the first line/spline knot
|
|
|
|
# will also apply offset and gain calibration data
|
|
|
|
# stores duration and the fact that this segment needs to be triggered
|
|
|
|
# both (duration and segment triggering flag) to be retrieved during
|
|
|
|
# kernel compilation, see transport()
|
2014-10-22 17:31:33 +08:00
|
|
|
self.tf.append(t, u, trigger=True,
|
|
|
|
name="to_stop")
|
2014-10-04 09:55:53 +08:00
|
|
|
# append the reverse transport (from stop to 0)
|
|
|
|
# both durations are the same in this case
|
2014-10-22 17:31:33 +08:00
|
|
|
self.tf.append(t[-1] - t[::-1], u[::-1], trigger=True,
|
|
|
|
name="from_stop")
|
2014-10-17 00:04:30 +08:00
|
|
|
# closes the frame with a wait line before jumping back into
|
|
|
|
# the jump table so that frame signal can be set before the jump
|
2014-10-04 09:55:53 +08:00
|
|
|
# also mark the frame as closed and prevent further append()ing
|
2014-10-17 00:04:30 +08:00
|
|
|
self.tf.close()
|
|
|
|
# user must pass all frames that are going to be used next
|
2014-10-19 13:09:10 +08:00
|
|
|
# selects possible frame id based on rtio_frame assignments
|
|
|
|
# from core device
|
|
|
|
# distributes frames to the sub-devices in CompoundPDQ2
|
|
|
|
# and uploads them
|
2014-10-04 09:55:53 +08:00
|
|
|
# uploading is ARM_DIS, writing, ARM_EN
|
2014-10-17 00:04:30 +08:00
|
|
|
self.electrodes.prepare(self.tf)
|
2014-10-04 09:55:53 +08:00
|
|
|
|
|
|
|
@kernel
|
|
|
|
def cool(self):
|
|
|
|
with parallel:
|
|
|
|
self.bd.pulse(200*MHz, 1*ms)
|
|
|
|
self.bdd.pulse(300*MHz, 1*ms)
|
|
|
|
self.bd.pulse(210*MHz, 100*us)
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def transport(self):
|
|
|
|
# ensures no frame is currently being actively played
|
|
|
|
# set rtio frame select signal to frame id
|
|
|
|
# rtio trigger jump into transport frame
|
2014-10-19 13:09:10 +08:00
|
|
|
# (does not advance the timeline)
|
2014-10-17 00:04:30 +08:00
|
|
|
self.tf.begin()
|
2014-10-04 09:55:53 +08:00
|
|
|
# triggers pdqs to start transport frame segment
|
|
|
|
# plays the transport waveform from 0 to stop
|
|
|
|
# delay()s the core by the duration of the waveform segment
|
2014-10-17 00:04:30 +08:00
|
|
|
self.tf.to_stop.advance()
|
2014-10-04 09:55:53 +08:00
|
|
|
# leaves the ion in the dark at the transport endpoint
|
|
|
|
delay(self.wait_at_stop)
|
|
|
|
# transport back (again: trigger, delay())
|
2014-10-17 00:04:30 +08:00
|
|
|
# segments can only be advance()ed in order
|
|
|
|
self.tf.from_stop.advance()
|
2014-10-04 09:55:53 +08:00
|
|
|
# ensures all segments have been advanced() through, must leave pdq
|
|
|
|
# in a state where the next frame can begin()
|
2014-10-17 00:04:30 +08:00
|
|
|
self.tf.finish()
|
2014-10-04 09:55:53 +08:00
|
|
|
|
|
|
|
@kernel
|
|
|
|
def detect(self):
|
|
|
|
with parallel:
|
|
|
|
self.bd.pulse(220*MHz, 100*us)
|
|
|
|
self.pmt.gate_rising(100*us)
|
|
|
|
self.bd.on(200*MHz)
|
|
|
|
self.bdd.on(300*MHz)
|
|
|
|
return self.pmt.count()
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def one(self):
|
|
|
|
self.cool()
|
|
|
|
self.transport()
|
|
|
|
return self.detect()
|
|
|
|
|
|
|
|
@kernel
|
|
|
|
def repeat(self):
|
2014-12-17 21:54:10 +08:00
|
|
|
hist = [0 for _ in range(self.nbins)]
|
2014-10-04 09:55:53 +08:00
|
|
|
|
|
|
|
for i in range(self.repeats):
|
|
|
|
n = self.one()
|
|
|
|
if n >= self.nbins:
|
|
|
|
n = self.nbins-1
|
|
|
|
hist[n] += 1
|
|
|
|
|
|
|
|
for i in range(self.nbins):
|
2014-10-05 08:25:36 +08:00
|
|
|
self.histogram.append(hist[i])
|
2014-10-04 09:55:53 +08:00
|
|
|
|
|
|
|
def scan(self, stops):
|
|
|
|
for s in stops:
|
2014-10-17 00:04:30 +08:00
|
|
|
self.histogram = []
|
2014-10-04 09:55:53 +08:00
|
|
|
# non-kernel, calculate waveforms, build frames
|
|
|
|
# could also be rpc'ed from repeat()
|
|
|
|
self.prepare(s)
|
|
|
|
# kernel part
|
|
|
|
self.repeat()
|
2014-10-05 08:25:36 +08:00
|
|
|
# live update 2d plot with current self.histogram
|
|
|
|
# broadcast(s, self.histogram)
|
2014-10-04 09:55:53 +08:00
|
|
|
|
2014-12-03 18:20:30 +08:00
|
|
|
def run(self):
|
2014-10-04 09:55:53 +08:00
|
|
|
# scan transport endpoint
|
2014-12-03 18:20:30 +08:00
|
|
|
stops = range(10, len(transport_data["t"]), 10)
|
|
|
|
self.scan(stops)
|