forked from M-Labs/artiq
1
0
Fork 0

ad9914: remove automatic continuous phase compensation (like Urukul)

This commit is contained in:
Sebastien Bourdeauducq 2018-11-19 22:00:20 +08:00
parent 22a223bf82
commit 8f9858be4c
2 changed files with 13 additions and 12 deletions

View File

@ -67,6 +67,11 @@ ARTIQ-4
clocks dynamically (i.e. without device restart) is no longer supported. clocks dynamically (i.e. without device restart) is no longer supported.
* ``set_dataset(..., save=True)`` has been renamed * ``set_dataset(..., save=True)`` has been renamed
``set_dataset(..., archive=True)``. ``set_dataset(..., archive=True)``.
* On the AD9914 DDS, when switching to ``PHASE_MODE_CONTINUOUS`` from another mode,
use the returned value of the last ``set_mu`` call as the phase offset for
``PHASE_MODE_CONTINUOUS`` to avoid a phase discontinuity. This is no longer done
automatically. If one phase glitch when entering ``PHASE_MODE_CONTINUOUS`` is not
an issue, this recommendation can be ignored.
ARTIQ-3 ARTIQ-3

View File

@ -80,8 +80,6 @@ class AD9914:
self.set_x_duration_mu = 7 * self.write_duration_mu self.set_x_duration_mu = 7 * self.write_duration_mu
self.exit_x_duration_mu = 3 * self.write_duration_mu self.exit_x_duration_mu = 3 * self.write_duration_mu
self.continuous_phase_comp = 0
@kernel @kernel
def write(self, addr, data): def write(self, addr, data):
rtio_output(now_mu(), self.bus_channel, addr, data) rtio_output(now_mu(), self.bus_channel, addr, data)
@ -194,18 +192,16 @@ class AD9914:
The "frequency update" pulse is sent to the DDS with a fixed latency The "frequency update" pulse is sent to the DDS with a fixed latency
with respect to the current position of the time cursor. with respect to the current position of the time cursor.
When switching from other phase modes to the continuous phase mode,
there is no jump in the DDS phase. This is however not true when
using the continuous phase mode after playing back a DMA sequence
that contained the other phase modes.
:param ftw: frequency to generate. :param ftw: frequency to generate.
:param pow: adds an offset to the phase. :param pow: adds an offset to the phase.
:param phase_mode: if specified, overrides the default phase mode set :param phase_mode: if specified, overrides the default phase mode set
by :meth:`set_phase_mode` for this call. by :meth:`set_phase_mode` for this call.
:param ref_time: reference time used to compute phase. Specifying this :param ref_time: reference time used to compute phase. Specifying this
makes it easier to have a well-defined phase relationship between makes it easier to have a well-defined phase relationship between
DDSes on the same bus that are updated at a similar time. DDSes on the same bus that are updated at a similar time.
:return: Resulting phase offset word after application of phase
tracking offset. When using :const:`PHASE_MODE_CONTINUOUS` in
subsequent calls, use this value as the "current" phase.
""" """
if phase_mode == _PHASE_MODE_DEFAULT: if phase_mode == _PHASE_MODE_DEFAULT:
phase_mode = self.phase_mode phase_mode = self.phase_mode
@ -224,7 +220,6 @@ class AD9914:
# Do not clear phase accumulator on FUD # Do not clear phase accumulator on FUD
# Disable autoclear phase accumulator and enables OSK. # Disable autoclear phase accumulator and enables OSK.
self.write(AD9914_REG_CFR1L, 0x0108) self.write(AD9914_REG_CFR1L, 0x0108)
pow += self.continuous_phase_comp
else: else:
# Clear phase accumulator on FUD # Clear phase accumulator on FUD
# Enable autoclear phase accumulator and enables OSK. # Enable autoclear phase accumulator and enables OSK.
@ -233,11 +228,11 @@ class AD9914:
pow -= int32((ref_time - fud_time) * self.sysclk_per_mu * ftw >> (32 - 16)) pow -= int32((ref_time - fud_time) * self.sysclk_per_mu * ftw >> (32 - 16))
if phase_mode == PHASE_MODE_TRACKING: if phase_mode == PHASE_MODE_TRACKING:
pow += int32(ref_time * self.sysclk_per_mu * ftw >> (32 - 16)) pow += int32(ref_time * self.sysclk_per_mu * ftw >> (32 - 16))
self.continuous_phase_comp = pow
self.write(AD9914_REG_POW, pow) self.write(AD9914_REG_POW, pow)
self.write(AD9914_REG_ASF, asf) self.write(AD9914_REG_ASF, asf)
self.write(AD9914_FUD, 0) self.write(AD9914_FUD, 0)
return pow
@portable(flags={"fast-math"}) @portable(flags={"fast-math"})
def frequency_to_ftw(self, frequency): def frequency_to_ftw(self, frequency):
@ -280,9 +275,10 @@ class AD9914:
def set(self, frequency, phase=0.0, phase_mode=_PHASE_MODE_DEFAULT, def set(self, frequency, phase=0.0, phase_mode=_PHASE_MODE_DEFAULT,
amplitude=1.0): amplitude=1.0):
"""Like :meth:`set_mu`, but uses Hz and turns.""" """Like :meth:`set_mu`, but uses Hz and turns."""
self.set_mu(self.frequency_to_ftw(frequency), return self.pow_to_turns(
self.set_mu(self.frequency_to_ftw(frequency),
self.turns_to_pow(phase), phase_mode, self.turns_to_pow(phase), phase_mode,
self.amplitude_to_asf(amplitude)) self.amplitude_to_asf(amplitude)))
# Extended-resolution functions # Extended-resolution functions
@kernel @kernel