esrf

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

I0_cub.mac
See other macros in category: All
Description:
    I0 board control
Documentation:
    DESCRIPTION
    Control of I0 boards for acquisition.
    In the spec setup, the user should define:
    • - I0_setup <device0> <virtex0> <spartanlist0> <device1> <virtex1> ...
      which defines the devices, virtex files and spartan list file.
    • - The definition of harmonics that the user wants by board/mezzanin/channel.
      - I0harminit <board[0..]> <mezz [1,2]> <ch[1,2,3,4]> <harm1> <harm2> ..
      - I0harmadd <board[0..]> <mezz [1,2]> <ch[1,2,3,4]> <harm1> <harm2> ..
      - ...
      note that I0harminit cleans all the already defined harmonics before starting a new definition, while I0harmadd add a new one.

    *****************************************
    The I0 boards may have 1 or 2 mezzanines.
    board numbers: [0..n]
    mezzanin: [1,2]
    channels: [1,2,3,4]
    *****************************************
    #We apply the following conventions for all the boards:

    - if 2 mezzanins, always mezzanin 1 will be the master and mezzanin 2 will be the slave
    - timer bit is disabled (stop acquisition done by a software stop and the data are normalized with the real acquisition time).
    - modes for acquisition: there are 3 modes:
    -- softare mode: each board is started independently
    -- hardware mode: a board is defined by the user as master trig board and is supposed to be daisy chained to all the other to transmit the start of acquisition. master trig board is started by soft.
    -- hardware external mode: same as previous but the master trig board is started by a hardware external signal.
    *** Modifications:
    - division of tablu by tim if not timer mode
    - now use I0tablutoch to work with I0_ch[] instead of tablu[][]
    - checking of board, mezzanin, channel parameters implemented
    - I0_dac, I0_savedac, I0_getdac
    - I0Rout and I0tablutoc(), do not recalculate I0_xch .... arrays
    - I0_gethwinfo
    - I0_sethwchan
    - remove debug print
    - clean I0_ch[][] before tablutoch

