esrf

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

#%TITLE% HP34401A.MAC
#%NAME%
# Use the hp 34401a multimeter as a pseudo-counter
#%DESCRIPTION%
# The hp 34401a multimeter can be used as a counter . Each time you
# ask spec to count it will look for counters with a name 
# hp_<hp_number>.
# The hp will be programmed to automatic scaling.
#%EXAMPLE%
# counter hp_1 has configured with spec
#   configuration editor.
#%DL%
# %DT% hp34401asetup 10 1 %DD%
#   You set up one hp on gpib address 10
# %DT% ct 2 %DD%
#   The actual values in the multimeter will be read 
#   and put into the counter hp_1 .
#   The 2 will not have any meaning if you did not configure another
#   counter. The hp will be read only once.
# %DT% ascan m1 0 10 1 1 %DD%
#   The motor m1 will be scanned and the hp values will be read at
#   each point. 
#%XDL%  

#%UU%  [first_gpib_channel] [number_of_hps] [funcs1] [scale1] [funcs2] [scale2] 
#%MDESC%
#    define the hp as a pseudo counter and ask user questions if
#  parameters are not given on command line. 

def hp34401asetup '
{
local args
#Setup the channel of the Hp Hp34401a as counter
global Hp34401a_CHANNEL Hp34401a_NO Hp34401a_MEAS Hp34401a_RATIO
Hp34401a_MEAS["dcv"]=":SENSE:FUNC \"VOLT:DC\"\n"
Hp34401a_MEAS["acv"]=":SENSE:FUNC \"VOLT:AC\"\n"
Hp34401a_MEAS["dci"]=":SENSE:FUNC \"CURR:DC\"\n"
Hp34401a_MEAS["aci"]=":SENSE:FUNC \"CURR:AC\"\n"
Hp34401a_MEAS["res"]=":SENSE:FUNC \"RES\"\n"
Hp34401a_MEAS["fres"]=":SENSE:FUNC \"FRES\"\n"
Hp34401a_MEAS["frq"]=":SENSE:FUNC \"FREQ\"\n"
Hp34401a_MEAS["tmp"]=":SENSE:FUNC \"TEMP\"\n"
if ($#) {
  split("$*",args)
  Hp34401a_CHANNEL=args[0]
  Hp34401a_NO =args[1]
  for (cc=0,ii=0;ii<Hp34401a_NO;ii++) {
     Hp34401a_MEAS[ii]=Hp34401a_MEAS[args[2*ii+2]]
     Hp34401a_RATIO[ii]=args[2*ii+3]+0.
  }	
} else {
  Hp34401a_CHANNEL = getval("The hp34401a multimeters start from which gpib channel ",Hp34401a_CHANNEL)
  Hp34401a_NO = getval("How many hp34401as do you use ",Hp34401a_NO)
  for (cc=0,ii=0;ii<Hp34401a_NO;ii++) {
      Hp34401a_RATIO[ii]=getval("  Scale",Hp34401a_RATIO[ii])
      Hp34401a_MEAS[ii]=Hp34401a_MEAS[getval("  Measurement unit \     (dcv,dci,acv,aci,res,fres,frq,tmp\)","dcv")]
  }

}
for (i=0; i<Hp34401a_NO; i++) { 
  cdef ("user_getcounts",sprintf("hp34401a_getcounts hp_%d %d %d ;",i+1,\
	Hp34401a_CHANNEL +i,i),sprintf("hp_%d",i+1),0x02)
}
hp34401a_init
}'


def hp34401a_init '
{
local i
for (i=0; i<Hp34401a_NO; i++) { 
  #gpib_put(Hp34401a_CHANNEL+i,":syst:pres\n")
}
}'


def hp34401a_getcounts '
{
gpib_put($2,Hp34401a_MEAS[$3])
gpib_put($2,":read?\n")
S[$1] = counter_par($1,"scale") * substr(gpib_get($2),0,15)*Hp34401a_RATIO[$3]
gpib_cntl($2,"gtl")
}'

#%MACROS%
#%IMACROS%
#%ATTENTION%
# The hp34401a offers many possiblities and is therefore very difficult
# to program. There are other version of this file. If you would like
# to read the internal buffer of the Hp34401a, you have to configure 
# the K2001 as a MCA in Spec.  
#%DEPENDENCIES%
# The file hp34401a.mac has to be read in          !done by: startup script
#    (this file needs: cpseudo.mac stchanges.mac)
#%AUTHOR%
# JK 9.94
#%TOC%