FB_BA_SetTime
The function block FB_BA_SetTime can be used to set the local NT system time and the date for a TwinCAT system (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. For further information please refer to the Beckhoff Information System under: Beckhoff Information System > Embedded-PC > Operating systems > CE > SNTP: Simple Network Time Protocol |
VAR_INPUT
bSet : BOOL;
sNetId : T_AmsNetId;
stSysTi : TIMESTRUCT;
udiTiOut_sec : 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. An empty string sNetId := ''; can also be specified for the local computer (see T_AmsNetId).
stSysTi: Structure with the new local NT system time (see TIMESTRUCT). 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_sec: Indicates the timeout time [s], which must not be exceeded during execution.
VAR_OUTPUT
bBusy : BOOL;
bError : BOOL;
sErrorDescr : T_MAXSTRING;
bBusy: If the function block is activated via a rising edge at bSet, this output is set and remains set until feedback occurs.
bErr: This output is set to TRUE, if either the system time to be transferred is incorrect or an ADS error occurs during the transfer.
sErrDescr: Contains the error description.
Error description |
---|
01: Error: Error: range exceeded year |
02: Error: Error: range exceeded month |
03: Error: Error: range exceeded day of the month |
04: Error: Error: range exceeded hour |
05: Error: Error: range exceeded minute |
06: Error: Error: range exceeded second |
07: Error: Error: range exceeded millisecond |
08: Warning: An ADS error occurred while setting the time (FB NT_SetLocalTime). The ADS error number is stated. |
Time specification limits
The time structure stUtcTi that was created is internally checked for limits (see TIMESTRUCT)
Requirements
Development environment | Required PLC library |
---|---|
TwinCAT from v3.1.4024.7 | Tc3_BA from v1.1.6.0 |