\documentclass[../thesis.tex]{subfiles}

\graphicspath{
	{.}
	{../../figures/}
	{../../../figures/}
}

\begin{document}
\chapter{Time Synchronisation Mechanisms}
\label{sec:time}
Need reference system with better accuracy to constrain


\begin{figure}
	\centering
	\includegraphics[width=\textwidth]{clocks/reference-clock.pdf}
	\caption{
		Using a reference clock to compare two other clocks.
	}
	\label{fig:reference-clock}
\end{figure}


\section{Global Navigation Satellite System}
\label{sec:time:gnss}
$\sigma_t \sim 20 \ns$

\section{White Rabbit Precision Time Protocol}
\label{sec:time:gnss}
\begin{figure}
	\centering
	\includegraphics[width=\textwidth]{white-rabbit/protocol/delaymodel.pdf}
	\caption{
		From \cite{WRPTP}.
		Delays between two White Rabbit nodes.
	}
	\label{fig:wr:delaymodel}
\end{figure}
\subsection{PTP}
\begin{figure}
	\centering
	\includegraphics[width=\textwidth,height=0.5\textheight,keepaspectratio]{white-rabbit/protocol/ptpMSGs-color.pdf}
	\caption{
		From \cite{WRPTP}.
		Precision Time Protocol (PTP) messages
	}
\end{figure}

\subsection{White Rabbit}
SyncE
\begin{figure}
	\centering
	\includegraphics[width=\textwidth,height=0.5\textheight,keepaspectratio]{white-rabbit/protocol/wrptpMSGs_1.pdf}
	\caption{
		From \cite{WRPTP}.
		White Rabbit extended PTP messages
	}
	\label{fig:wr:protocol}
\end{figure}

\begin{figure}
	\centering
	\includegraphics[width=\textwidth,height=0.5\textheight,keepaspectratio]{clocks/wr-clocks.pdf}
	\caption{
		White Rabbit clocks
	}
	\label{fig:wr:clocks}
\end{figure}

\section{Beacon}
\label{sec:time:beacon}
The idea of a beacon is semi-analogous to an oscillator in electronic circuits.
A periodic signal is sent out from a transmitter (the oscillator), and captured by an antenna (the chip the oscillator drives).

In a digital circuit, the oscillator often emits a discrete (square wave) signal (see Figure~\ref{fig:beacon:ttl}).
A tick is then defined as the moment that the signal changes from high to low or vice versa.

In this scheme, synchronising requires latching on the change very precisely.
As between the ticks, there is no time information in the signal.
\\

\todo{Possibly Invert story from short->long to long->short}
Instead of introducing more ticks in the same time, and thus a higher frequency of the oscillator, a smooth continous signal can also be used.
This enables the opportunity to determine the phase of the signal by measuring the signal at some time interval.
This time interval has an upper limit on its size depending on the properties of the signal, such as its frequency, but also on the length of the recording.


In Figure~\ref{fig:beacon:sine}, both sampling~1~and~2 can reconstruct the sine wave from the measurements.
Meanwhile, the square wave has some leeway on the precise timing.\todo{reword sentence}
\\

\begin{figure}[h]
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{beacon/ttl_beacon.pdf}
		\caption{
			Discrete (square wave) clocks are commonly found in digital circuits.
		}
		\label{fig:beacon:ttl}
	\end{subfigure}
	\hfill
	\begin{subfigure}{0.45\textwidth}
		\includegraphics[width=\textwidth]{beacon/sine_beacon.pdf}
		\caption{
			A sine wave clock, as will be employed throughout this document.
		}
		\label{fig:beacon:sine}
	\end{subfigure}

	\caption{
		Two different beacon signals with the same frequency.
		Both show two samplings with a small offset in time.
		Reconstructing the signal is easier to do for the sine wave with the same samplelength and number of samples.
	}
	\label{fig:beacon:ttl_sine_beacon}
	\todo{Add fourier spectra?}
\end{figure}

%% Second timescale needed

Instead of driving the antenna, the beacon is meant to synchronise the clock of the antenna with the clock of the transmitter.
With one oscillator, the antenna can work in phase with the transmitter, but the actual synchronization can be off by a multiple of periods.
To be able to determine this offset, a second timescale needs to be introduced in the signal.
\\

This slower timescale allows to count the ticks of the quicker signal.\todo{Extend paragraph}

\begin{figure}
	\begin{subfigure}{0.45\textwidth}
%		\includegraphics[width=0.5\textwidth]{beacon/sine_beacon_multiple_periods_off.pdf}
		\caption{
			Two syntonised beacons.
			The actual synchronization is off by a multiple of periods.
		}
		\label{fig:second_timescale:off}
	\end{subfigure}
	\hfill
	\begin{subfigure}{0.45\textwidth}
%		\includegraphics[width=0.5\textwidth]{beacon/sine_beacon_multiple_periods_off.pdf}
		\caption{
			Two syntonised beacons, the actual synchronization is off by a multiple of periods.
		}
		\label{fig:second_timescale:on}
	\end{subfigure}
	\caption{
		}
	\label{fig:second_timescale}
	\todo{Fill figure and caption}
\end{figure}

\begin{figure}
		\includegraphics[width=0.5\textwidth]{beacon/auger/1512.02216.figure2.beacon_beat.png}
		\caption{
			From Ref~\cite{PierreAuger:2015aqe}
			The beacon signal that the \PAObs\ employs.
		}
		\label{fig:beacon:pa}
\end{figure}



\subsection{Fourier Transform}
\begin{equation}
	\label{eq:fourier}
	\hat{f}(\omega) = \frac{1}{2\pi} \int \dif{t}\, f(t)\, \exp(i \omega t)
\end{equation}



\subsection{Beacons in Airshower timing}
To setup a time synchronising system for airshower measurements, actually only the high frequency part of the beacon must be employed.
The low frequency part, from which the number of oscillations of the high frequency part are counted, is supplied by the very airshower that is measured.


\begin{equation}
	\label{eq:correlation_cont}
	\Corr(\tau; u,v) = \int_{-\infty}^{\infty} \dif t \, u(t)\, v^*(t-\tau)
\end{equation}

\begin{equation}
	\label{eq:correlation_sample}
	\Corr(k; u,v) = \sum_n u[n] \, v^*[n-k]
\end{equation}

\end{document}
