From b5772f478a1327c7f78e2a3c1f7db81cac830c62 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Fri, 16 Jun 2017 19:31:57 +0200 Subject: [PATCH] sawg: add channel reset (closes #751) --- artiq/coredevice/sawg.py | 45 ++++++++++++++++++- .../examples/phaser/repository/demo_2tone.py | 5 +++ 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/artiq/coredevice/sawg.py b/artiq/coredevice/sawg.py index ba8c39951..ba7f9ef15 100644 --- a/artiq/coredevice/sawg.py +++ b/artiq/coredevice/sawg.py @@ -1,5 +1,5 @@ from artiq.language.types import TInt32, TFloat -from numpy import int32 +from numpy import int32, int64 from artiq.language.core import kernel, now_mu from artiq.coredevice.spline import Spline from artiq.coredevice.rtio import rtio_output @@ -26,13 +26,18 @@ class Config: :param channel: RTIO channel number of the channel. :param core: Core device. """ - kernel_invariants = {"channel", "core", "_out_scale", "_duc_scale"} + kernel_invariants = {"channel", "core", "_out_scale", "_duc_scale", + "_rtio_interval"} def __init__(self, channel, core, cordic_gain=1.): self.channel = channel self.core = core + # normalized DAC output self._out_scale = (1 << 15) - 1. + # normalized DAC output including DUC cordic gain self._duc_scale = self._out_scale/cordic_gain + # configuration channel access interval + self._rtio_interval = int64(3*self.core.ref_multiplier) @kernel def set_div(self, div: TInt32, n: TInt32=0): @@ -321,3 +326,39 @@ class SAWG: parallelism/self.core.coarse_ref_period) self.phase0 = Spline(width, time_width, channel_base + 9, self.core, 1.) + + @kernel + def reset(self): + """Re-establish initial conditions. + + This clears all spline interpolators, accumulators and configuration + settings. + + This method advances the timeline by the time required to perform all + eight writes to the configuration channel. + """ + self.frequency0.set_mu(0) + self.frequency1.set_mu(0) + self.frequency2.set_mu(0) + self.phase0.set_mu(0) + self.phase1.set_mu(0) + self.phase2.set_mu(0) + self.amplitude1.set_mu(0) + self.amplitude2.set_mu(0) + self.offset.set_mu(0) + self.config.set_clr(1, 1, 1) + delay_mu(self.config._rtio_interval) + self.config.set_iq_en(1, 0) + delay_mu(self.config._rtio_interval) + self.config.set_duc_i_min(-1.) + delay_mu(self.config._rtio_interval) + self.config.set_duc_i_max(1.) + delay_mu(self.config._rtio_interval) + self.config.set_duc_q_min(-1.) + delay_mu(self.config._rtio_interval) + self.config.set_duc_q_max(1.) + delay_mu(self.config._rtio_interval) + self.config.set_out_min(-1.) + delay_mu(self.config._rtio_interval) + self.config.set_out_max(1.) + delay_mu(self.config._rtio_interval) diff --git a/artiq/examples/phaser/repository/demo_2tone.py b/artiq/examples/phaser/repository/demo_2tone.py index 7089996b4..9ff1a099d 100644 --- a/artiq/examples/phaser/repository/demo_2tone.py +++ b/artiq/examples/phaser/repository/demo_2tone.py @@ -17,6 +17,11 @@ class SAWGTestTwoTone(EnvExperiment): self.core.reset() self.ttl_sma.output() + self.sawg0.reset() + self.sawg1.reset() + self.sawg2.reset() + self.sawg3.reset() + self.sawg0.config.set_clr(1, 1, 1) delay(10*us) self.sawg0.config.set_out_max(1.)