\documentclass[10pt]{datasheet}
\usepackage{palatino}
\usepackage{textgreek}
\usepackage{minted}
\usepackage{tcolorbox}
\usepackage{etoolbox}

\usepackage[justification=centering]{caption}

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

\usepackage{graphicx}
\usepackage{subfigure}

\usepackage{tikz}
\usepackage{pgfplots}
\usepackage{circuitikz}
\usetikzlibrary{calc}
\usetikzlibrary{fit,backgrounds} 

\title{5108 Sampler}
\author{M-Labs Limited}
\date{January 2022}
\revision{Revision 1}
\companylogo{\includegraphics[height=0.73in]{artiq_sinara.pdf}}

\begin{document}
\maketitle

\section{Features}

\begin{itemize}
\item{8-channel ADC.}
\item{16-bits resolution.}
\item{1.5 MSPS simultaneously on all channels.}
\item{Full scale input voltage $\pm$10mV to $\pm$10V.}
\item{BNC connector.}
\end{itemize}

\section{Applications}

\begin{itemize}
\item{Sample intermediate-frequency (IF) waveform.}
\item{Monitor laser power with a photodiode.}
\item{Synchronize laser frequencies with a phase frequency detector.}
\item{Form a laser intensity servo with 4410 Urukul.}
\end{itemize}

\section{General Description}
The 5108 Sampler is a 8hp EEM module part of the ARTIQ Sinara family.
It adds analog-digital converting capabilities to carrier cards such as 1124 Kasli and 1125 Kasli-SoC.

It provides 8 analog-to-digital channels, each exposed by a BNC connector.
Each channel supports input voltage ranges from \textpm 10mV to \textpm 10V.
All channels can be sampled simultaneously.

5108 Sampler provides a sample rate of 1.5 MSPS.
However, the sample rate in practice is typically limited by the use of ARTIQ-Python kernel code.

% Switch to next column
\vfill\break

