Hello everyone,

I wanted to test out the Sampler's ADC to see if I was measuring out the voltage with what I supplied it with. I connected a function generator to channel 0 of the Sampler with settings of 0-5V AC sin wave (offset of 2.5V), and a period of 1 sec. I have the SU-Servo variant so I used the functions in the suservo class. When I read from the ADC from channel 0 and plot the voltages, I'm getting values in-between -10V to 5V when I'm supplying it 0-5V. I'm wondering why I get negative voltages back and not positive voltages all the time. Shouldn't the ADC mirror the function generators signal? I thought it was a reading/writing at the same time issue, but I do disable the servo when I read the servo state, and re-enable it afterwards. However, there does not seem to be a change. Here is the code I have so far:

class SuservoTest(EnvExperiment):
    def build(self):
        self.setattr_device("core")
        self.setattr_device("suservo0")
        self.setattr_device("suservo0_ch0")
        self.channeln = 0
        self.input_gain = 0

    @kernel
    def run(self):
        self.core.reset()
        self.core.break_realtime()
        self.suservo0.init()
        self.suservo0.set_pgia_mu(self.channeln, self.input_gain)
        self.suservo0.set_config(enable=1)

        n_samples = 100
        self.set_dataset("samples", np.full(n_samples, np.nan), broadcast=True)
        for j in range(n_samples):
            self.suservo0.set_config(enable=0)
            delay(10*us)
            self.mutate_dataset("samples", j, self.suservo0.get_adc(0))
            delay(50*ms)
            self.suservo0.get_status()
            delay(10*us)
            self.suservo0.set_config(enable=1)
            delay(20*ms)

Picture below is the voltages (y-axis) I get back per sample (x-axis). From 0-15 samples, the function generator is off, then the function generator is left on:

Is this normal behavior, or am I missing something?
Thanks

You can try artiq_sinara_tester -o samplers to test it with your voltage. If you supply voltage different from 1.5V (the AA battery), it will fail and show you the readings from Sampler.

9 days later

Hi @esavkin, I tried running artiq_sinara_tester -o suservos in the terminal since I have the suservo variant, and a 0-5V AC sin wave voltage to channel 0 of the Sampler (so with the same settings described above). What comes up in the terminal is:

****** Sinara system tester ******

Mismatch between gateware (7.0.beta) and software (7.8173.ff97675) versions
*** Testing SUServos.
Initializing modules...
suservo0
...done
Setting up SUServo channels...
suservo0_ch0
suservo0_ch1
suservo0_ch2
suservo0_ch3
suservo0_ch4
suservo0_ch5
suservo0_ch6
suservo0_ch7
...done
Enabling...
suservo0
...done
Each Sampler channel applies proportional amplitude control
on the respective Urukul0 (ADC 0-3) and Urukul1 (ADC 4-7, if
present) channels.
Frequency: 10 MHz, output power: about -9 dBm at 0 V and about -15 dBm at 1.5 V
Verify frequency and power behavior.
Press ENTER when done.

I don't see the readings from the Sampler, am I missing something?

    jqt3 Well, in SUServo test you won't get Sampler's readings, instead you can check how applied voltage changes the amplitude of the Urukul's outputs.

    10 days later

    Hi @esavkin, currently I want to figure out why the voltages I get with get_adc() gives me values in-between -10V to 10 V, and so I was hoping that would not involve the Urukul board yet. For now, I have found a workaround that gives me readings that reflects the signal from the function generator. I've added conditional statements, where if the value from get_adc() is above or below 5, I would subtract or add 10, respectively. So the new code looks like this:

        def run(self):
            self.core.reset()
            self.core.break_realtime()
            self.suservo0.init()
            self.suservo0.set_pgia_mu(self.channeln, self.input_gain)
            self.suservo0.set_config(enable=1)
    
            n_samples = 100
            self.set_dataset("samples", np.full(n_samples, np.nan), broadcast=True)
            for j in range(n_samples):
                self.suservo0.set_config(enable=0)
                delay(10 * us)
                val = self.suservo0.get_adc(0)
                if val > 5:        # If statements are the workaround for +/- 5 V
                    val = val - 10
                elif val < -5:
                    val = val + 10
                self.mutate_dataset("samples", j, val)
                delay(50 * ms)
                self.suservo0.get_status()
                delay(10 * us)
                self.suservo0.set_config(enable=1)
                delay(20 * ms)

    With this code, I get a plot that mirrors the input from the function generator (settings of 1V peak to peak, 0V offset):

    Versus if I did not add the workaround, then my plot would look like this:

    (The Y axis is Voltage, and X is samples for both graphs.) I'm wondering why I have to implement this workaround to get a plot that mirrors the input. But also, where are the values of (10V + input) and (-10 V + input) as shown in the second graph coming from?
    Thanks.