esrf

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

#%TITLE% v560.mac
#$Revision: 1.1 $
#%NAME% v560.mac
#%DESCRIPTION%
# Use this macro set to control a Caen V560 counter card by the use of
# macro counters.
# %BR%
# For the internals:
# %BR%
# %BR%
# the channels are cleared before starting the counter; signal "prestart_all".
# %BR%
# all channels are read only once at the signal "halt_all".
# %BR%
# then each channel receives its value, signal "counts".
#%SETUP%
# The macro set needs the vmeds.mac file.
# %BR%
# %BR%
# In the config editor:
# %BR%    
# create a scaler controller like follows:
# %BR%
# YES          v560  IDXX/V560/0      16                     Macro Counter
# %BR% 
# then create up to 16 counters:
# %BR%
# 12      V560_1    V560_1   MAC_CNT     0     0(to15)    counter         1
#%END%
#
# Modifications history:
# 08/02/2007 Creation 

need vmeds

global v560_ADDR # this is only available in the macros here, not in the general
                 # name space of spec!

long array V560_DATA[16]


def v560_config(mne,type,unit,mod,chan) '{
    if (mne != "..") {
       print "Configuring " cnt_mne(mne) " as a V560 scaler on " v560_ADDR*1
    }
}'

def v560_cmd(mne, cmd, p1, p2) '{
    local V560_DS V560_CLEAR_ADDR V560_READ
    V560_CLEAR_ADDR = 0x50
    V560_DS         = v560_ADDR

    if (mne == ".." && cmd == "prestart_all") {
         # Clear all
         vmeds_put(V560_DS, 0x50, 1, "D16")
         V560_READ = 0
    }

    if (mne == ".." && cmd == "halt_all") {
        # read hardware only once per card
        vmeds_move(V560_DS,0x10,V560_DATA,0x10,"D32")
    }

    if (cmd == "counts") {
         chan = counter_par(mne,"channel")
         return(V560_DATA[chan])
    }
}'

#%MACROS%
#%IMACROS%
#%DEPENDENCIES%
# vmeds.mac has to be read in.
#%AUTHOR% BLISS - ESRF, V. Rey, H. Witsch
#$Revision: 1.1 $, $Date: 2007/02/08 16:23:09 $
#%TOC%