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 are generally not used during an experiment. These are used to optimise and protect the instrument and hence are used by the instrument scientist or computing & electronics staff. These values can be get and set using sics.getValue("hdb_path") and sics.set("hdb_path",value) You cannot use the motor short name. 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 that are persistent between restarts of SICS are marked as persists, otherwise a restart of SICS will revert to the value in the configuration file. Parameters to be added: Blockage_Thresh, Blockage_Ratio, Blockage_Fail, Backlash_offset Protocol, absEncoder, absEncHome, cntsPerX Creep_Offset, Creep_Precision, stepsPerX maxSpeed, maxAccel, maxDecel, motOffDelay, Debug, Settle. mot absenc Privilege = User Not implemented. Does not have an hdb_path. Get the absolute encoder reading.  (Only implemented by motors that have absolute encoders.) accel 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 (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 (persists) Privilege = Manager Units = seconds Get/Set the interval at which the motor driver checks the axis for significant changes in position decel 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 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 (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 (persists) Position faults will be ignored if this is greater than zero interruptmode (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 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 (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 (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 (persists) Default = Privilege = Manager Controls direction of motion, set to -1 to reverse. softlowerlim (persists) Privilege = User Get/set lower software limit.  This is automatically adjusted when you set the softzero or use the setpos command. softupperlim (persists) Privilege = User Get/set upper software limit.  This is automatically adjusted when you set the softzero or use the setpos command. softzero (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 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 an 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