\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
    \scalebox{1}{
    \begin{circuitikz}[european, scale=0.95, every label/.append style={align=center}]

        % Node to pin-point the locations of BNC symbols
        \draw[color=white, text=black] (-0.1, 1.225) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (bnc0) {};
        \draw[color=white, text=black] (-0.1, 0.875) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (bnc1) {};
        \draw[color=white, text=black] (-0.1, 0.525) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (bnc2) {};
        \draw[color=white, text=black] (-0.1, 0.175) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (bnc3) {};

        \draw[color=white, text=black] (-0.1, -0.175) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (bnc4) {};
        \draw[color=white, text=black] (-0.1, -0.525) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (bnc5) {};
        \draw[color=white, text=black] (-0.1, -0.875) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (bnc6) {};
        \draw[color=white, text=black] (-0.1, -1.225) node[twoportshape, circuitikz/bipoles/twoport/width=1.2, scale=0.4 ] (bnc7) {};

        % Labels for BNC 0-7
        \node [label=left:\tiny{IN 0}] at (0.35, 1.225) {};
        \node [label=left:\tiny{IN 1}] at (0.35, 0.875) {};
        \node [label=left:\tiny{IN 2}] at (0.35, 0.525) {};
        \node [label=left:\tiny{IN 3}] at (0.35, 0.175) {};
        \node [label=left:\tiny{IN 4}] at (0.35, -0.175) {};
        \node [label=left:\tiny{IN 5}] at (0.35, -0.525) {};
        \node [label=left:\tiny{IN 6}] at (0.35, -0.875) {};
        \node [label=left:\tiny{IN 7}] at (0.35, -1.225) {};

        % draw BNC 0-7
        \begin{scope}[scale=0.07 , rotate=-90, xshift=2.5cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=7.5cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=12.5cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=17.5cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=-2.5cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=-7.5cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=-12.5cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}
        \begin{scope}[scale=0.07 , rotate=-90, xshift=-17.5cm, yshift=2cm]
            \draw (0,0.65) -- (0,3);
            \clip (-1.5,0) rectangle (1.5,1.5);
            \draw (0,0) circle(1.5);
            \clip (-0.8,0) rectangle (0.8,0.8);
            \draw (0,0) circle(0.8);
        \end{scope}

        % Draw termination switches
        \draw (1.0, 1.925) node[twoportshape,t=\MymyLabel{100k/50\textOmega}{Switch \phantom{s} x8}, circuitikz/bipoles/twoport/width=1.5, scale=0.5] (termswitch) {};
        \begin{scope}[xshift=1.2cm, yshift=1.925cm, scale=0.12, every node/.style={scale=0.1}, rotate=-90 ]
            \draw (0.4,0) to[short,-o](0.75,0);
            \draw (0.78,0)-- +(30:0.46);
            \draw (1.25,0)to[short,o-](1.6,0)   ;   
        \end{scope}

        % Draw PGIAs
        % The connections are too complicated for the usual buffer/op-amp symbol
        \draw (3, 2.45) node[twoportshape,t=\MymyLabel{CH 0}{PGIA}, circuitikz/bipoles/twoport/width=1.2, scale=0.5] (pgia0) {};
        \draw (3, 1.75) node[twoportshape,t=\MymyLabel{CH 1}{PGIA}, circuitikz/bipoles/twoport/width=1.2, scale=0.5] (pgia1) {};
        \draw (3, 1.05) node[twoportshape,t=\MymyLabel{CH 2}{PGIA}, circuitikz/bipoles/twoport/width=1.2, scale=0.5] (pgia2) {};
        \draw (3, 0.35) node[twoportshape,t=\MymyLabel{CH 3}{PGIA}, circuitikz/bipoles/twoport/width=1.2, scale=0.5] (pgia3) {};
        \draw (3, -0.35) node[twoportshape,t=\MymyLabel{CH 4}{PGIA}, circuitikz/bipoles/twoport/width=1.2, scale=0.5] (pgia4) {};
        \draw (3, -1.05) node[twoportshape,t=\MymyLabel{CH 5}{PGIA}, circuitikz/bipoles/twoport/width=1.2, scale=0.5] (pgia5) {};
        \draw (3, -1.75) node[twoportshape,t=\MymyLabel{CH 6}{PGIA}, circuitikz/bipoles/twoport/width=1.2, scale=0.5] (pgia6) {};
        \draw (3, -2.45) node[twoportshape,t=\MymyLabel{CH 7}{PGIA}, circuitikz/bipoles/twoport/width=1.2, scale=0.5] (pgia7) {};

        % Drop termination connection to input lines
        \draw [-] (0.65, 1.675) -- (0.65, 1.225);
        \draw [-] (0.75, 1.675) -- (0.75, 0.875);
        \draw [-] (0.85, 1.675) -- (0.85, 0.525);
        \draw [-] (0.95, 1.675) -- (0.95, 0.175);
        \draw [-] (1.05, 1.675) -- (1.05, -0.175);
        \draw [-] (1.15, 1.675) -- (1.15, -0.525);
        \draw [-] (1.25, 1.675) -- (1.25, -0.875);
        \draw [-] (1.35, 1.675) -- (1.35, -1.225);

        % Connect BNC to PGIA, with termination line
        \draw [-latexslim] (bnc0.east) -- (1.9, 1.225) -- (1.9, 2.45) -- (pgia0.west);
        \draw [-latexslim] (bnc1.east) -- (2, 0.875) -- (2, 1.75) -- (pgia1.west);
        \draw [-latexslim] (bnc2.east) -- (2.1, 0.525) -- (2.1, 1.05) -- (pgia2.west);
        \draw [-latexslim] (bnc3.east) -- (2.2, 0.175) -- (2.2, 0.35) -- (pgia3.west);
        \draw [-latexslim] (bnc4.east) -- (2.2, -0.175) -- (2.2, -0.35) -- (pgia4.west);
        \draw [-latexslim] (bnc5.east) -- (2.1, -0.525) -- (2.1, -1.05) -- (pgia5.west);
        \draw [-latexslim] (bnc6.east) -- (2, -0.875) -- (2, -1.75) -- (pgia6.west);
        \draw [-latexslim] (bnc7.east) -- (1.9, -1.225) -- (1.9, -2.45) -- (pgia7.west);

        % Draw shift register & ADC
        \draw (4.7, 1) node[twoportshape,t=\MymyLabel{Shift}{Registers}, circuitikz/bipoles/twoport/width=1.6, scale=0.6, rotate=-90] (sr) {};
        \draw (4.7, -1) node[twoportshape,t={ADC}, circuitikz/bipoles/twoport/width=1.6, scale=0.6, rotate=-90] (adc) {};

        % Connect PGIA -> ADC paths
        \draw [-] (3.45, 2.55) -- (4, 2.55) -- (4, -1);
        \draw [-] (3.45, -2.35) -- (4, -2.35) -- (4, -1);
        \draw [-] (3.45, 1.85) -- ++ (0.55, 0);
        \draw [-] (3.45, 1.15) -- ++ (0.55, 0);
        \draw [-] (3.45, 0.45) -- ++ (0.55, 0);
        \draw [-] (3.45, -0.25) -- ++ (0.55, 0);
        \draw [-latexslim] (3.45, -0.95) -- ++ (0.95, 0);
        \draw [-] (3.45, -1.65) -- ++ (0.55, 0);

        % Connect SR -> PGIA paths
        \draw [latexslim-] (3.45, 2.35) -- (3.8, 2.35) -- (3.8, 1);
        \draw [latexslim-] (3.45, -2.55) -- (3.8, -2.55) -- (3.8, 1);
        \draw [latexslim-] (3.45, 1.65) -- ++ (0.35, 0);
        \draw [latexslim-] (3.45, 0.95) -- ++ (0.95, 0);
        \draw [latexslim-] (3.45, 0.25) -- ++ (0.35, 0);
        \draw [latexslim-] (3.45, -0.45) -- ++ (0.35, 0);
        \draw [latexslim-] (3.45, -1.15) -- ++ (0.35, 0);
        \draw [latexslim-] (3.45, -1.85) -- ++ (0.35, 0);

        % Draw LVDS transceivers & repeaters
        \draw (6.3, 1) node[twoportshape,t=\MymyLabel{LVDS}{Transceivers}, circuitikz/bipoles/twoport/width=1.8, scale=0.6, rotate=-90] (lvds) {};
        \draw (6.3, -1) node[twoportshape,t={Repeaters}, circuitikz/bipoles/twoport/width=1.8, scale=0.6, rotate=-90] (rep) {};

        % ADC & SR connection lines
        % Note: MISO line from shift register ignored, the repeater is omiited in some versions
        % Also, that MISO line does not do anything useful. The ARTIQ driver implementation is just a huge data integrity check.
        \draw [-latexslim] (6, 1.2) -- (5, 1.2);
        \draw [-latexslim] (6, 0.8) -- (5.5, 0.8) -- (5.5, -0.8) -- (5, -0.8);
        % Data comes out of the ADC, the only signal that goes in is the clock
        \draw [-latexslim] (5, -1.2) -- (6, -1.2);

        % Draw EEPROMs
        \draw (6, 2.35) node[twoportshape,t={EEPROM}, circuitikz/bipoles/twoport/width=1.4, scale=0.6] (eeprom0) {};
        \draw (6.3, -2.6) node[twoportshape,t={EEPROM}, circuitikz/bipoles/twoport/width=1.4, scale=0.6, rotate=-90] (eeprom1) {};

        % Draw EEM 0 & 1
        \draw (7.9, 1.9) node[twoportshape,t={EEM Port 0}, circuitikz/bipoles/twoport/width=3.4, scale=0.6, rotate=-90] (eem0) {};
        \draw (7.9, -1.9) node[twoportshape,t={EEM Port 1}, circuitikz/bipoles/twoport/width=2.6, scale=0.6, rotate=-90] (eem1) {};

        % Connect EEM Port 1
        \draw [-latexslim] (6.6, -1.2) -- (7.6, -1.2);
        \draw [latexslim-latexslim] (eeprom1.north) -- (7.6, -2.6);

        % Connect EEM Port 0
        \draw [-latexslim] (6.6, -0.8) -- (7.1, -0.8) -- (7.1, 0.8) -- (7.6, 0.8);
        \draw [latexslim-] (6.6, 1.2) -- (7.6, 1.2);
        \draw [latexslim-latexslim] (eeprom0.east) -- (7.6, 2.35);

        % Draw IO Expander
        \draw (3, 3.15) node[twoportshape,t={IO Expander}, circuitikz/bipoles/twoport/width=1.8, scale=0.5] (i2c) {};

        % Connect IO Expander
        \draw [-latexslim] (termswitch.north) -- (1, 3.15) -- (i2c.west);
        \draw [-latexslim] (i2c.east) -- (7.6, 3.15);

        % Stress that the termination status I2C interface is read-only
        \node [label=center:\tiny{Read Only}] at (1.6, 3.25) {};

        % State that PGIA stands for "Programmable Gain Instrumentation Amplifier"
        % The name is too long, and there isn't any good places to mention this
        \node [label=center:\tiny{Note: PGIA = Programmable Gain Instrumentation Amplifier}] at (3, -3) {};

    \end{circuitikz}
    }

    \caption{Simplified Block Diagram}