Macros:
    I0_setup
    Usage: I0_setup <device> <virtex> <spartanlist>
    list of I0 devices. The .bit files are supposed to be under /users/blissadm/local/spec/userconf/CUB/I0/BIT

    I0_load_virtex_spartan
    Usage: I0_load_virtex_spartan
    - loads virtex and spartan on the list of I0_setup
    the path to these files is:
    /users/blissadm/local/spec/userconf/CUB/XDS/BIT.
    - retrieves some hardware info

    I0harminit
    Usage: I0harminit <board[0..]> <mezz[1,2]> <ch[1,2,3,4]> <harm1> <harm2> ...
    cleans all the already defined harmonics and defines the harmonics for a board/mezz/channel.

    I0harmadd
    Usage: I0harmadd <board[0..]> <mezz[1,2]> <ch[1,2,3,4]> <harm1> <harm2> ...
    defines the harmonics for a board/mezz/channel.

    I0_showconf
    Usage: I0_showconf
    Shows the I0_ARR definitions

    I0_askforconf
    Usage: I0_askforconf
    Proposes to change some parameters of the global I0 boards configuration.

    I0h_applyarray
    Usage: I0h_applyarray
    applies the I0_ARR information on the boards in used
    - hw bit -
    - timer bit -
    - master/slave bit -
    - channels in use -

    I0_enable
    Usage: I0_enable <I0_index>
    define a board as in use

    I0_disable
    Usage: I0_disable <I0_index>
    define a board as unused

    I0_enable_ch
    Usage: I0_enable_ch <I0_index> <mezz 1:2> <ch1:4>
    enables channel for a board,mezzanin
    - I0_index: 0..
    - mezz: 1,2
    - ch: 1,2,3,4

    I0_disable_ch
    Usage: I0_disable_ch <I0_index> <mezz 1:2> <ch1:4>
    disable a channel for a board,mezza
    - I0_index: 0..
    - mezz: 1,2
    - ch: 1,2,3,4

    I0h_selectmez
    Usage: I0h_selectmez (<I0_index>, <mezz>)
    select mezzanine (val:1 or 2)

    I0_setmodehard
    Usage: I0_setmodehard
    Set mode hardware on all the I0 boards. They are supposed to be hardware trigged (daisy chain) by the mezzanine 1 of the master trig I0 board.
    the mezzanine 1 of master trig board is supposed to be software started -hw bit- is set to 1 to everybody but the mezzanine 1 of the master trig board.

    I0_setmodehardext
    Usage: I0_setmodehardext
    Set mode hardware on all the I0 boards. They are supposed to be hardware trigged (daisy chain) by the mezzanine 1 of the master trig board. -hw bit- will be set to 1 to every used board.

    I0_setmodesoft
    Usage: I0_setmodesoft
    Set mode sofware on the all the I0 boards:
    -hw bit- will be set to 0 for every used board.

    I0_setmastertrig
    Usage: I0_setmastertrig <I0_index>
    Redefines the master trig board.

    I0_settimerbit
    Usage: I0_settimerbit 0/1
    Redefines the timer bit for all the hardware
    0: default value. acquired data will be divided by the time
    1: no division in the data

    I0_setparam
    Usage: I0_setparam <silent>
    Proposes to change some parameters of the global I0 boards configuration before applying it to the hardware
    if give one parameter to the macro, applies the I0_ARR conf without asking for confirmation

    I0CsrR
    Usage: I0CsrR <I0_index>
    read csr

    I0ChEn
    Usage: I0ChEn <I0_index> <val>
    seg=2, add=18h MACRO: Enable channels for datacq val = 4 bits : channel 4 3 2 1, 1 for En, 0 for DIS

    I0RegR
    Usage: I0RegR (board,mezz,regad)
    provide address and read any I0 register of an already selected mezzanine

    I0RegW
    Usage: I0RegW (board,mezz,regad,val)
    write the value <val32> in Register <adreg> on board <bb> mezzanine <mez>

    I0LedR
    Usage: I0LedR <I0_index>
    seg=2, add=20h=32d MACRO: read LED Register

    I0ChR
    Usage: I0ChR (<I0_index>)
    seg=2, add=18h MACRO: read LED Register

    I0LedW
    Usage: I0LedW <I0_index> <val>
    seg=2, add=20h=32d MACRO: write the value <val> in LED register and <addr> position

    I0DacOutEn
    Usage: I0DacOutEn <I0_index> <DacOut_channel> <val>
    seg=2, add=20h=32d MACRO: Enable Dac Out channels in LED register

    I0DacOutClkEn
    Usage: I0DacOutClkEn <I0_index> <DacOut_channel> <val>
    seg=2, add=20h=32d MACRO: Enable free running clock on Dac Out channels in LED register

    I0DacOutPul
    Usage: I0DacOutPul <I0_index> <DacOut_channel>
    seg=2, add=20h=32d MACRO: Programming pulse on DAC_out channels in LED register

    I0DacOutReg
    Usage: I0DacOutReg <I0_index> <DacOut_register>
    seg=2, add=50h, 54h, 58h, 5Ch (=80d, 84d, 88d, 92d) MACRO: Programming DAC_out registers

    I0ChW
    Usage: I0ChW <I0_index> <val>
    seg=2, add=18h MACRO: write the value <val> in LED register and <addr> position

    I0TstR
    Usage: I0TstR <I0_index>
    seg=2, add=24h=36d MACRO: read TST Register

    I0TstW
    Usage: I0TstW <I0_index> <val>
    seg=2, add=24h=36d MACRO: write the value <val> in TST Register and <addr> position

    I0IdR
    Usage: I0IdR <I0_index>
    seg=2, add=2Ch=44d MACRO: read SDAC_ld Register

    I0SDacW
    Usage: I0SDacW (<I0_index>,<mezz 1,2>,<channel 1,2,3,4>,<dac_type G,O>,<12bit_val>)
    seg=2, add=30h to 3Ch = 48d to 60d for SDAC_reg then seg=2, add=2Ch = 44d for SDAC_ld MACRO: write the value <val> in channel <cha> SDAC_reg at G(ain), O(ffset), H(igh_in_dscri), L(ow_in_discri) then load with SDAC_ld

    I0TimeR
    Usage: I0TimeR (I0_index)
    seg=2, add=28h=40d MACRO: read Acquisition_Time register Register

    I0Rout
    Usage: I0Rout (<I0_index>,<mezza>)
    seg=2, add_ch4=4Ch, add_ch3=48h, add_ch2=44h, add_ch1=40h MACRO: Readout common to i04, i02, i01 Read Channel 4,3,2,1 (front panel order top to bottom)

    I0tablutoch_orig
    Usage: I0tablutoch_orig (<I0_index>, <mezza>)
    creates I0_ch[1], I0_ch[2], I0_ch[3], I0_ch[4] from tablu[]

    I0tablutoch
    Usage: I0tablutoch (<I0_index>, <mezza>)
    creates I0_ch[1], I0_ch[2], I0_ch[3], I0_ch[4] from tablu[]

    I0cton
    Usage: I0cton
    enables pseudo count.

    I0ctoff
    Usage: I0ctoff
    disables pseudo count.

    I0AcqStop
    Usage: I0AcqStop (I0_index)
    stop acquisition on the specified board, on the already selected mezzanin

    I0_putconf
    Usage: I0_putconf <filename>
    stores the present I0 configuration on <filename> (under ~blissadm/local/spec/userconf)

    I0_getconf
    Usage: I0_getconf <filename>
    reads a configuration file (under ~blissadm/local/spec/userconf) and applies it to the hardware

    I0_showharm
    Usage: I0_showharm
    Shows the harmonics defined by board/mezzanin/channel

    I0_dac
    Usage: I0_dac
    DAC definitions. interactive command. then applies to hardware

    I0_savedac
    Usage: I0_savedac <filename>
    write dac values to file

    I0_getdac
    Usage: I0_getdac <filename>
    gets dac values from file

    I0_gethwinfo
    Usage: I0_gethwinfo
    gets some info from hardware.

    I0_sethwchan
    Usage: I0_sethwchan
    sets hardware channel enable according to board version.

    I0_checkchinfo
    Usage: I0_checkchinfo
    check user requirement with hardware

    I0_debug
    Usage: I0_debug <0/1>
    set debug mode

