esrf

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

NATT.MAC
See other macros in category: Positioning
Description:
    %B%natt.mac%B% - move the new attenuators
Documentation:
    DESCRIPTION
    This macros control the standard ESRF filters. This attenuator consists of a motor controlled directly from SPEC, associated limit switches, and a home switch for every filter position. All the home switches are connected together to use the single home switch entry on the motor controller card.
    The macros attmv, attref, and attshow are the macros to operate these attenuators:
    • attmv to move it from the command line
    • attref to recover if ever the position of the motor is lost.
    • attshow to use the macros with a simple text menu
    • A graphical user interface which can be installed seperately
    There is also a set of macros which help in setting up the attenuators:
    • attdiag, attsetup, attsavesetup, attref, attlimits, attsetpos, attrefall, att_getxml, att_writexml.
    These macros are used as follows:
    • Call "attdiag <mne>" in order to have a complete and precise map (steps between filters, position and length of switches, backlash - direction and values) of the mne axis. The macro is not compulsory when configure an axis but is highly recommended to use if controlling the axis for the first time or in case of an abnormal behaviour. The execution might take 10-20 minutes.
    • Call "attsetup [<filename>]" to define motor mnemonics, filter name, attenuators type and security, The filter name is a string with no spaces. With no parameters you will answer to questions. With the filemane (full path) parameter, all the setup information will be retrieved from it. The file should be by default in the /users/blissadm/local/spec/userconf directory.
    • Call "attsavesetup <filename>" to save your current attenuator configuration so it can be used by attsetup. You should by default save the file to the /users/blissadm/local/spec/userconf directory (e.g. attsavesetup /users/blissadm/local/spec/userconf/att.save).
    • Call "attref <mne> [calibration_step [sign]]" if you have lost the filter positions of the axis. The motor will move to a hardware limit switch and then try to find the first filter position with the help of the home switches. The precision of the search and the direction can be specified. If not the macro will use the default values which are positive direction and 0.004 mm precision.
    • Call "attrefall <mne> [calibration_step [sign]]" if you have lost the filter positions of the axis and you have unequal distances between the fiters. The motor will move to a hardware limit switch and then try to find all the filter position with the help of the home switches. At the end the motor is moved to the second filter. The precision of the search and the direction can be specified. If not the macro will use the dafault values which are positive direction and 0.004 mm precision.
    • Call "attlimits <mne>" to get the positions of hardware limits and set them as software limits. Any subsequent move of the axis will make the software move the motor an ATT_DELTAMV mm before the limits, only if the difference between the position asked and the corrected position is below a certain value (ATT_DELTAMAX). Otherwise, the normal limits reached message will appear.
    • Use the standard SPEC set command - "set <mne> pos" when there is an offset between the home switches and the desired beam position. You can simply move the center of a filter in the beam and set this position to your new filter number. For example, if your second filter is currently in the center of thebeam, just type "set att1 2". This will result in an offset between your dial and user position. All other filters will shift automatically too. If you need to shift individual filter position (normally should not be necessary if everything works fine!), use the attsetpos macro for every filter position.
    • Use "attmv <mne> pos .. <mne> pos" to move the attenuators to the filter pos. The advantage over moving the motor with the normal mv command is a check if the motor really moved and if the home switches are active. You can also use the filter name (i.e. 0.18mm_Al) as a position.
    • Use "attshow" to see position of any axis and to move them
    • Use "_attmv(nb, mne[], pos[])" if you want to move your axis from a macro nb: Number of axis to move mne[]: Associative array containing the mnemonic of axis to move pos[]: Associative array containing the position where to move axis
    • Use "attsetpos <mne> <filter name> <pos>" to set position of a particular filter. There is a value associated with every filter name.This position is set by default to the position of the filter (e.g. 1 2 3 4 5 or 6). If after a scan, one filter position is not exactly 1, 2..., you can use this macro to set a new position for this filter. Afterwards, using filter name in attmv will move the axis to the new position. Filter values are used in attshow to move axis and saved with attsavesetup.


