From 48eb5a5ae37a25e5743839db1e782f0146b4494f Mon Sep 17 00:00:00 2001 From: occheung Date: Thu, 20 Jan 2022 17:16:50 +0800 Subject: [PATCH] 5432: relocate examples source Updates #24. --- 5432.tex | 47 +++++++---------------------------------- examples/zotino.py | 52 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 40 deletions(-) create mode 100644 examples/zotino.py diff --git a/5432.tex b/5432.tex index 9b28e57..5a786a8 100644 --- a/5432.tex +++ b/5432.tex @@ -4,8 +4,6 @@ \usepackage{minted} \usepackage{tcolorbox} \usepackage{etoolbox} -\BeforeBeginEnvironment{minted}{\begin{tcolorbox}[colback=white]}% -\AfterEndEnvironment{minted}{\end{tcolorbox}}% \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*{\MymyLabel}[3][4cm]{\parbox{#1}{\centering #2 \\ #3}} \newcommand{\repeatfootnote}[1]{\textsuperscript{\ref{#1}}} +\newcommand{\inputcolorboxminted}[2]{% + \begin{tcolorbox}[colback=white] + \inputminted[#1, gobble=4]{python}{#2} + \end{tcolorbox} +} \begin{figure}[h] \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. Voltages of all 4 channels are updated simultaneously with the use of \texttt{set\char`_dac()}. -\begin{minted}{python} -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} +\inputcolorboxminted{firstline=11,lastline=22}{examples/zotino.py} \newpage \subsection{Triangular Wave} 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. -\begin{minted}{python} -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) -\end{minted} +\inputcolorboxminted{firstline=30,lastline=52}{examples/zotino.py} \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}. diff --git a/examples/zotino.py b/examples/zotino.py new file mode 100644 index 0000000..3033a83 --- /dev/null +++ b/examples/zotino.py @@ -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)