FB_CTRL_GET_SYSTEM_TIME (only on a PC system)

FB_CTRL_GET_SYSTEM_TIME (only on a PC system) 1:

This function block reads the current Windows system time, making it available in SystemTimeStruct.

Description:

This function block makes the current system time available in its output structure. The resolution is specified through the tCtrlCycleTime parameter; the maximum resolution is 10 ms, and it is necessary to observe the condition tCtrlCycleTime > 2 • tTaskCycleTime. If this is not done, the resolution will be reduced to 2 • tCtrlCycleTime.

VAR_OUTPUT

VAR_OUTPUT
    stSystemTime    : TIMESTRUCT;
    eErrorId        : E_CTRL_ERRORCODES;
    bError      : BOOL;
END_VAR
TYPE TIMESTRUCT
STRUCT
    wYear       : WORD;
    wMonth      : WORD;
    wDayOfWeek    : WORD;
    wDay    : WORD;
    wHour       : WORD;
    wMinute       : WORD;
    wSecond       : WORD;
    wMilliseconds : WORD;
END_STRUCT
END_TYPE

stSystemTime : Structure in which the system time is output.

wYear : The year: 1970 ~ 2106;

wMonth : The month: 1 ~ 12 (January = 1, February = 2 etc.);

wDayOfWeek : The day of the week: 0 ~ 6 (Sunday = 0, Monday = 1 etc.);

wDay : The day of the month: 1 ~ 31;

wHour : Hour: 0 ~ 23;

wMinute : Minute: 0 ~ 59;

wSecond : Second: 0 ~ 59;

wMilliseconds : Millisecond: 0 ~ 999;

eErrorId : Supplies the error number when the bError output is set.

bError : Becomes TRUE as soon as an error situation occurs.

VAR_IN_OUT

VAR_IN_OUT
    stParams : ST_CTRL_GET_SYSTEM_TIME;
END_VAR

stParams : Parameter structure of the function block. This consists of the following elements:

TYPE
ST_CTRL_GET_SYSTEM_TIME:
STRUCT
    tTaskCycleTime   : TIME;  (* task cycle time [TIME]      
*)
    tCtrlCycleTime   : TIME;  (* controller cycle time [TIME]
*)
END_STRUCT
END_TYPE

tCtrlCycleTime : Cycle time with which the control loop is processed. This must be greater than or equal to the TaskCycleTime. The function block uses this input value to calculate internally whether the state and the output values have to be updated in the current cycle.

tTaskCycleTime : Cycle time with which the function block is called. If the function block is called in every task cycle this corresponds to the task cycle time of the calling task.

Requirements

Development environment

Target system type

PLC libraries to be linked

TwinCAT v2.8

PC (i386)

TcControllerToolbox.lib