FB_BACnet_Adapter

The following function block is used for linking the PLC program with a local BACnet adapter (network card). 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.

FB_BACnet_Adapter 1:
Fig. 1: Process data of the BACnet adapter in the System Manager.
FB_BACnet_Adapter 2:
Fig. 2: Function block of the BACnet adapter in the PLC program.

Use

The function block FB_BACnet_Adapter is used to read the state of the local BACnet adapter (process data "Device Status") and output it in the PLC program. In addition, the process data "AmsNetID" is used to read the AMS NetID of the BACnet adapter (ARRAY OF BYTE --> string) and to output it as a string.

An instance of the function block FB_BACnet_Adapter is provided through the PLC library as a global instance and does therefore not have to be created explicitly. The global instance is detected during PLC automapping and automatically linked with the BACnet adapter in the System Manager. The function block instance is required by the function blocks FB_BACnet_Device and FB_BACnet_RemoteDevice. The hierarchy between FB_BACnet_Adapter, FB_BACnet_Device and FB_BACnet_RemoteDevice and an object of type AnalogValue is shown below:

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

For information on the use of the function blocks FB_BACnet_Device and _RemoteDevice, see FB_BACnet_Device or FB_BACnet_RemoteDevice. Calling of the instance of the function block FB_BACnet_Adapter is not compulsory. If required, the adapter function block is called automatically by the instances of the function blocks FB_BACnet_Device or FB_BACnet_RemoteDevice.

VAR_OUTPUT

eAdapterStatus   : E_BACnetAdapterStatus;
bEthLinkOk       : BOOL;
bGatewayOk       : BOOL;
sAmsNetId        : T_AmsNetId;
bFirstCycle      : BOOL;
bError           : BOOL;
nErrorId         : UINT;

eAdapterStatus: Status of the BACnet adapter. The following values are possible:
0: BACnetAdapterStatus_Init (initialisation has commenced)
1: BACnetAdapterStatus_CheckIpAddr (checking the IP address)
2: BACnetAdapterStatus_CheckParam (checking the parameter)
3: BACnetAdapterStatus_GetGatewayMAC (determining the MAC of the gateway)
4: BACnetAdapterStatus_WaitGatewayMAC (waiting for MAC address of the gateway)
5: BACnetAdapterStatus_Complete (initialised and ready)

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).

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 = no valid AMS NetID). The error numbers can be queried as block constants via the FB instance (FB_BACnet_Adapter.nERR_xxx).

FB_BACnet_Adapter 4:

If there is no network connection (bEthLinkOk = FALSE) or the gateway cannot be reached (bGatewayOk = FALSE), all connected remote objects (clients) are blocked. Local objects are not affected.