FB_BA_ExternalSysTime

FB_BA_ExternalSysTime 1:

The template reads the NT system time of an external TwinCAT system at regular intervals.

If the readout was successful, then the external system time is written to the local NT system time of the TwinCAT system and the local BACnet system time of the TwinCAT system.

The two local system times are read out at regular intervals and mapped to local and global variables in the PLC.

Block diagram

FB_BA_ExternalSysTime 2:

Syntax

FUNCTION_BLOCK FB_BA_ExternalSysTime
VAR_INPUT CONSTANT
  sExternalAmsNetId                      : T_AmsNetId := '';
  {attribute 'parameterUnit':= 's'}
  GetExtSysTime_nTiAuto                  : UDINT := 600;
  {attribute 'parameterUnit':= 's'}
  GetLocalSysTime_nTiAuto                : UDINT := 60;
END_VAR
VAR_INPUT CONSTANT
  GetExtSysTime                          : FB_BA_GetTime;

  SetSysTimeLocal                        : FB_BA_SetTime;
  SetBACnetAdapterTime                   : FB_BA_SetBACnetAdapterTime;

  GetLocalSysTime                        : FB_BA_GetTime;
  GetBACnetAdapterTime                   : FB_BA_GetBACnetAdapterTime;
END_VAR
VAR
  GetExtSysTime_bSync                    : BOOL;
  GetExtSysTime_rtrigSync                : R_TRIG;

  GetBACnetAdapterTime_wYear             : WORD;
  GetBACnetAdapterTime_wMonth            : WORD;
  GetBACnetAdapterTime_wDayOfWeek        : WORD;
  GetBACnetAdapterTime_wDay              : WORD;
  GetBACnetAdapterTime_wHour             : WORD;
  GetBACnetAdapterTime_wMinute           : WORD;
  GetBACnetAdapterTime_wSecond           : WORD;
  GetBACnetAdapterTime_wMilliseconds     : WORD;
END_VAR

FB_BA_ExternalSysTime 3: Inputs CONSTANT

Name

Type

Description

sExternalAmsNetId

T_AmsNetId

The AmsNetId of the TwinCAT computer whose NT system time is to be read is specified here.

GetBACnetAdapterTime_nTiAuto

UDINT

Based on this time information, the local BACnet system time of a TwinCAT system is regularly determined automatically.

GetLocalSysTime_nTiAuto

UDINT

Based on this time information, the local NT system time of a TwinCAT system is regularly determined.

GetExtSysTime

FB_BA_GetTime

The function block GetExtSysTime determines the external NT system time of a TwinCAT system.

SetSysTimeLocal

FB_BA_SetTime

The locally determined BACnet system time (GetBACnetAdapterTime) is written to the local NT system time of the TwinCAT system using the function block SetSysTimeLocal.

SetBACnetAdapterTime

FB_BA_SetBACnetAdapterTime

The function block "SetBACnetAdapterTime" sets the local BACnet system time of the TwinCAT system.

GetLocalSysTime

FB_BA_GetTime

The function block GetLocalSysTime determines the local NT system time of the TwinCAT system. The determined time is transferred to the global variable lists SysTime.

GetBACnetAdapterTime

FB_BA_GetBACnetAdapterTime

The function block "GetBACnetAdapterTime" determines the local BACnet system time.

VAR

Name

Type

Description

GetExtSysTime_bSync

BOOL

The variable triggers the writing of the external system time to the local NT system time of the TwinCAT system and the local BACnet system time of the TwinCAT system.

GetExtSysTime_rtrigSync

R_TRIG

The function block generates a rising edge after successfully reading the external system time GetExtSysTime and passes this on to GetExtSysTime_bSync.

GetBACnetAdapterTime_wYear

WORD

Year specification of the BACnet system time.

GetBACnetAdapterTime_wMonth

WORD

Month specification of the BACnet system time.

GetBACnetAdapterTime_wDayOfWeek

WORD

Indication of the day of the week of the BACnet system time.

GetBACnetAdapterTime_wDay

WORD

Indication of the day in the month of the BACnet system time.

GetBACnetAdapterTime_wHour

WORD

Hour specification of the BACnet system time.

GetBACnetAdapterTime_wMinute

WORD

Minute specification of the BACnet system time.

GetBACnetAdapterTime_wSecond

WORD

Seconds specification of the BACnet system time.

GetBACnetAdapterTime_wMilliseconds

WORD

Milliseconds specification of the BACnet system time.

Requirements

Development environment

Necessary function

TwinCAT from v3.1.4024.35

TF8040 | TwinCAT Building Automation from V5.0.0.0