24
KOSMOS Document v1.1 2010 July 12 1 KOSMOS Kitt Peak-Ohio State Multi-Object Spectrograph Instrument Control Software Revision History Version Author Date Description 1.0 Gonzalez R., Pogge R. 2010 July 9 Initial Draft 1.1 Gonzalez R., Pogge, R. 2010 July 12 Final Draft

Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

  • Upload
    others

  • View
    12

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

1

KOSMOS Kitt Peak-Ohio State Multi-Object Spectrograph

Instrument Control Software

Revision History

Version Author Date Description

1.0 Gonzalez R., Pogge R. 2010 July 9 Initial Draft

1.1 Gonzalez R., Pogge, R. 2010 July 12 Final Draft

Page 2: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

2

Table of Contents 1 Overview ............................................................................................................................3

1.1 Relation to the KOSMOS NOCS Architecture.............................................................4 1.2 iebUtils Architecture....................................................................................................5

2 iebUtils library functions.....................................................................................................7 2.1 General Mechanism Commands ..................................................................................7

2.1.1 ieb_open() – Open a communications port to a mechanism ..................................7 2.1.2 ieb_close() – Close a communications port to a mechanism .................................8 2.1.3 ieb_reset() – Reset a mechanism ..........................................................................8 2.1.4 ieb_home() – Home a mechanism ........................................................................9 2.1.5 ieb_abort() – Abort a mechanism .......................................................................10 2.1.6 ieb_abortAll() – Abort all mechanisms...............................................................10 2.1.7 ieb_rdbits() – Read raw mechanism position sensor bits.....................................11 2.1.8 ieb_mlcCmd() – execute a raw MicroLYNX motor-controller command ...........12

2.2 Wheel Mechanism Commands...................................................................................13 2.2.1 ieb_getWheel() – Get the current wheel position................................................13 2.2.2 ieb_setWheel() – Set a wheel mechanism to an absolute position .......................13 2.2.3 ieb_stepWheel() – Step (offset) a wheel from its current position.......................14

2.3 Linear Stage Mechanism Commands .........................................................................16 2.3.1 ieb_getStage() – Get the current linear stage position.........................................16 2.3.2 ieb_setStage() – Set linear stage to a requested absolute position .......................16 2.3.3 ieb_stepStage() – Step (offset) a linear stage relative to its current position........17

2.4 Power Management and Environmental Monitoring Commands................................19 2.4.1 ieb_openWago() – Open communications to a WAGO FieldBus controller........19 2.4.2 ieb_closeWago() – Close communications with a WAGO FieldBus controller...19 2.4.3 ieb_setPower() – Turn device power ON or OFF ...............................................20 2.4.4 ieb_getPower() – Get power state of a specified device......................................21 2.4.5 ieb_powerState() – Return the power state of all IEB mechanisms .....................21 2.4.6 ieb_getTemps() – Read the instrument temperature sensors ...............................22 2.4.7 ieb_getMPower() – Read the motor drive power supply sensors.........................23

3 References.........................................................................................................................24

Page 3: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

3

1 Overview

The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram of the IEB is shown in Figure 1 below. The IEB houses the six MicroLYNX 7 programmable stepper motor controllers that operate the KOSMOS mechanisms (two filters wheels, a slit mask wheel, a disperser wheel and two focus stages), a WAGO modular automation system to provide environmental monitoring and power management functions (temperature sensor readouts, relays for power management, air circulation fan control, and voltage and current sensor readouts), a COMTROL DeviceMaster RTS 8-port serial port server that provides the serial communications interface for the MicroLYNX controllers, and an Ethernet hub that distributes Ethernet services to the IEB.

Figure 1: KOSMOS IEB functional block diagram

Page 4: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

4

The principal functions provided by the iebUtils library are as follows:

1. Command and control of individual KOSMOS mechanisms (filter wheels, slit wheel, disperser wheel, and focusers) except the shutter. The shutter is controlled by a custom circuit board in the IEB that is directly triggered by NOCS.

2. Readout of KOSMOS environmental and housekeeping monitors, including temperature, voltage, and current sensors.

