TAIT: TASS Automatic Imaging Telescope Control Program

Michael Richmond
Aug 27, 2001

I've written a program for controlling the TASS Mark IV camera from a computer running Linux. It's not in any finished state:

In addition, the communications occur on a very low level. One cannot request a set of many identical operations, for example. I'm not sure that this control program is the place to insert a scripting capability -- it might be better to write a high-level facility which allows a user to define a night's worth of observations, and produces as output a file containing low-level commands for this program to execute.

The goal of the program is to allow one to operate a Mark IV in two-and-a-half modes:

  1. Interactive: sit at keyboard, type command, wait for it to execute, then type next command, etc.
  2. File-driven: the program reads commands from a text file
  3. File-driven with interrupts: the program reads commands from a file, but that file may be modified at any time

Almost all the time, the program would simply read commands from a file and execute them one at a time. However, I wanted to permit a user to interrupt the regular schedule of operations in the middle of the night, in case something very interesting happened (a gamma-ray burst or nova). In addition, I wanted the user to be able to interrupt operations remotely, without having to travel to the telescope. Hence, the program is designed to run under Linux (so that a user can log in remotely and modify the command file), and the program reads the command file in a manner which allows one to modify the program on the fly.


The Command Set

The program reads simple ASCII text, one line at a time. Each line looks something like this:

       command   arg1 ....
where there is one command, and may be 0, 1, 2 or more arguments. Below is a list of the current commands and any arguments they take.
#
echo
Echo the entire input command line

nop
Do nothing ("No OPeration")

quit
exit
end
Terminate program execution. The program will also halt if it reaches the end of the input file, or if an interactive user presses "Control-D".

help
Print a list of all known commands

ra atlimit
ra on
ra off
ra ff
ra rev
ra tolimit (or home)
Control the RA motor. The atlimit argument checks to see if the RA drive is currently at its limit (or home) position (telescope pointing as far East as possible); if so, the program prints a line like this:
					OK  ra atlimit yes
		  
Otherwise, it prints a line like
					OK  ra atlimit no
		  
The on argument causes the RA motor to run at sidereal rate. The off argument causes the RA motor to stop. The ff argument causes the RA motor to move the telescope West at about 30 times sidereal rate. The rev argument causes the RA motor to move the telescope East at about 30 times sidereal rate. The tolimit or home argument causes the telescope to move to its home position.

motor action id steps direction
Control one of the stepper motors at a very low-level. This is not intended for the ordinary user, and may be disabled.

clamp on
clamp off
The on argument causes the clamp to hold the Dec axis tight, so that it can't move. The off argument loosens the clamp, so the Dec axis can rotate.

dec atlimit
dec abs NN
dec rel NN
dec tolimit (or home)
Control the Dec motor in some way. The atlimit command checks to see if the telescope is currently at the Dec "home" position, which means pointing roughly 60 degrees above the horizon. The abs NN command moves the Dec motor so that the telescope ends up pointing NN steps North of the home position; if NN is negative, then the telescope points the given number of steps South of the home position. The rel NN command moves the Dec motor so that the telescope ends up pointing NN steps away from its current position; again, positive NN means "move North", and negative NN means "move South". The tolimit or home argument causes the telescope to move to its Dec home position. All the commands dec abs, dec rel, and dec home automatically loosen the clamp before moving, and tighten it afterwards.

shutter v open
shutter v close
shutter i open
shutter i close
Cause the given shutter to open or close.

focus [v|i] atlimit
focus [v|i] abs NN
focus [v|i] rel NN
focus [v|i] tolimit (or home)
Control one of the two camera focus motors -- the user must supply either v or i as the first argument. Each has a limit switch which triggers when the camera is moved as close to the lens (i.e. upwards towards the sky) as far as possible. The atlimit argument checks to see if the given camera is currently sitting at the limit position. The abs argument moves the given camera NN steps away from the home position; the number of steps must be positive. The rel argument moves the given camera NN steps away from the current position, where negative values mean "up, towards limit", and positive values mean "down, away from limit". The tolimit or home argument causes the given camera to move to its home position.

exp dark NN
exp flat NN
exp object NN
Take an exposure of NN seconds with both cameras. Each camera is scanned once to clear immediately before the exposure is made, then scanned again to readout afterwards. If dark, then the shutters are closed for the exposure; otherwise, the shutters are opened for the requested number of seconds. There is no difference between the telescope actions for flat and object, only in the value of the IMAGETYP line in the FITS header.

The images are read out into the memory card, and then saved to disk via Robert Creager's downfits program, which is invoked from within the program via a system call. The FITS images are currently saved in the current working directory. File names are generated following Arne Henden's E-mail, msg 134 in June, 2001, with names like this:

    jjjjxxxc.fit

    where

          jjjj         is the integer portion of
                       Julian Date - 2,450,000

          xxx          is an image sequence number 
                       within the current run
                       (typically one run per night)

          c            is a code indicating the camera
                       'E' for the V-band camera
                       'F' for the I-band camera

saveimg
Do not take a new exposure, but simply save the current contents of the memory card to FITS files on disk, by invoking the downfits program. This command should probably never be called in ordinary use, and may disappear.

show adc
show dac
show seq
Print out some information to the screen (and log file). The adc argument prints out the ADC values. The dac argument prints out the DAC settings. The seq argument prints out the current sequence number for image file names.

set dac NN xxx
set seq NN
Set a value, either the current image file sequence number, for the seq argument, or DAC number NN to the value xxx.


Running the program

One runs the program by typing
           tait   [infile=foo]  [fake]
where the optional arguments are
       infile=             read commands from the given file;
                                 if not present, use stdin 

       fake                don't really talk to the Mark IV, 
                                 just run through the commands and
                                 parse each one for proper grammar.
                                 Sometime in the future, this might do
                                 more to simulate real operations.

The program prints diagnostics to stdout (usually the screen), and also to a log file called tait.log

Here's an example: given this simple input file, tait.in:

# Test of "tait" Mark IV control program
#   (these comments should be printed out)
#
nop
echo start of run
nop

echo end of run

quit

if we invoke

            tait  infile=tait.in  fake

we get output like this (both to the screen, and to the log file tait.log):

08/27/2001 22:31:10  
08/27/2001 22:31:10 starting tait control program 
open_port: Unable to open serial port : Permission denied
08/27/2001 22:31:10 ERROR     init_memcard: ioperm returns with error
08/27/2001 22:31:10 # Test of "tait" Mark IV control program 
08/27/2001 22:31:10 OK echo
08/27/2001 22:31:10 #   (these comments should be printed out) 
08/27/2001 22:31:10 OK echo
08/27/2001 22:31:10 # 
08/27/2001 22:31:10 OK echo
08/27/2001 22:31:10 nop 
08/27/2001 22:31:10 OK nop
08/27/2001 22:31:10 echo start of run 
08/27/2001 22:31:10 OK echo
08/27/2001 22:31:10 nop 
08/27/2001 22:31:10 OK nop
08/27/2001 22:31:10  
08/27/2001 22:31:10 echo end of run 
08/27/2001 22:31:10 OK echo
08/27/2001 22:31:10  
08/27/2001 22:31:10 quit 
08/27/2001 22:31:10    tait: parse_and_execute says to quit
08/27/2001 22:31:10 ending   tait control program 
08/27/2001 22:31:10  

The ERROR near the beginning occured because I ran the program as an ordinary user; in order to read the memory card, the program must be run as "root", the Unix super-user.

In real use, of course, the timestamps would show the time taken to carry out each of the commands.


Last modified Aug 27, 2001 by MWR.