#%TITLE% HP66XA.MAC
#%NAME%
# Macros to control Hewlett-Packard 664xA,665xA,667xA and 668xA power supplies
# as pseudo motors
#%DESCRIPTION%
# This macro set lets define the powersupplies as motors in spec.
#%EXAMPLE%
#%DL%
#%DT% mv hp4 1.2 %DD% (move the hp4 to 1.2 volts)
#%DT% ascan hp662 0 10 10 1 %DD%
# (scan hp662 from 0 to 10 microm. in 10 steps
# and count for 1 second)
#%DT% a2scan hp661 0 20 opti -5 5 10 1 %DD%
#(scan the optical table stepper motor from
# -5 to 5 degrees and scan at the same time the hp661 from 0 to 20 micr.)
#%XDL%
#%END%
#%UU% [No of hp66s] [hp661 motor name] [hp661 device name] ...
#%MDESC% Adds the given hp66s to the already defined hp66s
def hp66add '
{
global HP66_NO HP66_DEV HP66_MNE
local _pdev _pmne
_pdev[0]="$3" ; _pdev[1]="$5" ; _pdev[2]="$7" ; _pdev[3]="$9" ; _pdev[4]="$11"
_pmne[0]="$2" ; _pmne[1]="$4" ; _pmne[2]="$6" ; _pmne[3]="$8" ; _pmne[4]="$10"
nodev = int (($#-1)/2)
for (i=0; i< nodev; i++) {
HP66_MNE[HP66_NO+i]=_pmne[i]
HP66_DEV[HP66_NO+i]=_pdev[i]
}
HP66_NO += nodev
hp66_def
}'
#%UU% [No of hp66s] [hp661 motor name] [hp661 device name] ...
#%MDESC%
# ... [hp66 n motor name] [hp66 n device name]
# Sets up the hp66 motor. You have to do that before
# you can use the hp66. If you
# don't provide the dev name you will be asked for it .
# ATTENTION You have to enclose the device name with ""
# otherwise the / in the name will be interpreted as a
# division.
def hp66setup '
{
global HP66_NO HP66_DEV HP66_MNE HP66_ADD HP66_MODE HP66_OLD HP66_SCALE
HP66_NO = getval("How many HP66xx devices do you want to control",HP66_NO)
for (i=0;i<HP66_NO;i++) {
HP66_MNE[i] = getval(sprintf("\tMotor name for HP66xx %d ",i+1),HP66_MNE[i])
HP66_MODE[i] = getval(sprintf("\tMode for HP66xx %d (volt/curr)",i+1),HP66_MODE[i])
HP66_ADD[i] = getval(sprintf("\tGpib address for HP66xx %d ",i+1),HP66_ADD[i])
if (HP66_SCALE[i] == 0) HP66_SCALE[i] = 1
HP66_SCALE[i] = getval(sprintf("\tScale for HP66xx %d ",i+1),HP66_SCALE[i])
if (HP66_SCALE[i] == 0) {
printf("Wrong value for scale. Setting it to one\n")
HP66_SCALE[i] = 1
}
printf("\n")
}
hp66_def
}
'
#%IU%
#%MDESC% Defines pseudo motors from global HP66 variables
def hp66_def '
{
for (i=0;i<HP66_NO; i++) {
local ppstring
ppstring=sprintf ("%s _hp66move none _hp66getangles none none none none %s none\n",HP66_MNE[i],i)
pseudosdef ppstring
}
} '
def _hp66move '
if (HP66_OLD[$1] != A[$1]) {
# gpib_put(HP66_ADD[$2],"OUTP OFF\n")
gpib_put(HP66_ADD[$2],sprintf("%s %f\n",HP66_MODE[$2],A[$1]*HP66_SCALE[$2]))
# gpib_put(HP66_ADD[$2],"OUTP ON\n")
gpib_put(HP66_ADD[$2],sprintf("MEAS:%s?\n",HP66_MODE[$2]))
HP66_OLD[$1] = gpib_get(HP66_ADD[$2]/HP66_SCALE[$2])
sleep(0.5)
}
'
def _hp66getangles '
gpib_put(HP66_ADD[$2],sprintf("MEAS:%s?\n",HP66_MODE[$2]))
A[$1]=gpib_get(HP66_ADD[$2])/HP66_SCALE[$2]
HP66_OLD[$1]=A[$1]
'
#%MACROS%
#%IMACROS%
#%DEPENDENCIES%
# To use a hp66 as a motor the following conditions have to be fulfilled:
#%UL%
#%LI% The file hp66.mac has to be read in done by: startup s.
# (this file needs: pseudo.mac , stchanges.mac)
#%LI% the hp66 motors have to be configured done by: SPECADM
# (Controller NONE, mnemonic as in startupscript)
#%LI% setup the hp66s ( with hp66setup ) done by: startup s.
#%XUL%
#%AUTHOR%
#%TOC%
|