FB_BA_SetTime

FB_BA_SetTime 1:

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

FB_BA_SetTime 2: 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 3: 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: range exceeded year

02: Error: range exceeded month

03: Error: range exceeded day of the month

04: Error: range exceeded hour

05: Error: range exceeded minute

06: Error: range exceeded second

07: 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 created time structure stSysTi 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