PyFocus ====== Copyright 2012-2018 John Kielkopf Email: kielkopf@louisville.edu Last update: May 17, 2018 PyFocus is an telescope focuser control interface. Although intended for use with XmTel and XmCCD, it stands by itself and is the software needed to operate DC servo driven focusers such as the Planewave Hedrick focuser and the secondary mirror focuser of the RC Optical Systems Ritchie Chretien telescopes. PyFocus is written in Python, and has a dependency on the Phidgets library for a USB servo controller. The version here is for Linux, but Phidgets has a version for Windows so that it would be possible to build a system for a Windows OS based on this code if you feel adventurous. Installation is in three steps: 1. Run the installation script to install the requisite library and the rules for the Phidgets USB devices. If this has already been done for other uses it does not need to be repeated unless you are using a new device. 2. Run the Python setup script to install the supporting Phidgets Python files. 3. Copy the Python programs in "focus" to /usr/local/bin/ to enable the servo interface. The system uses status files in /usr/local/observatory/status/. Check that the entire directory structure is readable and writable by the user who is running the observatory. Version 2.0 Changes =================== The version introduces the Phidgets22 library which enables their new devices and changes the management of encoder and auxiliary devices connected to the motor control card. This lead to a thorough restructing of the code. The status file now saves the position of the focuser in microns. If the status file is not found, it is created and the position is set to zero. The command line version accepts a change in the radius of the defocussed star given in pixels. It displays the resulting radius in pixels and in arcseconds. The telescope and motor parameters must be set in the program focus_change_pixels.py to match the optics and the focuser mechanics for your telescope. This version also brings a Tk graphical user panel which may be kept up during an observing session. The motor is actuated only on a button press. The panel is a front end to the same software used in the command line code. However if the panel is open, the motor is assigned to the panel and the channel is kept open to make it more responsive to use requests. The status file is written upon completion of a change of position requested. Focus code and parameters ========================= The two programs that control the focus motor are focus_change.py and tk_focus_change.py. They differ only in that the "tk" version uses tkinter and runs in a GUI, while the other is a command line program that may be called in a script. They cannot be run simultaneously. The version under the "focus" directory assumes a motor is moving the camera. This would be a typical situation, but if the motor will move the secondary mirror, the image plane moves more than the secondary depending on the optical system magnification and that factor is needed too. We set the magnification to unity by default. The motor and focuser parameters are built into the program, rather than being read from a configuration file. Those lines are indicated as user-configurable and will have to be reset for your system. You need to know: fratio -- the focal ratio of the optical system fmag -- the secondary magnification (set to 1.0 if the motor moves the camera) pixel_size -- the camera pixel dimension in microns arcsecond_per_pixel -- focal plane scale counts_per_revolution -- encoder counts change for one output shaft rotation counts_per_micron -- encoder counts change for camera or secondary movement revolutions_per_second -- output shaft running with this controller dx_max -- maximum allowed movement in microns for one command (safety first) Suggested values ================ # Begin user installation parameters # # # Phidgets motor on the CDK20 telescopes # # Motor RPM at 100% duty cycle: 4000. # Motor RPM speed factor: 0.5 estimated # Motor shaft encoder counts/turn: 360. # Motor gear reduction: 139. + 184./1221. = 139.150696151 # Focuser screw pitch: 32 tpi # Focuser translation scale: 793.75 microns / shaft revolution # Motor counts per micron focuser motion: 63.111 # Focal ratio: f/6.8 # Pixel size: 9 microns # Secondary motion magnification: 1.0 # # Set CDK20 motor and focuser parameters # # counts_per_revolution = 360. # revolutions_per_second = 0.5*4000./60. # counts_per_second = counts_per_revolution * revolutions_per_second # counts_per_micron = 63.11 # delta_count_max = 1000.*counts_per_micron # # Set CDK20 telescope parameters # # f_ratio = 6.8 # f_mag = 1.0 # pixel_size = 9.0 # arcsecond_per_pixel = 0.53 # # # Pittman 9237S011-R1 motor on the RC telescopes # # Set RC motor and focuser parameters # # Screw pitch: 20 tpi # Motor encoder: 500 counts per turn # Motor gearing: 1:1 # No-load speed: 4370 rpm # # counts_per_revolution = 500. # revolutions_per_second = 20. # counts_per_second = counts_per_revolution * revolutions_per_second # counts_per_micron = 0.3937 # delta_count_max = 1000.*counts_per_micron # # Set RC telescope parameters # # f_ratio = 8.0 # f_mag = 4.0 # pixel_size = 9.0 # arcsecond_per_pixel = 0.39 In the case of the RC telescopes, the design of the secondary mirror translator is a direct coupling from the Pittman motor to the screw that drives the mirror with a pitch of 20 turns per inch. The motor is not geared down, and this results in a translation encoding of 0.39 counts per micron and 7 counts/pixel or about 18 counts per arcsecond. That is, only 7/500 turn for 1 arc second of image defocus.