FB_EcDcTimeCtrl

FB_EcDcTimeCtrl 1:

With this function block single components like year, month, day etc. of a 64 bit TwinCAT  "Distributed Clock System Time" variable can be read. The function block contains several A_GetXYZ  actions. After calling the wanted action the value of the XYZ component in the get-output variable is available. The put input parameter is not yet used.

The function block contains the following actions:

VAR_IN_OUT

VAR_IN_OUT
    in          : T_DCTIME;
END_VAR

in: TwinCAT "Distributed Clock System Time" variable;

VAR_INPUT

VAR_INPUT
    put         : WORD;
END_VAR

put: Input parameter (not used);

VAR_OUTPUT

VAR_OUTPUT
    bError      : BOOL;
    get         : WORD;
END_VAR

bError: This output is set, if an error occurs at the action call;

get: Output parameter (year, month, day, etc.);

Example of an implementation in ST:

PROGRAM P_TEST
VAR
    dcStruct    : DCTIMESTRUCT;
    dcTime      : T_DCTIME;
    fbCtrl      : FB_EcDcTimeCtrl;

    wYear       : WORD;
    wMonth      : WORD;
    wDay        : WORD;
    wDayOfWeek  : WORD;
    wHour       : WORD;
    wMinute     : WORD;
    wSecond     : WORD;
    wMilli      : WORD;
    wMicro      : WORD;
    wNano       : WORD;
END_VAR
dcTime := F_GetCurDcTickTime();

fbCtrl.A_GetYear( in := dcTime, get => wYear );
fbCtrl.A_GetMonth( in := dcTime, get => wMonth );
fbCtrl.A_GetDay( in := dcTime, get => wDay );
fbCtrl.A_GetDayOfWeek( in := dcTime, get => wDayOfWeek );
fbCtrl.A_GetHour( in := dcTime, get => wHour );
fbCtrl.A_GetMinute( in := dcTime, get => wMinute );
fbCtrl.A_GetSecond( in := dcTime, get => wSecond );
fbCtrl.A_GetMilli( in := dcTime, get => wMilli );
fbCtrl.A_GetMicro( in := dcTime, get => wMicro );
fbCtrl.A_GetNano( in := dcTime, get => wNano );

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v2.10.0 Build >= 1316 or higher

PC or CX (x86, ARM)

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

CX (ARM)