FB_EcDcTimeCtrl
Outdated function This function is outdated. Use the function block FB_EcDcTimeCtrl64 instead. |
This function block can be used to read the individual components such as year, month, day etc. of a 64-bit "Distributed Clock System Time" variable of type T_DCTIME. The function block has several A_GetXYZ actions. Once the required action has been called, the value of the XYZ component is available in the “get” output variable. The “put” input variable is currently not used.
The function block currently has the following actions:
- A_GetYear;
- A_GetMonth;
- A_GetDay;
- A_GetDayOfWeek;
- A_GetHour;
- A_GetMinute;
- A_GetSecond;
- A_GetMilli;
- A_GetMicro;
- A_GetNano;
Inputs
VAR_INPUT
put : WORD;
END_VAR
Name | Type | Description |
---|---|---|
put | WORD | Input parameter (currently not used) |
Inputs/outputs
VAR_IN_OUT
in : T_DCTIME;
END_VAR
Name | Type | Description |
---|---|---|
in | T_DCTIME | TwinCAT "Distributed Clock System Time" variable |
Outputs
VAR_OUTPUT
bError : BOOL;
get : WORD;
END_VAR
Name | Type | Description |
---|---|---|
bError | BOOL | This output is set if an error has occurred during the action call. |
get | WORD | 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 platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.0 | PC or CX (x86, x64, ARM) | Tc2_EtherCAT |