\documentclass[10pt]{datasheet}
\usepackage{palatino}
\usepackage{textgreek}
\usepackage{minted}
\usepackage{tcolorbox}
\usepackage{etoolbox}
\BeforeBeginEnvironment{minted}{\begin{tcolorbox}[colback=white]}%
\AfterEndEnvironment{minted}{\end{tcolorbox}}%

\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\usepackage[english]{isodate}

\usepackage{graphicx}
\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{circuitikz}
\usetikzlibrary{calc}

\title{2128 SMA-TTL}
\author{M-Labs Limited}
\date{July 2021}
\revision{Revision 1}
\companylogo{\includegraphics[height=0.73in]{artiq_sinara.pdf}}

\begin{document}
\maketitle

\section{Features}

\begin{itemize}
\item{8 channels.}
\item{Input and output capable.}
\item{Galvanically isolated.}
\item{3ns minimum pulse width.}
\item{SMA connectors.}
\end{itemize}

\section{Applications}

\begin{itemize}
\item{Photon counting.}
\item{External equipment trigger.}
\item{Optical shutter control.}
\end{itemize}

\section{General Description}
The 2128 SMA-TTL card is a 4hp EEM module part of the ARTIQ Sinara family.
It adds general-purpose digital I/O capabilities to carrier cards such as 1124 Kasli and 1125 Kasli-SoC.

It provides two banks of four digital channels each, with SMA connectors.
Each bank has individual ground isolation.
The direction (input or output) of each bank can be selected using DIP switches.
Each channel supports 50\textOmega~terminations individually controllable using DIP switches.
Outputs tolerate short circuits indefinitely.
The card support a minimum pulse width of 3ns.


% Switch to next column
\vfill\break

\begin{figure}[h]
    \begin{circuitikz}[european]
        \node[op amp] (amp1) {};
        \node[op amp, below = 0.5cm, xscale = -1] (amp2) {};
        \draw (amp1.out) |- (amp2.-);
        \draw (amp2.-) ++(0, 0.3cm) node[circ]{} to +(2,0) node[above left]{5};
        \draw (amp2.out) to (amp1.+);
        \draw (amp1.+) ++(0, -0.3cm) node[circ]{} to +(-2,0) node[above right]{2};
        \draw (amp1.-) to +(-2,0) node[above right]{1};
        \draw (amp2.+) to +(2,0) node[above left]{4};
        \draw (amp1.out) +(0,0.5cm) node (Vdd) {$\mathrm{V_{DD}}$};
        \draw (Vdd.east) to +(1.5,0) node [above left]{6};
        \draw (amp2.out) +(0,-0.5cm) node (Vss) {$\mathrm{V_{SS}}$};
        \draw (Vss.west) to +(-1.6,0) node [above right]{3};
        \draw ($(amp1.north west) + (-0.5,0.5)$) rectangle ($(amp2.south west) + (0.5,-0.5)$);
    \end{circuitikz}
    \caption{Block diagram (TODO)}
\end{figure}

\begin{figure}[h]
    \includegraphics[width=1.5in]{photo2128.jpg}
    \caption{Card photo}
\end{figure}

% For wide tables, a single column layout is better. It can be switched
% page-by-page.
\onecolumn

\section{Electrical Specifications}
All specifications are in $0\degree C \leq T_A \leq 70\degree C$ unless otherwise noted.

\begin{table}[h]
\begin{threeparttable}
\caption{Recommended Operating Conditions}
\begin{tabularx}{\textwidth}{l | c | c c c | c | X}
    \thickhline
    \textbf{Parameter} & \textbf{Symbol} & \textbf{Min.} & \textbf{Typ.} & \textbf{Max.} &
    \textbf{Unit} & \textbf{Conditions} \\
    \hline
    High-level input voltage & $V_{IH}$ & 2 &  &  & V &  \\
    \hline
    Low-level input voltage & $V_{IL}$ & & & 0.8 & V & \\
    \hline
    Input clamp current & $I_{OH}$ & & & -18 & mA & termination disabled \\
    \hline
    High-level output current & $I_{OH}$ & & & -160 & mA & \\
    \hline
    Low-level output current & $I_{OL}$ & & & 376 & mA & \\
    \thickhline
\end{tabularx}
\end{threeparttable}
\end{table}

\begin{table}[h]
\begin{threeparttable}
\caption{Electrical Characteristics}
\begin{tabularx}{\textwidth}{l | c | c c c | c | X}
    \thickhline
    \textbf{Parameter} & \textbf{Symbol} & \textbf{Min.} & \textbf{Typ.} & \textbf{Max.} &
    \textbf{Unit} & \textbf{Conditions} \\
    \hline
    High-level output voltage & $V_{OH}$ & 2 &  &  & V & $I_{OH}$=-160mA \\
     &  & 2.7 &  &  & V & $I_{OH}$=-6mA \\
    \hline
    Low-level output voltage & $V_{OL}$ & & 0.42 & 0.55 & V & $I_{OL}$=188mA \\
    &  &  &  & 0.7 & V & $I_{OL}$=376mA \\
    \hline
    Pulse width distortion & $PWD$ & & 0.2 & 4.5 & ns &  \\
    \hline
    Peak jitter & $T_{JIT(PK)}$ & & 350 & & ps &  \\
    \thickhline
\end{tabularx}
\end{threeparttable}
\end{table}

\section{Example ARTIQ code}
The sections below demonstrate simple usage scenarios of the 2128 SMA-TTL card with the ARTIQ control system.
They do not exhaustively demonstrate all the features of the ARTIQ system.
The full documentation for the ARTIQ software and gateware is available at \url{https://m-labs.hk}.

Timing accuracy in the examples below is well under 1 nanosecond thanks to the ARTIQ RTIO system.

\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}

\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}

\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}

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}

\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}

\section{Ordering Information}
To order, please visit \url{https://m-labs.hk} and select the 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}.

\section*{}
\vspace*{\fill}

\begin{footnotesize}
Information furnished by M-Labs Limited is believed to be accurate and reliable. However, no responsibility is assumed by M-Labs Limited for its use, nor for any infringements of patents or other rights of third parties that may result from its use.
Specifications subject to change without notice.
\end{footnotesize}

\end{document}
