}
Echelle Motion Control

Echelle Motion Control
Documentation


ACC Software Interface

    Table of Contents
  1. Command Structure
  2. Command Responses
  3. Command Descriptions
  4. Software Tutorial
  5. Compiling ACC Software
  6. ACC Configuration
  7. Known Software Issues

    Command Structure

    The command structure consists of 2 characters, a space (0x20 hex) and in some cases a parameter list. The parameters are alphanumeric characters. A full explanation of the various parameters can be found in the following text.

                	CMD p1 p2 p3 p4...<CR>
                

    The CMD portion of the command structure designates the action to be taken. The parameter fields adds additional information necessary to perform the desired action.


    Command Responses

    Each command sent to the motion control software receives an immediate response and then any other information that may have been requested. The following table illustrates the responses of the motion control software:

                	Command  Response
                    Valid    06 hex (ack)
                             0d hex (cr)
                             ">" 
                    Invalid  15 hex (nak)
                             0d hex (cr)
                             "Invalid Commande"
                             0d hex (cr)
                             ">"
                
                    TABLE 0: Serial Responses
                

    Commands

                	Command        Action               Parameters
                      KL       Total Shutdown               -
                      RS       Reset Software               -
                      PA       Power On                 Board ID
                      PO       Power Off                Board ID
                      MV       Move Motors              Absolute position
                      FH       Find Home of Motor       Motor ID
                      ZC       Zero Motor Counter       Motor ID
                      ST       Status Request               -
                      IS       Interface Status             -
                      CI       Calibration Mirror In        -
                      CO       Calibration Mirror Out       -
                      LA       Lamp On                  Lamp ID
                      LO       Lamp Off                 Lamp ID
                      LX       Lamp On, Exclusive       Lamp ID
                      VA       Vacuum Sensor On         Vacuum Sensor ID
                      VO       Vacuum Sensor Off        Vacuum Sensor ID
                      IA       Ion Pump On                  -
                      IO       Ion Pump Off                 -
                      WV       Write Vacuum Enable          -
                      WO       Write Vacuum Disable         -
                      DG       DeGas Camera Tank            -
                
                        TABLE 1: Command Summary
                

    KL (Shutdown System)

    The KL command is used to shutdown the system. This command does the following things:

    1. Turns OFF vacuum gauges
    2. Turns OFF all calibration lamps
    3. Turns ON the Ion Pump
    4. Turns OFF all driver boards
    5. Turns OFF all power in the motor controller boxes

    This state is maintained until ANY command is received from the serial port or console keyboard. The program does not exit.

    RS (Reset Software) - Not Implemented

    The RS command is used to remotely reset the motion control software. The command performs a Ctrl-Alt-Del to reboot the motion control computer. The command syntax is:

                    RS<CR>

    PA (Power Activate)

    PA activates power to a specific driver board, or motor controller box. The valid Board IDs for this command are:

                	ID	Description
                    1       OptiDriver 1 - Filter wheels, Cal. Mirror
                    2       OptiDriver 2 - Slit Focus, Echelle Grating
                    3       OptiDriver 3 - Tip, Tilt
                    4       OptiDriver 4 - CCD Focus
                    5       All Low Voltage (5, 10, 24 V)
                
                         TABLE 2: Power Board IDs
                

    The specified board remains powered until commanded off (see PO) or a shutdown occurs. Only the first Board ID will be processed.

    PO (Power Off)

    PO disable power to the specified board. The valid Board IDs for the command are identical to those listed above for PA. Only the first Board ID will be processed per command.

    MV (Move)

    The MV command is used to instruct a motor or motors to move a specified distance. The motors move in units of steps. A step is 0.9 degrees of rotation of the motor shaft. The parameter list follows the format:

                    MV m1 m2 m3 m4 m5 m6 m7 m8<CR>

    The parameters are separated by spaces (0x20 hex). Each parameter (m1, m2, m3...) is a motor step or position value. The first 3 motors, calibration mirror, echelle filter and guide camera filter are indexed moves. The remainder of the motors are absolute position moves. If the motor is not to be moved a parameter of "N" (ascii ) should be used. Not all the parameters are necessary. Parameters may be omitted as long as the sequence of the command string is preserved. Examples to follow.

                	Parameter	Description		Range (integer steps)
                    m1		Calibration Mirror	{0 (out),  1 (in)}
                    m2		Echelle Filter Wheel	{1,2,3,4,5,6}
                    m3		Camera Filter Wheel	{1,2,3,4,5,6}
                    m4		Echelle Grating 	(-1000000,1000000)
                    m5		Slit Focus		(-1000000,1000000)
                    m6		CCD Tip			(-1000000,1000000)
                    m7		CCD Tilt		(-1000000,1000000)
                    m8		CCD Focus		(-1000000,1000000)
                
                        TABLE 3: MV Command Parameters
                

      Examples
    1. MV 1 2 3 N N 500 500 N<CR>
      This command would move the Calibration mirror to move "IN", Echelle Filter to position 2, the Camera Filter to position 3, the CCD Tip and CCD Tilt to move to absolute position +500 steps. The motors that have "N" parameters are ignored.
    2. MV 0 N N -450 N 23<CR>
      This example shows the omissions of the motors CCD Tilt and CCD Focus. The command orders the Calibration Mirror and the 2 Filter Wheels to be ignored, the Grating to move to position -450 steps, the Slit to be ignored, the CCD Tip to move to position +23 steps and the CCD Tip and CCD Focus to be ignored.
    3. MV 0<CR>
      This example is the extreme case where the Calibration Mirror is the only motor accessed. All other motors are ignored.

    FH (Find Home)

    The FH command is used to position the motor at a propositioned location known as "Home". This command is used internally by the motion control application but may also be accessed through the laboratory software applications as well as the remote software. The command syntax is:

    	FH mID<CR>

    where mID is the motor ID (1 to 8).

    ZC(Zero Motor Counter)

    The ZC command is used to reset the hardware counters of the motion control boards to zero. This command is proprietary to laboratory characterization and will not be used by any user of the Echelle Spectrograph. The command syntax is:

    	ZC mID<CR>

    where mID is the motor ID (1 to 8).

    ST (Status)

    ST commands the motion control software to transmit information on the position of the motors, lamps and vacuum. The command syntax is:

    	ST<CR>

    IS (Interface Status)

    IS commands the motion control software to transmit a limited information set on the motor positions and the vacuum conditions. The transmission is a single string delimited by spaces. Keywords are used as a parsing tool. The sting has the following composition:

    	"KEYWORD=######## KEYWORD=####### .... "

    The following table describes the available keywords and their associated information. The order of the keywords in the table is the order in which they appear in the string.

                	KEYWORD		Associated Object
                    CalbMir		Calibration Mirror Position
                    EchFltr		Echelle Filter Position
                    GCFiltr		Guide Camera Filter Position
                    Grating		Echelle Grating Motor Position
                    SlitFcs		Slit Focus Motor Position
                    TipMotr		CCD Tip Motor Position
                    TiltMtr		CCD Tilt Motor Position
                    CCDFocs		CCD Focus Motor Position
                    VacuumLO	Low Vacuum Sensor Reading
                    VacuumHI	High Vacuum Sensor Reading
                    IonHV		Ion Pump High Voltage Status
                
                        TABLE 6: Keyword Summary
                

    The command syntax is:

    	IS<CR>

    CI (Calibration In)

    CI commands the Calibration mirror to move into position for calibration to take place. The command syntax is:

    	CI<CR>

    CO (Calibration Out)

    CO commands the Calibration mirror to move out of the optical path of the Echelle Spectrograph. The command syntax is:

    	CO<CR>

    LA (Lamp Activate)

    The LA command activates one of 3 lamps used for calibration of the spectrograph. The command syntax is:

    	LA lampID<CR>

    Once the lamp is activated it will remain active until commanded off (see LO).

                	lampID		Description
                    "F"		Fe/Ne Lamp
                    "T"		Th/Ar Lamp
                    "W"		White Lamp
                    "A"		All Lamps (only used with LO)
                
                    TABLE 5: LA/LO Command Parameters 
                

    LO (Lamp Off)

    The LO command deactivates one of 3 lamps used for calibration of the spectrograph. The command syntax is:

    	LO lampID<CR>

    Refer to the LA command for a description of parameters.

    LX (Lamp activate, eXclusive)

    The LX command activates one of 3 lamps used for calibration of the spectrograph. ALL other lamps are deactivated by this command! It is equivalent to issuing the commands:
    	LO A
                    LA lampID

    The command syntax is:

    	LX lampID<CR>

    Once the lamp is activated it will remain active until commanded off (see LO).

    VA (Vacuum Activate)

    VA commands the motion control software to activate one or both of the echelle vacuum sensors. The command parameters are described in TABLE 7: VA/VO command parameters. The sting has the following syntax:

    	VA vacuumID<CR>

                	vacuumID	Description
                    "L"		Low vacuum sensor
                    "H"		High vacuum sensor
                
                    TABLE 7: VA/VO command Parameters
                

    VO (Vacuum Off)

    VO commands the motion control software to de-activate one or both of the echelle vacuum sensors. VO syntax:

    	VO vacuumID<CR>

    For valid "vacuumID"s, see VA.

    Note: An artifact of the electronics design forces both vacuum sensors to be de-activated when the "VO L" command is given.

    IA (Ion Activate)

    IA turns on the ion pump. There are no parameters.

    IO (Ion OFF)

    IO turns off the ion pump. There are no parameters.

    WV (Write Vacuum)

    WV starts writing vacuum readings to the file "vacuum.log". All data is appended to the file, so there is no danger of overwriting previous data. There is no error checking for disk space, etc. Vacuum readings are recorded every 30 seconds. WV will not turn on or off the vacuum gauges. A timestamp is included for logging purposes.

    This command should only be issued from the console! Issuing it over the serial link may not produce expected results!

    WO (Write Off)

    WO stops recording vacuum readings to a file. It does not change the state of the vacuum guages. No timestamp is written to indicate logging has stopped.

    This command should only be issued from the console! Issuing it over the serial link may not produce expected results!

    DG (DeGas)

    DG is a meta-command that moves all camera tank motors limit-to-limit N times, then conducts a "Find Home". This is to allow gasses trapped in the motor windings and threads to be vented. The DeGas procedure requests the # of cycles to run from the keyboard; there are no parameters on the command-line. DeGas can take a long time; for 5 cycles, it is estimated to take well over 1 hour. Once started, the procedure cannot be aborted without rebooting the ACC. This reboot cannot be done remotely.

    This command may only be issued from the console! Issuing it over the serial link will result in a locked ACC that is waiting for keyboard input! This state cannot be fixed remotely!


    Software Tutorial

    Getting Started

    Turn on the computer and monitor. From the command line, run "C:\MOTORS\MOTORS.EXE". The last position of the motors will be loaded from the hard disk. Once the position information is loaded (less than 5 seconds) the motors are ready to be moved. If you wish to skip the startup seek of the last known filter positions and cal. mirror, give the "/d" switch to MOTORS.EXE when starting.

    Entering Commands

    There are two methods to enter commands. The first is using a terminal connected to the Motor PC. The second method is using "Control-K" interrupts at the Motor PC console.
    Terminal Communications
    The software was designed to be controlled by another computer over an RS232 Serial connection. This is the easiest way to control the motors. Any computer runniing a terminal emulator at 9600 baud, 8 bits , 1 stop bit and no parity will be able to communicate with the Motor PC. Issue the above commands as listed.
    "Ctrl-K" Interrupts
    Commands can be entered from the Motor PC's keyboard. Here's how to do it: Briefly, press the "CTRL" key and the "K" key at the same time. Repeat until the message "KEYBOARD MODE...Enter Command" appears. On the next line a ">" will appear. At this point enter the command. You may also enter "Console-only" commands from this prompt. There are some drawbacks to using the Control-K entry method:
    1. Editing of the command line is virtually impossible
    2. Each command requires pressing CTRL-K to get the input prompt
    3. The ACC is often difficult to work at due to location

    Motors

    There are 8 motors used in the Echelle. Each motor has a number designation as well as a name. Here is the list of motors:

                	Motor #		Name
                    0...............Calibration Mirror
                    1...............Echelle Filter Wheel
                    2...............Guider Filter Wheel
                    3...............Grating Tilt
                    4...............Slit Bench Focus
                    5...............CCD Tip
                    6...............CCD Tilt
                    7...............CCD Focus
                
                Movement Ranges
                Motor 0	        0 = Out, 1 = IN
                Motor 1, 2	{1,2,3,4,5,6}
                Motor 3 - 7	(-1000000, 1000000) [integers only]
                Note: Actual travel for motors 3 through 7 may be less than stated 
                upper range.
                

    Compiling Echelle ACC Software

    All software for the ACC is written in MicroSoft Visual C++ under Windows 3.1. It is compiled as a DOS program from Windows 3.1. The build machine for the flight ACC software is a Pentium machine that is using only 386 optimizations. On the Pentium, it takes <10 minutes to compile from scratch.

    The source code listing includes the Makefile used for MS Visual C++, although it is not recommended to enter this Makefile by hand (it is very long and tedious).

    Porting to another compiler should be relatively simple - the only potential pitfalls are the use of <conio.h> for DOS-specific functions (kbhit() and clearscreen()), and whatever is in <afx.h>. There should not be any Visual C++-specific classes used in the code.


    Echelle ACC Configuration

                Device/Card           Address   Slot #    IRQ #         Description
                OptiStep Card #1        250        4      Disabled      Controller for Calibration 
                                                                        Mirror and Filter Wheels 
                OptiStep Card #2        260        3      Disabled	Controller for Grating and 
                                                                        Slit Focus motors
                OptiStep Card #3        270        2      Disabled	Controller for CCD Tip 
                                                                        and CCD Tilt motors
                OptiStep Card #4        280        1      Disabled	Controller for CCD Focus 
                                                                        motors
                DAS-1402 Card           2A0        5      N/A		A/D Converter for Vacuum 
                                                                        and Temperature monitors
                PIO-24 Card             300        6      Disabled	Digital I/O for device 
                                                                        power control
                CTM-05 Card #1          330        7      Disabled	Counter Card for 
                                                                        encoders
                CTM-05 Card #2          390        8      Disabled	Counter Card for 
                                                                        encoders
                CAT975                  N/A        9      IRQ 4 = COM1	386sx Computer Card
                                                          IRQ 14 = HD
                                                          IRQ 6 = Floppy
                                                          IRQ 5 = Parallel Port
                                                          IRQ 12 = PS/2 Mouse(Disabled)
                

    Known Software Issues

    The following are the known "software issues":
    1. If the program is stopped, then restarted without rebooting, it dies with the error "abnormal program termination". The death occurs when attempting to initialize the PIO board. Current hypothesis is that the problem is a lack of memory, and the program can't create a new PIO object and calls abort().
    2. Occasionally, there are spurious limit switch and shield switch triggers. When told to move, the move is stopped by a limit or shield switch trigger. If told to move to the same location again, the move completes normally. This has been seen mostly with the CCD focus, although other camera tank motors have had the problem. No reports of this problem with slit focus, grating tilt, filter wheels, or cal flat.
    3. RS not implemented. This requires the use of a specific DOS interrupt, and has not been coded yet. The RS command does nothing.