I am using two TTL channels as edge_counters
to measure the flourescence of two ions simultaneously. I followed the documentation in the manual (https://m-labs.hk/artiq/manual/core_drivers_reference.html#module-artiq.coredevice.edge_counter) and arrived at the following minimum working example:
class GenericTest(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("ccb")
self.setattr_device("scheduler")
self.setattr_device("ttl0_counter")
self.setattr_device("ttl1_counter")
self.setattr_argument("t_accu", NumberValue(
default = 100*ms,
unit = "ms"))
def prepare(self):
self.ccb.issue("create_applet", "counts_0",
"${artiq_applet}plot_xy test.counts_0", ["Test"])
self.set_dataset("test.counts_0", [0], broadcast=True)
self.ccb.issue("create_applet", "counts_1",
"${artiq_applet}plot_xy test.counts_1", ["Test"])
self.set_dataset("test.counts_1", [0], broadcast=True)
def run(self):
self.run_kernel()
@kernel
def run_kernel(self):
while True:
self.core.break_realtime()
with parallel:
self.ttl0_counter.gate_rising(self.t_accu)
self.ttl1_counter.gate_rising(self.t_accu)
counts_0 = self.ttl0_counter.fetch_count()
counts_1 = self.ttl1_counter.fetch_count()
if self.cb(counts_0, counts_1):
break
def check_stop(self) -> TBool:
try:
self.scheduler.pause()
except TerminationRequested:
return True
return False
def cb(self, counts_0, counts_1) -> TBool:
self.append_to_dataset("test.counts_0", counts_0)
self.append_to_dataset("test.counts_1", counts_1)
try:
self.scheduler.pause()
except TerminationRequested:
return True
return False
When I start the experiment, I see the expected number of counts with the expected sampling speed (i. e. for 100 ms integration time, I have a sample interval of roughly 100 ms, instead of 200 ms). When I block the common repump path of the ions, I see the drop in fluorescence on both counters, but counter_0
is delayed by roughly 10 samples. This is independent of the actual sample rate, so the delay is the same for 100 ms integration time and 10 ms integration time. See the following plots:
![edgecounter-repumpoff.png](https://forum.m-labs.hk/assets/files/2022-09-22/1663850612-847782-edgecounter-repumpoff.png)
In addition, when I stop the experiment with e.g. 100 ms integration time and I start it again with 10 ms integration time, I see around 10 samples on counter_0
that correspond to the first integration time (100 ms), then it drops to the correct value. This behaviour is independent of the order I put the gate_rising
and fetch_count
calls in the experiment. counter_0
is always delayed with respect to counter_1.
If I understand the documentation correctly, all remaining output events should be cleared, when a new gate_rising is called, right (https://m-labs.hk/artiq/manual/core_drivers_reference.html#artiq.coredevice.edge_counter.EdgeCounter.gate_both)? On the other hand, it is mentioned, that multiple subsequent gate
events can be queued up and read out sequentially, so maybe there are some lingering gates
(https://m-labs.hk/artiq/manual/core_drivers_reference.html#artiq.coredevice.edge_counter.EdgeCounter.gate_both)? Just running fetch_count
for a couple of seconds did not change the behaviour. See these plots:
![edgecounter-restart.png](https://forum.m-labs.hk/assets/files/2022-09-22/1663851307-955297-edgecounter-restart.png)
How do I synchronize the two edge_counters
, or at least can get rid of the events from a previous experiment? When using the channels as normal TTLs, I did not see this behaviour.
ARTIQ version: ARTIQ v7.8116.eba143a