5432: relocate examples source

Updates #24.
nix_fix
occheung 2022-01-20 17:16:50 +08:00
parent 708330a57a
commit 48eb5a5ae3
2 changed files with 59 additions and 40 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}
@ -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}.

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)