Mover Object
The Mover function block is the heart of the solution. It contains essential functionality, including:
- Basic administrative commands like enabling & disabling
- Easily commanding movements to absolute positions or stations
- Reading out current move status information like position, velocity, etc.
- Updating motion parameters during operation
Many of the motion related commands are chainable as noted below. This allows a concise set of motion commands to be written on one line.
1 2 |
|
Setup & Execution
It is recommended, but not required, to declare Movers as an array.
1 2 |
|
Movers must also be added to the Mediator object. By default, this is handled automatically.
1 2 |
|
Methods
ActivateTrack
ActivateTrack( DesiredTrack : Track )
Updates the mover's logical track.
This method is used with track management to change the track that the mover is assigned to. Two conditions should be considered when changing tracks:
- A mover will stop immediately when ActivateTrack is called. It's recommended to only change tracks when the mover is in standstill
- A mover's position can change when calling ActivateTrack. This will happen if the zero point for the current track and new track are different.
A track change takes several PLC and NC scans. Issuing a motion command while this change is in progress will cause the mover to throw an error. To check if the track change is complete monitor the Mover.IsTrackReady
property.
1 2 3 4 5 6 7 8 |
|
Cyclic
Cyclic()
Handles background tasks for the mover such as populating status bits and handling completion of tasks that take more than 1 scan.
Important
Cyclic must be called every cycle. By default this is handled automatically by the Mediator.
Disable
Disable()
Chainable
Disables the mover. Holding Torque will be lost. Method will automatically remove the mover from its Collision Avoidance group.
1 |
|
Enable
Enable()
Chainable
Carries out steps to prepare the Mover for motion commands.
- An internal MC_Reset function block is called to reset any errors that may exist on the Axis object.
- The mover, via the Mediator, will read M1 Detection Settings configured in the XtsProcessingUnit. If M1 Detection is configured, it will activate this process to find Mover 1. If this is not configured, this step is skipped.
- An internal MC_Power function block is called to energize the axis object.
- The mover will automatically add itself to a Collision Avoidance group, and if necessary will also automatically enable this group.
- The mover will set its
Ready
output True.
1 |
|
GroupStop
GroupStop()
Chainable
Immediately stops all enabled movers on the system with the deceleration parameters of the mover on which the method was called.
Since the method acts upon the collision avoidance group, all enabled movers on the system are immediately stopped and any active movements are cancelled. New motion commands to each mover are ignored until the Stop has completed.
1 2 3 4 |
|
Halt
Halt()
Chainable
Immediately stops the commanded mover with the deceleration parameters stored in the Mover object
Halt does not alter the mover's internal axis state, so new movements can be executed at any point to send the mover onwards.
1 2 3 4 |
|
LogUserEvent
LogUserEvent( Text1 : STRING, Text2 : STRING, Text3 : STRING )
Chainable
Submits custom log events to the Event Logger which can be viewed in TwinCAT
1 2 3 |
|
MoveToPosition
MoveToPosition( Destination : LREAL )
Chainable
Executes an Absolute Move (with Collision Avoidance) to the target location.
1 2 3 4 |
|
MoveToStation
MoveToStation( Destination : Station )
Chainable
Executes an Absolute Move (with Collision Avoidance) to the location of the target Station, and implicitly calls that Station's RegisterMover method.
1 2 3 4 |
|
MoveVelocity
MoveVelocity( DesiredVelocity : LREAL )
Chainable
Executes a Velocity movement (with Collision Avoidance) at the specified Velocity. This command also implicitly updates the Mover's internal Velocity Motion Parameter.
1 2 3 4 |
|
ReissueCommand
ReissueCommand()
Chainable
Executes the latest command that was issued to the mover, e.g. a MoveToPosition command. The move is executed with the current internal Motion Parameters of the Mover, so the dynamics of the mover may not exactly match what was initially commanded. However, in cases of MoveToPosition or MoveToStation, the destination will be the same.
To determine what type of movement ReissueCommand() will repeat, see Mover properties CurrentMoveType
, CurrentObjective
, and CurrentDestinationPosition
.
1 2 3 4 5 6 7 8 9 10 11 12 |
|
Reset
Reset()
Chainable
Calls a reset on the underlying axis immediately. The state machine unaffected and will, for example, keep the mover in the enabled state if .Reset() is called while is in the enable state.
The mover's error properties will be cleared, and if and Axis error continues to exist after the reset, the error properties will continue to reflect this.
SetAcceleration
SetAcceleration( DesiredAccel : LREAL )
Chainable
Updates the Mover's internal Motion Parameter for Acceleration (mm/s²) and immediately reissues any currently executing motion blocks so that the parameter update takes effect immediately
1 2 3 4 |
|
Notice
This method implicitly calls .ReissueCommand() in the background in order for the updated dynamics to take effect immediately. If this is not the intent, consider modifying the Mover[x].MotionParameters property instead.
SetDeceleration
SetDeceleration( DesiredDecel : LREAL )
Chainable
Updates the Mover's internal Motion Parameter for Deceleration (mm/s²) and immediately reissues any currently executing motion blocks so that the parameter update takes effect immediately
1 2 3 4 |
|
Notice
This method implicitly calls .ReissueCommand() in the background in order for the updated dynamics to take effect immediately. If this is not the intent, consider modifying the Mover[x].MotionParameters property instead.
SetDirection
SetDirection( Direction : Tc3_Mc3Definitions.MC_Direction );
Chainable
Updates the Mover's internal Motion Parameter for Direction and immediately reissues any currently executing motion blocks so that the parameter update takes effect immediately
Caution
This method implicitly calls .ReissueCommand() in the background in order for the updated dynamics to take effect immediately. If this is not the intent, consider modifying the Mover[x].MotionParameters property instead. This method should only be used with care, and an understanding that a mover enroute can immediately reverse course and execute a motion command in the opposite direction when this method is called.
1 2 3 4 5 6 |
|
SetGap
SetGap( Gap : LREAL )
Chainable
Sets the collision avoidance gap for the specified mover in mm. This takes effect immediately.
Caution
This method can cause unexpected motion. If setting a larger gap for a mover that currently has movers within the new gap distance (on either side of the mover). Each affected mover will immediately attempt to adjust for the new gap which may result in movers moving forwards or backwards.
When increasing the gap between movers it's recommended to do this one mover at a time only when the space in front of the mover is clear for at least the new gap distance. This can be accomplished with either a PositionTrigger or Zone.
1 |
|
SetGapMode
SetGapMode( Mode : Tc3_Mc3Definitions.MC_GAP_CONTROL_MODE )
Chainable
Sets the collision avoidance gap control mode for the specified mover. This takes effect immediately.
Default defers to the mode set in the NC's Collision Avoidance object.
Note
For modes other than Standard the NC's Collision Avoidance object must be set to mcGapCtrlDirectionPositive
. This paramater can only be set in configuration and not during runtime.
Mode | Description |
---|---|
mcGapControlModeGroupDefault | This value indicates that the GapControlMode set in the group parameters should be used for this motion command. |
mcGapControlModeStandard | "Caterpillar" The axes fan out characteristically during the acceleration phase, such that a collision during the motion command is prevented. |
mcGapControlModeFast | "Lock-step" All Axes move at the same time and with the full dynamics. |
mcGapControlModeNone | This value indicates that the Gap Control is not active in the command. After the command, the Standby Gap Control takes effect again with the mode, which is set in the group and the gap size of the last valid command. |
Additional documentation of gap control mode is available on Infosys which includes graphs comparing the options.
1 |
|
SetJerk
SetJerk( Jerk : LREAL )
Chainable
Updates the Mover's internal Motion Parameter for Jerk [mm/s3] and immediately reissues any currently executing motion blocks so that the parameter update takes effect immediately
1 2 3 4 |
|
Notice
This method implicitly calls .ReissueCommand() in the background in order for the updated dynamics to take effect immediately. If this is not the intent, consider modifying the Mover[x].MotionParameters property instead.
SetVelocity
SetVelocity( DesiredVelocity : LREAL )
Chainable
Updates the Mover's internal Motion Parameter for Velocity [mm/s] and immediately reissues any currently executing motion blocks so that the parameter update takes effect immediately
1 2 3 4 |
|
Notice
This method implicitly calls .ReissueCommand() in the background in order for the updated dynamics to take effect immediately. If this is not the intent, consider modifying the Mover[x].MotionParameters property instead.
SyncToAxis
SyncToAxis( MasterAxis : AXIS_REFERENCE, MasterSyncPos : LREAL, SlaveSyncPos : LREAL, SyncStrategy : MC_SYNC_STRATEGY )
Chainable
Pairs the current mover with an external axis (real or virtual) with specified Master & Slave Sync Positions. The current mover will synchronize according to the parameter SyncStrategy and a 1:1 gear ratio. The synchronization can be ended by executing a call on the slave for any other motion command, e.g.
MoveToPosition
orHalt
.
MasterAxis is a reference to the NC axis object that the mover should synchronize with, real or virtual.
MasterSyncPos is the position of the Master at which point the mover will be InSync and will have the correct gear ratio (1:1).
SlaveSyncPos is the position of the mover at which point it is InSync
SyncStrategy defines the type of calculation used to blend the movements and establish the synchronization. Simply put, the mover should synchronize immediately & aggressively, as late as possible and aggressively, or as gently as possible.
For more information on these inputs, see InfoSys documentation for the underlying MC_GearInPosCA Function Block
See also: Mover.IsSyncedToAxis
1 2 3 4 5 |
|
SyncToMover
SyncToMover( MasterMover : Mover, Gap : LREAL )
Chainable
Pairs the current mover with a desired mover at a specified gap distance. The current mover will immediately move (with CA) to a specified distance from the Master Mover and then mimic all motion from the master. The synchronization can be ended by executing a call on the slave for any other motion command, e.g.
MoveToPosition
orHalt
.
Gap specifies a center-to-center following distance between master and slave movers. This gap cannot be achieved if it is below the minimum collision avoidance distance established in the CA group. Positive Gap values will result in a following position behind the master and negative values will result in a slave that precedes the master.
Additional calls to this method can be used to update the gap between paired movers.
See also: Mover.IsSyncedToMover and Mover.MasterMover
1 2 3 4 5 6 7 |
|
1 2 3 4 5 6 7 8 9 10 11 |
|
UnregisterFromAll
UnregisterFromAll()
Unregisters a mover from all Mover Lists, Position Triggers, Station and Zones.
ValidateTrack
ValidateTrack()
Confirms that a valid track is selected and returns true. Otherwise logs an error and returns false to be handled by higher-level code.
This method is typically used internally by other motion methods of movers to log an error message when a command is issued to a mover who is not on a valid track. The property .IsTrackReady is intended for use in user code.
Properties
.CurrentDestinationPosition
LREAL
Provides the current destination position for the last movement command issued to the Mover. For Station commands, this will be the Position of the Station. For Velocity commands with no real destination position, the value is set to +/-1E300.
.CurrentDestinationTrack
DINT
Provides the current destination track for the last movement command issued to the Mover. When track management is used, it should be queried along with the property .CurrentDestinationPosition to validate destinations.
.CurrentMoveType
MoverCommandType_enum
1 2 3 4 |
|
Provides the current (last executed) type of movement command issued to the Mover
.CurrentObjective
STRING
Provides the current Objective destination for the Mover. Right now this is only valid when the Mover is destined for a Station objective, and provides a string name for that station.
.CurrentTrack
POINTER TO Track
Returns a pointer to the track that this mover is currently assigned to.
Use the ^ operator to dereference the pointer and query track properties
1 |
|
.IsCollisionAvoidanceActive
BOOL
Returns true if collision avoidance is affecting the desired motion profile of this mover
1 2 3 |
|
.IsErrorMover
BOOL
Returns TRUE if the current Mover reference is an Error Mover. An Error mover is automatically returned when an invalid command is given to an interface capable of returning a Mover. See Diagnostics / ErrorMovers for more information.
1 2 3 4 5 6 |
|
.IsSyncedToAxis
BOOL
Returns true if the mover is slaved to an external axis and has successfully reached the following position specified by the Master & Slave Sync Positions
.IsSyncedToMover
BOOL
Returns true if the mover is slaved to another mover and has successfully reached the following position specified by the Gap.
.IsTrackReady
BOOL
Returns true when the ActivateTrack() method has completed successfully. When using track management motion commands should not be issued unless this value is true or the mover will throw an error.
When using track management it can take several PLC scans for the .ActivateTrack method to complete. It is advised to wait for this to return after issuing an .ActivateTrack() command to avoid motion errors.
.MasterMover
REFERENCE To Mover
Reference variable that refers to the Mover this Mover is currently slaved to
When this mover is not slaved to another mover, .MasterMover is an invalid reference. There is therefore an ErrorMover object which will return information on what action was requested by the object while .MasterMover was invalid. This will show up in TwinCAT's Event Logs. See Diagnostics / ErrorMovers for more information.
It is recommended that all evaluations are nested inside IF checks for .IsSyncedToMover OR by calling __ISVALIDREF
.MotionParameters
MotionParameters_typ
Defines a structure containing the dynamics settings for the Mover. Any new motion commands issued will utilize these values.
Note
Despite listing this value as a Property here in the documentation, MotionParameters are actually defined as a regular Input to the Mover object. This allows component access to the members of the STRUCT, which is not possible for Properties.
1 2 3 4 5 6 7 8 9 |
|
Modifying a mover's Motion Parameters will not affect the current dynamics of a mover enroute. Updated dynamics properties will only take effect when the next motion command is issued.
It is also possible to alter motion paramaters with mover methods such as .SetVelocity()
, .SetAcceleration()
and others. These methods implicitly call .ReissueCommand() and therefore take effect immediately.
.NextMover
Returns the next mover in line with respect to this mover. Specifically, it returns the closest mover with a greater Position value than the current mover, regardless of actual direction of travel.
.Payload
Data associated with the product on the mover.
The code uses a structure with some example data that may be relevant to an in-process part on the mover. The structure is located in the PLC Project > DUTs > MoverPayload_typ.
1 2 3 4 5 6 7 8 9 |
|
This data travels with the mover and when a mover arrives at a station it can be queried or modified based on the station's process. This structure can be modified as needed to suit the application.
Note that because .Payload is a property that returns a structure an intermediate variable must be used for access as shown in the examples below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
.PreviousMover
Returns the previous mover in line with respect to this mover. Specifically, it returns the closest mover with a lesser Position value than the current mover, regardless of actual direction of travel.
.TrackInfo
Returns information provided by MC_ReadTrackPositions for use with track management.
Note
Despite listing this value as a Property here in the documentation, TrackInfo is actually defined as a regular Output from the Mover object. This allows component access to the members of the STRUCT, which is not possible for Properties.
Member | Type | Description |
---|---|---|
TrackId | OTCID | The hardware ID of the track the mover is assigned to |
PartId | OTCID | The hardware ID of the part the mover is physically present on |
TrackPosition | LREAL | Position of the mover measured from the zero point of the track. This may differ from Mover.AxisReference.NcToPLC.ActPos in certain track configurations |
PartPosition | LREAL | Position of the mover measured from the zero point of the part the mover is physically on |