esrf

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

FLIP.MAC Flip Magnet
See other macros in category: Other hardware Tools
Description:
    Flip magnet polarity during scans.
Documentation:
    DESCRIPTION
    Those macros add to standard scan facility (motor scans and time scan), the possibility of flipping magnet polarity or whatever at counting. The data are plotted in additional windows and saved to standard DATAFILE in additional columns.

    EXAMPLE
    flipsetup; flipcounterselect det; flipstyle 4; fliphdwrelay ID16/Relay/80
    initialisation and setup.
    flip ascan m0 0 10 10 1
    flip scan command.
    flipon; ascan m0 0 10 10 1 ; flipoff
    almost the same. _flip_usermacro1 and 2 are not called, nor _flip_readpol macro.


    SETUP
    There is no general setup macro but several ones.
    flipsetup macro:
    initialisation, default and general setup: COMPULSORY.
    flipcounterselect macro:
    counters selection for plotting.
    flipsave macro:
    counters selection for data saving.
    flipstyle* macros:
    way of flipping setup. basically, sets the number of countings at each scan steps.
    fliphdw* macros:
    installation of the device that will control the flipping. You can add your own device. Check the ones that are already existing (fliphdw* macros) and see how to proceed in %{%<A HREF="#INTERNALS_1">INTERNALS,chapter I</A>%}%.
    flipcal*/flipcal*off macros:
    insert or remove some online calculations to/from the flip. You can add your own calculations as well. (%{%<A HREF="#INTERNALS_2">INTERNALS, chapter II</A>%}%).


    INTERNALS
    %{%<A NAME="INTERNALS_1"></A>%}%
    I - HARDWARE CONTROL.
     setup macros 	: fliphdw* flipresetcontrol
     global related : FLPOL
    
    fliphdw* macro
    installs the flipping hardware control into flip software by r-def-ing _flip_* macros listed below:
    _flip_flip
    polarity toggling
    _flip_neg
    polarity - setting
    _flip_pos
    polarity + setting
    _flip_move
    whatever to be executed prior to motor move.
    _flip_get
    whatever to be executed after angles reading.
    _flip_readpol
    returns the actual polarity
    flipresetcontrol
    un-install everything. It is safe to call it at the beginning of any fliphdw* macros.
    FLPOL
    internally given -1/1 values to keep track of the polarity.

    _flip_move and _flip_get were created to allow "flip scans" of a magnet pseudo motor. This sort of scan implies the polarity control is disabled from motion commands, so that the absolute intensity of the field can vary along the scan, while its polarity is flipped only at each scan step.

    ATTENTION

    _flip_flip, _flip_neg and _flip_pos
    macros must never call each others because of the internal assignment of FLPOL.
    FLPOL
    is always updated at the end of each _flip_flip, _flip_neg and _flip_pos macros.
    _flip_readpol
    is just read once at the beginning of a scan, %{%<a href="flip_src.html#flip">flip</a>%}% command only, in order to read in the actual polarity of the hardware. It will not be called if flipon/flipoff is used rather than the prefix flip.

    EXEMPLES

    %{%<a href="flip_src.html#fliphdwsim">fliphdwsim</a>%}% %{%<a href="flip_src.html#fliphdwrelay">fliphdwrelay</a>%}% %{%<a href="flip_src.html#fliphdwpulse">fliphdwpulse</a>%}% %{%<a href="flip_src.html#fliphdwdacpulse">fliphdwdacpulse</a>%}% %{%<a href="flip_src.html#fliphdwdio">fliphdwdio</a>%}% %{%<a href="flip_src.html#fliphdwsd">fliphdwsd</a>%}% %{%<a href="flip_src.html#fliphdwox">fliphdwoxford</a>%}%.


    %{%<A NAME="INTERNALS_2"></A>%}%
    II - DATA STORAGE AND ONLINE CALCULATIONS.
     setup macros 		: flipcal* flipcal*off
     cdef key     		: free, one per calculation.
     global array related	: FLPDAT
    
    flipcal* macro
    installs online calculations into flip software by c-def-ing _flip_* macros listed below with macros performing calculations. Several calculations can be installed each having a specific cdef key.
    _flip_calcs
    calculation macros
    _flip_calcs_splot
    related final plotting
    flipcal*off
    un-install the corresponding calculation.
    FLPDAT
    array holds the scan data. It is filled up in %{%<A HREF="flip_src.html#_flip_count">_flip_count</A>%}% macro, called from scan_count, and always before _flip_calcs. It is formatted the following way:
    array FLPDAT [4096] [ 1 + FLPSTYLE * COUNTERS]
    
    ie: [scan step] [0] 		: motor position or whatever x.
                    [1:COUNTERS] 	: 1st counter positions set 
    				  1st positive polarity counting
                    [COUNTERS+1:2*COUNTERS]
    			 	: 2nd counter positions set 
    				  1st negative polarity counting
                    [2*COUNTERS+1:3*COUNTERS]
    			 	: 3rd counter positions set 
    				  2nd positive polarity counting
    		...
    


    EXEMPLES

    %{%<a href="flip_src.html#flipcaldelta">flipcaldelta</a>%}% %{%<a href="flip_src.html#flipcadeltaoff">flipcadeltaoff</a>%}%


    III - SCAN
     macros        : flip  flipon  flipoff
     cdef key      : flps
    
    The flip software is hooked to standard scan user macros from flipon/flipoff commands, or by having usual scan commands preceeded by the word %{%<a href="flip_src.html#flip">flip</a>%}%. (eg: flip ascan mot0 0 10 10 1). In the last case, all is removed at the end of the scan. The hooks are listed below: (see %{%<a href="flip_src.html#flipon">flipon</a>%}%)

    • user_cleanup2_flip_cleanup
    • user_checkall_flip_move
    • user_getpangles_flip_get;_flip_heading
    • Fheader_flip_Fhead
    • Flabel_flip_Flab
    • Pheader_flip_Phead
    • Plabel_flip_Plab
    • Fout_flip_Fout
    • Pout_flip_Pout
    • and rdef scan_count_flip_count


    IV - PLOT COUNTERS SELECTION
     macros         : flipcounterselect
     globals 	: FLP_CNO  FLP_CLST
    
    %{%<a href="flip_src.html#flipcounterselect">flipcounterselect</a>%}% macro selects the counters to be plotted in the flip window, as setplot does for standard scan window. FLP_CNO holds the number of selected counters, and the array FLP_CLST holds selected counters mnemonics.


    V - SAVE COUNTERS SELECTION
     macros         : flipsave
     globals 	: FLP_SNO  FLP_SLST
    
    %{%<a href="flip_src.html#flipsave">flipsave</a>%}% macro selects the counters which value should be dumped to scan file more than once at each scan step (in fact, each time a flip counting occurs). FLP_SNO holds the number of selected counters, and the array FLP_SLST holds selected counters numbers. If flipsave is never called, default behavior applies, i.e. all the measurements are dumped to the file. Any scan will always start with a measurement at POSITIVE polarity. Then the following measurements results are always dumped alternating - and +, even if they did not actually occured that way.


    DEPENDENCIES
    The file flip.mac has to be read in.
    It also needs:
    • stlocal.mac
    • flipping device specific macros.(oxPS.mac, dio.mac ...)


