We are trying to build an artiq program, which starts on an external trigger arriving each 100ms, and then executes our needed output triggers. This is done repeatedly in order to sync with other devices.
We started from the code suggested in https://forum.m-labs.hk/d/387-start-immediately-after-rising-edge-detected and made a few modifications.
However, we find that some of the external triggers the artiq should receive are not caught. This was confirmed by a scope and printing the exception in
if trigger_mu>0... else...
This is not deterministic- we observed 3 types of behaviors (all in 10 attempts to run the code):
- The artiq misses trigger number 2 (specifically number 2).
- The artiq misses one or more triggers from the start of the 30 triggers.
- The expected behavior is achieved.
We would highly appreciate help in solving this bug and understanding the behavior of the Artiq.
This is the code we are using:
`from artiq.experiment import *
import numpy as np
self.t0_cycle = np.int64(1)
while self.ttl0.timestamp_mu(now_mu()) >= 0: # flush buffer
delay(5.*us) # slack
for i in range(30):
close_mu = self.ttl0.gate_rising(80*ms)
trigger_mu = self.ttl0.timestamp_mu(close_mu)
if trigger_mu > 0:
at_mu(trigger_mu + self.core.seconds_to_mu(5*us))
self.t0_cycle = now_mu()
at_mu(self.t0_cycle + self.core.seconds_to_mu(5*1e-6))
at_mu(self.t0_cycle + self.core.seconds_to_mu(10*1e-6))