\end{figure}

\begin{figure}[h]
    \centering
    \includegraphics[height=1.9in]{Sampler_FP.jpg}
    \includegraphics[height=1.9in]{photo5108.jpg}
    \caption{Sampler Card photo}
\end{figure}

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

\section{Electrical Specifications}

\begin{table}[h]
\centering
\begin{threeparttable}
\caption{Input Specifications}
\begin{tabularx}{0.9\textwidth}{l | c c c | c | X}
    \thickhline
    \textbf{Parameter} & \textbf{Min.} & \textbf{Typ.} & \textbf{Max.} &
    \textbf{Unit} & \textbf{Conditions} \\
    \hline
    Input voltage & -10 & & 10 & V & 1x gain, termination off* \\
     & -1 & & 1 & V & 10x gain\\
     & -100 & & 100 & mV & 100x gain\\
     & -10 & & 10 & mV & 1000x gain\\
    \hline
    DC Input signal impedance & \multicolumn{4}{c|}{100 k$\Omega$} & Termination off\\
     & \multicolumn{4}{c|}{50 $\Omega$} & Termination on\\
    \hline
    Resolution &\multicolumn{4}{c|}{16 bits}& \\
    \thickhline
    \multicolumn{6}{l}{*At 1x gain with 50\textOmega~termination enabled, the input voltage magnitude must not exceed 5V.}
