Exampe of a IST script to be translated into a procedure to be called by the observation script

Header's information

// Missionphase  : FM ILT
//
// Purpose       : SFT in Open Loop Mode (warm conditions)
//                  
// Author        : Markus Nielbock
// CUS author    : MN
//
// Description   : SFT warm for FM1 chopper in open-loop mode. All 3 coils are
//                 operative. The chopper is commanded between -20 mA and +20mA
//                 in steps of 4 mA.
//                 The first part consists of chopper deflections equivalent to
//                 commanded chopper coil currents between 0 and +/-20 mA,
//                 alternating between positive and negative values. Absolute
//                 position commanding is used.
//                 The second part consists of a ramp of chopper deflections
//                 between -20 and +20 mA, commanded in relative steps of 4 mA.
//                 Finally, the chopper returns to its zero position.
//                  
// Dependencies  : 
//
// Preconditions : PACS switched-on in spectroscopy mode, chopper is switched
//                 off and disabled, diagnostic HK not running
//                 
// Comments      : Adapted from PACS_Chopper_SFT_Cold_OpenLoop_OBS.cus
//
// Version       : 1.0
// 
// History       : 1.0 12-03-07 creation by MN
// Begin Mode description

Here starts a long and complex script which only purpose is the setup the Chopper. It can be easily modified to an observation procedure which shall be called by the observation script proper

This will have to be edited out

mode PACS_Chopper_SFT_Warm_OpenLoop_OBS {
}{
   // Get OBSID from environment
    int myOBSID = $OBSID;
    // Send OBSID to DMC
    WriteOBSID(myOBSID);

here:

proc PACS_Chopper_SFT_Warm_OpenLoop {

}{

    // Start diagnostic HK
    PACS_SPEC_Chopper_OpenLoop_MoveAbs_dHK_BB("ON");
    delay(5);
    // Set default spectroscopy timing parameters
    SPEC_Chopper_SynchBlue();
    // Set Chopper Controller Parameters: CONFChopper -> SFTwarm
    CONF_chopper("CONFChopper","SFTwarm");
    delay(2);
    // Switch on chopper
    PACS_Chopper_SWON_SWOF_only("ON");
    delay(10);
    // Set open-loop mode and enable chopper
    PACS_SPEC_Chopper_SetOpenLoop_BB("ON");
    delay(1);
    EnDis_chopper("ON");
    delay(10);
    // Translate mA into ROU
    // The conversion factor is in fact 130, but we use 133 in order to be able
    // to compare the measurement with previous ones, where the same value was
    // assumed.
    double chop_max_ma = 20.0;
    // chopper maximal deflection in mA
    double chop_step_ma = 4.0;
    // chopper movement step size in mA
    int chop_damptime = 15;
    // chopper timescale in seconds allowing for
    // initial oscillation damping in open-loop mode
    double chop_max_rou = chop_max_ma * 32767.0 / 133.0;
    double chop_step_rou = chop_step_ma * 32767.0 / 133.0;
    int ichop_max_rou = iround(chop_max_rou);
    int ichop_step_rou = iround(chop_step_rou);
    // Create table of chopper positions for absolute movement
    // Starting position (integer)
    int ichop_pos = 0;
    // Array of chopper positions sequence 1
    int[] chop_steps = [];
    // Running variable
    int i = 0;
    chop_steps[i] = ichop_pos;
    i = i + 1;
    ichop_pos = ichop_pos + ichop_step_rou;
    while(ichop_pos <= ichop_max_rou) {
        chop_steps[i] = ichop_pos;
        i = i + 1;
        chop_steps[i] = -ichop_pos;
        i = i + 1;
        ichop_pos = ichop_pos + ichop_step_rou;
    }
    int len = length(chop_steps);
    //Length of array
    // First sequence: alternating chopper movement
    for(int s1 = 0 .. len - 1) {
        PACS_SPEC_Chopper_OpenLoop_MoveAbs_BB(chop_steps[s1]);
        delay(chop_damptime);
    }
    // End of first sequence
    // Move chopper to zero position
    PACS_SPEC_Chopper_OpenLoop_MoveAbs_BB(0);
    delay(chop_damptime);
    // Second sequence: alternating chopper movement, repeated once -> k loop
    PACS_SPEC_Chopper_OpenLoop_MoveAbs_BB(-5 * ichop_step_rou);
    delay(chop_damptime);
    for(int s2 = 1 .. 10) {
        PACS_SPEC_Chopper_OpenLoop_MoveRel_BB(ichop_step_rou);
        delay(chop_damptime);
    }
    // End of second sequence
    // Move chopper to zero position
    PACS_SPEC_Chopper_OpenLoop_MoveAbs_BB(0);
    delay(chop_damptime);
    // Disable chopper and switch off open-loop mode
    EnDis_chopper("OFF");
    PACS_SPEC_Chopper_SetOpenLoop_BB("OFF");
    delay(10);
    // Switch off chopper 
    PACS_Chopper_SWON_SWOF_only("OFF");
    delay(5);
    // Set Chopper Controller Parameters: CONFChopper -> SFTwarm
    CONF_chopper("CONFChopper","SFTwarm");
    delay(2);
    // Stop diagnostic HK
    PACS_SPEC_Chopper_OpenLoop_MoveAbs_dHK_BB("OFF");

This part will be edited out

    // Reset OBSID and BBID
    WriteEndID();

}