Macros:
    flipsetup
    Usage: flipsetup [sleep]
    General initialisation and default settings.
    One can specify here the time to wait after flipping has occured.

    flipinit
    Usage: flipinit
    Initialises internal macros and set defaults.
    Called by flipsetup.

    flipunsetup
    Usage: flipunsetup
    Remove flip software.

    flipstyle
    Usage: flipstyle [[number (always even)] [flag]] | | [style_string]
    Sets the number of countings and flippings.
    If flag is zero, flipping occurs between each couting; if it is 1, I dont know how to explain it, but the style_string way might help. It is a string of + and - ordered along with the flippings. e.g. +-+- would mean 4 countings flipped (flipstyle 4), +--+ is also 4 countings, but not flipped at the middle. It is flag 1. (flipstyle 4 1). There must be as many negative as positive countings for it works, and it will neither allow an odd number of countings. Means that allowed entries are 1, 2, 4 0, 4 1, or +--+, or +-+-. +-+--+-+ would also work, but not +-++-+...

    flipcounterselect
    Usage: flipcounterselect [ALL|mnemonic] [mnemonic] [mnemonic] ...
    Select the counters that will be plotted in flip window.

    flipsave
    Usage: flipsave [ALL|mnemonic] [mnemonic] [mnemonic] [mnemonic]
    Select the counters that will be dumpped their content to the file for additionnal measurements produced by flip.

    flipresetcontrol
    Usage: flipresetcontrol
    Remove any flip controller installed.

    fliphdwsim
    Usage: fliphdwsim
    Install a simulation of a hardware flipping.

    fliphdwrelay
    Usage: fliphdwrelay <relay_device_server_name>
    needs dio.mac macros.
    Install one CS Relay device server to control the flipping. Relay opens for negative polarity and closes for positive.

    fliphdwpulse
    Usage: fliphdwpulse <pulsedrelay_device_server_name> <pulse_time>
    needs dio.mac macros.
    Install one CS Pulsed Relay device server to control the flipping. Flipping occurs on relay pulsing.

    fliphdwdacpulse
    Usage: fliphdwdacpulse <dac_device_server_name> <pulse_time> <rest_voltage> <pulse_voltage>
    Install one DAC (icv712) output to control the flipping. Flipping occurs when output pulses.

    fliphdwdacpulse1
    Usage: fliphdwdacpulse1 <dac_device_server_name> <pulse_time> <pulse_voltage> <rest_voltage>
    Install one DAC (icv712) output to control the flipping. Goes to positive polarity when pulse is positive, and to negative when pulse is negative.

    fliphdwdac
    Usage: fliphdwdac <dac_device_server_name> <positive_voltage> <negative_voltage>
    Install one DAC (icv712) output to control the flipping. Goes to positive polarity when <positive_voltage> is applied, and to negative when <negative_voltage> is applied.

    fliphdwdio
    Usage: fliphdwdio <dio_actuator_name>
    needs dio.mac macros and diosetup done.
    Install one DIO channel to control the flipping. This works only if diosetup has been done. Otherwise, use fliphdwrelay or fliphdwpulse.

    fliphdwsd
    Usage: fliphdwsd
    needs sdlin.mac macros and sdsetup
    Install the Sodilec BOS/S Power Supply to control the flipping.

    fliphdwoxford
    Usage: fliphdwoxford <oxpssetup_device_number>
    needs oxPS1.mac macros, and oxpssetup
    Install an Oxford PS 180 or 120 type Power Supply to control the flipping. <oxpssetup_device_number> starts from 1.

    flipcaldelta
    Usage: flipcaldelta
    Install some online DELTA calculation.

    flipcaldeltaoff
    Usage: flipcaldeltaoff
    Un-install delta calculation.

    flipcalaverage
    Usage: flipcalaverage
    Install some online AVERAGE calculation.

    flipcalaverageoff
    Usage: flipcalaverageoff
    Un-install average calculation.

    flip
    Usage: flip <standard_usual_scan_command>
    Does the flip scan.

    flipon
    Usage: flipon
    Hooks the flip to standard scans.

    flipoff
    Usage: flipoff
    Detach the flip from standard scans.

    flipsplot
    Usage: flipsplot
    Screen plot of flip data.

    flippplot
    Usage: flippplot [detector-mnemonic] [detector-mnemonic] ...
    flip data printer plot, pplot like.

    flipcplot
    Usage: flipcplot [detector-mnemonic] [detector-mnemonic] ...
    flip data cplot, cplot like.

    flipstat
    Usage: flipstat
    Shows what is installed.