Macros:
    _attinittable
    Usage: _attinittable
    Initialise the table of parameters for the existing attenuator types.

    attsetup
    Usage: attsetup [filename]
    Initialise the attenuator motor, answering questions or get the information from filename.

    attsavesetup
    Usage: attsavesetup [filename]
    Write current attenuator configuration (all axis) in a file.

    attref
    Usage: attref <motor_mnemonic [calibration_step [sign]]>
    Find the "second filter". Set it as reference position (2) and step on it. The motor will move to a hardware limit switch and then try to find the second filter position with the help of the home switches. The direction of the movement sign is defined as 1 (from negative limit in positive direction) or -1 (positive limit in negative direction). The precision for the home switch search calibration_step [mm] could be defined - default value is 0.004 mm.

    attlimits
    Usage: attlimits <motor_mnemonic>
    Find both limit switches position and set them as software limits for the motor
    attref has to be called already. Otherwise the hardware limit position will not be correct.

    attmv
    Usage: attmv [<motor_mnemonic>] [<filter position>/<filter name>] .....
    Move the axis <motor_mnemonic> to the given position <filter_number> Move to an intermediate position, check the switch, move to the final position and check again that the switch is on.

    attsetpos
    Usage: attsetpos <axis mnemonic> <filter num> <pos>
    Set the position for filter #n of attenuator axis.

    attwa
    Usage: attwa
    Show selected filters on every axis.

    att_getxml
    Usage: att_getxml
    Get the filter names and corresponding motor positions for the current axe from the default hardware object - xml file.

    att_writexml
    Usage: att_writexml
    Write the filter names and corresponding motor positions for the current axe from the default hardware object - xml file. The information to write is taken from the ATTFILTERS arary.

    attrefall
    Usage: attrefall <motor_mnemonic [calibration_step [sign]]>
    Scan the blade motor_mnemonic. The direction of the movement sign is defined as 1 (from negative limit in positive direction) or -1 (positive limit in negative direction) - default value is 1. The algorithm is based on the home switch signal being active or not, moving in fine steps, which absolute [mm] value calibration_step could be set - default value is 0.004 mm.