3. Power management functions both for individual stepper motor controllers and for the main 65V motor drive power supply.

4. Control of the air circulation and exhaust fans.

Each of the six MicroLYNX stepper motor controllers use on-board PLC microcode to perform the actual mechanism operation. This allows all KOSMOS mechanisms to be operated in parallel. The iebUtils library functions are therefore designed to be thread-safe.

1.1 Relation to the KOSMOS NOCS Architecture

The iebUtils libraries are a small component of the overall NOCS system[1] that will be used to operate KOSMOS by observers and support personnel. The NOCS architecture for KOSMOS is shown below

Figure 2. KOSMOS NOCS Architecture

The iebUtils library constitutes the portion of the NICS system labeled ICD 3.2 in Figure 2. The

Page 5: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

5

design of the iebUtils functions is to make them readily implemented in the wrappers described in the NICS ICD[2]. This requires that we code the library in standard ANSI C to make it portable and to include all external libraries needed to make it self-contained. We have adopted a simple, modular architecture to implement the mechanism functions.

1.2 iebUtils Architecture

All mechanisms, whether wheels or linear stages, need functions to read (“get”) their current position, “set” them to a new position, and to perform basic low-level functions like open, close, reset, and abort. Convenience functions are provided for homing and stepping the mechanisms (these are common subsets of the more generic “set” function). Additionally, we provide basic diagnostic functions to read raw sensor bits and provide engineering access to the MicroLYNX command layer. Each mechanism is assigned a simple yet descriptive mechanism ID to distinguish them (e.g., filter1, slit, colfoc) listed in Table 1. The KOSMOS instrument, like OSMOS, has two basic mechanism topologies:

Indexed Wheels: Rotary devices with 6 mechanically indexed, kinematically docked positions. The only valid positions are the 6 indexed locations encoded with three position sensors bits and a fourth in-position sensor used to sense when the wheel is out of one of these docked positions. There are four indexed wheels in KOSMOS: two filter wheels, a slit mask wheel, and a disperser wheel. Linear Stages: Precision linear stages that can be positioned continuously between two hard limits. A conversion factor is carried in the code to convert stepper motor revolutions (the basic unit of the MicroLYNX) into linear motion of the stage payload in microns. KOSMOS has two linear stages: the camera lens focus stage and the collimator lens focus stage.

The iebUtils library abstracts the mechanisms into wheel and stage types as described in §2.2 and §2.3, respectively, providing generic get, set, and step functions for each. Non-mechanism functions of the IEB include reading out temperature sensors deployed throughout the instrument, reading voltage and current sensors on the main motor drive power supply, and switched power for the main drive supply, the individual MicroLYNX controllers, and to control the operation of the air circulation and exhaust fans in the IEB enclosure. The iebUtils library provides functions implementing all of these features. For the power control functions, iebUtils abstracts these as get and set functions, using a device ID to distinguish the utility being controlled. A list of device IDs is given in Table 2. The iebUtils library functions are summarized in Tables 3 and 4. The following sections of this document describe these functions in detail.

Page 6: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

6

Table 1: KOSMOS IEB Mechanism IDs mechID Mechanism ID names for MicroLYNX controllers filter1 Filter1 wheel (6 index positions) filter2 Filter2 wheel (6 index positions) disperser Disperser wheel (6 index positions) slit Slit wheel holds (6 index positions) camfoc Camera lens linear focus stage colfoc Collimator lens linear focus stage

Table 2: KOSMOS IEB Device IDs for Power Management

deviceID Description MPOWER 65VDC motor controller power supply for all 6 mechanisms CFAN IEB enclosure internal air circulation fan EFAN IEB enclosure exhaust fan MLCn n = 1..7, individual MicroLYNX controllers (6 + 1 hot spare)

Table 3: iebUtils Library Mechanism Control Functions

