esrf

Beamline Instrument Software Support
SPEC Macro documentation: [ Macro Index | BCU Home ]

CHKBEAM.MAC
See other macros in category: X-ray beam Scans
Description:
    Macros for checking beam presence during scans.
Documentation:
    OVERVIEW
    These macros implement beam checking during scans. When activated (by onbeamchk) all standard scans are affected. After each scan step the counting rate of the monitor is calculated. If it drops below a certain high threshold (the default is 80% of the monitor value during the previous counting interval) it is assumed that the beam was lost and the program goes into a loop in which counting is repeated and the monitor rate is periodically checked. The loop is exited and the scan is resumed when the monitor rate becomes stable and greater than a low threshold (defaulted to 10% of the value before the beam lost). The thresholds can be changed by setting global variables (see below).
    In order to avoid perturbances due to fast monitor fluctuations the monitor rate is filtered by an algorithm that adds an extra waiting time defaulted to 5 minutes.
    This checking procedure requires a beam monitor that measures the actual intensity of the beam. The variable MON must be set to the scaler used as a monitor, as selected by the counters macro. If possible an integrating monitor, as a counting detector or an analog detector followed by a F/V converter, should be used.
    With the current version it is possible to use analog signals loaded into pseudocounters like signals acquired by means of ADC's without integration. When it is possible, the macros try to detect whether the monitor is an integrating device or not. In the case of the waitforbeam macro, the user must add an extra parameter to signal that the monitor is analog.
    The global variables BEAMCHK_ON and BEAMCHK_FLAG give extra information when these macros are used inside other macros or command files.
    BEAMCHK_ON is set whenever the beam checking mode is active.
    BEAMCHK_FLAG is set to 1 to indicate a `beam lost condition'. Non standard scan macros can use this variable to detect beam losses but it is their responsability to set it to zero before counting.
    The global variable BEAMCHK_TAU contains the waiting time in seconds (300 seconds by default).
    The high and low thresholds can be set to values different from the defaults (80% and 10% respectively) by assigning new values to the global variables BEAMCHK_HI and BEAMCHK_LO. Positive numbers represent absolute thresholds while negative numbers represent values relative to the monitor rate. For instance: BEAMCHK_HI=1000 represent a high theshold of 1000 monitor counts while BEAMCHK_HI=-0.5 represent a threshold of 50% of the current monitor rate.

    EXAMPLE
    onbeamchk
    Activates beam checking.
    offbeamchk
    Cancels beam checking.
    waitforbeam 5 1e6
    Waits until the monitor counts accumulated in 5 seconds stabilize around one million (200000 c/s).
    waitforbeam 1 1e6 analog
    Loops counting for 1 second until the monitor value stabilizes around one million (analog value).


Macros:
    onbeamchk
    Usage: onbeamchk [<counting_interval> [<monitor_counts> ["analog"]]
    Activates the beam checking feature.
    If <monitor_counts> is not especified, the macro estimates the current monitor rate and the type of monitor device (analog or integrating).
    If both <counting_interval> and <monitor_counts> are given, the monitor rate is evaluated from these values. In such a case the monitor is supposed to be by default an integrating device. This can overriden by setting as third parameter the literal "analog".


    offbeamchk
    Usage: offbeamchk
    Cancels the beam checking feature.


    waitforbeam
    Usage: waitforbeam [<counting_interval> [<monitor_counts> ["analog"]]]
    Waits until the beam is back. This macro loops counting for <counting_interval> until the monitor counts stabilize near <monitor_counts> (the threshold is actually 10%% of this value).

Internal Macros:
    _onbeamchk
    Usage: _onbeamchk
    Activates the beam checking feature. This macro is called from onbeamchk and waitforbeam.

    _chk_chkbeam
    Usage: _chk_chkbeam


    __chk_beam
    Usage: __chk_beam()
    This is the macro function that does the job. It returns "True" if the counting was ok and "False" if it has to be repeated.

Filename: chkbeam.mac
Author: P. Fajardo, (Original 6/94). $Revision: 4.2 $ / $Date: 2008/02/27 13:27:42 $
Last mod.: 27/02/2008 14:27 by rey