Description of the problem: I'm not sure if this is intended or not, but I found that when accessing a variable initiated in prepare() or build(), it will throw an RTIO underflow error upon reading a ttl input if I use the at_mu(timestamp) scheme @sb10q specified here: https://forum.m-labs.hk/d/387-start-immediately-after-rising-edge-detected/3 . What's weird is that if I don't access that variable and instead hardcode the wanted value e.g. delay(1*us) instead of delay(self.dummy_delay), the experiment runs completely fine with no RTIO underflow errors. This leads me to think that there are hidden delays when accessing a variable with ARTIQ.
There is another way to make it work and that is by adding a buffer time in at_mu(timestamp + buffer) where buffer is >100us. This will make the experiment run with and without accessing variables in prepare/build. A 100us wait time is too long of a duty cycle while 1-10us cycle would be reasonable. Are there any ways around this? In a normal experiment, I have many variables I would want to access.
Code that I am running:
`
from artiq.experiment import *
class Missingtrigger(Exception):
pass
class TTLTrigger(EnvExperiment):
def build(self):
self.setattr_device("core")
self.setattr_device("ttl3")
self.setattr_device("ttl6")
def prepare(self):
self.dummy_delay = 1*us
@kernel
def run(self):
self.core.reset()
self.ttl3.input()
self.ttl6.off()
while self.ttl3.timestamp_mu(now_mu()) >= 0:
pass
self.core.break_realtime()
with parallel:
self.ttl6.pulse(50*ns)
with sequential:
delay(103*ns) # needed to be in line with pulse with parallel since pulse takes longer to come out
close_mu = self.ttl3.gate_rising(2*us)
trigger_mu = self.ttl3.timestamp_mu(close_mu)
if trigger_mu < 0:
raise Missingtrigger()
at_mu(trigger_mu + self.core.seconds_to_mu(10000*ns))
self.ttl6.pulse(50*ns)
delay(self.dummy_delay)
#delay(1*us)
print("TTL Trigger experiment done")
`
The RTIO underflow error that occurs when running this in the dashboard:
root:Terminating with exception (RTIOUnderflow: RTIO underflow at channel 0x0017:unknown, 160403582780730 mu, slack -26206 mu)
Core Device Traceback:
Traceback (most recent call first):
File "ksupport/rtio.rs", line 69, column 14, in (Rust function)
<unknown>
^
File "<artiq>/coredevice/ttl.py", line 49, in ... artiq.coredevice.ttl.TTLOut.set_o<artiq.coredevice.ttl.TTLOut>(...) (RA=+0x418)
rtio_output(self.target_o, 1 if o else 0)
File "<artiq>/coredevice/ttl.py", line 57, in ... artiq.coredevice.ttl.TTLOut.on<artiq.coredevice.ttl.TTLOut>(...) (inlined)
self.set_o(True)
File "<artiq>/coredevice/ttl.py", line 83, in ... artiq.coredevice.ttl.TTLOut.pulse<artiq.coredevice.ttl.TTLOut>(...) (inlined)
self.on()
File "C:/Users/DQP/repos/dqpcontrol/artiq-master/repository/ttltrigger.py", line 38, in artiq_worker_ttltrigger.TTLTrigger.run(..., ...) (inlined)
self.ttl6.pulse(50*ns)
artiq.coredevice.exceptions.RTIOUnderflow(0): RTIO underflow at channel 0x0017:unknown, 160403582780730 mu, slack -26206 mu
End of Core Device Traceback
Traceback (most recent call last):
File "C:/msys64/clang64/lib/python3.12/site-packages/artiq/master/worker_impl.py", line 358, in main
exp_inst.run()
File "C:/msys64/clang64/lib/python3.12/site-packages/artiq/language/core.py", line 54, in run_on_core
return getattr(self, arg).run(run_on_core, ((self,) + k_args), k_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:/msys64/clang64/lib/python3.12/site-packages/artiq/coredevice/core.py", line 172, in run
self._run_compiled(kernel_library, embedding_map, symbolizer, demangler)
File "C:/msys64/clang64/lib/python3.12/site-packages/artiq/coredevice/core.py", line 161, in run_compiled
self.comm.serve(embedding_map, symbolizer, demangler)
File "C:/msys64/clang64/lib/python3.12/site-packages/artiq/coredevice/comm_kernel.py", line 734, in serve
self.serve_exception(embedding_map, symbolizer, demangler)
File "C:/msys64/clang64/lib/python3.12/site-packages/artiq/coredevice/comm_kernel.py", line 716, in _serve_exception
raise python_exn
artiq.coredevice.exceptions.RTIOUnderflow: RTIO underflow at channel 0x0017:unknown, 160403582780730 mu, slack -26206 mu