FB_BA_SetTime
Setting the system time
Functional description
The local NT system time and the date of a TwinCAT system can be set with the function block FB_BA_SetTime (the local NT system time is shown in the taskbar). The system time is specified via the structure stSysTi.
Internally, an instance of the function block NT_SetLocalTime from the TcUtilities library is called in the function block.
The local NT system time can also be synchronized with a reference time with the aid of the SNTP protocol. More information can be found in the Beckhoff Information System under: |
Inputs/outputs
VAR_INPUT
bSet : BOOL;
sNetId : T_AmsNetId;
stSysTi : TIMESTRUCT;
udiTiOut : UDINT;
bSet: activation of the function block with a rising edge
sNetId: this parameter can be used to specify the AmsNetID of the TwinCAT computer, whose local NT system time is to be set. If applicable, an empty string sNetId := ''; can be specified for the local computer.
stS ysTi structure with the new local NT system time. If the time is not available as structure, it is advisable to use the function block FB_BA_CnvtTiSt, which brings the subvariables of date and time in a structure together.
udiTiOut: indicates the timeout time [s], which must not be exceeded during execution.
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
udiErrorId : UDINT;
bInvalidParameter : BOOL;
bBusy: If the function block is activated via a rising edge at bSetLocalTime, this output is set and remains set until feedback occurs.
bError: This output is set if an error occurs during the transfer of the NT system time. bError is reset when the function block is activated via the input variable bSetLocalTime.
bErr: This output is set to TRUE, if either the system time to be transferred is faulty (see below) or an ADS error occurs during the transfer. Both error types are reflected in a clear description of the output variables udiErrId / udiErrArg.
udiErrId / udiErrArg: Contains the error number and the error argument. See Error codes.
Time specification limits
The created time structure stSysTi is checked for limits within the function block:
Year: 1970..2106 - this range refers to the maximum time domain (years) that can be displayed in the TwinCAT system
Month: 1..12
Day of the month: 1..28/29/30/31, depending on month and leap year - both are determined and considered
Hour: 0..23
Minute: 0..59
Second: 0..59
Millisecond: 0..999
Requirements
Development environment | Target system | required library | required supplement |
---|---|---|---|
TwinCAT 2.11 R3/x64 | PC/CX | TcBA library from V1.0.0 | TS8040 | TwinCAT Building Automation from V1.0.0 |