Function Description int ieb_open() Open communications to a mechanism MicroLYNX controller int ieb_close() Close communications to a mechanism MicroLYNX controller int ieb_reset() Reset a mechanism int ieb_home() Home a mechanism int ieb_abort() Abort mechanism motion int ieb_abortAll() Abort all mechanisms int ieb_rdbits() Read a mechanism’s sensor bits int ieb_mlcCmd() Issue a raw MicroLYNX command to the named mechanism int ieb_getWheel() Get the current wheel mechanism position int ieb_setWheel() Set a wheel mechanism to a specified position int ieb_stepWheel() Step to +/-n wheel positions relative to the current position float ieb_getStage() Get the current linear stage mechanism’s current position float ieb_setStage() Set a linear stage mechanism to a given position float ieb_stepStage() Step (offset) the linear stage relative to the current position

Table 4: iebUtils Library Power Management and Environmental Monitor Functions Function Description int ieb_openWago() Open communications to a WAGO FieldBus controller int ieb_closeWago() Close communications to a WAGO FieldBus controller int ieb_getPower() Get the current power state of a device int ieb_setPower() Turn device power on/off int ieb_powerState() Get the power state of all IEB devices int ieb_getTemps() Read all IEB temperature sensors int ieb_getMPower() Read the motor power sensors (voltage and current)

Page 7: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

7

2 iebUtils library functions

The iebUtils library functions will be implemented in ANSI standard C language, using the Gnu C Compiler (gcc) suite. The functions are designed to be simple, modular, and thread-safe. The design of the iebUtils functions is to provide all of the functions needed to operate the KOSMOS IEB mechanisms and utilities at the most basic level. Higher-level functions, like runtime initialization file parsing, maintenance of device population tables (like filter and slit lists), are the responsibility of the NOCS architecture.

2.1 General Mechanism Commands

These functions are generic to all KOSMOS mechanisms regardless of topology (wheel or linear stage). They provide functions for opening and closing communications to a mechanism’s MicroLYNX controller, functions for reseting an active mechanism, aborting mechanism motions, and reading the raw sensors data (either position sensors for a wheel mechanism or upper/lower limit sensors for linear mechanisms). In addition, we provide two convenience functions for homing a mechanism (moving to a reference mechanical home/zero position), aborting all mechanisms. Finally, a generic function provides direct “bare metal” access to the MicroLYNX controller proper for diagnostic engineering purposes. In all of these functions (except ieb_abortAll) address mechanisms by name using one of the valid mechanism IDs listed in Table 1.

2.1.1 ieb_open() – Open a communications port to a mechanism

Prototype: int ieb_open(char *mechID, char *hostIP, int hostPort, int minPos, int maxPos, int timeout, double convf, char *replyStr)

Parameters: char *mechID mechanism ID (e.g., filter1, slit) char *hostIP IP address of mechID’s Comtrol port int hostPort Port number of mechID’s Comtrol port int minPos Minimum device position (nearest integer) int maxPos Maximum device position (nearest integer) int timeout Communications timeout in integer seconds double convf Conversion between revs and physical position (e.g., µm/rev) char *replyStr String to hold command replies

Returns: 0 on success -1 on errors, with the error message in replyStr

Page 8: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

8

Description:

Opens the TCP/IP communications port on the Comtrol to the named mechanism, and sets the basic mechanism parameters. The port connection stays open until either an ieb_close() is sent, or the host program terminates. For wheel mechanisms with indexed positions, the convf parameter is ignored, and should be set to 1.0 as a placeholder. For linear stages, the convf parameter gives the conversion between revolutions of the stepper motor shaft and physical motion of the stage in units of microns per revolution.

Example: ieb_open(’filter1’,’172.16.1.85’,8001,1,8,30,1.0,replyStr);

See Also: ieb_close(), ieb_reset()

2.1.2 ieb_close() – Close a communications port to a mechanism

Prototype: int ieb_close(char *mechID, char *replyStr)

Parameters: char *mechID mechanism ID (e.g., filter1, slit) char *replyStr String to hold command replies

Returns: 0 on success -1 on errors, with the error message in replyStr

Description: Closes the TCP/IP communications port on the Comtrol to the named mechanism.

Example: ieb_close(’filter2’,replyStr);

See Also: ieb_open()

2.1.3 ieb_reset() – Reset a mechanism

