lf_10
Revised code:
from artiq.experiment import *
class Sequence(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("ttl_in")
self.waitingTime = 10*s
self.N = 10
@kernel
def first_input(self):
t_gate = self.ttl_in.gate_rising(self.waitingTime)
t_trig = self.ttl_in.timestamp_mu(t_gate)
return t_trig
@kernel
def sequence_input(self):
totalTime = self.N * 30
t_gate = self.ttl_in.gate_rising(totalTime*us)
while True:
t = self.ttl_in.timestamp_mu(t_gate)
if t < 0:
break
def run(self):
self.core.reset()
t_trig = self.first_input()
if t_trig >= 0:
self.sequence_input()
In this version, the waiting gate for the first trigger is separated from the gate used to record the following sequence of triggers. Since we consider that the waiting time for the first input is not defined, we open a long gate. (This example only checks whether the triggers were received.)
Another possibility, maybe more robust, is to open a single gate that is long enough and record the first AND the sequence of inputs altogether (replacing def first_input(self) and def sequence_input(self):):
@kernel
def run(self):
self.core.reset()
t_gate = self.ttl_in.gate_rising(10*s + self.N*30*us)
while True:
t = self.ttl_in.timestamp_mu(t_gate)
if t < 0:
break
A third option is to loop until the the first trigger is received and then open a gate and record the sequence:
class Sequence(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("ttl_in")
self.waitingTime = 100*ms
self.N = 10
@kernel
def run(self):
self.core.reset()
t_trig = -1
while t_trig < 0:
t_gate = self.ttl_in.gate_rising(self.waitingTime)
t_trig = self.ttl_in.timestamp_mu(t_gate)
sequenceTime = self.N * 30
t_gate2 = self.ttl_in.gate_rising(sequenceTime*us)
while True:
t = self.ttl_in.timestamp_mu(t_gate2)
if t < 0:
break
For this last version, you can refer here