Internal Macros:
    _att_find_key
    Usage: _att_find_key (filename, key)
    Find a keyword key in the attenuator config file filename.

    _attref
    Usage: _attref (mnum)
    Internal function to find the "zero reference filter". The algorithm is based on the fact that the first home switch is passed when we move 0.5 filter distances (i.e.33mm/2 = 16mm) from the limit. The mnum is the axis ordinal number in the motors list.

    _att_gotolim
    Usage: _att_gotolim (mnum, sign)
    Go to positive or negative limit (positive means same sign as the step_size (positive motor movement). Show some animation during the move. Return the current motor position.

    _show_waitf
    Usage: _show_waitf ()
    Draw a bar while action goin on

    _attswitchf
    Usage: _attswitchf (motor_mnemonic, motor_steps, parameter)
    If par=99, return the home switch status (0-active, 4-nonactive). Otherwise check if home switch signal is active (par=0) or not (par=4) and move the motor untill the desired status reached. Retunt the current motor position.

    _attlimitswitchf
    Usage: _attlimitswitchf (motor_number, sign)
    Return the limit switch status (0-nonactive, 1=-active). Check low or high limit switch according to the sign. position.

    _attswitchicepap
    Usage: _attswitchicepap (motor_number, motor_steps, parameter)
    If par=99, return the home switch status (0-active, 4-nonactive). Otherwise check if home switch signal is active (par=0) or not (par=4) and move the motor motor_steps untill the desired status reached. Retunt the current motor position.

    _attswitchmaxe
    Usage: _attswitchmaxe (motor_number, motor_steps, parameter)
    If par=99, return the home switch status (0-active, 4-nonactive). Otherwise check if home switch signal is active (par=0) or not (par=4) and move the motor motor_steps untill the desired status reached. Retunt the current motor position.

    _check_mne
    Usage: _check_mne (motor_mnemonic)
    Check if the motor exists in the configuration.

    _att_checkhomef
    Usage: _att_checkhomef (mnum)
    Return the home switch signal value - activ (0) or not (4).

    _attmv
    Usage: _attmv (<nb. motor>, <motor num array>, <motor pos array>)
    Function to test the limits, correct the position, send to intermediate and then to final postion the motors specified in the second parameter (an associative array). The first parameter is the number of motors to move. The third parameter is an associative array containing the final positions for the motors to move.

    _attwm_f
    Usage: _attwm_f (motmne)
    Return the selected filter for motor motmne.

    attshow
    Usage: attshow


    attshow_ascii
    Usage: attshow_ascii
    Start the interactive ASCII menu.

    _getval_timeout
    Usage: _getval_timeout(msg, default, tout)


    _attshowmenu
    Usage: _attshowmenu
    Prepare and show the menu on the screen.

    attdiag
    Usage: attdiag <motor_mnemonic>
    Calculate [steps] the size between the filters as well as the backlash. The procedure is: send the motor to a hardware limit, start moving (in fine steps) in the other direction to find all the home switches and store their positions. Repete the procedure in the oposite direction to estimate the backlash.

    _attdiagprint
    Usage: _attdiagprint (mnum, way, course, nbfilt)
    Print the information gathered during the diagnostic scan.

    _attdiag
    Usage: _attdiag (mnum, way, course)
    Internal function to scan the blade mnum in the direction of the scan way defined in advance as 1 (from negative to positive limit) or -1 (positive to negative limit). The algorithm is based on the home switchsignal being active or not moving in fine steps for at most course position. Returns the number of filters (home switches) found.

    _attrefallinit
    Usage: _attrefallinit (mnum)
    Internal function to scan the blade mnum. The direction of the scan (_SIGN) could be defined in advance as 1 (from negative to positive limit) or -1 (positive to negative limit). The algorithm is based on the home switch signal being active or not moving in fine steps, which absolute value (_CALIB_STEP) could be set as well. This is the procedure used with icepep controller. Returns the number of filters (home switches) found.

    _att_locked
    Usage: _att_locked ()
    Define a user macro to lock the attenuators.

    _att_getxml
    Usage: _att_getxml (ho, motmne, keys_root, keys)
    Get the filter names and corresponding motor positions for the motnum axis from the ho hardware object - xml file.

    _att_writexml
    Usage: _att_writexml (ho, motmne, keys_root, keys)
    Write the filter names and corresponding motor positions for the motnum axis in the ho hardware object - xml file. The information to write is taken from the ATTFILTERS arary.

    _attrefall
    Usage: _attrefall (mnum)
    Internal function to scan the blade mnum. The direction of the scan (_SIGN) should be defined in advance as 1 (from negative to positive limit) or -1 (positive to negative limit). The algorithm is based on the home switchsignal being active or not moving in fine steps, which absolute value (_CALIB_STEP) should be set. Returns the number of filters (home switches) found.

    _attrefhome
    Usage: _attrefhome (mnum)
    Internal function to find the "zero reference filter". The algorithm is based on the spec home mechanism. The direction of the movement (_SIGN) should be defined in advance as 1 (from negative limit in positive direction) or -1 (positive limit in negative direction). The absolute value of the step for the fine move when the home switch is active (_CALIB_STEP) should be set. At the end move to the centre of the filter and set it as position 2.

    _attrefhomeall
    Usage: _attrefhomeall (mnum)
    Internal function to scan the blade mnum. The direction of the scan (_SIGN) should be defined in advance as 1 (from negative to positive limit) or -1 (positive to negative limit). The algorithm is based on the home switch being hardware configured the same way for all the filters and uses the spec home mechanism. The absolute value of the step for the fine move when the home switch is active (_CALIB_STEP) should be set. Returns the number of filters (home switches) found.

    attshow_old
    Usage: attshow_old [<where to see atenuators (gui/ascii)]
    Starts the interactive menu. If no parameter is set, choose gui if SpecGUI is running 0n the SPEC version. Otherewise take the parameter.

    attshow_gui
    Usage: attshow_gui
    Starts the interactive ASCII menu.

    Xattsetup
    Usage: Xattsetup
    setup GUI use of attenuator, chains Xattwa with user_getpangles

    Xattwa
    Usage: Xattwa
    update GUI att filter. GUI outputfield name must be "att-mnemonic"_name, e.g. att1 -> att1_name This macro can be chained with user_getpangles.

    Xattconfig
    Usage: Xattconfig
    Send configuration to graphical application

Filename: natt.mac
Author:
Last mod.: 08/12/2014 14:28 by beteva