Prototype: int ieb_reset(char *mechID, char *replyStr)

Parameters: char *mechID mechanism ID (e.g., filter1, slit) char *replyStr String to hold command replies

Page 9: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

9

Returns:

0 on success -1 on errors, with the error message in replyStr

Description: Resets the named mechanism, performing the following actions:

1. Closes then re-opens the communications port using the parameters set initially by the ieb_open() call for this mechanism.

2. On re-opening communications, resets the MicroLYNX program state.

3. Homes the mechanism.

a. For linear stages, it drives the mechanism to the mechanical home position.

b. For wheels, it makes sure the mechanism is in the nearest (or current) valid position (it does not move the wheel to position 1).

4. Clears any additional relevant mechanism state flags.

In this sense, “reset” does more than just home the mechanism, even though that is the most readily apparent outcome.

Example: ieb_reset(’camfoc’,replyStr);

See Also: ieb_open(), ieb_close()

2.1.4 ieb_home() – Home a mechanism

Prototype: int ieb_home(char *mechID, char *replyStr)

Parameters: char *mechID mechanism ID (e.g., filter1, slit) char *replyStr String to hold command replies

Returns: 0 on success -1 on errors, with the error message in replyStr

Description: Moves the named mechanism to its mechanical home position. For linear stages, it drives the mechanism to the mechanical home position located usually at the “safe” limit of travel for the stage. For wheel mechanisms, it moves the wheel into position 1, although “homing” a wheel mechanism usually makes little sense in a rotary mechanism with an arbitrary home position.

Page 10: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

10

Example:

ierr = ieb_home(’camfoc’,replyStr);

See Also: ieb_reset()

2.1.5 ieb_abort() – Abort a mechanism

Prototype: int ieb_abort(char *mechID, char *replyStr)

Parameters: char *mechID mechanism ID (e.g., filter1, slit) char *replyStr String to hold command replies

Returns: 0 on success -1 on errors, with the error message in replyStr

Description: Aborts any current motion of the named mechanism. The mechanism stops in place, which for a wheel mechanism could leave the wheel in between valid positions and requiring a reset to recover function. If the mechanism is not currently moving, an abort has no effect. It is not considered an error to abort an idle mechanism.

Example: ierr = ieb_abort(’colfoc’,replyStr);

See Also: ieb_abortAll(), ieb_reset()

2.1.6 ieb_abortAll() – Abort all mechanisms

Prototype: int ieb_abortAll(char *replyStr)

Parameters: char *replyStr String to hold command replies

Returns: 0 on success -1 on errors, with the error message in replyStr

Page 11: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

11

Description: This function aborts the motion of all instrument mechanisms. This is a convenience function provided as a way to implement a way to stop all motions (panic stop) at once. It has no effect on idle mechanism. Aborted mechanisms may require a reset to restore function.

Example: ierr = ieb_abortAll(replyStr);

See Also: ieb_abort(), ieb_reset()

2.1.7 ieb_rdbits() – Read raw mechanism position sensor bits

Prototype: int ieb_rdbits(char *mechID, char *replyStr)

Parameters: char *mechID mechanism ID (e.g., filter1, slit) char *replyStr String to hold command replies

Returns: 0 on success, with the bit pattern in replyStr -1 on errors, with the error message in replyStr

Description: Reads out all position sensors for the named mechanism and returns the results as a bit pattern string. For linear mechanisms, the bits are the clockwise and counterclockwise limit sensors. For example, for a focus stage rdbits might return of “01” would indicate that the mechanism was against the counterclockwise limit sensor, whereas “00” means the camera focus stage is at a position between the two limits. If the bit pattern returned by a linear stage is “11”, this is a sensor fault (you cannot have both limit sensors asserted at the same time) and -1 will be returned. For wheel mechanisms, the bits read are the LSB to MSB position bits, followed by the in-position sensor bit. For example, “0101”, for a filter wheel would mean that the wheel is in position 3 (bits 010 = 2, so physical position 2+1=3), and the 4th bit means it is in a valid position. If the wheel was stuck between positions, rdbits would return “0000”. This is meant to be used as a diagnostic function to test the various limit and discrete sensor data. To read the position of a linear stage or wheel, the appropriate “get” function should be used.

