Hello,
I'm trying to write the RAM on an Urukul AD9910 for short pulses and experiencing some errors and behaviour that I cannot explain.
For this discussion, I simplified the following code as much as possible.
class UrukulSync(EnvExperiment):
def build(self):
self.setattr_device("core")
self.urukul1 = self.get_device("urukul0_ch1")
def prepare(self):
self.init_att = 10
self.init_freq = 10
self.mu_att = np.int32(round(255. - self.init_att*8))
self.mu_freq = self.urukul1.frequency_to_ftw(self.init_freq*MHz)
ram_data1_raw = []
ram_data2_raw = []
for i in range(1024):
ram_data1_raw.append(1.0)
ram_data2_raw.append(0.5 + 0.2 * np.sin(0.01 * i))
self.ram_data1 = [(self.urukul1.amplitude_to_asf(value) << 18) for value in ram_data1_raw]
self.ram_data2 = [(self.urukul1.amplitude_to_asf(value) << 18) for value in ram_data2_raw]
@kernel
def run(self):
self.core.reset()
self.urukul1.cpld.init()
self.urukul1.init()
self.urukul1.set_att_mu(self.mu_att)
self.urukul1.set_ftw(self.mu_freq)
self.urukul1.set_cfr1(ram_enable=0)
self.urukul1.set_profile_ram(start=0, end=1023, step=1)
delay(1000*us)
self.urukul1.write_ram(self.ram_data2)
self.urukul1.set_cfr1(ram_enable=1, ram_destination=RAM_DEST_ASF)
self.urukul1.sw.on()
self.urukul1.cpld.io_update.pulse_mu(1024 * 4)
self.urukul1.sw.off()
I prepare two RAM settings, ram_data1 filled with 1.0 and ram_data2 filled with a sine between 0.3 and 0.7. Each one are using all 1024 available RAM Integers.
I've made the following observations:
- Running the script the first time (after a reboot) with ram_data1 does nothing. Running it the second time and third etc. will output the constant pulse with 1.0 amplitude normally.
- Running the script with ram_data2 the first time does nothing. Running it a second time will raise a ValueError: Urukul AD9910 AUX_DAC mismatch at init. (Probably because the first run left the Artiq System in an error state)
- Running the script first with ram_data1 (once is enough, even if it doesn't output anything) and then with ram_data2, it will output the sine and also each consecutive run with either ram_data will behave normally.
- Writing a single int32 into the RAM (and accordingly setting the profile to the range start=0, end=0) will always work and output normally on the first run.
What I've tried:
- changing the order of things
- adding long delays everywhere
I hope it's possible to normally run the script without doubling code or having to run it twice.
I'm using Artiq 5.
Regards,
Kai