FB_BACnet_RemoteDevice

The following function block is used for linking the PLC program to a remote BACnet device object (local client). The linking of the function block takes place with the aid of process data.

The process data can be linked manually or automatically via PLC automapping. The comments required for PLC automapping ( (* ~ (BACnet... | ??? | ??? ) *) ) are already included in the declaration of the function block. The process data for the BACnet device object also include the required process data for linking the BACnet client.

FB_BACnet_RemoteDevice 1:
Fig. 1: Process data of the remote BACnet device object and client in the System Manager.
FB_BACnet_RemoteDevice 2:
Fig. 2: Function block of the remote BACnet device object and client in the PLC program.

Use

The function block FB_BACnet_RemoteDevice is used to read the status of the remote BACnet device object (System_Status) and output it in the PLC program. The process data "Client Control" and "Client Status" are also used to control the local BACnet client (disable/enable WriteOnChange, resubscription to properties, automatic subscription of properties after connection faults and error acknowledgement).

The function block FB_BACnet_RemoteDevice also requires a global instance of the function block FB_BACnet_Adapter for each PLC project. The function block FB_BACnet_Adapter establishes the connection between PLC and BACnet adapter in the System Manager. This global instance is already provided by the PLC library. The hierarchy between FB_BACnet_Adapter, FB_BACnet_Device and FB_BACnet_RemoteDevice and an object of type AnalogValue is shown below:

FB_BACnet_RemoteDevice 3:
Figure 3: Example for linking the FB instances in the PLC.

Information for use: see also function blocks FB_BACnet_Adapter or FB_BACnet_Device.

VAR_INPUT

bReset           : BOOL;
bAutoReset       : BOOL;
bDisableWOC      : BOOL;
bReSubscribeCOV  : BOOL;
bAutoReSubscribe : BOOL;

bReset: Resets the error state in the event of a signal change FALSE --> TRUE.

bAutoReset: When input is TRUE, errors with ID 20 and 21 are automatically acknowledged. Related remote FBs will not be blocked (bReady of the FB remains TRUE). Instead of the error ID, an error counter is incremented (see nTimeoutCnt and nServiceFailCnt).

bDisableWOC: If the input is set to TRUE, WriteOnChange (WOC) is suppressed for all objects of this client. This means that changes in the process data do not automatically trigger writing of the properties to the remote objects (only applies to properties that are configured for WriteOnChange under the client).

bReSubscribeCOV: A signal change at the input from FALSE to TRUE triggers resubscription of all properties that are configured for COV. This function may affect many objects and should therefore only be executed when necessary. Normally all subscribed properties are automatically re-subscribed once a timeout time has elapsed (resubscription interval).

bAutoReSubscribe: If the input is set to TRUE, automatic resubscription of all properties that are configured for COV is triggered as required. Not to be confused with the resubscription interval! Automatic resubscription is triggered if a remote server was no longer accessible and the connection has been restored, for example. If the input is set to FALSE, resubscription is only triggered once the resubscription interval has elapsed.

VAR_OUTPUT

eSystemStatus    : E_BACnetDeviceStatus;
bEthLinkOk       : BOOL;
bGatewayOk       : BOOL;
sAmsNetId        : T_AmsNetId;
bEnabledWOC      : BOOL;
bOperational     : BOOL;
bConnecting      : BOOL;
bFirstCycle      : BOOL;
bError           : BOOL;
nErrorId         : UINT;
bClientTimeout   : BOOL;
bServiceFailed   : BOOL;
nTimeoutCnt      : UDINT;
nServiceFailCnt  : UDINT;

eSystemStatus: Current status of the remote BACnet server object (see BACnet specification DIN EN ISO 16484-5 for BACnet device object and property System_Status).
0: BACnetDeviceStatus_Operational
1: BACnetDeviceStatus_OperationalReadOnly (only read access to properties)
2: BACnetDeviceStatus_DownloadRequired (loading of the configuration required)
3: BACnetDeviceStatus_DownloadInProgress (configuration download in progress)
4: BACnetDeviceStatus_NonOperational
5: BACnetDeviceStatus_BackupInProgress

bEthLinkOk: The local Ethernet connection is active (cable connected, adapter linked) if the output is set to TRUE.

bGatewayOk: The configured gateway can be reached if the output is set to TRUE.

sAmsNetId: Output of the AMS NetID of the local BACnet adapter (can be used for asynchronous access to BACnet objects via ADS).

bEnabledWOC: WriteOnChange (WOC) is activated for properties that are configured for COV.

bOperational: BACnet device object of the remote server reports "operational" (System_Status = 0), the device adapter reports status bEthLinkOk, status bConnecting is FALSE and bit 0 of the process data "Client Status" is not set (nERR_CLIENT_TIMEOUT). If the output becomes FALSE, all linked objects are blocked (block instances).

bConnecting: The connection to the remote server is established (process data "Client Status" is less than 0x04xx).

bFirstCycle: Is set for one cycle when the block instance is first called after a PLC reset or restart.

bError: An error is pending.

nErrorId: Error number
0 = no error
1 = function block of the corresponding client (RemoteDevice) is not called or not called regularly enough from the PLC program.
1 = no valid AMS NetID
3 = no network connection (bEthLinkOk = FALSE)
4 = gateway cannot be reached (bGatewayOk = FALSE)
20 = timeout during communication with remote server
21 = error during execution of a service between the remote server (Subscribe-COV, Property-Write etc.)
The error numbers can be queried as block constants via the FB instance (FB_BACnet_RemoteDevice.nERR_xxx). All errors with error number equal or greater than 20 must be acknowledged with bReset.

bClientTimeout: When output is set to TRUE, a timeout error (ID 20) has occurred. The output would reset to FALSE if no error occurred for 10 seconds.

bServiceFailed: When output is set to TRUE, a service error (ID 21) has occurred. The output would reset to FALSE if no error occurred for 10 seconds.

nTimeoutCnt: Number of timeout errors that occurred (ID 20). The positive edge of the corresponding status flag of client will count.

nServiceFailCnt: Number of errors that occurred Service (ID 21). The positive edge of the corresponding status flag of client will count.

An instance of the function block "FB_BACnet_RemoteDevice" is required whenever objects of a remote BACnet server are to be accessed from the PLC with the aid of a local BACnet client. Several instances of the function block "FB_BACnet_RemoteDevice" can be created and linked with the corresponding clients in the System Manager via PLC automapping. All instances of the function block "FB_BACnet_RemoteDevice" use the same global instance of function block FB_BACnet_Adapter.

If several instances of the function block FB_BACnet_Adapter are to be used, the corresponding instance of the BACnet adapter function block must be called before the instance of the BACnet client function block is called. A CFC example is provided below (Please note the order in which the function blocks are called!):

FB_BACnet_RemoteDevice 4:
Figure 4: Example for using several adapter and client instances in a PLC project.
FB_BACnet_RemoteDevice 5:
Figure 5: Example for calling function blocks of type FB_BACnet_RemoteAnalogValue with different remote BACnet servers in a PLC project.

The use of several BACnet adapters in a PLC project is a special case and is not recommended. It could make sense (e.g. in cases where several network cards and therefore separate BACnet networks are used) to use several PLC projects and therefore several PLC runtimes. Data exchange between the individual runtimes can be realized via process data mapping or ADS communication. In this case PLC automapping could be used for BACnet objects.