esrf

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

#%TITLE% cy.mac
#%NAME%
#   Guide for the choice of the stepping parameters for Vpap boards equipped with 
#   the CY550 chip at 12 MHz clock frequency.
#
#%CATEGORY% Positioning
#
#%DESCRIPTION%
#   The stepping parameters, i.e. the steady state rate, the base rate and the acceleration time 
#   are either read from the config file if a motor mnemonic is given as argument to the macro, 
#   or input by the user. From these values, the macro calculates and displays the allowed acceleration 
#   time range and dynamic range to operate the CY550 chip. This is to check if the values you have 
#   chosen are correct or not. The set of values is correct when "OK" is mentionned 5 times.
#%BR%
#   The corresponding parameters for command S (Slope) of the os9 program "vpaptst" is issued as well. 
#   Refer to the CY550 step rate tables to deal which others commands (F and R) accordingly to your 
#   velocity and base rate.
#
#%ATTENTION%
#   Be aware that due to the complex nature of the CY550 stepping algorithm, it is difficult to 
#   provide an exact formula concerning its acceleration behaviour. The formula used in this macro 
#   is an aproximate formula. This should be used as a general guide only, with actual timing 
#   and acceleration values best determined experimentally. 
#
#%EXAMPLE%
#%PRE%
#%B%cy m0%B%
#
#base_rate in Hz (200)? 
#velocity in Hz (600)? 
#acceleration time in msec  (1000)? 755
#
#                  actual value       min       max
#
#BASE_RATE     :       200 Hz   (     15      4950)  => OK
#VELOCITY      :       600 Hz   (     15     14925)  => OK
#DYNAMIC RANGE :       400 Hz   (399.706    101925)  => OK
#ACCEL. TIME   :       755 msec (      2       755)  => OK
#
#vpaptst SLOPE :         1      (      1       255)  => OK
#
#%PRE%
#
#%END%

#%UU% [<motor>]
#%MDESC% 

def cy '
{
global cy_vel cy_bas cy_acc

local  _p1 _p2 _txt _rge

if ("$1"!="0") {
  if ((whatis("$1")&571473924)!=571473924) {
    print "$1 is not a motor"
    exit
  } else {
    print
    print "MOTOR $1"
  }
  cy_bas = motor_par($1,"base_rate")
  cy_vel = motor_par($1,"velocity")
  cy_acc = motor_par($1,"acceleration")
} else {
  cy_bas = getval("base_rate in Hz",cy_bas)
  cy_vel = getval("velocity in Hz",cy_vel)
  cy_acc = getval("acceleration time in msec ",cy_acc)
}

if (cy_vel<cy_bas) { 
  p "\n!!! ERROR: BASE RATE > SLEW RATE !!!"  
  exit
}

printf("\n%30s%10s%10s\n","actual value","min","max")
_rge="15      4950";_txt="OK"
if ((cy_bas<15)||(cy_bas>4950)) _txt="OUT OF RANGE"
printf("\nBASE_RATE     :%10d Hz   (%17s)  => %s",cy_bas,_rge,_txt)
_rge="15     14925";_txt="OK"
if ((cy_vel<15)||(cy_vel>14925)) _txt="OUT OF RANGE"
printf("\nVELOCITY      :%10d Hz   (%17s)  => %s",cy_vel,_rge,_txt)

_rge=cy_vel-cy_bas
_p1 = 135*cy_acc/255
_p2 = 135*cy_acc
if ((_rge>_p2)||(_rge<_p1)) _txt="OUT OF RANGE"
else _txt="OK"
printf("\nDYNAMIC RANGE :%10d Hz   (%7s%10s)  => %s",_rge,_p1,_p2,_txt)

_p1 = int((cy_vel-cy_bas)/135)
_p1 = (_p1>0)?_p1:0
_p2 = int(((cy_vel-cy_bas)*255)/135)
_p2 = (_p2>0)?_p2:0
if ((cy_acc>_p2)||(cy_acc<_p1)) _txt="OUT OF RANGE"
else _txt="OK"
printf("\nACCEL. TIME   :%10d msec (%7s%10s)  => %s",cy_acc,_p1,_p2,_txt)

if ((cy_vel-cy_bas)>0) {
  _p1 = 256 - ((135*cy_acc)/(cy_vel-cy_bas))
  _p2=int(_p1)
  if ((_p1-_p2)>0.5) _p1=_p2+1
  else _p1=_p2
  if ((_p1<1)||(_p1>255)) _txt="OUT OF RANGE"
  else _txt="OK"
} else if ((cy_vel-cy_bas)==0) {
  _p1=0;_txt="?"
}
print
printf("\nvpaptst SLOPE :%10d      (%7s%10s)  => %s\n",_p1,"1","255",_txt) 
}'

#%MACROS%
#%IMACROS%
#%AUTHOR% Marie-Claire LAGIER, 1994
#%TOC%