FB_BACnet_RemoteDevice

FB_BACnet_RemoteDevice 1:

Application

Function block for interfacing of the PLC program with a remote object BACnet device object (client). The function block is linked with the aid of process data and ADS (evaluate AMS port, read object list and determine the stack revision).

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 TwinCAT System Manager via PLC automapping.

FB_BACnet_RemoteDevice 2:

As a rule, the function block is backward compatible (revision 6). If Revision 6 is used, some ADS services of the BACnet stack are limited; e.g. the AMS port of the BACnet device (server and client) can only be determined automatically from Revision 12. If revision 6 is used, the AMS port (Ads port) shown in the TwinCAT System Manager must therefore be transferred at input nAmsPort (see Figure 1)!

FB_BACnet_RemoteDevice 3:
Fig. 1: AMS port of the BACnet Client in the TwinCAT System Manager

VAR_INPUT

FB_BACnet_RemoteDevice 4:

Variables are optional and do not have to be assigned if revision 12 or higher is used.

bReset            : BOOL;
bAutoReset        : BOOL;
bDisableWOC       : BOOL;
bReSubscribeCOV   : BOOL;
bAutoReSubscribe  : BOOL;
bTriggerWOC       : BOOL;
bReload           : BOOL;
nAmsPort          : UINT:=0;  (*siehe Info*)

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

bAutoReset: if the input is set to TRUE, errors with ID 22 and 23 are acknowledged automatically. Linked remote function blocks are not blocked (bReady at the object FBs remains TRUE). Instead of the error 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 --> 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: setting the input to TRUE triggers the automatic resubscription of all properties configured for COV on demand. 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.

bTriggerWOC: from revision 12: change from FALSETRUE writes all process data again.

bReload: the ADS connection is renewed. Subsequent function blocks, which use the ADS connection, are also triggered.

FB_BACnet_RemoteDevice 5:

nAmsPort: only if revision 6 is used, otherwise do not use: AMS port of the local BACnet client. In the standard case, this is not defined and must be read in the TwinCAT System Manager (see Figure 1).

VAR_OUPUT

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

eSystemStatus: Status of the remote BACnet server object (see BACnet specification DIN EN ISO 16484-5 for BACnet device object and property System_Status).

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 (timeout error). 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: see global constants BACnet_Globals.

bClientTimeout: A timeout error has occurred if the output is set. The output is only reset once no more timeout errors have occurred for 10 seconds.

bServiceFailed: A service error has occurred if the output is set. The output is only reset once no more errors have occurred for 10 seconds.

nTimeoutCnt: Number of timeout errors that have occurred. The positive edge of the corresponding status flag of the client is counted.

nServiceFailCnt: Number of service errors that have occurred. The positive edge of the corresponding status flag of the client is counted.