forked from sinara-hw/datasheets
ttl: factor out examples
Also, the ttl timestamp_mu method has a parameter.
This commit is contained in:
parent
611a0009af
commit
9488a03aa4
@ -4,8 +4,6 @@
|
||||
\usepackage{minted}
|
||||
\usepackage{tcolorbox}
|
||||
\usepackage{etoolbox}
|
||||
\BeforeBeginEnvironment{minted}{\begin{tcolorbox}[colback=white]}%
|
||||
\AfterEndEnvironment{minted}{\end{tcolorbox}}%
|
||||
|
||||
\usepackage[justification=centering]{caption}
|
||||
|
||||
@ -68,6 +66,11 @@ The card support a minimum pulse width of 3ns.
|
||||
\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
|
||||
@ -434,78 +437,27 @@ Timing accuracy in the examples below is well under 1 nanosecond thanks to the A
|
||||
|
||||
\subsection{One pulse per second}
|
||||
The channel should be configured as output in both the gateware and hardware.
|
||||
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
while True:
|
||||
self.ttl0.pulse(500*ms)
|
||||
delay(500*ms)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=9,lastline=15}{examples/ttl.py}
|
||||
|
||||
\newpage
|
||||
|
||||
\subsection{Morse code}
|
||||
This example demonstrates some basic algorithmic features of the ARTIQ-Python language.
|
||||
\begin{minted}{python}
|
||||
def prepare(self):
|
||||
# As of ARTIQ-6, the ARTIQ compiler has limited string handling
|
||||
# capabilities, so we pass a list of integers instead.
|
||||
message = ".- .-. - .. --.-"
|
||||
self.commands = [{".": 1, "-": 2, " ": 3}[c] for c in message]
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
for cmd in self.commands:
|
||||
if cmd == 1:
|
||||
self.led.pulse(100*ms)
|
||||
delay(100*ms)
|
||||
if cmd == 2:
|
||||
self.led.pulse(300*ms)
|
||||
delay(100*ms)
|
||||
if cmd == 3:
|
||||
delay(700*ms)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=23,lastline=40}{examples/ttl.py}
|
||||
|
||||
\subsection{Counting rising edges in a 1ms window}
|
||||
The channel should be configured as input in both the gateware and hardware.
|
||||
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
gate_end_mu = self.ttl0.gate_rising(1*ms)
|
||||
counts = self.ttl0.count()
|
||||
print(counts)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=48,lastline=53}{examples/ttl.py}
|
||||
|
||||
This example code uses the software counter, which has a maximum count rate of approximately 1 million events per second.
|
||||
If the gateware counter is enabled on the TTL channel, it can typically count up to 125 million events per second:
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
self.edgecounter0.gate_rising(1*ms)
|
||||
counts = self.edgecounter0.fetch_count()
|
||||
print(counts)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=61,lastline=66}{examples/ttl.py}
|
||||
|
||||
\newpage
|
||||
|
||||
\subsection{Responding to an external trigger}
|
||||
One channel needs to be configured as input, and the other as output.
|
||||
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
self.ttlin.gate_rising(5*ms)
|
||||
timestamp_mu = self.ttlin.timestamp_mu()
|
||||
at_mu(timestamp_mu + self.core.seconds_to_mu(10*ms))
|
||||
self.ttlout.pulse(1*us)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=75,lastline=81}{examples/ttl.py}
|
||||
|
||||
\section{Ordering Information}
|
||||
To order, please visit \url{https://m-labs.hk} and select the 2118 BNC-TTL/2128 SMA-TTL in the ARTIQ Sinara crate configuration tool. The card may also be ordered separately by writing to \url{mailto:sales@m-labs.hk}.
|
||||
|
68
2238.tex
68
2238.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 @@ This card can achieve higher speed and lower jitter than the isolated 2118/2128
|
||||
|
||||
\newcommand*{\MyLabel}[3][2cm]{\parbox{#1}{\centering #2 \\ #3}}
|
||||
\newcommand*{\MymyLabel}[3][4cm]{\parbox{#1}{\centering #2 \\ #3}}
|
||||
\newcommand{\inputcolorboxminted}[2]{%
|
||||
\begin{tcolorbox}[colback=white]
|
||||
\inputminted[#1, gobble=4]{python}{#2}
|
||||
\end{tcolorbox}
|
||||
}
|
||||
|
||||
\begin{figure}[h]
|
||||
\centering
|
||||
@ -560,75 +563,24 @@ Timing accuracy in the examples below is well under 1 nanosecond thanks to the A
|
||||
|
||||
\subsection{One pulse per second}
|
||||
The channel should be configured as output in both the gateware and hardware.
|
||||
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
while True:
|
||||
self.ttl0.pulse(500*ms)
|
||||
delay(500*ms)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=9,lastline=15}{examples/ttl.py}
|
||||
|
||||
\subsection{Morse code}
|
||||
This example demonstrates some basic algorithmic features of the ARTIQ-Python language.
|
||||
\begin{minted}{python}
|
||||
def prepare(self):
|
||||
# As of ARTIQ-6, the ARTIQ compiler has limited string handling
|
||||
# capabilities, so we pass a list of integers instead.
|
||||
message = ".- .-. - .. --.-"
|
||||
self.commands = [{".": 1, "-": 2, " ": 3}[c] for c in message]
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
for cmd in self.commands:
|
||||
if cmd == 1:
|
||||
self.led.pulse(100*ms)
|
||||
delay(100*ms)
|
||||
if cmd == 2:
|
||||
self.led.pulse(300*ms)
|
||||
delay(100*ms)
|
||||
if cmd == 3:
|
||||
delay(700*ms)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=23,lastline=40}{examples/ttl.py}
|
||||
|
||||
\newpage
|
||||
\subsection{Counting rising edges in a 1ms window}
|
||||
The channel should be configured as input in both the gateware and hardware.
|
||||
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
gate_end_mu = self.ttl0.gate_rising(1*ms)
|
||||
counts = self.ttl0.count()
|
||||
print(counts)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=48,lastline=53}{examples/ttl.py}
|
||||
|
||||
This example code uses the software counter, which has a maximum count rate of approximately 1 million events per second.
|
||||
If the gateware counter is enabled on the TTL channel, it can typically count up to 125 million events per second:
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
self.edgecounter0.gate_rising(1*ms)
|
||||
counts = self.edgecounter0.fetch_count()
|
||||
print(counts)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=61,lastline=66}{examples/ttl.py}
|
||||
|
||||
\subsection{Responding to an external trigger}
|
||||
One channel needs to be configured as input, and the other as output.
|
||||
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
self.ttlin.gate_rising(5*ms)
|
||||
timestamp_mu = self.ttlin.timestamp_mu()
|
||||
at_mu(timestamp_mu + self.core.seconds_to_mu(10*ms))
|
||||
self.ttlout.pulse(1*us)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=75,lastline=81}{examples/ttl.py}
|
||||
|
||||
\section{Ordering Information}
|
||||
To order, please visit \url{https://m-labs.hk} and select the 2238 MCX-TTL in the ARTIQ Sinara crate configuration tool. The card may also be ordered separately by writing to \url{mailto:sales@m-labs.hk}.
|
||||
|
69
2245.tex
69
2245.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}
|
||||
|
||||
@ -69,6 +67,11 @@ Only shielded Ethernet Cat-6 cables should be connected.
|
||||
|
||||
\newcommand*{\MyLabel}[3][2cm]{\parbox{#1}{\centering #2 \\ #3}}
|
||||
\newcommand*{\MymyLabel}[3][4cm]{\parbox{#1}{\centering #2 \\ #3}}
|
||||
\newcommand{\inputcolorboxminted}[2]{%
|
||||
\begin{tcolorbox}[colback=white]
|
||||
\inputminted[#1, gobble=4]{python}{#2}
|
||||
\end{tcolorbox}
|
||||
}
|
||||
|
||||
\begin{figure}[h]
|
||||
\centering
|
||||
@ -466,76 +469,24 @@ Timing accuracy in the examples below is well under 1 nanosecond thanks to the A
|
||||
|
||||
\subsection{One pulse per second}
|
||||
The channel should be configured as output in both the gateware and hardware.
|
||||
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
while True:
|
||||
self.ttl0.pulse(500*ms)
|
||||
delay(500*ms)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=9,lastline=15}{examples/ttl.py}
|
||||
|
||||
\subsection{Morse code}
|
||||
This example demonstrates some basic algorithmic features of the ARTIQ-Python language.
|
||||
\begin{minted}{python}
|
||||
def prepare(self):
|
||||
# As of ARTIQ-6, the ARTIQ compiler has limited string handling
|
||||
# capabilities, so we pass a list of integers instead.
|
||||
message = ".- .-. - .. --.-"
|
||||
self.commands = [{".": 1, "-": 2, " ": 3}[c] for c in message]
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
for cmd in self.commands:
|
||||
if cmd == 1:
|
||||
self.led.pulse(100*ms)
|
||||
delay(100*ms)
|
||||
if cmd == 2:
|
||||
self.led.pulse(300*ms)
|
||||
delay(100*ms)
|
||||
if cmd == 3:
|
||||
delay(700*ms)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=23,lastline=40}{examples/ttl.py}
|
||||
|
||||
\newpage
|
||||
|
||||
\subsection{Counting rising edges in a 1ms window}
|
||||
The channel should be configured as input in both the gateware and hardware.
|
||||
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
gate_end_mu = self.ttl0.gate_rising(1*ms)
|
||||
counts = self.ttl0.count()
|
||||
print(counts)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=48,lastline=53}{examples/ttl.py}
|
||||
|
||||
This example code uses the software counter, which has a maximum count rate of approximately 1 million events per second.
|
||||
If the gateware counter is enabled on the TTL channel, it can typically count up to 125 million events per second:
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
self.edgecounter0.gate_rising(1*ms)
|
||||
counts = self.edgecounter0.fetch_count()
|
||||
print(counts)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=61,lastline=66}{examples/ttl.py}
|
||||
|
||||
\subsection{Responding to an external trigger}
|
||||
One channel needs to be configured as input, and the other as output.
|
||||
|
||||
\begin{minted}{python}
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
self.ttlin.gate_rising(5*ms)
|
||||
timestamp_mu = self.ttlin.timestamp_mu()
|
||||
at_mu(timestamp_mu + self.core.seconds_to_mu(10*ms))
|
||||
self.ttlout.pulse(1*us)
|
||||
\end{minted}
|
||||
\inputcolorboxminted{firstline=75,lastline=81}{examples/ttl.py}
|
||||
|
||||
\section{Ordering Information}
|
||||
To order, please visit \url{https://m-labs.hk} and select the 2245 LVDS-TTL in the ARTIQ Sinara crate configuration tool. The card may also be ordered separately by writing to \url{mailto:sales@m-labs.hk}.
|
||||
|
81
examples/ttl.py
Normal file
81
examples/ttl.py
Normal file
@ -0,0 +1,81 @@
|
||||
from artiq.experiment import *
|
||||
|
||||
|
||||
class OnePulsePerSecond(EnvExperiment):
|
||||
def build(self):
|
||||
self.setattr_device("core")
|
||||
self.ttl0 = self.get_device("ttl0")
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
self.core.break_realtime()
|
||||
while True:
|
||||
self.ttl0.pulse(500*ms)
|
||||
delay(500*ms)
|
||||
|
||||
|
||||
class MorseCode(EnvExperiment):
|
||||
def build(self):
|
||||
self.setattr_device("core")
|
||||
self.led = self.get_device("led0")
|
||||
|
||||
def prepare(self):
|
||||
# As of ARTIQ-6, the ARTIQ compiler has limited string handling
|
||||
# capabilities, so we pass a list of integers instead.
|
||||
message = ".- .-. - .. --.-"
|
||||
self.commands = [{".": 1, "-": 2, " ": 3}[c] for c in message]
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
for cmd in self.commands:
|
||||
if cmd == 1:
|
||||
self.led.pulse(100*ms)
|
||||
delay(100*ms)
|
||||
if cmd == 2:
|
||||
self.led.pulse(300*ms)
|
||||
delay(100*ms)
|
||||
if cmd == 3:
|
||||
delay(700*ms)
|
||||
|
||||
|
||||
class SoftwareEdgeCount(EnvExperiment):
|
||||
def build(self):
|
||||
self.setattr_device("core")
|
||||
self.ttl0 = self.get_device("ttl0")
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
gate_end_mu = self.ttl0.gate_rising(1*ms)
|
||||
counts = self.ttl0.count(gate_end_mu)
|
||||
print(counts)
|
||||
|
||||
|
||||
class EdgeCounter(EnvExperiment):
|
||||
def build(self):
|
||||
self.setattr_device("core")
|
||||
self.edgecounter0 = self.get_device("ttl0_counter")
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
self.edgecounter0.gate_rising(1*ms)
|
||||
counts = self.edgecounter0.fetch_count()
|
||||
print(counts)
|
||||
|
||||
|
||||
class ExternalTrigger(EnvExperiment):
|
||||
def build(self):
|
||||
self.setattr_device("core")
|
||||
self.ttlin = self.get_device("ttl0")
|
||||
self.ttlout = self.get_device("ttl4")
|
||||
|
||||
@kernel
|
||||
def run(self):
|
||||
self.core.reset()
|
||||
gate_end_mu = self.ttlin.gate_rising(5*ms)
|
||||
timestamp_mu = self.ttlin.timestamp_mu(gate_end_mu)
|
||||
at_mu(timestamp_mu + self.core.seconds_to_mu(10*ms))
|
||||
self.ttlout.pulse(1*us)
|
Loading…
Reference in New Issue
Block a user