February, 2012

MMT WFS - F5 image capture

A great introduction to the F5 wavefront sensor hardware is the 2003 manual written by Daniel Fabricant.

A dedicated computer named "wavefront" is used to control the F5 wavefront sensor camera and associated hardware. This computer is physically located in the "cone" area inside the telescope and is difficult to physically acess. The machine is a small form factor motherboard, and runs windows XP "Professional". A solid state hard drive holds the operating system, with the hopes that this would achieve reliability. It has failed once already. The original 6G drive was replaced with a 32G drive, and the old partition copied verbatim (using Norton Ghost). This leaves 24G of the new drive unused. We do not install windows updates on this machine as we have discovered that this breaks the software.

We access this box over the network via VNC using the password "w4u".

Windows is required to run some of the drivers used to control motors and such. Cygwin is used to provide a unix like environment which runs the camera software, which at the top level at least is coded in Tcl. The bulk of the software was written by the SAO staff, with major contributions by John Roll. The MMT staff does their best to treat this as a black box -- it was provided to us as a turnkey system that should not require significant maintenance or additional software development.

System startup

Windows is setup to auto login user "wave" when the system boots. This causes c:\documents and settings\wave\Start Menu\Programs\Startup to be referenced. It contains a "shortcut to wfs" shortcut file which starts in C:\cygwin with the target being the MS_DOS batch file c:\cygwin\wfs.bat. This file contains the following:
chdir c:\cygwin\bin
bash --rcfile /.wfsrc -i
The file .wfsrc contains:
export PATH=$PATH:/home/wave/bin
export CVS_RSH=ssh
export CVSROOT=john@tdc.cfa.harvard.edu:/data/mmti/CVSROOT
. /home/wave/wfs.sh 
The file /home/wave/wfs.sh contains:
#!/bin/sh
cd ~/src/waveserv
wish waveserv.tcl &
sleep 120
wish wavecamr.tcl &
And that is how things startup up.

Tcl surprises

At some point, it became desirable to modify some of the Tcl files in /home/wave/src/wavefront. To our surprise, editing these files had no effect whatsoever! In the case in question, we were editing the file camserv.tcl -- this file is "invoked" by the top level script wavecamr.tcl by the Tcl statement "package require camserv", and it would seem that this statement searches some path of standard places which does not include the current directory. In fact it seems to find the file C:/Tcl/lib/mmti/camserv.tcl

The proper "thing to do" is to type "make install" in the /home/wave/src/wavefront directory after modifying files there. This copies a whole gang of tcl files to /Tcl/lib/mmti, along with copying the file pkgIndex.tcl to that directory. This apparently sets things up the way Tcl expects to find them.

Camera

The lenslet array is part of the Puntino assembly, and yields a square grid of spots (in contrast to the hexagonal grid yielded by the f9 lenslet array. The Camera which captures the spot images is an SBIG (Santa Barbara Instrument Group) SBIG ST9XE unit with a Kodak KAF-0261E chip. It yields a 512x512 pixel image. The pixels themselves are 20x20 micron, the chip is 10.2 by 10.2 mm. The Camera has a USB 1.1 interface, and has a 16 bit A to D converter. Exposures from 0.12 to 3600 seconds are possible with 10 ms resolution.

Two servers run on this computer. Both are coded in Tcl and use the MSG protocol developed by SAO.

We use the following shell script to read an image from the camera hosted by this computer. This script takes two arguments. The first is the exposure time in seconds. The second is the name of the file that should be saved. The sleep delays in this script have been tuned by trial and error, and are a source of some concern and annoyance.

#!/bin/sh

echo "1 expose 0 light $1" | nc -w 10 wavefront 3001 > /dev/null
sleep $1
sleep 2
echo "1 readout" | nc -w 10 wavefront 3001 > /dev/null
sleep 5
echo "1 fits 0 1322240" | nc -w 10 wavefront 3001 | tail -n +2 > $2
echo "1 idle" | nc -w 10 wavefront 3001 > /dev/null
A single image is captured as a 532800 byte file with a name like manual_wfs_0000.fits. This file holds a 512 by 512 pixel image with each pixel represented by 16 bits (2 bytes). The pixels themselves occupy 524288 bytes; the remaining 8512 bytes are FITS header records. Processing will nearly double these file sizes when 2 byte integer pixels are replaced by 4 byte floating point values.

The port 3001 "wavecamr" server is implemented by the file /home/wave/src/waveserv/wavecamr.tcl. This file pull in 3 files:

The sbig.tcl is a tcl wrapper that uses the critcl Tcl extension to embed C code which accesses the vendor supplied dynamic library: C:\Windows\system\SBIGUDrv.dll. Some documentation for the driver API provided in this library can be found in the file SBIGUDrv_4r22.pdf (26 pages, September, 2002).

Using the msg protocol on port 3001

The following MSG procedures are registered:

The following MSG variables are published: