Hello,
We've been experimenting some strange (strange to us, at least) Underflow Errors during some experiments, which used to run properly a week or so ago.
They arise at the dds (ad9910) channel initialization step.
Below is a minimal example with the corresponding traceback call.
We are using a custom wrapper class around Urukul channels for simplicity, we included a minimal version in this example code (ofc feedback and improvements are welcomed!) .
The error at least appears consistent between runs (i.e. it usually raises with slack ~ -5000mu).
We've tried adding delays before each step on our code to increase slack, but to no success.
Sorry if this is a stupid question but could it be that we somehow need to "clear" or "free" the channel after being used in a experiment before initiating it again in a new one?
Thanks!!
Artiq version: ARTIQ v5.7158.beb49d4d (planning on updating to 6 soon)
Working example code:
from artiq.experiment import *
class UrukulCh(HasEnvironment):
def build(self, ch=0, freq=100.0, amp=1.0):
self.ch = ch
self.amp = amp
self.freq = freq
self.channel = self.get_device(f"urukul0_ch{self.ch}")
self.frequency = self.get_argument(f"freq_ch{self.ch}",
NumberValue(self.freq*MHz, unit='MHz', scale=MHz, min=1*MHz, max=400*MHz),
f"channel_{self.ch}")
self.amplitude = self.get_argument(f"amp_ch{self.ch}",
NumberValue(self.amp, min=0., max=1.),
f"channel_{self.ch}")
@kernel
def initialize_channel(self):
# initialises CPLD the selected channel
self.channel.cpld.init()
self.channel.init()
@kernel
def set_channel(self):
self.channel.set(self.frequency, amplitude=self.amplitude)
@kernel
def set_o(self, state):
self.channel.sw.set_o(state)
class TestUnderflow(EnvExperiment):
def build(self):
self.setattr_device("core")
self.laserIR = UrukulCh(self, ch=1, freq=208.0, amp=0.35)
@kernel
def run(self):
self.core.reset()
self.laserIR.initialize_channel()
self.core.break_realtime()
self.laserIR.set_channel()
delay(10*us)
# Just try to pulse the laser
self.laserIR.set_o(True)
delay(1*ms)
self.laserIR.set_o(False)
Traceback:
root:Terminating with exception (RTIOUnderflow: RTIO underflow at 3929960246184 mu, channel 8, slack -5384 mu)
Core Device Traceback (most recent call last):
File "---/minimal_example_underflow.py", line 44, in artiq_worker_minimal_example_underflow.TestUnderflow.run(..., ...) (RA=+0xa8c)
self.laserIR.initialize_channel()
File "---/minimal_example_underflow.py", line 25, in ... artiq_worker_minimal_example_underflow.UrukulCh.initialize_channel<artiq_worker_minimal_example_weird_underflow.UrukulCh>(...) (inlined)
self.channel.init()
File "<artiq>/coredevice/ad9910.py", line 422, in ... artiq.coredevice.ad9910.AD9910.init<artiq.coredevice.ad9910.AD9910>(...) (RA=+0x1c14)
sta = self.cpld.sta_read()
File "<artiq>/coredevice/urukul.py", line 226, in ... artiq.coredevice.urukul.CPLD.sta_read<artiq.coredevice.urukul.CPLD>(...) (inlined)
self.bus.set_config_mu(SPI_CONFIG | spi.SPI_END | spi.SPI_INPUT, 24,
File "<artiq>/coredevice/spi2.py", line 169, in ... artiq.coredevice.spi2.SPIMaster.set_config_mu<artiq.coredevice.spi2.SPIMaster>(...) (inlined)
rtio_output((self.channel << 8) | SPI_CONFIG_ADDR, flags |
File "ksupport/rtio.rs", line 67, column 14, in (Rust function)
<unknown>
^
artiq.coredevice.exceptions.RTIOUnderflow(0): RTIO underflow at 3929960246184 mu, channel 8, slack -5384 mu