Internal Macros:
    _flip_config
    Usage: _flip_config
    Configuration macro. (config_mac)

    _flip_style_keep_request
    Usage: _flip_style_keep_request


    _flip_Fhead
    Usage: _flip_Fhead
    _cols update and File output formatting. (Fheader).

    _flip_Foutput
    Usage: _flip_Foutput
    Compiles the global variables FLP_OUT and FLP_LABEL out of the flip style set up. Both are used for printing out flip data to scan file. Each counter name is added a suffix like "_1", for each measurement over the regular one.
    e.g.:
     FLP_LABEL = "Counter 1  Counter 2" or "Counter 1  Counter 2  Counter 1_1 ..."
     FLP_OUT   = ",FLPDAT[NPTS][1],FLPDAT[NPTS][2]"
    


    flip_Foutput_old
    Usage: flip_Foutput_old


    _flip_Flab
    Usage: _flip_Flab
    (Flabel)

    _flip_delta
    Usage: _flip_delta
    DELTA online calculations.
    i.e. substracts negative countings from positive countings, stores the result in FLPDELTA array, and plots it out.

    _flip_average
    Usage: _flip_average
    AVERAGE online calculations.
    i.e. average all countings, stores the result in FLPAVER array, and plots it out.

    _flip_heading
    Usage: _flip_heading
    Scan heading string. (HEADING)

    _flip_count
    Usage: _flip_count
    (scan_count). Here is the flipping_counting manager.

    _flip_cleanup
    Usage: _flip_cleanup
    Cleanup macro. (user_cleanup2)

    _flip_rplot
    Usage: _flip_rplot <filter_num> <data_array_name> [window_title]
    Running scan plot for all flip data.

    _flip_splot
    Usage: _flip_splot <filter_num> <data_array_name>
    Final scan plot for all flip data.

    _flip_plotwhat
    Usage: _flip_plotwhat (number_of_countings)
    Returns FLPDAT array index string of what to plot.

    _flip_cplot
    Usage: _flip_cplot
    Does for cplot.

    _flip_y
    Usage: _flip_y
    Compiles Y index string to pass to cp_mplot.

    menu_2lists
    Usage: menu_2lists(list,sz,list0,sz0)
    Menu stuff.

    flipbody
    Usage: flipbody(mode)
    For use of blmenu (use blmenu.mac).

Filename: flip.mac
Author: FLIP.MAC - Marie-Claire LAGIER - 96/10/21
Last mod.: 09/09/2011 16:05 by witsch