From 12d699f2a849d65e9f8d56079d1ca93a917f2a35 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Wed, 21 Mar 2018 10:11:23 +0000 Subject: [PATCH] suservo: add sampler example --- .../kasli_suservo/repository/sampler.py | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 artiq/examples/kasli_suservo/repository/sampler.py diff --git a/artiq/examples/kasli_suservo/repository/sampler.py b/artiq/examples/kasli_suservo/repository/sampler.py new file mode 100644 index 000000000..fc4e425ee --- /dev/null +++ b/artiq/examples/kasli_suservo/repository/sampler.py @@ -0,0 +1,35 @@ +from artiq.experiment import * + + +class Sampler(EnvExperiment): + def build(self): + self.setattr_device("core") + self.setattr_device("sampler0") + + def run(self): + self.data = [] + self.sample() + for d in self.data: + print(d) + + @kernel + def sample(self): + self.core.break_realtime() + self.sampler0.init() + for g in range(4): + for ch in range(8): + self.sampler0.set_gain_mu(ch, g) + self.ret([self.sampler0.get_gains_mu()]) + delay(10*ms) + raw = [0] * 8 + self.sampler0.sample_mu(raw) + self.ret(raw) + delay(10*ms) + data = [0.] * 8 + self.sampler0.sample(data) + self.ret(data) + delay(10*ms) + + @rpc(flags={"async"}) + def ret(self, data): + self.data.append(data)