Internal Macros:
    _I0_LoadVirtex
    Usage: _I0_LoadVirtex <board> <bit file>
    loads virtex. A timeout of 40 sec is set for the load on the device

    _I0_LoadSpartanList
    Usage: _I0_LoadSpartanList <board> <bit file>
    loads list of spartan. A timeout of 40 sec is set for the load on the device

    _I0_checkifset
    Usage: _I0_checkifset
    checks if I0_ARR global associative array has been already set

    _I0_preparearray
    Usage: _I0_preparearray
    prepare the I0_ARR array with some information.
    Should be called inside I0_setup.
    - reads if mezzanine 2 is present
    If following not already set decide that:
    - all boards are in use (can be changed with I0_enable, I0_disable)
    - work in software mode (can be changed with I0_setmodehard, setmodehardext, setmodesoft)
    - enable only channel4 on each mezzanine
    for all, mezzanine 1 is master and mezzanine 2 is slave (cannot be changed)

    _I0_isused
    Usage: _I0_isused (I0_index)
    returns 1 if used, 0 if not in use

    _I0h_ismez2
    Usage: _I0h_ismez2 (<I0_index>)
    returns 1 if mezzanine 2 is present, 0 if not

    _I0h_sethwbit
    Usage: _I0h_sethwbit <I0_index> <val:0,1>
    set hardware bit to <val> on the selected mezzanine
    do nothing if board not in used

    _I0h_settimerbit
    Usage: _I0h_settimerbit <I0_index> <val:0,1>
    set timer bit to <val> on the selected mezzanine
    do nothing if board not in used

    _I0h_sethmasterbit
    Usage: _I0h_sethmasterbit <I0_index> <val:0,1>
    set timer bit to <val> on the selected mezzanine
    do nothing if board not in used

    _I0h_setchannel
    Usage: _I0h_setchannel <I0_index> <ch1> <ch2> <ch3> <ch4>
    set channel on or off on an already selected mezzanine
    do nothing if board not in used

    I0setdim
    Usage: I0setdim


    I0Calc
    Usage: I0Calc (i0fft)


    I0body
    Usage: I0body(mode)
    For blmenu (use blmenu.mac).

    I0count_precount
    Usage: I0count_precount
    precount pseudo mechanism.Enables acqui on all boards mezzanines and finishing with the mezzanin 1 of master trig board

    I0Acq_precount
    Usage: I0Acq_precount <I0_index>
    enables acquisitions on a board, on the already selected mezzanin.
    - Stop acqui
    - Read CSR
    - set acq_en bit in CSR

    I0ctcalc_getcounts
    Usage: I0ctcalc_getcounts
    pseudo reading data mechanism. gets the data for mezzanin 1, and mezzanin 2 (if exists)

    _I0ctcalc_getcounts
    Usage: _I0ctcalc_getcounts (I0_index,mezza)
    get data for a particular mezzanin (1 or 2)
    this macro provides also 4 blocks of data corresponding to each channel of the mezzanin.
    - I0_index : 0..
    - mezza: 1,2

    I0_calc
    Usage: I0_calc (I0_index,mezza)
    calculate data for a particular board/mezzanin
    - I0_index : 0..
    - mezza: 1,2

    I0_calcdef
    Usage: I0_calcdef (I0_index,mezza,ch)
    calculate the serie of harmonics for a particular board/mezzanin/channel
    I0_ch[1:4][] contains the raw data for the 4 channels
    - I0_index : 0..
    - mezza: 1,2
    - ch: 1,2,3,4

    I0_showin
    Usage: I0_showin <I0_index> <mezza> <ch>
    Shows raw data on board/mezzanin/channel

    I0_showrms
    Usage: I0_showrms <I0_index> <mezza> <ch>
    Shows fft spectrum on board/mezzanin/channel

    _I0_compat_nbdev
    Usage: _I0_compat_nbdev (nb_devref,nb_dev)
    verifies if the number of elements are compatible to the reference number.
    return: 0 if not ok, 1 if ok

    _I0_getconf
    Usage: _I0_getconf <filename>
    reads the file in ~blissadm/local/spec/userconf

    _I0_compatarchi
    Usage: _I0_compatarchi()
    checks if the architecture loaded in I0_m_xx is compatible with the present devices. it checks:
    - presence of requested devices
    - number of mezzanin on the devices.
    creates an array I0_m_corres for corrspondance I0_m_xx -> I0_ARR

    _I0_cpconf
    Usage: _I0_cpconf
    copies the configuration loaded in the I0_ARR array

    _i0_check_board
    Usage: _i0_check_board (board)
    check validity of a board number: returns 1 if board number is a valid number

    _i0_check_mezz
    Usage: _i0_check_mezz (mezz)
    check validity of a mezzanin number :returns 1 if mezzanin is [1,2], 0 else

    _i0_check_ch
    Usage: _i0_check_ch (ch)
    check validity of a channel number: returns 1 if ch is [1,2,3,4], 0 else

    _I0_applydac
    Usage: _I0_applydac()
    applies gain and offset values to hardware

    _I0h_getchinfo_old
    Usage: _I0h_getchinfo_old (<I0_index>, <mezza>)


    _I0h_gethwinfo
    Usage: _I0h_gethwinfo (<I0_index>, <mezza>)


    _I0h_sethwchan
    Usage: _I0h_sethwchan (<I0_index>, <mezza>)
    sets hardware bit4 and bit5 to enable channels, according to version.

Filename: I0_cub.mac
Author: G.Goujon, MCD
Last mod.: 08/12/2011 13:22 by domingue