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