From ac8d398f5ebfd5feb40db992f9f4953666eebdf5 Mon Sep 17 00:00:00 2001 From: occheung Date: Thu, 20 Jan 2022 16:48:55 +0800 Subject: [PATCH] suservo: refrain from generating channel list For consistency with other DDS examples that uses multiple channels. e.g. TTL relay external trigger, DDS synchronization --- 4410-4412.tex | 8 ++++---- examples/suservo.py | 12 +++++------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/4410-4412.tex b/4410-4412.tex index 95ff36e..405bd50 100644 --- a/4410-4412.tex +++ b/4410-4412.tex @@ -821,16 +821,16 @@ In the following example, the amplitude of DDS is proportional to the ADC input First, initialize the RTIO, SU-Servo and its channel. Note that the programmable gain of the Sampler is $10^0=1$, the input range is [-10V, 10V]. -\inputcolorboxminted{firstline=14,lastline=21}{examples/suservo.py} +\inputcolorboxminted{firstline=12,lastline=19}{examples/suservo.py} Next, setup the PI control as an IIR filter. It has -1 proportional gain $k_p$ and no integrator gain $k_i$. -\inputcolorboxminted{firstline=22,lastline=29}{examples/suservo.py} +\inputcolorboxminted{firstline=20,lastline=27}{examples/suservo.py} Then, configure the DDS frequency to 10 MHz with 3V input offset. When input voltage $\geq$ offset voltage, the DDS output amplitude is 0. -\inputcolorboxminted{firstline=30,lastline=34}{examples/suservo.py} +\inputcolorboxminted{firstline=28,lastline=32}{examples/suservo.py} SU-Servo encodes the ADC voltage in a linear scale [-1, 1]. Therefore, 3V is converted to 0.3. @@ -838,7 +838,7 @@ Note that the ASF of all DDS channels are capped at 1.0, the amplitude clips whe Finally, enable the SU-Servo channel with the IIR filter programmed beforehand. -\inputcolorboxminted{firstline=36,lastline=37}{examples/suservo.py} +\inputcolorboxminted{firstline=34,lastline=35}{examples/suservo.py} A 10 MHz DDS signal is generated from the example above, with amplitude controllable by ADC. The RMS voltage of the DDS channel against the ADC voltage is plotted. diff --git a/examples/suservo.py b/examples/suservo.py index 6b028bb..f700fab 100644 --- a/examples/suservo.py +++ b/examples/suservo.py @@ -7,9 +7,7 @@ class SUServoExample(EnvExperiment): def build(self): self.setattr_device("core") self.suservo = self.get_device("suservo0") - self.suschannels = [ - self.get_device("suservo0_ch0") - ] + self.suschannel0 = self.get_device("suservo0_ch0") @kernel def run(self): @@ -18,8 +16,8 @@ class SUServoExample(EnvExperiment): self.suservo.init() self.suservo.set_pgia_mu(0, 0) # unity gain self.suservo.cplds[0].set_att(0, 15.) - self.suschannels[0].set_y(profile=0, y=0.) # Clear integrator - self.suschannels[0].set_iir( + self.suschannel0.set_y(profile=0, y=0.) # Clear integrator + self.suschannel0.set_iir( profile=0, adc=0, # take data from Sampler channel 0 kp=-1., # -1 P gain @@ -27,11 +25,11 @@ class SUServoExample(EnvExperiment): g=0., # no integrator gain limit delay=0. # no IIR update delay after enabling ) - self.suschannels[0].set_dds( + self.suschannel0.set_dds( profile=0, offset=-.3, # 3 V with above PGIA settings frequency=10*MHz, phase=0.) # enable RF, IIR updates and set profile - self.suschannels[0].set(en_out=1, en_iir=1, profile=0) + self.suschannel0.set(en_out=1, en_iir=1, profile=0) self.suservo.set_config(enable=1)