\documentclass[12pt]{article}

\title{Using analog-to-digital inputs with TV6}
\author{A. C. Finnefrock}
\date{\today \\ version 0.1}

\begin{document}

\maketitle


This document describes how to use load arbitrary analog voltage inputs into
TV6, read them from the command prompt, and then how to find them from the
TIFF headers later. 


\section{Hardware Setup}
\label{sec:Hardware-Setup}

You need two hardware components: the internal data acquisition card, and a
patch panel box.   The internal card is a Advantech PCL 818 D/A, A/D card
that reads at rates up to 100kHz.  (Note: this card has now been 
superseded by the PCL 818H, which seems to retain the same functionality and
programming commands.)  

The outputs of the card are connected through two PC-slots to four serial-type
connectors labelled I, II, III, IV.  These connect to the corresponding ports
in the back of the rack-mountable patch-panel.  This feeds through to BNC
connectors on the front.  Although there is only panel in existence, another
could be easily constructed.



\section{TV6 Setup}
\label{sec:TV6-Setup}

Before running TV6, check the file in the TV6 directory
(\mbox{\texttt{C:$\backslash$TV62K}} presently) named \texttt{default.tbl}.

It should contain the lines:
\begin{verbatim}
  FIXME (ACF 2001-01-17)
\end{verbatim}

%%enable_shotim = 1 



\section{Within TV6}
\label{sec:Within-TV6}

Within TV6, you can interactively check the voltage levels and set the
appropriate ranges for the analog-to-digital conversion.  Full information can
be found by typing 
\texttt{help atod}.
The two modes are 
\begin{quotation}
\texttt{atod} \textit{channel\_number} \textit{range\_number}
\end{quotation}
to set the voltage ranges,
and
\begin{quotation}
\texttt{atod} \textit{channel\_number}
\end{quotation}
to read a voltage value.
The correlation between voltage ranges and \textit{range\_number} is given
in the help file.



At the CHESS D1 station, the connections are presently set for
I0, I1, I$_\mathrm{mono}$, I$_\mathrm{prot}$
in channels 0 \ldots 3, respectively.
You should check these, because they could be changed by another user.  You
are also welcome to switch them for your own nefarious purposes.  If possible,
please label the patch cables for your and the next users' convenience.

The VtoF (voltage to frequency) CAMAC modules at CHESS typically accept a
0--10V range, which then becomes TTL pulses.  So the ion chambers will be set
up to give no more than a 10V signal.  For this reason, the default range for
\texttt{atod} is also set at 0--10V (\textit{range\_number} = 4)

Samples are taken approximately every second.  The output of the \texttt{atod}
command will show ``mon'' (monitor) and ``avg'' (average) values, which are
respectively the most recent value and the average value.


\section{TIFF headers}
\label{sec:TIFF-headers}

None of this is terribly useful, except that TV6 records the same A/D values
in each image file. 
TV6 image
 files are TIFF files with the data given by 16-bit (unsigned or signed)
integers.  Additional information about each exposure is given by TIFF
``tags'' in the header, following the standard TIFF specification.  Besides
the usual tags, TIFF also uses extra tags for information specific to taking
data from a CCD.  These are given in the following excerpt of C code.
Standalone C source code is also available from the Gruner group (see me or Gil
Toombes) for parsing these extra tags.

\begin{verbatim}

// Non-standard Tiff Tag Numbers.  Standard in struct tagname
#define NUM_EXPOSURE_TAG         0x9001  // long
#define NUM_BACKGROUND_TAG       0x9002  // long
#define EXPOSURE_TIME_TAG        0x9003  // long
#define BACKGROUND_TIME_TAG      0x9004  // long
#define SUB_BPP_TAG              0x9009  // long
#define SUB_WIDE_TAG             0x900a  // long
#define SUB_HIGH_TAG             0x900b  // long
#define BLACK_LEVEL_TAG          0x900c  // float
#define DARK_CURRENT_TAG         0x900d  // float
#define READ_NOISE_TAG           0x900e  // float 
#define DARK_CURRENT_NOISE_TAG   0x900f  // float
#define BEAM_MONITOR_TAG         0x9010  // float
#define USER_VARIABLES_TAG       0x9100  // long array
\end{verbatim}

The A/D values are stored as consecutive long integers in the
\verb*XUSER_VARIABLES_TAGX field.






\section{Acknowledgements}
\label{sec:Acknowledgements}

TV6 was written by Sol Gruner, Eric Eikenberry, and Mark Tate.  Mark 
demonstrated to me all the TV6 steps in this document.  Any errors are my
responsibility.





\end{document}
