[docs]classSampler(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"]=8ADC.__init__(self,*args,**kwargs)self._sampler_device=sampler_deviceself.default_gain=default_gain@kerneldef_prerun(self):self.core.break_realtime()self._sampler_device.init()delay(1*ms)# set default gainsforiinrange(len(self.default_gain)):self.set_gain(i,self.default_gain[i])
@kerneldef_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)returntarget_arr
[docs]classSamplerChannel(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 levelself.adc_device.default_gain[kwargs["channel"]]=default_gain
[docs]@kerneldefset_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)