ConvertPosToDcTime

ConvertPosToDcTime 1:

This function block converts an NC axis position into an associated 32-bit Distributed Clock System Time (i.e. the time at which this NC axis position was or will be reached exactly).

VAR_INPUT

VAR_INPUT
    nAxisId         : UDINT;
    nSubIdx         : UDINT;
    fPosition       : LREAL;
END_VAR

nAxisId

ID of the NC axis.

nSubIdx

This 32 bit input magnitude is composed of two different items of information, and is divided into two 16-bit values:
The low word (the 16 bits with the lowest value) contains the sub-index for relative addressing of an encoder sub-element at an axis. The sub-index is counted upwards from zero. For the typical case of an axis that has just one encoder, the null sub-index is correct.
The high word (the 16 bits with the highest value) contains a control word (bit mask) that affects the way in which the position is calculated (e.g. the type of interpolation or extrapolation). A bit mask value of 0x0001 means that the set acceleration of the axis is to be included in the calculation.

fPosition

NC axis position that will be converted through calculation into the corresponding 32 bit distributed clock system time (T_DCTIME32).
If the DC system time associated with the position is outside the expected time window of ± 2.147 seconds, the conversion is refused and an error number returned.

 

VAR_OUTPUT

VAR_OUTPUT
    dcTime  : T_DCTIME32;(* 32 bit distributed clock time *)
    iErr    : UDINT;
END_VAR

dcTime

Supplies the 32 bit Distributed Clock System Time (T_DCTIME32) associated with the input fPosition.

iErr

Supplies an error number if an error occurs, e.g.
- error 0x4012: axis ID is not allowed, or axis is not present in the system,
- error 0x4361: time window exceeded (future),
- error 0x4362: time window exceeded (past),
- error 0x4363: position cannot be found mathematically.

Requirements

Development Environment

Target System

PLC Libraries to include

TwinCAT v2.11.0 Build >= 1524 or higher

PC or CX (x86, ARM)

TcEtherCAT.Lib
( Standard.Lib; TcBase.Lib; TcSystem.Lib, TcUtilities.Lib are included automatically )