Page 12: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

12

Example:

ierr = ieb_rdbits(’disperser’,replyStr);

2.1.8 ieb_mlcCmd() – execute a raw MicroLYNX motor-controller command

Prototype: int ieb_mlcCmd(char *mechID, char *cmdStr, char *replyStr)

Parameters: char *mechID mechanism ID (e.g., filter1, slit) char *cmdStr raw microLynx command to execute char *replyStr string to hold command replies

Returns: 0 on success with any output in replyStr -1 on errors, with the error message in replyStr

Description: Sends the raw MicroLYNX command cmdStr to the named mechanism. If the command executes without errors, the function returns 0 and replyStr contains any output generated by the MicroLYNX controller. If the requested command caused an error in the MicroLYNX controller, the function returns -1 an replyStr contains an error message. Access to the lowest-level MicroLYNX commands is provided for diagnostic or engineering purposes. The MicroLYNX series controllers have a rich command set. Consult the MicroLYNX manual for the commands and their syntax. Please note that this command gives you “bare metal” access to the mechanisms, so great care should be taken in using this function, as it is possible to issue commands that can damage mechanisms (e.g., overdrive a pinion gear, jam a lead screw, etc.).

Example: ierr = ieb_mlcCmd(’slit’,’PRINT VM’,replyStr);

See Also:

Page 13: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

13

2.2 Wheel Mechanism Commands

KOSMOS has 4 wheel mechanisms: two filter wheels, one slit wheel, and one disperser wheel. Each wheel has 6 discrete positions numbered 1 through 6. These functions are used to query a wheel position, set a wheel to a given absolute position, or step a wheel by a given number of positions relative to the current position. As with the generic mechanism functions listed in §2.1, mechanisms are addressed by name using one of the wheel mechanism IDs listed in Table 1.

2.2.1 ieb_getWheel() – Get the current wheel position

Prototype: int ieb_getWheel(char *mechID, char *replyStr)

Parameters: char *mechID wheel mechanism ID (e.g., filter1, slit) char *replyStr String to hold command replies

Returns: Current Position (1..6) on success -1 on errors, with an error message (replyStr)

Description: Get the position of wheel mechanism mechID. On success it returns the integer indexed position, 1..6. On errors, it returns -1 and an error message in replyStr.

Example: int filt1Pos = ieb_getWheel(’filter1’,replyStr);

See Also: ieb_setWheel(), ieb_stepWheel(),ieb_rdbits()

2.2.2 ieb_setWheel() – Set a wheel mechanism to an absolute position

Prototype: int ieb_setWheel(char *mechID, int reqPos, char *replyStr)

Parameters: char *mechID wheel mechanism ID (e.g., filter1, slit) int reqPos requested absolute position (Range:1..6) char *replyStr string to hold command replies

Returns: Final wheel position (1..6) on success -1 on errors, with the error message in replyStr

Page 14: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

14

Description: Set the wheel mechanism mechID to absolute index position reqPos. The MicroLYNX controller for mechID computes the move that will take the least time clockwise or counterclockwise relative to the current position to complete the move. On success, this function will return the position (1..6) at the end of the move. If the move fails to reach the requested position for any reason, this function returns -1 with an error message in replyStr. If the requested position is out of the valid range, it will return -1 and a syntax error message without attempting to move.

Example: int newFilter2 = ieb_setWheel(’filter2’,4,replyStr);

See Also: ieb_getWheel(), ieb_stepWheel(), ieb_reset(), ieb_rdbits(), ieb_abort()

2.2.3 ieb_stepWheel() – Step (offset) a wheel from its current position

Prototype: int ieb_stepWheel(char *mechID, int deltaPos, char *replyStr)

Parameters: char *mechID wheel mechanism ID (e.g., filter1, slit) int deltaPos number of positions to step the wheel char *replyStr string to hold command replies

Returns: New wheel position (1..6) after stepping on success -1 on errors, with the error message in replyStr

