From 440b3ef3df58678f509d0f6749d0c9b643b1dee8 Mon Sep 17 00:00:00 2001 From: occheung Date: Tue, 26 Jul 2022 18:26:52 +0800 Subject: [PATCH] 2118-2128: add t_min info from #26 --- 2118-2128.tex | 9 +++++++++ examples/ttl_in.py | 41 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/2118-2128.tex b/2118-2128.tex index fd4ee79..42267e7 100644 --- a/2118-2128.tex +++ b/2118-2128.tex @@ -606,6 +606,15 @@ Typically, with the coarse RTIO clock at 125 MHz, a \texttt{ClockGen} channel ca \inputcolorboxminted{firstline=72,lastline=75}{examples/ttl.py} +\newpage +\subsection{Maximum Sustained Event Separation} +The maximum sustained event separation is the least amount of time separation between input gated events, in which all gated edges can be continuously \& reliabily timestamped by the RTIO system without causing \texttt{RTIOOverflow} exceptions. +The following \texttt{run()} function finds the separation by approximating the time of running \texttt{timestamp\char`_mu()} as a constant. Import the \texttt{time} library to use \texttt{time.sleep()}. + +\inputcolorboxminted{firstline=60,lastline=92}{examples/ttl_in.py} + +The result fluctuates at around 650ns with Kasli v1.1. + \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}. diff --git a/examples/ttl_in.py b/examples/ttl_in.py index b9ece47..a35bd08 100644 --- a/examples/ttl_in.py +++ b/examples/ttl_in.py @@ -49,3 +49,44 @@ class ExternalTrigger(EnvExperiment): 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) + + +class MeanTimestampDuration(EnvExperiment): + def build(self): + self.setattr_device("core") + self.ttlin = self.get_device("ttl0") + self.ttlclk = self.get_device("ttl7") + + @kernel + def get_timestamp_duration(self, pulse_num) -> TInt64: + self.core.break_realtime() + delay(1*ms) + gate_start_mu = now_mu() + # Start input gate & advance timeline cursor to gate_end_mu + gate_end_mu = self.ttlin.gate_rising(1*ms) + at_mu(gate_start_mu) + + self.ttlclk.set_mu(0x800000) + delay(16*pulse_num*ns) + self.ttlclk.set_mu(0) + + # Guarantee t0 > gate_end_mu + # Otherwise timestamp_mu may wait for pulses till gate_end_mu + self.rpc_sleep(1*ms) + t0 = self.core.get_rtio_counter_mu() + while self.ttlin.timestamp_mu(gate_end_mu) >= 0: + pass + t1 = self.core.get_rtio_counter_mu() + return t1 - t0 + + @rpc + def rpc_sleep(self, duration): + time.sleep(duration) + + @kernel + def run(self): + self.core.reset() + t64 = self.get_timestamp_duration(64) + t8 = self.get_timestamp_duration(8) + print("Mean timestamp_mu duration:") + print(self.core.mu_to_seconds((t64 - t8)/((64 + 1) - (8 + 1))))