MC_Home

MC_Home 1:

An axis reference run is carried out with the function block MC_Home.

The referencing mode is set in the TwinCAT System Manager with the encoder parameter "Reference Mode". Depending on the connected encoder system, different sequences are possible (see also Reference mode for incremental encoders in the TwinCAT 3 ADS Interface NC documentation).

MC_Home 2: Inputs

VAR_INPUT
    Execute         : BOOL; 
    Position        : LREAL         := DEFAULT_HOME_POSITION;
    HomingMode      : MC_HomingMode;
    BufferMode      : MC_BufferMode; 
    Options         : ST_HomingOptions;
    bCalibrationCam : BOOL; 
END_VAR

Name

Type

Description

Execute

BOOL

The command is executed with a rising edge.

Position

LREAL

Absolute reference position to which the axis is set after homing. Alternatively, the constant DEFAULT_HOME_POSITION can be used here. In this case, the "Reference position for homing" specified in the TwinCAT System Manager is used.

HomingMode

MC_HomingMode

Determines how the calibration is performed.

  • MC_DefaultHoming
    Initiates default homing.
  • MC_Direct
    Sets the axis position directly to Position without executing a movement.
  • MC_ForceCalibration
    Enforces the "axis is calibrated" state. No movement takes place, and the position remains unchanged.
  • MC_ResetCalibration
    Resets the calibration state of the axis. No movement takes place, and the position remains unchanged.

BufferMode

MC_BufferMode

Currently not implemented.

Options

ST_HomingOptions

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

  • ClearPositionLag: is only effective in "MC_Direct" mode. Can optionally be used to set the set and actual positions to the same value. In this case the following error is cleared.

bCalibrationCam

BOOL

Reflects the signal of a referencing cam that can be applied to the controller via a digital input.

MC_Home 3:

Since the reference position is generally set during the motion, the axis will not stop exactly at this position. The standstill position differs by the braking distance of the axis, although the calibration is nevertheless exact.

See also: General rules for MC function blocks

MC_Home 4: Inputs/outputs

VAR_IN_OUT
    Axis     : AXIS_REF;
END_VAR

Name

Type

Description

Axis

AXIS_REF

Axis data structure of the type AXIS_REF, which uniquely addresses an axis in the system. Among other parameters it contains the current axis status, including position, velocity or error state.

Referencing process

The referencing process has several phases. The calibration state is signaled in the cyclic interface of the axis (Axis.NcToPlc.HomingState). The following diagram shows the process flow after starting function block MC_Home with the individual phases.

If an axis is to be referenced without referencing cam, i.e. only based on the sync pulse of the encoder, the referencing cam can be simulated via the PLC program. The "bCalibrationCam" signal is initially activated and then canceled, if Axis.NcToPlc.HomingState is equal or greater 4.

MC_Home 5:

MC_Home 6: Outputs

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

Name

Type

Description

Done

BOOL

TRUE when the axis has been calibrated and the movement is complete.

Busy

BOOL

TRUE as soon as the command is started with "Execute" and as long as the movement 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", "CommandAborted" or "Error" is set.

Active

BOOL

Currently not implemented - "Active" indicates that the command is running. If the command has been buffered, it may only become active after a running command has been terminated.

CommandAborted

BOOL

TRUE if the command could not be executed completely.

Error

BOOL

TRUE as soon as 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