Description: Step the wheel mechanism mechID by deltaPos wheel positions, with + deltaPos being clockwise and – deltaPos being counterclockwise rotation of the wheel. For example, deltaPos=+2 will move the wheel by two full positions clockwise from the current position. On success, this function returns the new wheel position after the step. On errors, this function returns -1 and replyStr contains an error message describing why the requested motion failed. This function is meant primarily as an engineering utility, for example to be used in conjunction with ieb_rdbits() to scan a wheel’s position sensors to diagnose sensor faults. In normal operation all wheel functions are provided for by ieb_getWheel() and ieb_setWheel().

Page 15: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

15

Example: int newSlit = ieb_stepWheel(’slit’,-1,replyStr);

See Also: ieb_getWheel(), ieb_setWheel(), ieb_rdbits()

Page 16: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

16

2.3 Linear Stage Mechanism Commands

KOSMOS has two linear stages for focusing the camera and collimator lenses. These functions are used to query the current position of a given linear stage, move the linear stage to a given absolute position measured in microns from it mechanical home (zero) position, or to step (offset) a stage relative to the current position. As with the generic mechanism functions listed in §2.1, mechanisms are addressed by name using one of the linear stage mechanism IDs listed in Table 1.

2.3.1 ieb_getStage() – Get the current linear stage position

Prototype: float ieb_getStage(char *mechID, char *replyStr)

Parameters: char *mechID linear stage mechanism ID (camfoc or colfoc) char *replyStr String to hold command replies

Returns: Current absolute stage position in microns from home on success -1.0 on errors, with an error message in replyStr

Description: Get the current position of the linear stage mechID. The position is returned as a floating point number in units of microns measured from the linear stage’s mechanical home (zero) position. On errors, this function returns -1.0 with an error string in replyStr.

Example: float camFocus = ieb_getStage(’camfoc’,replyStr);

See Also: ieb_setStage(), ieb_stepStage()

2.3.2 ieb_setStage() – Set linear stage to a requested absolute position

Prototype: float ieb_setStage(char *mechID, float reqPos, char *replyStr)

Parameters: char *mechID linear stage mechanism ID (camfoc or colfoc) float reqPos requested position (Range 0..10000 microns) char *replyStr String to hold command replies

Page 17: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

17

Returns: New absolute stage position in microns from home on success -1.0 on errors, with an error message in replyStr

Description: This function moves linear stage mechanism mechID to the requested position reqPos. The position is in units of microns from its mechanical home (zero) position, and is always positive definite. Position 0 is equivalent to homing the mechanism, although the ieb_home() function is the preferred way to home a linear stage mechanism. The maximum position is nominally 10000 microns (10mm), but the actual maximum position may be a little less depending on the precise location of the stage’s clockwise limit switch. Because of a combination of a harmonic reducing gear and the linear lead screw pitch in the two KOSMOS focus stages, the precision of the stage motion is 1/3 of a micron, which is rounded to the nearest 0.1 microns. In general, both linear focus stages should be set in units of 1.0 microns, and the depth of focus is such that motions of 10s of microns are required to produce measurable changes in image quality (e.g., while focusing the camera or collimator lens). If the requested position reqPos is out of range, the function returns -1 with an out-of-range error in replyStr. If any other error occurs, it returns -1 and replyStr contains an error message.

Example: float newPos = ieb_setStage(’camfoc’,1000.0,replyStr);

See Also: ieb_getStage(), ieb_stepStage(), ieb_home()

2.3.3 ieb_stepStage() – Step (offset) a linear stage relative to its current position

Prototype: float ieb_stepStage(char *mechID, float deltaPos, char *replyStr)

Parameters: char *mechID linear stage mechanism ID (camfoc or colfoc) float deltaPos step (offset) to apply in microns (see below) char *replyStr string to hold command replies

Returns: Absolute stage position in microns from home after the step -1 on errors, with an error message in replyStr

Page 18: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

18

