ls *-cam1.jpg| jpeg2yuv -f 20 -I p| yuv2lav -f a -b 10000 -q 75 -o mov1.avi ls *-cam2.jpg| jpeg2yuv -f 20 -I p| yuv2lav -f a -b 10000 -q 75 -o mov2.avi ls *-cam3.jpg| jpeg2yuv -f 20 -I p| yuv2lav -f a -b 10000 -q 75 -o mov3.avi

skycam program

Software architecture, interfacing to hardware

Overview of software architecture and interfacing with hardware
All components and software are off-the shelf, except for a single C program (9900 lines of code)

Source Code

Software source code: skycam.c .
This file contains all custom software to run the system, and is approximately 7000 lines of C code.

Output of "skycam help"

A single executable is created by compiling skycam ( compile command line). The single executable is then used to issues low level and high level commands. The executable (named skycam) keeps track of the system status using files which are written and read as needed. A list of commands is obtained by typing "./skycam help":
--------------- LIST OF COMMANDS -------------------

      help                     : print list of commands and exit

ASTRONOMICAL COMMANDS--------------------------------

      utcnow                   : compute current UTC (->utc.txt)
      lst yr mo day            : compute local sidearal time (->lst.txt)
      lstnow                   : compute current local sidereal time (->lst.txt)
      radec2altaz              : convert ra dec into alt az (deg)
      altaz2radec              : convert alt az into ra dec (deg)
      moonpos                  : get current Moon position
      sunpos                   : get current Sun position

COMMUNICATION SETUP-------------------------------------

      resetusb       : reset usb port
      scanusb                  : scan usb ports, write USBports.txt and exit

LOW LEVEL COMMANDS--------------------------------------

      readdio                  : read digital input
      setdio ch x              : set TTL channel (C-..) ch to x (0/1)
      powercams x              : turn power on/off (0/1) for cameras
      powerwebcam x            : turn power on/off (0/1) for webcams
      powermount x             : turn aux power on/off (0/1) for mount
      led x                    : turn on/off LED

MOUNT COMMANDS----------------------------------------

      home                     : home mount
      tracksidN                : track sid rate, North hemisphere
      mountstop                : stop tracking or slew
      dispmc                   : display mount coordinates
      dispmlsw                 : display mount limit switches
      movpos mra mdec          : move to position 0.0 < maz < 1.0 and 0.0 < malt < 1.0
      track az alt             : track (units = steps / sec)
      park                     : park system into standby

TEMPERATURE & HUMIDITY & LUMINOSITY COMMANDS---------------

      gettemp1                 : get temperature for sensor 1
      gettemp2                 : get temperature for sensor 2
      gettemp12                : get temperature for sensors 1 & 2. Run for 100 samples, output to log file
      gettemp12loop            : execute gettemp12 in loop
      gethum                   : get humidity, run for 100 samples, output to log file
      getacpowst               : get AC power status, run for 100 samples
      getlum              : get luminosity of webcam 

CAMERA COMMANDS--------------------------------------

      setcammode    : set camera mode (0=off, 1=USB, 2=TTL)
      camlistfiles        : list files on camera 
      camloadfiles        : load files from camera 
      camrmfiles          : rm files from camera 
      camsetiso  : set ISO mode on camera (1=100 ..) 

HIGH LEVEL COMMANDS------------------------------------

      startwebcamloop     : start webcam loop for cameras 1 to 
      stopwebcamloop      : stop webcam loop for cameras 1 to 
      init                     : init system (scanusb + home)
      polaralign               : polar align sequence
      test                     : test routine
      observingstatus          : set observing status according to weather
      takedark etime isomode   : take dark
      taketestim etime isomode : take test image
      mainloop                 : main loop
      monitorloop              : monitor loop
      mloweathermon            : monitor MLO observatory weather (infinite loop)

DATA MANAGEMENT AND ANALYSIS---------------------------

      compress yyyy-mm-dd frnb         : compress frame
      raw2fits yyyy-mm-dd frnb         : convert from raw to fits, use compressed file if .CR2 does not exist
      mkimlist                         : make/update image list file
      trackinganalysis    : perform tracking analysis
      mergetracking                    : merge all tracking log data
      trackrate       : compute tracking rate for mRA, mDEC, flip


Main loop

The main loop is started by typing "./skycam mainloop". It will monitor the weather, and decide what to do (nothing, take darks, take flats, or observe) from weather data, time, and position of the Sun.

Keeping it safe: monitorloop

The camera system does not have a dome - it is therefore essential to make sure that it is properly parked during bad weather, and that it NEVER points at the Sun (this would destroy the camera, and lens). The software is written with this goal in mind. The "monitorloop" command checks, through the filesystem, that the main loop heartbeat is beating (periodically updates a file), and takes control of the system to park the camera if the main loop has crashed.

Astrometry, data quality verification

Astrometric fit to a single raw image
Left: raw image; right: model of the image (HIP catalog sources). The raw image is modeled from the HIP catalog to measure astrometric parameters (including field distortion coefficients) and approximate photometry.

Communication with camera (gphoto2)

The camera is connected to the computer through USB. gphoto2 is used to communicate to the camera.
Example commands:
# set iso to 400
/usr/local/bin/gphoto2 --set-config /main/imgsettings/iso=4

# set aperture to F1.2
/usr/local/bin/gphoto2 --set-config /main/capturesettings/aperture=1.2

# capture a 120s exposure
/usr/local/bin/gphoto2 --bulb=120.0 --capture-image-and-download

Communication with monitoring webcams

Webcams are on USB ports. streamer is used to acquire frames.

Software Notes

The system runs on Ubuntu 10.04 (64-bit). Cfits is used for image analysis.

Camera control: gphoto2

sudo apt-get install gphoto2
# installed version 2.4.5 of gphoto and verstion 2.4.8 of libgphoto2 

# need newer version to support Bulb exposure ... moving to manual install

sudo apt-get install libltdl7-dev
sudo apt-get install libpopt-dev
sudo apt-get install libjpeg-dev


# download libgphoto2-2.4.9 
./configure
make
sudo make install



# download gphoto2-2.4.9
./configure
make
make install

# NOTES: 
# gphoto2 2.4.8 is : /usr/local/bin/gphoto2
# gphoto2 2.4.5 is : /usr/bin/gphoto2 [default]