MC_ReadStatus

MC_ReadStatus 1:

The MC_ReadStatus function block determines the current operating state of an axis and signals it at the function block outputs.

The updated operating state is additionally stored in the Status output data structure and in the Axis.Status axis data structure. This means the operating state only has to be read once at the start of each PLC cycle and can then be accessed via Axis.Status.

The Axis variable (type AXIS_REF) already includes an instance of the function block MC_ReadStatus. This means that the operating state of an axis can be updated at the start of a PLC cycle by calling up Axis.ReadStatus.

Sample:

PROGRAM MAIN
VAR
    Axis1 : AXIS_REF
END_VAR

(* call the read status function *)
Axis1.ReadStatus;

MC_ReadStatus 2: Inputs

VAR_INPUT
    Enable : BOOL; 
END_VAR

Name

Type

Description

Enable

BOOL

If Enable = TRUE, the axis operating state is updated with each call of the function block.

See also: General rules for MC function blocks

MC_ReadStatus 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_ReadStatus 4: Outputs

VAR_OUTPUT
    Valid              : BOOL; 
    Busy               : BOOL; 
    Error              : BOOL;
    ErrorId            : UDINT;
    (* motion control statemachine states: *)
    ErrorStop          : BOOL; 
    Disabled           : BOOL; 
    Stopping           : BOOL; 
    StandStill         : BOOL; 
    DiscreteMotion     : BOOL; 
    ContinuousMotion    : BOOL; 
    SynchronizedMotion : BOOL; 
    Homing             : BOOL;
    (* additional status *)
    ConstantVelocity   : BOOL;
    Accelerating       : BOOL;
    Decelerating       : BOOL; 
    (* status data structure *)
    Status             : ST_AxisStatus; 
END_VAR

Name

Type

Description

Valid

BOOL

Indicates that the axis operating state indicated at the other outputs is valid.

Busy

BOOL

TRUE, as long as the function block is called with Enable = TRUE.

Error

BOOL

TRUE, if an error occurs.

ErrorID

UDINT

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

ErrorStop

BOOL

Axis status according to the PlcOpen state diagram

Disabled

BOOL

Axis status according to the PlcOpen state diagram

Stopping

BOOL

Axis status according to the PlcOpen state diagram

StandStill

BOOL

Axis status according to the PlcOpen state diagram

DiscreteMotion

BOOL

Axis status according to the PlcOpen state diagram

ContinuousMotion

BOOL

Axis status according to the PlcOpen state diagram

SynchronizedMotion

BOOL

Axis status according to the PlcOpen state diagram

Homing

BOOL

Axis status according to the PlcOpen state diagram

ConstantVelocity

BOOL

The axis is moving with constant velocity.

Accelerating

BOOL

The axis accelerates.

Decelerating

BOOL

The axis decelerates.

Status

ST_AxisStatus

Extended status data structure with additional status information. (Type: ST_AxisStatus)

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