# macros concerning motors and movements # # hp 20.10.1999 # hp 21.10.1999 motor movement commands gmv, gmvr, ugmv, ugmvr implemented # hp 02.12.1999 small errors solved # hp 28.07.2000 added brackets to macros to protect local variables # # # # ################################################################################ # # _hp_mv # hp 20.10.1999 # # enters position motor should move to but dos not start moving # ################################################################################ # def _hp_mv ' { if ($# != 2) { eprint "Usage: mv motor position" exit } _check0 "$1" A[$1]=($2) ifp { fprintf(PRINTER,"\nmv $1 %g\n", A[$1]) } } ' # # # # ################################################################################ # # _hp_mvr # hp 21.10.1999 # # enters relative position motor should move to but dos not start moving # ################################################################################ # def _hp_mvr ' { if ($# != 2) { eprint "Usage: mv motor position" exit } _check0 "$1" A[$1]+=($2) ifp { fprintf(PRINTER,"\nmv $1 %g\n", A[$1]) } } ' # # # # ################################################################################ # # gmv # hp 21.10.1999 # # macro to move several motors at the same time, calls _gmv # ################################################################################ # def gmv '_gmv $*; move_poll' # # # # ################################################################################ # # ugmv # hp 21.10.1999 # # macro to move several motors at the same time, calls _gmv # ################################################################################ # def ugmv '_gmv $*; hp_update_gmv $*' # # # # ################################################################################ # # gmvr # hp 21.10.1999 # # macro to move several motors at the same time, calls _gmvr # ################################################################################ # def gmvr '_gmvr $*; move_poll' # # # # ################################################################################ # # ugmvr # hp 21.10.1999 # # macro to move several motors at the same time, calls _gmvr # ################################################################################ # def ugmvr '_gmvr $*; hp_update_gmv $*' # # # # ################################################################################ # # hp_update_gmv # hp 21.10.1999 # # update during motor moves, called by ugmv and ugmvr # ################################################################################ # def hp_update_gmv ' { local _hp_n _hp_n = $# if (_hp_n == 2) { _update("$1") } if (_hp_n == 4) { _update("$1 $3") } if (_hp_n == 6) { _update("$1 $3 $5") } if (_hp_n == 8) { _update("$1 $3 $5 $7") } if (_hp_n == 10) { _update("$1 $3 $5 $7 $9") } if (_hp_n == 12) { _update("$1 $3 $5 $7 $9 $11") } if (_hp_n == 14) { _update("$1 $3 $5 $7 $9 $11 $13") } if (_hp_n == 16) { _update("$1 $3 $5 $7 $9 $11 $13 $15") } if (_hp_n == 18) { _update("$1 $3 $5 $7 $9 $11 $13 $15 $17") } if (_hp_n == 20) { _update("$1 $3 $5 $7 $9 $11 $13 $15 $17 $19") } } ' # # # # ################################################################################ # # _gmv # hp 21.10.1999 # # macro to move several motors at the same time, will be called by gmv and ugmv, # should not be used directly # ################################################################################ # def _gmv ' { local _hp_n, _hp_max_n _hp_max_n = 10 # Maximum numbers of motors driven at the same time _hp_n = $# if (_hp_n > 2*_hp_max_n) { printf("Not more than %i motors can be driven at the same time.", _hp_max_n) exit } if (_hp_n<2) { eprint "Usage: gmv mot1 pos1 mot2 pos2 mot3 pos3 ..." exit } if (_hp_n/2 != int(_hp_n/2)) { eprint "Usage: gmv mot1 pos1 mot2 pos2 mot3 pos3 ..." exit } waitmove; get_angles if (_hp_n >= 2) { _hp_mv $1 $2 } if (_hp_n >= 4) { _hp_mv $3 $4 } if (_hp_n >= 6) { _hp_mv $5 $6 } if (_hp_n >= 8) { _hp_mv $7 $8 } if (_hp_n >= 10) { _hp_mv $9 $10 } if (_hp_n >= 12) { _hp_mv $11 $12 } if (_hp_n >= 14) { _hp_mv $13 $14 } if (_hp_n >= 16) { _hp_mv $15 $16 } if (_hp_n >= 18) { _hp_mv $17 $18 } if (_hp_n >= 20) { _hp_mv $19 $20 } move_em } ' # # # # ################################################################################ # # _gmvr # hp 21.10.1999 # # macro to move several motors relative to their actual position at the same time, # will be called by gmvr and ugmvr, should not be used directly # ################################################################################ # def _gmvr ' { local _hp_n, _hp_max_n _hp_max_n = 10 # Maximum numbers of motors driven at the same time _hp_n = $# if (_hp_n > 2*_hp_max_n) { printf("Not more than %i motors can be driven at the same time.", _hp_max_n) exit } if (_hp_n<2) { eprint "Usage: gmvr mot1 pos1 mot2 pos2 mot3 pos3 ..." exit } if (_hp_n/2 != int(_hp_n/2)) { eprint "Usage: gmvr mot1 pos1 mot2 pos2 mot3 pos3 ..." exit } waitmove; get_angles if (_hp_n >= 2) { _hp_mvr $1 $2 } if (_hp_n >= 4) { _hp_mvr $3 $4 } if (_hp_n >= 6) { _hp_mvr $5 $6 } if (_hp_n >= 8) { _hp_mvr $7 $8 } if (_hp_n >= 10) { _hp_mvr $9 $10 } if (_hp_n >= 12) { _hp_mvr $11 $12 } if (_hp_n >= 14) { _hp_mvr $13 $14 } if (_hp_n >= 16) { _hp_mvr $15 $16 } if (_hp_n >= 18) { _hp_mvr $17 $18 } if (_hp_n >= 20) { _hp_mvr $19 $20 } move_em } ' # # # #