MC_SetPosition
This function block shifts the coordinate system of an axis by manipulating both the setpoint position as well as the actual position of an axis with the same value without any movement caused (Re-calibration with same following error). This can be used for instance for a reference situation.
Syntax
Definition:
FUNCTION_BLOCK MC_SetPosition
VAR_INPUT
Axis : Type_PtpSetPosition;
Execute : BOOL;
Position : LREAL;
Relative : BOOL;
ClearPositionLag : BOOL;
END_VAR
VAR_OUTPUT
Done : BOOL;
Busy : BOOL;
Error : BOOL;
ErrorId : UDINT;
END_VAR
Inputs
|
Name |
Type |
Default |
Description |
|---|---|---|---|
|
Axis |
|
Reference to the axis | |
|
Execute |
BOOL |
|
Trigger the command with rising edge. |
|
Position |
LREAL |
#Invalid |
New position value ([PosUnit]) or distance if Relative = TRUE |
|
Relative |
BOOL |
false |
Shift axis position by value |
|
ClearPositionLag |
BOOL |
|
Resets position lag to zero. |
Outputs
|
Name |
Type |
Description |
|---|---|---|
|
Done |
BOOL |
Position has new value. |
|
Busy |
BOOL |
Function block is not finished and new output values are to be expected. |
|
Error |
BOOL |
Error occurred within function block. |
|
ErrorId |
UDINT |
Error identifier |
Further information
The MC_SetPosition function block sets the current axis position to a parameterizable value. To do this, the axis must be at a standstill.
In the default case (input Relative = FALSE), the actual position is set to the parameterized absolute value of input Position. In the relative case (input Relative = TRUE), the actual position is offset by the value of the Position input. In both cases, the target position of the axis is set so that any potential position lag is retained. If the position lag is to be cleared, this can be done via the Options.ClearPositionLag input.
Note on the migration from NC2 to MC3
The Relative input corresponds to the Mode input of the Tc2_MC2.MC_SetPosition function block.
Possible error codes
For this function block, the following values, among others, are possible for the ErrorId output:
Error(Hex) | Error(Dec) | Error type | Description |
|---|---|---|---|
0x8145 | 33093 | Function Block | Mapping of cyclic interface between NC and PLC is missing (e.g., AXIS_REF, AXES_GROUP_REF, ...). A reference used by the function block (e.g., to an axis, group, mover or other motion object) is not linked to the corresponding NC object, or its cyclic mapping is incomplete. |
0x8148 | 33096 | Function Block | Invalid input value. At least one input of the function block is outside its allowed range or inconsistent with the other inputs. |
0x8151 | 33105 | State | Command is not allowed in current axis state. If the axis has no controller enable, is in error or has been added to a group, some commands are not permitted. |
0x8182 | 33154 | Monitoring | Software position limit violation. Software position limits of at least one axis have been or would have been violated by a command. |
0x8196 | 33174 | Initialization | Invalid position or distance. The actual or specified position or distance could not be determined or is invalid. |
0x818c | 33164 | Parameter | Position is out of modulo range. Position must be larger or equal to zero and less or equal to the modulus when using modulo positioning. When using modulo positioning, the target position is interpreted in consideration of the AdditionalTurns variable at the Options input. |
An overview of all NC error codes can be found here:
Version information
- TwinCAT Standard >= v3.1.4026.23.1
- TF5500 MC3 Base >= v4.0.6