FB_EcDcTimeCtrl
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:
- A_GetYear;
- A_GetMonth;
- A_GetDay;
- A_GetDayOfWeek;
- A_GetHour;
- A_GetMinute;
- A_GetSecond;
- A_GetMilli;
- A_GetMicro;
- A_GetNano;
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 |
CX (ARM) |