FB_BA_SetTime

FB_BA_SetTime 1:

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 tSysTi.
Internally, an instance of the function block NT_SetLocalTime from the TcUtilities library is called in the function block.

FB_BA_SetTime 2:

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

FB_BA_SetTime 3:

FB_BA_SetTime 4: Inputs

VAR_INPUT
  bSet         : BOOL;
  tNetId       : T_AmsNetId;
  tSysTi       : TIMESTRUCT;
  nTiOut       : UDINT;
END_VAR

Name

Type

Description

bSet

BOOL

Activation of the function block with a rising edge.

tNetId

T_AmsNetId

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.

tSysTi

TIMESTRUCT

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.

nTiOut

UDINT

Indicates the timeout time [s], which must not be exceeded during execution.

FB_BA_SetTime 5: Outputs

VAR_OUTPUT
  bBusy           : BOOL;
  bErr            : BOOL;
  sErrDescr       : T_MAXSTRING;
END_VAR

Name

Type

Description

bBusy

BOOL

If the function block is activated via a rising edge at bSet, this output is set and remains set until feedback occurs.

bErr

BOOL

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

T_MAXSTRING

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 (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.22

Tc3_BA2 from v5.2.5.0