Compare commits

...

4 Commits

Author SHA1 Message Date
occheung 48eb5a5ae3 5432: relocate examples source
Updates #24.
2022-01-20 17:17:13 +08:00
occheung 708330a57a suservo.py: remove unnecessary import 2022-01-20 17:00:54 +08:00
occheung ac8d398f5e suservo: refrain from generating channel list
For consistency with other DDS examples that uses multiple channels.
e.g. TTL relay external trigger, DDS synchronization
2022-01-20 16:48:58 +08:00
occheung 8404fed3da 4410-4412: get example code from file
Updates #24. Added example files for DDS and SUServo respectively.
2022-01-20 16:43:45 +08:00
5 changed files with 245 additions and 165 deletions

View File

@ -4,8 +4,6 @@
\usepackage{minted} \usepackage{minted}
\usepackage{tcolorbox} \usepackage{tcolorbox}
\usepackage{etoolbox} \usepackage{etoolbox}
\BeforeBeginEnvironment{minted}{\begin{tcolorbox}[colback=white]}%
\AfterEndEnvironment{minted}{\end{tcolorbox}}%
\usepackage[justification=centering]{caption} \usepackage[justification=centering]{caption}
@ -69,6 +67,11 @@ RF switches (1ns temporal resolution) on each channel provides 70 dB isolation.
\newcommand*{\MyLabel}[3][2cm]{\parbox{#1}{\centering #2 \\ #3}} \newcommand*{\MyLabel}[3][2cm]{\parbox{#1}{\centering #2 \\ #3}}
\newcommand*{\MymyLabel}[3][4cm]{\parbox{#1}{\centering #2 \\ #3}} \newcommand*{\MymyLabel}[3][4cm]{\parbox{#1}{\centering #2 \\ #3}}
\newcommand{\repeatfootnote}[1]{\textsuperscript{\ref{#1}}} \newcommand{\repeatfootnote}[1]{\textsuperscript{\ref{#1}}}
\newcommand{\inputcolorboxminted}[2]{%
\begin{tcolorbox}[colback=white]
\inputminted[#1, gobble=4]{python}{#2}
\end{tcolorbox}
}
\begin{figure}[h] \begin{figure}[h]
\centering \centering
@ -688,37 +691,13 @@ Generate a 10MHz sinusoid from RF0 with full scale amplitude, attenuated by 6 dB
Both the CPLD and the DDS channels should be initialized. Both the CPLD and the DDS channels should be initialized.
By default, AD9910 single-tone profiles are programmed to profile 7. By default, AD9910 single-tone profiles are programmed to profile 7.
\begin{minted}{python} \inputcolorboxminted{firstline=11,lastline=18}{examples/dds.py}
@kernel
def run(self):
self.core.reset()
self.cpld.init()
self.dds0.init()
self.dds0.cfg_sw(True)
self.dds0.set_att(6.*dB)
self.dds0.set(10*MHz)
\end{minted}
If the synchronization feature of AD9910 was enabled, RF signal across different channels of the same Urukul can be synchronized. If the synchronization feature of AD9910 was enabled, RF signal across different channels of the same Urukul can be synchronized.
For example, phase-coherent RF signal can be produced on both channel 0 and channel 1 after configuring an appropriate phase mode. For example, phase-coherent RF signal can be produced on both channel 0 and channel 1 after configuring an appropriate phase mode.
\begin{minted}{python}
@kernel
def run(self):
self.core.reset()
self.cpld.init()
self.dds0.init() \inputcolorboxminted{firstline=28,lastline=43}{examples/dds.py}
self.dds0.cfg_sw(True)
self.dds0.set_phase_mode(PHASE_MODE_TRACKING)
self.dds0.set_att(6.*dB)
self.dds1.init()
self.dds1.cfg_sw(True)
self.dds1.set_phase_mode(PHASE_MODE_TRACKING)
self.dds1.set_att(6.*dB)
self.dds0.set(frequency=10*MHz, phase=0.0)
self.dds1.set(frequency=10*MHz, phase=0.25) # 0.25 turns phase offset
\end{minted}
Note that the phase difference between the 2 channels might not be exactly 0.25 turns, but it is a constant. Note that the phase difference between the 2 channels might not be exactly 0.25 turns, but it is a constant.
It can be negated by adjusting the \texttt{phase} parameter. It can be negated by adjusting the \texttt{phase} parameter.
@ -727,49 +706,7 @@ It can be negated by adjusting the \texttt{phase} parameter.
This examples demonstrates that the RF signal can be modulated by amplitude using the RAM modulation feature of AD9910. This examples demonstrates that the RF signal can be modulated by amplitude using the RAM modulation feature of AD9910.
By default, RAM profiles are programmed to profile 0. By default, RAM profiles are programmed to profile 0.
\begin{minted}{python} \inputcolorboxminted{firstline=53,lastline=91}{examples/dds.py}
from artiq.coredevice.ad9910 import RAM_MODE_CONT_RAMPUP
def prepare(self):
self.amp = [0.0, 0.0, 0.0, 0.7, 0.0, 0.7, 0.7] # Reversed Order
self.asf_ram = [0] * len(self.amp)
@kernel
def init_dds(self, dds):
self.core.break_realtime()
dds.init()
dds.set_att(6.*dB)
dds.cfg_sw(True)
@kernel
def configure_ram_mode(self, dds):
self.core.break_realtime()
dds.set_cfr1(ram_enable=0)
self.cpld.io_update.pulse_mu(8)
self.cpld.set_profile(0) # Enable the corresponding RAM profile
# Profile 0 is the default
dds.set_profile_ram(start=0, end=len(self.asf_ram)-1,
step=250, profile=0, mode=RAM_MODE_CONT_RAMPUP)
self.cpld.io_update.pulse_mu(8)
dds.amplitude_to_ram(self.amp, self.asf_ram)
dds.write_ram(self.asf_ram)
self.core.break_realtime()
dds.set(frequency=5*MHz, ram_destination=RAM_DEST_ASF)
# Pass osk_enable=1 to set_cfr1() if it is not an amplitude RAM
dds.set_cfr1(ram_enable=1, ram_destination=RAM_DEST_ASF)
self.cpld.io_update.pulse_mu(8)
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
self.cpld.init()
self.init_dds(self.dds0)
self.configure_ram_mode(self.dds0)
\end{minted}
The generated RF output of the above example consists of the following features in sequence: The generated RF output of the above example consists of the following features in sequence:
\begin{enumerate} \begin{enumerate}
@ -815,12 +752,8 @@ Urukul was operated with a 50$\Omega$ termination to produce the waveform.
\subsection{Simple Amplitude Ramp (AD9910 Only)} \subsection{Simple Amplitude Ramp (AD9910 Only)}
An amplitude ramp of an RF signal can be generated by modifying the \texttt{self.amp} array in the previous example. An amplitude ramp of an RF signal can be generated by modifying the \texttt{self.amp} array in the previous example.
\begin{minted}{python}
def prepare(self): \inputcolorboxminted{firstline=95,lastline=98}{examples/dds.py}
# Reversed Order
self.amp = [1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.0]
self.asf_ram = [0] * len(self.amp)
\end{minted}
The generated RF output has an incrementing amplitude scale factor (ASF), increasing by 0.1 at every microsecond. The generated RF output has an incrementing amplitude scale factor (ASF), increasing by 0.1 at every microsecond.
Once the ASF reaches 1.0, it drops back to 0.0 at the next microsecond. Once the ASF reaches 1.0, it drops back to 0.0 at the next microsecond.
@ -871,25 +804,13 @@ Urukul was operated with a 50$\Omega$ termination to produce the waveform.
Multiple RAM channels can also be synchronized. Multiple RAM channels can also be synchronized.
Similar to the 10 MHz single-tone RF signals, specify \texttt{phase} when calling \texttt{dds.set()} in \texttt{configure\char`_ram\char`_mode}. Similar to the 10 MHz single-tone RF signals, specify \texttt{phase} when calling \texttt{dds.set()} in \texttt{configure\char`_ram\char`_mode}.
For example, set phase to 0 for the channels (\texttt{phase=0.0}). For example, set phase to 0 for the channels (\texttt{phase=0.0}).
\begin{minted}{python}
dds.set(frequency=5*MHz, phase=0.0, ram_destination=RAM_DEST_ASF) \inputcolorboxminted{firstline=116,lastline=116}{examples/dds.py}
\end{minted}
Then, replace the \texttt{run()} function with the following. Then, replace the \texttt{run()} function with the following.
\begin{minted}{python}
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
self.cpld.init()
self.init_dds(self.dds0) \inputcolorboxminted{firstline=122,lastline=134}{examples/dds.py}
self.init_dds(self.dds1)
self.dds0.set_phase_mode(PHASE_MODE_TRACKING)
self.dds1.set_phase_mode(PHASE_MODE_TRACKING)
self.configure_ram_mode(self.dds0)
self.configure_ram_mode(self.dds1)
\end{minted}
Two phase-coherent RF signal with the same waveform as the previous figure (from either RAM examples) should be generated. Two phase-coherent RF signal with the same waveform as the previous figure (from either RAM examples) should be generated.
\subsection{Voltage-controlled DDS Amplitude (SU-Servo Only)} \subsection{Voltage-controlled DDS Amplitude (SU-Servo Only)}
@ -899,41 +820,17 @@ Amplitude of the DDS output can be controlled by the ADC input of the Sampler th
In the following example, the amplitude of DDS is proportional to the ADC input from Sampler. In the following example, the amplitude of DDS is proportional to the ADC input from Sampler.
First, initialize the RTIO, SU-Servo and its channel. 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]. Note that the programmable gain of the Sampler is $10^0=1$, the input range is [-10V, 10V].
\begin{minted}{python}
@kernel \inputcolorboxminted{firstline=10,lastline=17}{examples/suservo.py}
def run(self):
self.core.reset()
self.core.break_realtime()
self.suservo.init()
self.suservo.set_pgia_mu(0, 0) # unity gain
self.suservo.cplds[0].set_att(0, 15.)
self.channel.set_y(profile=0, y=0.) # Clear integrator
\end{minted}
Next, setup the PI control as an IIR filter. It has -1 proportional gain $k_p$ and no integrator gain $k_i$. Next, setup the PI control as an IIR filter. It has -1 proportional gain $k_p$ and no integrator gain $k_i$.
\begin{minted}{python} \inputcolorboxminted{firstline=18,lastline=25}{examples/suservo.py}
self.channel.set_iir(
profile=0,
adc=0, # take data from Sampler channel 0
kp=-1., # -1 P gain
ki=0./s, # no integrator gain
g=0., # no integrator gain limit
delay=0. # no IIR update delay after enabling
)
\end{minted}
Then, configure the DDS frequency to 10 MHz with 3V input offset. Then, configure the DDS frequency to 10 MHz with 3V input offset.
When input voltage $\geq$ offset voltage, the DDS output amplitude is 0. When input voltage $\geq$ offset voltage, the DDS output amplitude is 0.
\begin{minted}{python} \inputcolorboxminted{firstline=26,lastline=30}{examples/suservo.py}
self.channel.set_dds(
profile=0,
offset=-.3, # 3V with above PGIA settings
# Note the inverted sign
frequency=10*MHz,
phase=0.)
\end{minted}
SU-Servo encodes the ADC voltage in a linear scale [-1, 1]. SU-Servo encodes the ADC voltage in a linear scale [-1, 1].
Therefore, 3V is converted to 0.3. Therefore, 3V is converted to 0.3.
@ -941,10 +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. Finally, enable the SU-Servo channel with the IIR filter programmed beforehand.
\begin{minted}{python} \inputcolorboxminted{firstline=32,lastline=33}{examples/suservo.py}
self.channel.set(en_out=1, en_iir=1, profile=0)
self.suservo.set_config(enable=1)
\end{minted}
A 10 MHz DDS signal is generated from the example above, with amplitude controllable by ADC. 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. The RMS voltage of the DDS channel against the ADC voltage is plotted.

View File

@ -4,8 +4,6 @@
\usepackage{minted} \usepackage{minted}
\usepackage{tcolorbox} \usepackage{tcolorbox}
\usepackage{etoolbox} \usepackage{etoolbox}
\BeforeBeginEnvironment{minted}{\begin{tcolorbox}[colback=white]}%
\AfterEndEnvironment{minted}{\end{tcolorbox}}%
\usepackage[justification=centering]{caption} \usepackage[justification=centering]{caption}
@ -65,6 +63,11 @@ Channels can broken out to BNC, SMA or MCX by adding external 5518 BNC-IDC, 5528
\newcommand*{\MyLabel}[3][2cm]{\parbox{#1}{\centering #2 \\ #3}} \newcommand*{\MyLabel}[3][2cm]{\parbox{#1}{\centering #2 \\ #3}}
\newcommand*{\MymyLabel}[3][4cm]{\parbox{#1}{\centering #2 \\ #3}} \newcommand*{\MymyLabel}[3][4cm]{\parbox{#1}{\centering #2 \\ #3}}
\newcommand{\repeatfootnote}[1]{\textsuperscript{\ref{#1}}} \newcommand{\repeatfootnote}[1]{\textsuperscript{\ref{#1}}}
\newcommand{\inputcolorboxminted}[2]{%
\begin{tcolorbox}[colback=white]
\inputminted[#1, gobble=4]{python}{#2}
\end{tcolorbox}
}
\begin{figure}[h] \begin{figure}[h]
\centering \centering
@ -265,51 +268,15 @@ The full documentation for the ARTIQ software and gateware is available at \url{
The following example initializes the Zotino card, then emits 1.0 V, 2.0 V, 3.0 V and 4.0 V at channel 0, 1, 2, 3 respectively. The following example initializes the Zotino card, then emits 1.0 V, 2.0 V, 3.0 V and 4.0 V at channel 0, 1, 2, 3 respectively.
Voltages of all 4 channels are updated simultaneously with the use of \texttt{set\char`_dac()}. Voltages of all 4 channels are updated simultaneously with the use of \texttt{set\char`_dac()}.
\begin{minted}{python} \inputcolorboxminted{firstline=11,lastline=22}{examples/zotino.py}
def prepare(self):
self.channels = [0, 1, 2, 3]
self.voltages = [1.0, 2.0, 3.0, 4.0]
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
self.zotino.init()
delay(1*ms)
self.zotino.set_dac(self.voltages, self.channels)
\end{minted}
\newpage \newpage
\subsection{Triangular Wave} \subsection{Triangular Wave}
A triangular waveform at 10 Hz, 16 V peak-to-peak. A triangular waveform at 10 Hz, 16 V peak-to-peak.
Timing accuracy of the RTIO system can be demonstrated by the precision of the frequency. Timing accuracy of the RTIO system can be demonstrated by the precision of the frequency.
\begin{minted}{python}
from scipy import signal
import numpy
def prepare(self): \inputcolorboxminted{firstline=30,lastline=52}{examples/zotino.py}
self.period = 0.1*s
self.sample = 128
t = numpy.linspace(0, 1, self.sample)
self.voltages = 8*signal.sawtooth(2*numpy.pi*t, 0.5)
self.interval = self.period/self.sample
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
self.zotino.init()
delay(1*ms)
counter = 0
while True:
self.zotino.set_dac([self.voltages[counter]], [0])
counter = (counter + 1) % self.sample
delay(self.interval)
\end{minted}
\section{Ordering Information} \section{Ordering Information}
To order, please visit \url{https://m-labs.hk} and select the 5432 Zotino in the ARTIQ Sinara crate configuration tool. The card may also be ordered separately by writing to \url{mailto:sales@m-labs.hk}. To order, please visit \url{https://m-labs.hk} and select the 5432 Zotino in the ARTIQ Sinara crate configuration tool. The card may also be ordered separately by writing to \url{mailto:sales@m-labs.hk}.

134
examples/dds.py Normal file
View File

@ -0,0 +1,134 @@
from artiq.experiment import *
from artiq.coredevice.ad9910 import *
class Sinusoid(EnvExperiment):
def build(self):
self.setattr_device("core")
self.cpld = self.get_device("urukul0_cpld")
self.dds0 = self.get_device("urukul0_ch0")
@kernel
def run(self):
self.core.reset()
self.cpld.init()
self.dds0.init()
self.dds0.cfg_sw(True)
self.dds0.set_att(6.*dB)
self.dds0.set(10*MHz)
class SynchronizedSinusoid(EnvExperiment):
def build(self):
self.setattr_device("core")
self.cpld = self.get_device("urukul0_cpld")
self.dds0 = self.get_device("urukul0_ch0")
self.dds1 = self.get_device("urukul0_ch1")
@kernel
def run(self):
self.core.reset()
self.cpld.init()
self.dds0.init()
self.dds0.cfg_sw(True)
self.dds0.set_phase_mode(PHASE_MODE_TRACKING)
self.dds0.set_att(6.*dB)
self.dds1.init()
self.dds1.cfg_sw(True)
self.dds1.set_phase_mode(PHASE_MODE_TRACKING)
self.dds1.set_att(6.*dB)
self.dds0.set(frequency=10*MHz, phase=0.0)
self.dds1.set(frequency=10*MHz, phase=0.25) # 0.25 turns phase offset
class PulseRAM(EnvExperiment):
def build(self):
self.setattr_device("core")
self.cpld = self.get_device("urukul0_cpld")
self.dds0 = self.get_device("urukul0_ch0")
self.dds1 = self.get_device("urukul0_ch1")
def prepare(self):
self.amp = [0.0, 0.0, 0.0, 0.7, 0.0, 0.7, 0.7] # Reversed Order
self.asf_ram = [0] * len(self.amp)
@kernel
def init_dds(self, dds):
self.core.break_realtime()
dds.init()
dds.set_att(6.*dB)
dds.cfg_sw(True)
@kernel
def configure_ram_mode(self, dds):
self.core.break_realtime()
dds.set_cfr1(ram_enable=0)
self.cpld.io_update.pulse_mu(8)
self.cpld.set_profile(0) # Enable the corresponding RAM profile
# Profile 0 is the default
dds.set_profile_ram(start=0, end=len(self.asf_ram)-1,
step=250, profile=0, mode=RAM_MODE_CONT_RAMPUP)
self.cpld.io_update.pulse_mu(8)
dds.amplitude_to_ram(self.amp, self.asf_ram)
dds.write_ram(self.asf_ram)
self.core.break_realtime()
dds.set(frequency=5*MHz, ram_destination=RAM_DEST_ASF)
# Pass osk_enable=1 to set_cfr1() if it is not an amplitude RAM
dds.set_cfr1(ram_enable=1, ram_destination=RAM_DEST_ASF)
self.cpld.io_update.pulse_mu(8)
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
self.cpld.init()
self.init_dds(self.dds0)
self.configure_ram_mode(self.dds0)
class AmpRAM(PulseRAM):
def prepare(self):
# Reversed Order
self.amp = [1.0, 0.9, 0.8, 0.7, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0.0]
self.asf_ram = [0] * len(self.amp)
class SynchronizedPulseRAM(PulseRAM):
@kernel
def configure_ram_mode(self, dds):
self.core.break_realtime()
dds.set_cfr1(ram_enable=0)
self.cpld.io_update.pulse_mu(8)
self.cpld.set_profile(0) # Enable the corresponding RAM profile
# Profile 0 is the default
dds.set_profile_ram(start=0, end=len(self.asf_ram)-1,
step=250, profile=0, mode=RAM_MODE_CONT_RAMPUP)
self.cpld.io_update.pulse_mu(8)
dds.amplitude_to_ram(self.amp, self.asf_ram)
dds.write_ram(self.asf_ram)
self.core.break_realtime()
dds.set(frequency=5*MHz, phase=0.0, ram_destination=RAM_DEST_ASF)
# Pass osk_enable=1 to set_cfr1() if it is not an amplitude RAM
dds.set_cfr1(ram_enable=1, ram_destination=RAM_DEST_ASF)
self.cpld.io_update.pulse_mu(8)
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
self.cpld.init()
self.init_dds(self.dds0)
self.init_dds(self.dds1)
self.dds0.set_phase_mode(PHASE_MODE_TRACKING)
self.dds1.set_phase_mode(PHASE_MODE_TRACKING)
self.configure_ram_mode(self.dds0)
self.configure_ram_mode(self.dds1)

33
examples/suservo.py Normal file
View File

@ -0,0 +1,33 @@
from artiq.experiment import *
class SUServoExample(EnvExperiment):
def build(self):
self.setattr_device("core")
self.suservo = self.get_device("suservo0")
self.suschannel0 = self.get_device("suservo0_ch0")
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
self.suservo.init()
self.suservo.set_pgia_mu(0, 0) # unity gain
self.suservo.cplds[0].set_att(0, 15.)
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
ki=0./s, # no integrator gain
g=0., # no integrator gain limit
delay=0. # no IIR update delay after enabling
)
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.suschannel0.set(en_out=1, en_iir=1, profile=0)
self.suservo.set_config(enable=1)

52
examples/zotino.py Normal file
View File

@ -0,0 +1,52 @@
from artiq.experiment import *
from scipy import signal
import numpy
class Voltage(EnvExperiment):
def build(self):
self.setattr_device("core")
self.zotino = self.get_device("zotino0")
def prepare(self):
self.channels = [0, 1, 2, 3]
self.voltages = [1.0, 2.0, 3.0, 4.0]
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
self.zotino.init()
delay(1*ms)
self.zotino.set_dac(self.voltages, self.channels)
class TriangularWave(EnvExperiment):
def build(self):
self.setattr_device("core")
self.zotino = self.get_device("zotino0")
from scipy import signal
import numpy
def prepare(self):
self.period = 0.1*s
self.sample = 128
t = numpy.linspace(0, 1, self.sample)
self.voltages = 8*signal.sawtooth(2*numpy.pi*t, 0.5)
self.interval = self.period/self.sample
@kernel
def run(self):
self.core.reset()
self.core.break_realtime()
self.zotino.init()
delay(1*ms)
counter = 0
while True:
self.zotino.set_dac([self.voltages[counter]], [0])
counter = (counter + 1) % self.sample
delay(self.interval)