Description: Step (offset) the linear stage mechanism mechID by the requested amount relative to the current position in units of microns, with + deltaPos moving away from the mechanism home (zero) position, and – deltaPos moving the mechanism toward mechanism home. On success, the function returns the absolute stage position after the move in units of microns from the mechanical home (zero) position. On errors, the function returns -1 with an error string in replyStr. Note that ieb_stepStage() does not test the requested step to see if a move relative to the current stage position will run into either of the stage limits.

Example: float newPos = ieb_stepStage(’colfoc’,-50.0,replyStr);

See Also: ieb_getStage(), ieb_setStage()

Page 19: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

19

2.4 Power Management and Environmental Monitoring Commands

All IEB power management and environmental sensors are operated using a WAGO-I/O-Series 750 FieldBus controller. A suite of WAGO modules mounted on a DIN-rail inside the IEB provide readout of temperature sensors, operation of relays for power switching, and readout of ADCs connected to voltage and current sensors. These functions are used to interact with the WAGO modules via the FieldBus controller’s TCP/IP port.

2.4.1 ieb_openWago() – Open communications to a WAGO FieldBus controller

Prototype: int ieb_openWago(char *hostIP, char *replyStr)

Parameters: char *hostIP IP address of the WAGO FieldBus controller char *replyStr String to hold command replies

Returns: 0 on success -1 on errors, with the error message in replyStr

Description:

Opens a TCP/IP communications port to the WAGO FieldBus controller on network addres hostIP. All WAGO FieldBus controllers use the same port for TCP/IP communications, so unlike ieb_open() we do not need to specify the port. The TCP/IP connection stays open until either an ieb_closeWago() is sent, or the host program terminates.

Example: ieb_openWago(’172.16.1.123’,replyStr);

See Also: ieb_closeWago()

2.4.2 ieb_closeWago() – Close communications with a WAGO FieldBus controller

Prototype: int ieb_closeWago(char *replyStr)

Parameters: char *replyStr String to hold command replies

Returns: 0 on success -1 on errors, with the error message in replyStr

Page 20: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

20

Description: Closes the TCP/IP communications session with the WAGO FieldBus controller.

Example: ieb_closeWago(replyStr);

See Also: ieb_openWago()

2.4.3 ieb_setPower() – Turn device power ON or OFF

Prototype: int ieb_setPower(char *deviceID, int power, char *replyStr)

Parameters: char *deviceID device to power on or off (see below) int power requested power state: 1=ON, 0=OFF char *replyStr string to hold command replies

Returns: 0 if the device was successfully turned off 1 if the device was successfully turned on -1 on errors, with the error message in replyStr

Description: This function is used to switch the power for deviceID ON or OFF. If the function is successful, it returns 0 if the device is OFF or 1 if the device is ON after the function call. On errors, the function returns -1 with an error message in the replyStr. Devices under remote power control are as follows:

deviceID Description MPOWER 65VDC Motor drive power for all 6 mechanisms MLCn MicroLYNX controller #n, n=1..7 EFAN IEB exhaust fan power CFAN IEB internal air circulation fan power

In general, it is recommended that only MPOWER, EFAN, and CFAN be implemented as user functions. The ability to individually switch power to each MicroLYNX controller is provided only as an engineering function. Powering on a single controller induces a momentarily large in-rush current that can cause one of the power relays to fuse over time (luckily the failure mode is for the relay to fail so as to keep the MicroLYNX in question always powered on). For cycling power on the IEB to do a “hard reset” of the MicroLYNX controllers, the preferred method is to power off the 65VDC drive power via

Page 21: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

21

mechID=MPOWER.

Example: ierr = ieb_setPower(’EFAN’,1,replyStr);

See Also: ieb_getPower()

2.4.4 ieb_getPower() – Get power state of a specified device

Prototype: int ieb_getPower(char *deviceID, char *replyStr)

Parameters: char *deviceID device ID (see ieb_setPower() for a table) char *replyStr String to hold command replies

Returns: 0 if the device is OFF, 1 if the device is ON -1 on errors, with the error message in replyStr

Description: This function returns the current power state of deviceID, returning the integer 0 if deviceID is powered OFF, and 1 if deviceID is powered ON. If the power state cannot be read or any other fault occurs, this function returns -1 along with a descriptive error message in replyStr.

