Motor Functions¶
-
py4syn.utils.motor.
createMotor
(name='', PV='')[source]¶ Create and add a motor to the mtrDB dictionary
Parameters: - name : string
Mnemonic of the motor
- PV : string
The Epics PV for this Motor
Examples
>>> from py4syn.utils.motor import * >>> mtop = 'mtop' >>> mbot = 'mbot' >>> createMotor(mtop,'SOL:DMC1:m3') # creates a motor using the mnemonic and PV. >>> createMotor(mbot,'SOL:DMC1:m4') >>> umv(mtop, 10) # move the motor mtop to the position 10. >>> wa() # print the position of all motors registered. >>> mtopPosition = wmr(mtop) # store the motor mtop position in the variable mtopPosition.
-
py4syn.utils.motor.
createPseudoMotor
(name='', description='', backFormula='', forwardDict={})[source]¶ Create and add a pseudo-motor to the mtrDB dictionary
Parameters: - name : string
Mnemonic of the pseudo-motor
- description : string
Description of the pseudo-motor
- backFormula : string
Formula to define the pseudo-motor position based on other motors
Note
- Numpy and Math functions can be used on formulas, specially form numpy users must explicit declare it, e.g. numpy.linalg.solve(..)
- T refers to the motor Target position
- A refers to the motor Actual position
- forwardDict : dictionary
A dictionary that contains a formula to be applied for each motor when the pseudo-motor is moved
Note
- Numpy and Math functions can be used on formulas, specially form numpy users must explicit declare it, e.g. numpy.linalg.solve(..)
- T refers to the motor Target position
- A refers to the motor Actual position
Examples
>>> from py4syn.utils.motor import * >>> >>> # Define the formula to calculate the Bragg Value >>> braggBackFormula = "asin(1.977/A[energy])" >>> >>> # Define the relationship between thetaCrystal and bragg target value >>> braggForwardDict = {"thetaCrystal": "T[bragg]"} >>> >>> # Define the formula to calculate the Energy Value >>> energyBackFormula = "1.977/sin(A[thetaCrystal])" >>> >>> # Define the relationship between the needed motors and the energy target value >>> energyForwardDict = {"bragg": "asin(1.977/T[energy])", >>> "gap": "A[beamOffset]*tan(T[bragg])/ (sin(T[bragg])+(cos(T[bragg])*tan(T[bragg])))", >>> "trans":"A[beamOffset]/(sin(T[bragg])+(cos(T[bragg])*tan(T[bragg])))"} >>> >>> # Define the formula to calculate the Beam Offset and the >>> beamOffsetBackFormula = "2*A[trans]*tan(A[bragg])*cos(A[bragg])" >>> >>> # Define the relationship between the needed motors and the beam offset >>> beamOffsetForwardDict = {"trans": "T[beamOffset]/(sin(A[bragg])+cos(A[bragg])*tan(A[bragg]))", >>> "gap": "(T[beamOffset]*tan(A[bragg]))/(sin(A[bragg])+(cos(A[bragg])*tan(A[bragg])))"} >>> >>> # Crete a simple motor for the 2nd Crystal Translation >>> createMotor("trans", "SOL:DMC1:m1") >>> >>> # Crete a simple motor for the 2nd Crystal Gap >>> createMotor("gap", "SOL:DMC1:m3") >>> >>> # Crete a simple motor for the 1st Crystal Rotation >>> createMotor("thetaCrystal", "SOL:DMC1:m4") >>> >>> >>> # Create the Pseudo motor Bragg, Energy and BeamOffset with the respective formulas and relationships >>> createPseudoMotor("bragg", "Bragg Angle (radians)", backFormula=braggBackFormula, forwardDict=braggForwardDict) >>> createPseudoMotor("energy", "Energy (kev)", backFormula=energyBackFormula, forwardDict=energyForwardDict) >>> createPseudoMotor("beamOffset", "Beam offset (mm)", backFormula=beamOffsetBackFormula, forwardDict=beamOffsetForwardDict) >>> >>> # Print all motor positions >>> wa() >>> >>> # Move the motor Energy to the value 2. >>> mv("energy", 4, wait=True) >>> >>> # Print all motor positions >>> wa()
-
py4syn.utils.motor.
mmv
(**kargs)[source]¶ Perform absolute movement in multiple motors at almost the same time
Parameters: - kargs : string
The motor name and desired position, e.g. x=10,y=10
-
py4syn.utils.motor.
mmvr
(**kargs)[source]¶ Perform relative movement in multiple motors at almost the same time
Parameters: - kargs : string
The motor name and desired position, e.g. x=10,y=10
-
py4syn.utils.motor.
mv
(motor, position, wait=True)[source]¶ Move the desired motor to an absolute position, can or not wait until movement ends,**don’t** show the position while moving.
Parameters: - motor : string
Mnemonic of the motor used on the createMotor and createPseudoMotor functions
- position : double
The desired absolute position
- wait : bool
Optional parameter that indicates if this function must wait until the movement finishes. Default value is True
Note
- If wait is set to False the code will follow as the motor moves.
-
py4syn.utils.motor.
mvr
(motor, position, wait=True)[source]¶ Move the desired motor to a relative position, can or not wait until movement ends,**don’t** show the position while moving.
Parameters: - motor : string
Mnemonic of the motor used on the createMotor and createPseudoMotor functions
- position : double
The desired relative position
- wait : bool
Optional parameter that indicates if this function must wait until the movement finishes. Default value is True
Note
- If wait is set to False the code will follow as the motor moves.
-
py4syn.utils.motor.
print_no_newline
(s)[source]¶ Print information without an new line
Parameters: - s : string
Text to be printed
-
py4syn.utils.motor.
set
(mtr, position)[source]¶ Change the motor user coordinates
Parameters: - mtr : string
Mnemonic of the motor used on the createMotor and createPseudoMotor functions
- position : double
Desired position for user coordinates
-
py4syn.utils.motor.
set_dial
(mtr, position)[source]¶ Change the motor dial coordinates
Parameters: - mtr : string
Mnemonic of the motor used on the createMotor and createPseudoMotor functions
- position : double
Desired position for dial coordinates
-
py4syn.utils.motor.
set_lm
(mtr, ll, hl)[source]¶ Set the motor soft limits in user coordinates, will change DHLM and DLLM
Parameters: - mtr : string
Mnemonic of the motor used on the createMotor and createPseudoMotor functions
- ll : double
Low Soft Limit value
- hl : double
High Soft Limit value
-
py4syn.utils.motor.
tw
(mtr, step)[source]¶ Move the desired motor relative, wait the movement end and ask if you need to move again
Parameters: - mtr : string
Mnemonic of the motor used on the createMotor and createPseudoMotor functions
- step : double
Desired relative step size
-
py4syn.utils.motor.
ummv
(**kargs)[source]¶ Perform absolute movement in multiple motors at almost the same time and wait until movement finishes
Parameters: - kargs : string
The motor name and desired position, e.g. x=10,y=10
-
py4syn.utils.motor.
ummvr
(**kargs)[source]¶ Perform relative movement in multiple motors at almost the same time and wait until movement finishes
Parameters: - kargs : string
The motor name and desired position, e.g. x=10,y=10
-
py4syn.utils.motor.
umv
(motor, position)[source]¶ Move the desired motor to an absolute position, waiting until movement ends,and show the position while it happens.
Parameters: - motor : string
Mnemonic of the motor used on the createMotor and createPseudoMotor functions
- position : double
The desired absolute position
-
py4syn.utils.motor.
umvr
(motor, position)[source]¶ Move the desired motor to a relative position, waiting until movement ends,and show the position while it happens.
Parameters: - motor : string
Mnemonic of the motor used on the createMotor and createPseudoMotor functions
- position : double
The desired relative position