MC_SetEncoderScalingFactor

MC_SetEncoderScalingFactor 1:

The function block MC_SetEncoderScalingFactor changes the scaling factor of the active encoder of an axis, either at standstill or in motion.

The change can be absolute or relative. This mode is only suitable at standstill, since in absolute mode the change in scaling factor leads to a position discontinuity. In relative mode an internal position offset is adapted at the same time such that no discontinuity occurs. Note that an intervention during the motion results in a change in the actual axis velocity, while the real velocity remains constant. Therefore only small changes can be implemented during the motion.

MC_SetEncoderScalingFactor 2: Inputs

VAR_INPUT
    Execute       : BOOL;
    ScalingFactor : LREAL; 
    Mode          : E_SetScalingFactorMode; 
    Options       : ST_SetEncoderScalingOptions; 
END_VAR

Name

Type

Description

Execute

BOOL

The command is executed with a rising edge.

ScalingFactor

LREAL

Scaling factor of the active encoder of an axis. The scaling factor is specified in physical positioning units [u] divided by the number of encoder increments.

Mode

E_SetScalingFactorMode

The scaling factor can be set in absolute or relative mode (ENCODERSCALINGMODE_ABSOLUTE, ENCODERSCALINGMODE_RELATIVE).
In absolute mode, counting starts at the zero point of the axis coordinate system, therefore a position jump results when the scaling factor is changed. In relative mode the actual position of the axis does not change. This mode is therefore also suitable for changes during motion.

Options

ST_SetEncoderScalingOptions

Data structure containing additional, rarely used parameters. The input can normally remain open.

  • SelectEncoderIndex: can be set if an axis with several encoders is used and the position of a certain encoder is to be set (Options.EncoderIndex).
  • EncoderIndex: indicates the encoder (0..n) if "SelectEncoderIndex" is TRUE.

See also: General rules for MC function blocks

MC_SetEncoderScalingFactor 3: Inputs/outputs

VAR_IN_OUT
    Axis : AXIS_REF;
END_VAR

Name

Type

Description

Axis

AXIS_REF

Axis data structure that unambiguously addresses an axis in the system. Among other parameters it contains the current axis status, including position, velocity or error state.

MC_SetEncoderScalingFactor 4: Outputs

VAR_OUTPUT
    Done    : BOOL;
    Busy    : BOOL;
    Error   : BOOL;
    ErrorID : UDINT;
END_VAR

Name

Type

Description

Done

BOOL

TRUE if the position was set successfully.

Busy

BOOL

TRUE as soon as the command is started with Execute and as long as the command is processed. If "Busy" is FALSE, the function block is ready for a new order. At the same time, one of the outputs "Done" or "Error" is set.

Error

BOOL

TRUE, if an error occurs.

ErrorID

UDINT

If the error output is set, this parameter supplies the error number.

See also: General rules for MC function blocks

Requirements

Development environment

Target system type

PLC libraries to include

TwinCAT v3.0.0

PC or CX (x86 or x64)

Tc2_MC2