\end{tabularx}
\end{threeparttable}
\end{table}


The electrical characteristics are based on various test results\footnote{\label{sinara226}https://github.com/sinara-hw/sinara/issues/226}\textsuperscript{,}
\footnote{\label{sinara489}https://github.com/sinara-hw/sinara/issues/489}\textsuperscript{,}
\footnote{\label{sampler2}https://github.com/sinara-hw/Sampler/issues/2}.

\begin{table}[hbt!]
\centering
\begin{threeparttable}
\caption{Electrical Characteristics}
\begin{tabularx}{\textwidth}{l | c c c | c | X}
    \thickhline
    \textbf{Parameter} & \textbf{Min.} & \textbf{Typ.} & \textbf{Max.} &
    \textbf{Unit} & \textbf{Conditions / Comments} \\
    \hline
    % Github wiki page info regarding BW is outdated, so only coarse estimate here
    % There is an updated plot for this. See the plots.
    -6dB bandwidth\repeatfootnote{sampler2} & & & & & See bandwidth plots \\
     & & 200 & & kHz & 1x/10x/100x gain \\
     & & 90 & & kHz & 1000x gain \\
    \hline
    Noise\repeatfootnote{sampler2} & & & & & 83.33 kHz sampling rate \\
    \hspace{18mm} 1x gain & & 1.78 & & LSB & Termination on \\
    & & 1.75 & & LSB & Termination off \\
    \hspace{18mm} 10x gain & & 1.84 & & LSB & Termination on \\
    & & 3.09 & & LSB & Termination off \\
    \hspace{18mm} 100x gain & & 3.47 & & LSB & Termination on \\
    & & 26.02 & & LSB & Termination off \\
    \hspace{18mm} 1000x gain & & 13.87 & & LSB & Termination on \\
    & & 206.3 & & LSB & Termination off \\
    % \hline
    DC cross-talk\repeatfootnote{sinara226} & & & -96 & dB & 1x gain\\
    \hline
    % AC cross-talk data on wiki is also outdated (when it was still novo)
    % sinara-hw/sinara #489 is a better source of info
    % But it seems that AC-XT is not channel-invariant
    % So it is tabulated instead.
    Second-order harmonics\repeatfootnote{sinara226} & & & & & 25 kHz input, termination on, 1x gain \\
    & & -51 & & dBc & 0.1 V\textsubscript{pp} (-48dBFS), limited by ADC (-100dBFS) \\
    & & -69 & & dBc & 1 V\textsubscript{pp} (-28dBFS) \\
    & & -58.8 & & dBc & 10 V\textsubscript{pp} (-8dBFS) \\
    \thickhline
\end{tabularx}
\end{threeparttable}
\end{table}

\newpage

\begin{table}[h]
\begin{threeparttable}
\caption{Electrical Characteristics (cont.)}
\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 / Comments} \\
    \hline
    Common-mode rejection ratio\repeatfootnote{sinara226} & CMRR & & & & & 2 V\textsubscript{pp} sine wave as CM input, termination on\\
    \hspace{12mm} 1x gain & & & & -98 & dB & $f=0.01,0.1,1$ kHz \\
    & & & -87 & & dB & $f=10$ kHz \\
    & & & -55 & & dB & $f=100$ kHz \\
    & & & -83 & & dB & $f=1$ MHz \\
    & & & -85 & & dB & $f=10$ MHz \\
    \cline{3-7}
    \hspace{12mm} 100x gain & & & & -118 & dB & $f=0.01$ kHz \\
    & & & -98 & & dB & $f=0.1$ kHz \\
    & & & -88 & & dB & $f=1$ kHz \\
    & & & -70 & & dB & $f=10$ kHz \\
    & & & -50 & & dB & $f=100$ kHz \\
    & & & -80 & & dB & $f=1$ MHz \\
    & & & & -118 & dB & $f=10$ MHz \\
    \thickhline
\end{tabularx}
\end{threeparttable}
\end{table}

\newpage

Crosstalk between ADC channels of 5108 Sampler is shown below\repeatfootnote{sinara489}.

A 10 V\textsubscript{pp} signal is the input.
The aggressor channel always has 1x gain.
All channels have 50 \textOmega~termination enabled.

Data is acquired by taking 512 samples at 80 kHz sampling rate 20 times to average out the FFT.

\newcolumntype{Y}{>{\centering\arraybackslash}X}

\begin{table}[h]
\begin{threeparttable}
\caption{Crosstalk with 35 kHz input frequency, 1000x gain on victim}
\begin{tabularx}{\textwidth}{| c | Y | Y | Y | Y | Y | Y | Y | Y |}
    \thickhline
    \multirow{2}{*}{\textbf{Aggressor}} &
    \multicolumn{8}{c|}{\textbf{Crosstalk (dB) on Victim Channels}}\\
    \cline{2-9} & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\
    \hline
    Channel 0 & 0.00 &  -114.90 &  -129.35 &  -131.54 &  -132.19 &  -142.56 &  -145.39 &  -159.98 \\
    \thickhline
\end{tabularx}
\end{threeparttable}
\end{table}

\begin{figure}[hbt!]
    \centering
    \includegraphics[width=\textwidth]{sampler_xt_35khz.png}
    \caption{Crosstalk with 35 kHz input frequency, 1000x gain on victim, channel 0 as the aggressor}
\end{figure}

\begin{table}[hbt!]
\begin{threeparttable}
\caption{Crosstalk with 300 kHz input frequency, 1000x gain on victim}
\begin{tabularx}{\textwidth}{| c | Y | Y | Y | Y | Y | Y | Y | Y |}
    \thickhline
    \multirow{2}{*}{\textbf{Aggressor}} &
    \multicolumn{8}{c|}{\textbf{Crosstalk (dB) on Victim Channels}}\\
    \cline{2-9} & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\
    \hline
    Channel 0 & 0.00 &  -109.18 &  -123.94 &  -128.46 &  -131.11 &  -134.45 &  -135.62 &  -158.51 \\
    \hline
    Channel 1 & -112.90 &  0.00 &  -114.98 &  -124.11 &  -131.40 &  -142.61 &  -145.94 &  -168.51 \\
    \hline
    Channel 2 & -123.27 &  -112.58 &  0.00 &  -111.17 &  -121.46 &  -129.97 &  -137.31 &  -163.77 \\
    \hline
    Channel 3 & -140.61 &  -125.20 &  -114.49 &  0.00 &  -111.84 &  -125.10 &  -133.74 &  -164.55 \\
    \hline
    Channel 4 & -140.12 &  -131.07 &  -124.30 &  -112.65 &  0.00 &  -109.22 &  -124.71 &  -160.22 \\
    \hline
    Channel 5 & -140.33 &  -135.77 &  -134.42 &  -126.34 &  -116.35 &  0.00 &  -118.40 &  -156.63 \\
    \hline
    Channel 6 & -142.39 &  -139.25 &  -138.51 &  -134.73 &  -125.00 &  -108.91 &  0.00 &  -146.29 \\
    \hline
    Channel 7 & -145.06 &  -138.97 &  -144.31 &  -139.50 &  -135.50 &  -120.62 &  -114.28 &  0.00 \\
    \thickhline
\end{tabularx}
\end{threeparttable}
\end{table}

\newpage

% The plots are quite small given that it is 8-plots-in-1, but the numbers should give a better picture
\begin{figure}[hbt!]
    \centering
    \includegraphics[width=\textwidth]{sampler_xt_300khz.png}
    \caption{Crosstalk with 300 kHz input frequency, 1000x gain on victim, channel 0 as the aggressor}
\end{figure}

\begin{table}[hbt!]
\begin{threeparttable}
\caption{Crosstalk with 300 kHz input frequency, 1x gain on victim}
\begin{tabularx}{\textwidth}{| c | Y | Y | Y | Y | Y | Y | Y | Y |}
    \thickhline
    \multirow{2}{*}{\textbf{Aggressor}} &
    \multicolumn{8}{c|}{\textbf{Crosstalk (dB) on Victim Channels}}\\
    \cline{2-9} & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\
    \hline
    Channel 0 & 0.00 & -84.36 & -100.65 & -100.16 & -102.72 & -93.51 & -96.23 & -105.70 \\
    \hline
    Channel 1 & -91.95 & 0.00 & -87.47 & -104.87 & -115.80 & -99.91 & -101.55 & -106.71 \\
    \hline
    Channel 2 & -109.04 & -86.28 & 0.00 & -88.78 & -96.81 & -95.41 & -108.53 & -109.23 \\
    \hline
    Channel 3 & -101.31 & -97.47 & -92.72 & 0.00 & -88.65 & -96.58 & -100.80 & -97.46 \\
    \hline
    Channel 4 & -101.27 & -95.18 & -97.16 & -88.29 & 0.00 & -87.26 & -99.11 & -100.12 \\
    \hline
    Channel 5 & -103.41 & -102.10 & -101.54 & -104.59 & -99.87 & 0.00 & -89.34 & -102.49 \\
    \hline
    Channel 6 & -104.62 & -104.64 & -103.39 & -101.73 & -104.08 & -87.61 & 0.00 & -88.34 \\
    \hline
    Channel 7 & -100.67 & -99.20 & -97.34 & -95.48 & -102.93 & -113.76 & -92.80 & 0.00 \\
    \thickhline
\end{tabularx}
\end{threeparttable}
\end{table}

\newpage

\begin{figure}[hbt!]
    \centering
    \includegraphics[width=\textwidth]{sampler_xt_300khz_1x_gain.png}
    \caption{Crosstalk with 300 kHz input frequency, 1x gain on victim, channel 3 as the aggressor}
\end{figure}

Noise density is measured using the following configuration\repeatfootnote{sampler2}:
\begin{enumerate}
    \item 1/12\textmu s sampling rate
    \item 10k samples per measurement, averaging over 100 measurements
    \item Measured at channels 6 \& 7. Channel 6 has the 50\textOmega~termination on, channel 7 has it off
\end{enumerate}
Noise density with respect to different gain settings with termination on/off are plotted below.

\begin{multicols}{2}

\begin{figure}[H]
    \includegraphics[width=3.3in]{sampler_noise_term.png}
    \caption{Noise density with termination enabled}
\end{figure}

\columnbreak

\begin{figure}[H]
    \includegraphics[width=3.3in]{sampler_noise_no_term.png}
    \caption{Noise density with termination disabled}
\end{figure}

\end{multicols}

\newpage

Bandwidth of small signal and large signal input is shown below\repeatfootnote{sampler2}. The setup is as the following:
\begin{enumerate}
    \itemsep0em
    \item 10k samples, sampled at 79.37 kHz
    \item Driven by sinusoid from Keysight 33500B generator; Sampled using channel 7 without termination
    \item Small signal measured using 2V\textsubscript{pp}/gain; Large signal measured using 15V\textsubscript{pp}/gain
\end{enumerate}
\begin{multicols}{2}

\begin{figure}[H]
    \includegraphics[width=3.3in]{sampler_small_signal_bw.png}
    \caption{Small signal bandwidth}
\end{figure}

\columnbreak

\begin{figure}[H]
    \includegraphics[width=3.3in]{sampler_large_signal_bw.png}
    \caption{Large signal bandwidth}
\end{figure}

\end{multicols}

\newpage

\section{Front Panel Drawings}
\begin{multicols}{2}

\begin{center}
    \centering
    \includegraphics[height=2.7in]{sampler_drawings.pdf}
    \captionof{figure}{5108 Sampler front panel drawings}
\end{center}

\columnbreak

\begin{center}
    \centering
    \includegraphics[height=2.7in]{sampler_assembly.pdf}
    \captionof{figure}{5108 Sampler front panel assembly}
\end{center}

\end{multicols}

\begin{multicols}{2}
\begin{center}
    \captionof{table}{Bill of Material (Standalone)}
    \tiny
    \begin{tabular}{|c|c|c|c|}
    \hline
    Index & Part No. & Qty & Description \\ \hline
    1 & 90504202 & 1 & FP-FRONT PANEL, EXTRUDED, TYPE 2, STATIC, 3Ux8HP \\ \hline
    2 & 3218843 & 2 & FP-ALIGNMENT PIN (LOCALIZATION) \\ \hline
    3 & 3020716 & 0.04 & SLEEVE GREY PLAS.M2.5 (100PCS) \\ \hline
    \end{tabular}
\end{center}
\columnbreak
\begin{center}
    \captionof{table}{Bill of Material (Assembled)}
    \tiny
    \begin{tabular}{|c|c|c|c|}
    \hline
    Index & Part No. & Qty & Description \\ \hline
    1 & 90504202 & 1 & FP-LYKJ 3U4HP PANEL \\ \hline
    2 & 3033098 & 0.04 & SCREW COLLAR M2.5X12.3 (100X) \\ \hline
    3 & 3040138 & 2 & PB HOLDER DIE-CAST \\ \hline
    4 & 3001012 & 2 & SCR M2.5*6 PAN PHL NI DIN7985 \\ \hline
    5 & 3010110 & 0.02 & WASHER PLN.M2.7 DIN125 (100X) \\ \hline
    6 & 3201099 & 0.01 & SCR M2.5*8 OVL PHL ST NI 100EA \\ \hline
    7 & 3040005 & 1 & HANDLE 8HP GREY PLASTIC \\ \hline
    8 & 3207076 & 0.01 & SCR M2.5*12 PAN 100 21101-222 \\ \hline
    9 & 3201130 & 0.01 & NUT M2.5 HEX ST NI KIT (100PCS) \\ \hline
    10 & 3211232 & 1 & SCR M2.5*14 PAN PHL SS \\ \hline
    \end{tabular}
\end{center}
\end{multicols}

\section{Configuring Termination}
\begin{multicols}{2}
The input termination can be configured by switches.
The per-channel termination switches are found at the middle left part of the card.

Switching on the termination switch adds a 50\textOmega~termination between the differential input signals.

Regardless of the switch configurations, the differential input signals are separately terminated with 100k\textOmega~to the PCB ground.
\columnbreak
\begin{center}
    \centering
    \includegraphics[height=1.7in]{sampler_switches.jpg}
    \captionof{figure}{Position of switches}
\end{center}
\end{multicols}

\newpage

\section{Example ARTIQ code}
The sections below demonstrate simple usage scenarios of the 5108 Sampler 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}.

\subsection{Get input voltage}
The following example initializes the Sampler card with 1x gain on all ADC channels.
Sample all ADC channels at the end.

\inputcolorboxminted{firstline=9,lastline=21}{examples/sampler.py}

\subsection{Voltage-controlled DDS Amplitude (SU-Servo Only)}
The SU-Servo feature can be enabled by integrating the 5108 Sampler with 4410 DDS Urukuls.
Amplitude of the DDS output can be controlled by the ADC input of the Sampler through PI control, characterised by the following transfer function.
\[H(s)=k_p+\frac{k_i}{s+\frac{k_i}{g}}\]
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 with 1x gain.

\inputcolorboxminted{firstline=10,lastline=17}{examples/suservo.py}

Next, setup the PI control as an IIR filter. It has -1 proportional gain $k_p$ and no integrator gain $k_i$.

\inputcolorboxminted{firstline=18,lastline=25}{examples/suservo.py}

Then, configure the DDS frequency to 10 MHz with 3V input offset.
When input voltage $\geq$ offset voltage, the DDS output amplitude is 0.

\inputcolorboxminted{firstline=26,lastline=30}{examples/suservo.py}

SU-Servo encodes the ADC voltage in a linear scale [-1, 1].
Therefore, 3V is converted to 0.3.
Note that the ASF of all DDS channels are capped at 1.0, the amplitude clips when ADC input $\leq -7V$ with the above IIR filter.

Finally, enable the SU-Servo channel with the IIR filter programmed beforehand.

\inputcolorboxminted{firstline=32,lastline=33}{examples/suservo.py}

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 DDS channel is terminated with 50\textOmega.

\begin{center}
\begin{tikzpicture}[
    declare function={
        func(\x)= and(\x>=-10, \x<-7) * (160) +
            and(\x>=-7, \x<3) * (16*(3-x)) +
            and(\x>=3, \x<10) * (0);
    }
]
\begin{axis}[
    axis x line=middle, axis y line=middle,
    every axis x label/.style={
        at={(axis description cs:0.5,-0.1)},
        anchor=north,
    },
    every axis y label/.style={
        at={(ticklabel* cs:1.05)},
        anchor=south,
    },
    minor x tick num=3,
    grid=both,
    height=8cm,
    width=12cm,
    ymin=-5, ymax=180, ytick={0,16,...,160}, ylabel=DDS RMS Voltage ($mV_{rms}$),
    xmin=-10, xmax=10, xtick={-10,-8,...,10}, xlabel=Sampler Voltage ($V$),
]

\addplot[very thick, blue, samples=21, domain=-10:10]{func(x)};
\end{axis}
\end{tikzpicture}
\end{center}

DDS signal should be attenuated.
High output power affects the linearity due to the 1 dB compression point of the amplifier at 13 dBm output power.
15 dB attenuation at the digital attenuator was applied in this example.

\section{Ordering Information}
To order, please visit \url{https://m-labs.hk} and select the 5108 Sampler 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 provided in good faith in the hope that it will be useful. However, no responsibility is assumed by M-Labs Limited for its use. Specifications may be subject to change without notice.
\end{footnotesize}

\end{document}
