Motor Controls & Drive using Python Ferdi Franceschini 2008-11-08 12:48 Drive commands Many objects in SICS are drivable . This means they can run to a new value. Obvious examples are motors. Less obvious examples include composite adjustments such as setting a wavelength or an energy. Such devices are also called virtual motors. This class of objects can be operated by the drive, run, success family of commands. These commands cater for blocking and non-blocking modes of operation. In the example commands below, "mot1" can be replaced by the motor short name, or the hdb_path. hdb_path is the verbose path to the motor e.g. /sample/azimuthal_angle whereas the short name is stth. The tcl command line only allows use of the short name for these commands. Commands are CASE SENSITIVE. These python commands are available from both the python command line and python scripts. Firstly you must import the sics module. from gumpy.commons import sics Commands sics.execute ("any_sics_command") executes any_sics_command without feedback. Useful for when a sics command is not implemented in python. sics.run ("mot1", pos1) runs mot1 to pos1. Asynchronous. sics.set ("mot1", pos1) is the same as sics.run. Prints log information to console. "set" is a universal computing keyword for setting values. Asynchronous. success() not implemented in python. In tcl, waits and blocks the command connection until all pending operations have finished (or an interrupt occured). sics.drive ("mot1", pos1) is the same as run but it blocks the client that requested the drive from issuing commands until the motion has finished. This command will set the variables in motion and wait until the driving has finished. A drive can be seen as a sequence of a run command as stated above immediatly followed by a success command sics.multiDrive ({"mot1":pos1, "mot2":pos2}) is the same as sics.drive but allows you to drive a list of motors simultaneously. Due to the verbose syntax to create a list, this is not the default drive command. sics.setpos ("mot", oldPosition, newPosition) Sets the position value of oldPosition to newPosition. TO BE TESTED. sics.getValue("mot") returns the current position of the motor. All zero point and sign corrections are applied mot hardposition not implemented in python mot list not implemented in python mot reset not implemented in python mot interest not implemented in python mot uninterest not implemented in python mot homerun not implemented in python Parameters These values can be get and set using sics.getValue("hdb_path") and sics.set("hdb_path",value) via their hdb_path. BUG: If you try to set values that are at a higher level of privilege, the console will report OK, but the SICS Server view will report an error. Parameters to be added: Blockage_Thresh, Blockage_Ratio, Blockage_Fail, Backlash_offset, mot absenc Privilege = User not implemented in python. Value of absolute encoder not available via hdb_path. Get the absolute encoder reading.  (Only implemented by motors that have absolute encoders.) accel sics.getValue("/hdb_path/accel") sics.set("/hdb_path/accel",val) Privilege = User Get/Set the acceleration along/about the axis controlled by this motor in physical units per square second, ie mm/s^2, deg/s^2 accesscode sics.getValue("/hdb_path/accesscode") sics.set("/hdb_path/accesscode",val)(persists) Default = i.e. user Privilege = Manager Controls which type of user is allowed to control the motor Allowed val Internal. Motor is reserved for internal use by SICS Manager. Only users who logon as managers are allowed to move the motor. Usually just instrument scientists User Spy. Anyone is allowed to move the motor Blockage_Check_Interval sics.getValue("/hdb_path/blockage_check_interval") sics.set("/hdb_path/blockage_check_interval",val)(persists) Privilege = Manager Units = seconds Get/Set the interval at which the motor driver checks the axis for significant changes in position decel sics.getValue("/hdb_path/decel") sics.set("/hdb_path/decel",val) Privilege = User Get/Set the deceleration along/about the axis controlled by this motor in physical units per second, ie mm/s2, deg/s2. failafter sics.getValue("/hdb_path/failafter") sics.set("/hdb_path/failafter",val) Privilege = Manager This is the number of consecutive failures of positioning operations this motor allows before it thinks that something is really broken and aborts the experiment fixed sics.getValue("/hdb_path/fixed") sics.set("/hdb_path/fixed",val) (persists) Default = 1.0 Privilege = User Set to 1.0 to prevent the motor from being moved, set to -1.0 to allow movement. NOTE: The instrument manager can set the accesscode to prevent users from moving a motor. mot home val subject to change. This may be changed to a configuration only parameter Privilege = Manager Get/Set the home position for the axis which the motor controls, (ie phi, chi, two-theta, x, y).  So it is the physical home position in the units given by the units parameter below, (ie mm, degrees, ...) ignorefault sics.getValue("/hdb_path/ignorefault") sics.set("/hdb_path/ignorefault",val) (persists) Position faults will be ignored if this is greater than zero interruptmode sics.getValue("/hdb_path/interruptmode") sics.set("/hdb_path/interruptmode",val) (persists) Default = 0 (continue) Privilege = Manager Controls what effect a motor failure has on operations Allowed val one of: Continue. A motor failure will not affect other operations AbortOperation. Stop current hardware operation but no scans or batchfiles AbortScan. Stop current scan or operation but continue processing of batch files with next command AbortBatch. Stop all processing, even batch files maxretry sics.getValue("/hdb_path/maxretry") sics.set("/hdb_path/maxretry",val) Default = Privilege = Manager The number of times that SICS will retry a move if a motor has not reached the target position to within the required precision movecount sics.getValue("/hdb_path/movecount") sics.set("/hdb_path/movecount",val) (persists) Default= Privilege = Manager Controls frequency with which position changes are reported if a user subscribes interest to a motor.  A larger value reduces the frequency precision sics.getValue("/hdb_path/precision") sics.set("/hdb_path/precision",val) (persists) Privilege = Manager Controls precision of movements.  If a motor has not completed a move to the required precision then the move command will be resent.  The number of retries is controlled by the maxretry parameter. sign sics.getValue("/hdb_path/sign") sics.set("/hdb_path/sign",val) (persists) Default = Privilege = Manager Controls direction of motion, set to -1 to reverse. softlowerlim sics.getValue("/hdb_path/softlowerlim") sics.set("/hdb_path/softlowerlim",val) (persists) Privilege = User Get/set lower software limit.  This is automatically adjusted when you set the softzero or use the setpos command. softupperlim sics.getValue("/hdb_path/softupperlim") sics.set("/hdb_path/softupperlim",val) (persists) Privilege = User Get/set upper software limit.  This is automatically adjusted when you set the softzero or use the setpos command. softzero sics.getValue("/hdb_path/softzero") sics.set("/hdb_path/softzero",val) (persists) Default = 0 Privilege = User Sets the zero position to val. You probably want to use setpos described below, it's easier to understand.  speed sics.getValue("/hdb_path/speed") sics.set("/hdb_path/speed",val) Privilege = User Get/Set the speed of motion along/about the axis controlled by this motor in physical units per second, ie mm/s, deg/s. mot units val Privilege = User Not implemented. Does not have a hdb_path. Get/Set the physical units Preferred val: <command>list </command>output mot list shows the values of the parameters listed below, in the order listed below. Position Reports the current positon TargetPosition Shows target position hardlowerlim Hardware lower limit for motor set in SICS configuration file hardupperlim Hardware upper limit for motor set in SICS configuration file softlowerlim Lower software limit.  This is automatically adjusted when you set the softzero or use the setpos command. softupperlim Upper software limit.  This is automatically adjusted when you set the softzero or use the setpos command. softzero The zero position. fixed prevents movement allows movement. NOTE: The instrument manager can set the accesscode to prevent users from moving a motor. interruptmode Controls what effect a motor failure has on operations Values: Continue. A motor failure will not affect other operations AbortOperation. Stop current hardware operation but no scans or batchfiles AbortScan. Stop current scan or operation but continue processing of batch files with next command AbortBatch. Stop all processing, even batch files precision Controls precision of movements.  If a motor has not completed a move to the required precision then the move command will be resent.  The number of retries is controlled by the maxretry parameter. accesscode Controls which type of user is allowed to control the motor Allowed values: Internal. Motor is reserved for internal use by SICS Manager. Only users who logon as managers are allowed to move the motor. Usually just instrument scientists User Spy. Anyone is allowed to move the motor sign Default = 1 Privilege = Manager Controls direction of motion, set to -1 to reverse. failafter This is the number of consecutive failures of positioning operations this motor allows before it thinks that something is really broken and aborts the experiment maxretry The number of times that SICS will retry a move if a motor has not reached the target position to within the required precision ignorefault Position faults will be ignored if this is greater than zero movecount Default=10 Controls frequency with which position changes are reported if a user subscribes interest to a motor.  A larger value reduces the frequency home home position for the axis which the motor controls, (ie phi, chi, two-theta, x, y).  So it is the physical home position in the units given by the units parameter below, (ie mm, degrees, ...) speed The speed of motion along/about the axis controlled by this motor in physical units per second, ie mm/s, deg/s. maxSpeed Speed in units/s accel Acceleration along/about the axis controlled by this motor. Configurable maxAccel Maximum allowed acceleration in units/s2 decel Deceleration along/about the axis controlled by this motor. Configurable maxDecel Maximum allowed deceleration in units/s2 motOffDelay Number of msec to wait before switching off a motor after a move Default = Debug Settle Blockage_Check_Interval Blockage_Thresh Blockage_Ratio Blockage_Fail Backlash_offset Protocol absEncoder Allowed values: no absolute encoder absolute encoder enabled absEncHome The calibrated "home" position in encoder counts Required if absEncoder = 1 cntsPerX Number of absolute encoder counts per unit of movement along/about the axis of motion Creep_Offset Creep_Precision posit_count posit_1 posit_2 posit_3 stepsPerX Number of motor steps per unit of movement along/about the axis of motion