beckhoff TF4100 — 4.2.1.1.1 FB_CTRL_GET_SYSTEM_TIME

PLC API In order to interpret the specified cycle times as ticks, the variable bInterpretCycleTimeAsTicks in the global structure stCtrl_GLOBAL_CycleTimeInterpretation is set to TRUE. Within this structure, the base time unit has to be set in variable fBaseTime . By setting the flag bInterpretCycleTimeAsTicks , the interpretation of the parameters with the names tTaskCycleTime tCtrlCycleTime is changed. The interpretation and effect of all other parameters of type TIME remains unaffected. Sample The base time unit of the TwinCAT system is 200µs. The PLC task, and therefore the function blocks of the Toolbox, are called cyclically every 400µs. Setting the global structure:

stCtrl_GLOBAL_CycleTimeInterpretation.bInterpretCycleTimeAsTicks := TRUE; stCtrl_GLOBAL_CycleTimeInterpretation.fBaseTime := 200E-6; Parameterization of a function block from the Toolbox: stParams.tTaskCycleTime := T#2ms; (* 2*200µs=400µs *) stParams.tCtrlCycleTime := T#4ms; (* 4*200µs=800µs *) stParams. ... The TaskCycleTime specified on the function blocks is "2•200E-6s = 400µs" and thus corresponds to the set PLC cycle time. The CtrlCycleTime is set to "800µs = 4•200E-6s" so that the control loop operates with a sampling time of 800µs, i.e. it is processed in every second PLC cycle.

4.2 Reference 4.2.1 Function blocks 4.2.1.1 Auxiliary 4.2.1.1.1 FB_CTRL_GET_SYSTEM_TIME The function block reads the current Windows system time and makes it available in the 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". Otherwise the resolution is reduced to "2 • tCtrlCycleTime". Outputs VAR_OUTPUT stSystemTime : TIMESTRUCT; eErrorId : E_CTRL_ERRORCODES; bError : BOOL; END_VAR TYPE TIMESTRUCT TF4100 20 Version: 2.2.4