Source code for atomiq.components.sinara.sampler

from __future__ import annotations

from atomiq.components.electronics.adc import ADC, ADCChannel
from artiq.experiment import kernel, delay
from artiq.language.types import TFloat, TInt32, TList, TArray
from artiq.language.units import ms, us


[docs] class Sampler(ADC): """Sinara Sampler 8 Channel ADC This class represents the Sinara Sampler with all its 8 channels. It allows to sample all channels at once and to read out the result. Args: sampler_device: The ARTIQ device for the sampler from the `device_db`, e.g. `@sampler0` default_gain: List with 8 entries setting the default gain for the 8 channels at startup. (default [0, .. , 0]) """ kernel_invariants = {"_sampler_device", "default_gain"} def __init__(self, sampler_device, default_gain: TList(TInt32) = [0]*8, *args, **kwargs): """ A Sampler card with all 8 channels. :param sampler_device: ARTIQ sampler device from the device db :param default_gain: (list(int)) default gain (0: 1, ..., 3: 1000) for the 8 channels """ kwargs["num_chan"] = 8 ADC.__init__(self, *args, **kwargs) self._sampler_device = sampler_device self.default_gain = default_gain @kernel def _prerun(self): self.core.break_realtime() self._sampler_device.init() delay(1 * ms) # set default gains for i in range(len(self.default_gain)): self.set_gain(i, self.default_gain[i])
[docs] @kernel def set_gain(self, channel: TInt32, gain: TInt32 = 0): self._sampler_device.set_gain_mu(channel=channel, gain=gain)
@kernel def _measure(self, target_arr: TArray(TFloat)) -> TArray(TFloat): """ Measure a single sample on all 8 channels at once. This function advances the timeline by 175 us """ self._sampler_device.sample(target_arr) delay(175*us) return target_arr
[docs] class SamplerChannel(ADCChannel): """Single ADC Channel of a Sinara Sampler This class represents a single channel of a Sinara Sampler as an :class:`~atomiq.components.electronics.adc.ADCChannel`. Args: default_gain: Default gain to set for the Sampler channel at startup. (default 0) """ def __init__(self, default_gain: TInt32 = 0, *args, **kwargs): ADCChannel.__init__(self, *args, **kwargs) # overwrite the default gain set on the ADC level self.adc_device.default_gain[kwargs["channel"]] = default_gain
[docs] @kernel def set_gain(self, gain: TInt32): """ Set the gain for the Sampler Channel :param gain: Gain in machine units (0: 1, ..., 3: 1000) """ self.adc_device.set_gain(self.channel, gain)