Example: int mlcPower1 = ieb_getPower(’MLC1’,replyStr);

See Also: ieb_setPower(), ieb_powerState()

2.4.5 ieb_powerState() – Return the power state of all IEB mechanisms

Prototype: int ieb_powerState(char *replyStr)

Parameters: char *replyStr String to hold command replies

Returns: Positive integer value on success -1 on errors, with the error message in replyStr

Description:

Page 22: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

22

This function queries the power state of all IEB devices, returning an integer value that must be read in base2 to determine power state of a particular mechanism.

WAGO 16-bit word for the Power Relay status Decimal Hex Binary 0=ON, 1=OFF Descriptions

0 0x0 0000 0000 0000 0000 Power ON for all mechanisms 1 0x1 0000 0000 0000 0001 MLC1 power OFF 2 0x2 0000 0000 0000 0010 MLC2 power OFF 4 0x4 0000 0000 0000 0100 MLC3 power OFF 8 0x8 0000 0000 0000 1000 MLC4 power OFF 16 0x10 0000 0000 0001 0000 MLC5 power OFF 32 0x20 0000 0000 0010 0000 MLC6 power OFF 64 0x40 0000 0000 0100 0000 MLC7 power OFF

128 0x80 0000 0000 1000 0000 EFAN power OFF 256 0x100 0000 0001 0000 0000 CFAN power OFF

On errors this function returns -1 with a descriptive error message in replyStr.

Example: int pState = ieb_powerState(replyStr); int efanPower = pState & 0x80;

See Also: ieb_setPower(), ieb_getPower()

2.4.6 ieb_getTemps() – Read the instrument temperature sensors

Prototype: int ieb_getTemps(char *replyStr)

Parameters: char *replyStr String to hold command replies

Returns: 0 on success with temperature values in replyStr -1 on errors, with the error message in replyStr

Description: This function reads the four temperature sensors deployed in the instrument and IEB, returning a list of temperatures in units of degrees Celsius to a precision of 0.1°C. The temperatures are in ASCII format in replyStr with a space separating them. If an error occurs, this function returns -1 with a descriptive error message in replyStr.

Page 23: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

23

Calibrated platinum resistance temperature detectors (RTDs) are deployed at 4 locations in KOSMOS: KOSMOS optical bench KOSMOS internal air temperature IEB internal air temperature External (ambient) air temperature outside the instrument enclosure The reply string is 4 decimal numbers, separated by spaces. For example ’21.2 21.3 22.0, 21.5’

which are, from left to right, the optical bench, instrument air, IEB air, and ambient temperatures in degrees Celsius.

Example: int ierr = ieb_getTemps(replyStr);

See Also: ieb_getMPower()

2.4.7 ieb_getMPower() – Read the motor drive power supply sensors

Prototype: int ieb_getMPower(char *replyStr)

Parameters: char *replyStr String to hold command replies

Returns: 0 on success with motor drive power supply sensor values in replyStr -1 on errors, with the error message in replyStr

Description: This function reads the voltage and current sensors on the 65V motor drive power, returning the data as a string with the voltage and current in VDC and Amps. If an error occurs, this function returns -1 with a descriptive error message in replyStr. The reply string is 2 decimal numbers, separated by spaces. For example ’64.9 8.52’

which are the supply voltage (64.9 VDC) and the supply current (8.52 Amps), reading from left to right.

Example: int ierr = ieb_getMPower(replyStr);

See Also: ieb_getTemps()

Page 24: Instrument Control Software · The iebUtils library is used to control all KOSMOS instrument functions provided by the Instrument Electronics Box (IEB). A functional block diagram

KOSMOS Document v1.1 2010 July 12

24

3 References 1. Daly, P. N. et al., 2008, ‘The NEWFIRM Observing Software: From Design To

Implementation’, in Advanced Software and Control for Astronomy II, edited by Alan Bridger and Nicole M. Radziwill, Proc. SPIE, Volume 7019, pp701913-1 to 701913-15.

2. Daly, P. N., 2010, ICD 3.1, Kosmos Project, NOAO.