I installed a new sampler ( v 2.3.1) with one EMM (port 0) in our system which has a master with a kasli soc and 3 satellites with kaslis. I rebuilt all the gateware and flashed it (latest version of artiq 8). I rebuilt the device_db.
When I use the code below to test the sampler the behavior is unexpected:

  • If self.core.reset() is called at the beginning the only way of making the sampler work as expected is to call gains = self.sampler2.get_gains_mu() once before doing anything else. This first call return some meaningless value of gains of around 65500 which is always different.
  • If self.core.reset() is not called the sampler seems to work as expected.
  • If self.core.reset() is called and after self.sampler2.get_gains_mu() is called the sampler seems to work as expected.
from artiq.experiment import *
import numpy as np

class SamplerTest(EnvExperiment):
    """Sampler Test"""

    def build(self):
        self.setattr_device("core")
        self.setattr_device("sampler2")

    @kernel
    def run(self):
        g = 0 # gain in mu

        self.core.reset()
        self.core.break_realtime()
        delay(10*ms)
        gains = self.sampler2.get_gains_mu()
        print("Gains: ", gains)
        delay(10*ms)
        for i in range(8):
            delay(1*ms)
            self.sampler2.set_gain_mu(i, g) # set gain on Sampler channel i to 10**g

        delay(10*ms)
        
        # self.sampler2.get_gains_mu() returns all the gains as a int32
        gains = self.sampler2.get_gains_mu()
        delay(1*ms)
        print("Gains: ", gains)
        delay(100*ms)
        for i in range(8):
            mask = (0b11 << (2*i)) # mask to extract gain of channel i, gains are 2 bits per channel
            print("Sampler channel ", i, " gain: ", (gains & mask) >> (2*i))
            delay(100*ms)

        # initialize data container
        data = [0.0]*8

        # collect and show data
        self.sampler2.sample(data)
        for i in range(8):
            print("Voltage ", i, ": ", data[i], " V")
            delay(100*ms)

    I mean in your example code as well, right after self.core.break_realtime().

      fsagbuya Adding self.sampler2.init() right after self.core.break_realtime() does not solve the issues. The behavior stays the same as what I described above

      fsagbuya I mean in your example code as well, right after self.core.break_realtime().

      I think that's not necessary and doing it in the startup kernel should be sufficient.