-
Notifications
You must be signed in to change notification settings - Fork 2
McLennan motors
Wiki > The Backend System > Specific Device IOC Motor IOCs > McLennan
The McLennan motor is a controller that support multiple independent motors. It is often used at ISIS for rotation stages.
**WARNING: Unlike many other motor controllers that remember settings through autosave the McLennan exclusively uses macros. This means for changing parameters in a persistent way you will need to change them in the IOC configuration rather than the motor details panel, otherwise they will get lost on IOC restart. We now plan to make these settings appear read-only in the motor view to avoid any confusion **
Instructions on how to convert a labview mclennan ini file are at the end of this document in the converting values from labview section
The motor resolution is set with the MSTPn IOC macros and in units of steps/mm
(same as in SECI/labview), this will be inverted by the IOC internally as the EPICS motor record MRES
field uses the inverse mm/step
.
The encoder ratio rather than encoder resolution is set with the ERESn IOC macros, this is a string like 400/4096
and bears no direct relation to the EPICS motor record ERES
. As the mclennan driver pretends to be open loop (no encoder present as per MSTA
field) whatever mode it is running in, the motor record ERES
is not actually used and is set to 0
in the st.cmd
and will then display as the same value as motor record MRES
when later viewed. So ignore the encoder resolution value displayed on the motor record screen.
The encoder ratio written M/E
is providing motor_steps_per_revolution / encoder_steps_per_revolution
, in SECI/labview this was referred to as Numerator / Demoninator
. So actual_position_steps = encoder_steps_readback * encoder_ratio
. For closed loop (encoder feedback) controller mode to work this ratio needs to be correct so that commanded_motor_steps_moved = encoder_steps_moved * encoder_ratio
, if the ratio isn't right the motor will fail to get position leading to many retries and an error. It is possible to work out the ratio by e.g. going to motor console (PuTTY/hterm), doing a small MR relative move and comparing command position (CP) and actual position (AP). dbior
command on an ioc window now shows these values, as does the QP
command at the motor low level serial interface. The Raw encoder steps is IP
or Input Position
which is scaled by encoder ratio to give actual (AP) position. If encoder and motor move in opposite directions, add a minus sign to encoder ratio.
The McLennan motor velocity is set with the VELOn IOC macros, the value set is in mm/second
, same units as EPICS motor record uses.
The IOC macro ACCLn for acceleration is the the number of seconds under linear acceleration to reach maximum speed, the same convention as the EPICS motor record (The acceleration value on the device itself is the acceleration in units of step/s^2
, this is calculated in the IOC as velocity divided by the product of the motor resolution and ACCL value).
See Set the raw position of the motor without moving it
There are several homing modes on the McLennan set via the HOME
macro. The choice of mode depends on the motor, modes 1 and 3 (constant velocity homes to limit switches) are controlled in software by SNL, others by controller HD
(home to datum) command. Modes are:
- 0: Controller does internal home to an external home signal (not normally used).
- 1: Do a reverse constant velocity move (jog) until limit switch is hit, but do not zero the motor (this is deprecated)
- 2: Do a hardware reverse (-) direction search for a home signal and then zero the motor
- 3: Do a reverse constant velocity move (jog) until limit switch is hit then zero the motor.
- 4: Do a hardware forward (+) direction search for a home signal and then zero the motor
- 5: Move to forward limit, do a hardware reverse direction search for a home signal and then zero the motor
- 6: Move to reverse limit, do a hardware forward direction search for a home signal and then zero the motor
The constant velocity move uses JVEL and is set to be a 1/10 of the normal velocity unless the macro is set to change it.
There is a special homing sequence for Vesuvio because it doesn't quite work until ticket 5739 is done
There is a special homing sequence for HRPD low temp sample changer because it doesn't quite work until ticket 5739 is done
The way this works in the code is that the motor driver send the correct home (or no home) dependent on the mode set in request_mode
, for SNL then takes care of other moves.
Rotary switch SW1 and SW2 give axis address, address is 10*SW1 + SW2
DIP Switch SW3
- 1=ON 2=OFF gives serial baud 9600, see manual for other combinations
- 3=OFF 7bit even parity, or 3=ON 8bit no parity
- 4=OFF (no hardware flow control)
- 5=ON (quiet command reply mode, required by EPICS driver)
- 6=OFF
- 7=OFF (rs232)
- 8=OFF (no terminator for rs485)
SW4 controls encoder termination, with OFF=single ended (TTL), ON=differential pair (RS422). Not for us to change, leave to motion engineers.
When configuring a particular axis, an axes.cmd
file is required in C:\Instrument\Settings\config\[INSTMACHINE]\configurations\mclennan
. See the the motion control pages for additional details. It is often desirable to set up a number of axes depending which controller, and which axis is in use. There are specific environment variables set up to let you do this. The following example shows a stretching rig set up on MOT0201
and a linear sample changer on MOT0101
:
$(IFMTRCTRL1)$(IFAXIS1) dbLoadRecords("$(AXIS)/db/axis.db","P=$(MYPVPREFIX)MOT:,AXIS=STACK:LIN,mAXIS=MTR0101")
$(IFMTRCTRL2)$(IFAXIS1) dbLoadRecords("$(AXIS)/db/axis.db","P=$(MYPVPREFIX)MOT:,AXIS=STRETCH:LIN,mAXIS=MTR0201")
You can see the environment variables being used at the start of the line. The available variables are:
-
IFMTRCTRLn
: The line is run if the controller number for the motor isn
wheren
is between 1 and 24. This corresponds to theMTRCTRL
IOC macro. -
IFAXISn
: The line is run if the axis number for the motor isn
wheren
is between 1 and 8. This corresponds to theAXISn=yes
IOC macro.
Note that the equivalent IFNOT...
environment variables also exist but are typically of less use.
Also note that the two environment variables combine as an and
operation when used in this form. That is, the line will only execute if both conditions are met. There is currently no way to combine the environment variable with an or
operator.
The IBEX McLennan driver is set to send a reset command on any request to move. This is intended to clear errors (e.g. tracking abort) and avoid the need for power cycling that would clear the position.
The IBEX McLennan driver sends the following sequence of commands when a stop is requested:
STOP
RESET
STOP
The first stop will stop the motor as part of the normal operation and the 2nd and 3rd command will have no effect. If the motor enters an error state during a move, the first stop will have no effect and the 2nd and 3rd command will stop it. The first command is necessary since the 2nd and 3rd commands will not cause it to stop under normal operation.
Quick note on this learnt from SECI; It appears that the SC command which set the speed for HD (home to datum) may be limited in it range. We don't think it can be set faster than the normal speed and maybe be limited to 400. Investigate when and if we need this.
The McLennan now prints its current mode of operation (moving, homing, Idle, tracking abort etc) and any error messages to the IOC log file/ioc command window screen.
When starting the unit:
- Start the controller
- Start/restart the IOC (so that it can send the motor and encoder resolutions to the controller)
- Home the device
Check the MCLEN
IOC log file for error messages and also examine output from dbior
and dbior * 1
typed at the IOC console window.
If it doesn't move at all try using the macros for an axis number other than 1 (e.g. 2 or 3) in the ibex GUI. The axis to be driven by the buttons on the front panel are set by a position dial inside the mclennan crate, so you may not be be trying to control the correct axis id.
If it moves a short distance and stops it may be going into Tracking abort
. A tracking abort means the encoder and motor step counters have got further apart than expected during the move, this could be due to:
- The encoder and motor resolutions are incorrect/incompatible, so "expected" and "actual" position are diverging. The first thing to do is to restart the McLennan hardware and then the IOC so that the values are resent. If this does not fix it then check the settings are correct.
- you are trying to accelerate or move too quickly, or possibly move too slowly, meaning there is a time lag between the motor pulses being sent and the motor response. Try changing these parameters. See end of this page if you need to change the tracking abort window.
If the McLennan moves but does not stop at the position you requested it could be that the encoder and motor resolutions have not been sent to the controller or are incorrect. This must be done whenever the unit is restarted and is done by restarting the IOC.
check Controller Switch settings
above - if IBEX has been set to use 7 bit even parity but the crate dip switch is set at 8 bits no parity, then this could lead to parity errors being generated. Make sure the IBEX MCLEN IOC and the crate agree on this setting.
In homing modes 1 and 3, the McLennan homes via SNL and uses JVEL
as it's speed. JVEL
defaults to VELO/10
if not set, so try increasing the jog speed and see if this speeds up homes
In other homing modes, the McLennan uses an internal homing routine. This uses the "creep speed" which IBEX now does set as of https://github.com/ISISComputingGroup/IBEX/issues/4815. If you need to manually make homing faster, do the following:
- Set
HVEL
macro to an appropriate speed for homing via IBEX configuration macros - Restart the IOC
Note that the creep speed for the PM600 at least is limited to 800 steps per second. We cater for this in the motor record and set it to the HVEL
value if lower than 800 and otherwise set it to 800.
Most McLennans have 2 RS232 ports, for daisy chain in&out. The out port is required to have an rs-232 terminator installed in it, this looks similar to a null modem and bridges two pins. If this terminator is not installed the mclennan will not communicate at all using any comms settings.
The office McLennan(s, there are two) needs the following:
- No Null terminator or gender changer (if using a straight-through male-female cable from a PC)
- Note: If the mclennan has two ports (for daisy chaining), the out port MUST have an RS232 terminator in it. This looks similar to a null modem and bridges two serial pins. If this is not present, the motor controller will not communicate.
Use following IOC macro setting:
note: the comms settings should be labelled on the device, so refer to those
-
BAUD
9600 -
BITS
7 -
PARITY
even -
AXIS3
yes (all others no) -
MODE3
CLOSED -
ACCL3
1 -
VELO3
0.5 -
ERES3
400/4096 -
MSTP3
4000
console to IOC and type dbior
for basic information. For extended information pass a higher report level to dbior e.g. dbior drvPM304 1
(the drvPM304
is the mclennan driver name and restricts details to just that, the second argument is the debug level. You can use *
instead of drvPM304
but will then get extended details for asyn
and other loaded drivers too)
if you need to convert a previous SECI/labview mclennan ini file, these are usually found in c:\labview modules\Drivers\Mclennan PM600\INI Files
on the NDX computer. A file will have an entry like:
[M0]
Name = "Mclennan Newport"
Enabled = TRUE
Units = "deg"
Com Port = 7
Axis Address = 1
Baud Rate = 9600
Data Bits = 8
Parity = 0
Stop Bits = 10
Acceleration = 40000
Velocity = 10000
Motor steps per unit = 8000.000000
Encoder counts per unit = 1000.000000
Correction Gain = 70
Window = 50
Creep Speed = 5000
Creep Steps = 0
Settling Time = 0
Jog Speed = 10000
Control Mode = 4
BackOff Steps = 0
Deceleration = 40000
Upper limit = 180.000000
Lower Limit = -180.000000
Enable State = 1
KF = 0
KP = 10
KS = 0
KV = 0
KX = 0
Numerator = 8.000000
Denominator = 1.000000
Homing Method = 2
Homing Speed = 10000
Home Offset = 0.000000
Apply Home Position = TRUE
Home Position = 0.000000
Apply Home Offset = FALSE
Calculate the appropriate MCLEN IOC macros as follows:
-
Axis Address = 1
andEnabled = TRUE
so we setAXIS1=yes
and then set other macros with a suffix of1
-
Name = "Mclennan Newport"
so we setNAME1 = Mclennan Newport
-
Motor steps per unit = 8000.000000
so we setMSTP1 = 8000
(which will lead to an EPICS motor record MRES of 0.000125) -
Encoder counts per unit = 1000.000000
this is not used directly, but see comment onNumerator
andDenominator
below -
Velocity = 10000
this is in steps per second, so we divide by motor steps per unit to get units per second (10000 / 8000),VELO1 = 1.25
-
Acceleration = 40000
this is in steps / s^2, we divide velocity by acceleration (10000 / 40000) to get the acceleration timeACCL1 = 0.25
-
Units = "deg"
so we setUNIT1 = deg
-
Jog Speed = 10000
so like velocity above we divide by steps (10000 / 8000) to getJVEL1 = 1.25
-
Upper limit = 180.000000
is already in proper units so setDHLM = 180.0
-
Lower Limit = -180.000000
is already in proper units so setDLLM = -180.0
-
Homing Speed = 10000
so divide by motor steps (10000/8000) to getHVEL1 = 1.25
-
Numerator = 8.000000
andDenominator = 1.000000
refer to the encoder ratio components so we setERES1 = 8/1
(This should be the equivalent numeric ratio toMotor steps per unit
/Encoder counts per unit
which is true here as 8000 / 1000 == 8 / 1 ) -
Home Position = 0.000000
IOC always applies a dial home position of 0, if labview value is non-zero setOFST1
IOC macro to this value -
Control Mode = 4
in labview4
is "closed loop stepper" so setCMOD1 = CLOSED
(if labview was1
that means "open loop stepper" so would setCMOD1 = OPEN
. We don't currently handle other values and they are not used at ISIS as far as we know) -
Homing Method = 2
for labview 0=none; 1=home signal+; 2=home signal-; 3=reverse limit,home signal+; 4=forward limit,home signal-;5=reverse limit;6=forward limit. So labview method2
is a reverse direction hardware home so after examining the Homing section above the equivalent ibex IOC mode isHOME1 = 2
-
Window = 50
this is the end of move check window before an internal mclennan retry. It is a bit like the retry deadband of the motor record, but done at the controller. If a moves plus retries completes and is still outside this Window, an error will be signalled. So we setWIN1 = 50
-
Creep Steps = 0
number of steps to approach final position at the slowerCreep speed
in the final phase of a move. So we setCRST1 = 0
-
Settling Time = 0
how long motor readback must be withinWindow
of requested position at end of move, if not achieved triggers a timeout abort. So we setSETL1 = 0
-
BackOff Steps = 0
used for backlash correction. We can setBOST1 = 0
but this is the default anyway.
Some labview values do not currently have macros and get IOC defaults. Edit MCLEN IOC st-motor-init.st
if you need to temporarily change them and then create a ticket to add a proper IOC macro
-
Correction Gain = 70
this is equivalent to the IOC defaultPCOF = 0.7
for a stepper motor -
Creep Speed = 5000
only important for us ifCreep Steps
> 0 as this is temporary set toHVEL
during a home so does not now affect homes.
Some mclennan values were not covered in labview but exist in MCLEN IOC st-motor-init.st
- Tracking window - a parameter used to determine if a TRACKING ABORT should be signalled, it is the max allowed difference between current and requested position during a move (also known as the following error). This may get triggered by a motor being told to move/accelerate quicker than it can, or move too slowly and so stalling, or an incorrect encoder ratio so motor and encoder get out of step, or incorrect encoder values being returned from the hardware
- Not Complete/Time-Out time - the max time at end of a move for any settling/auto corrections etc. to take place, otherwise triggers a NOT COMPLETE/TIMEOUT ABORT This could mean the
Window
mclennan parameter is too small and cannot be achieved, try increasing relevantWIN*
macro.
Command syntax is aXXnnn
where a
is address, XX
command, nnn
optional argument e.g. 1HD-1
homes axis 1 to datum in negative direction.
CO - query current operation
OS - query status
QA - query all parameters
QM - query modes
QP - query positions
QS - query speeds
modes give a bit pattern - see manual for meaning