FB_BACnet_WriteProp

Function block for access to BACnet properties via ADS. All BACnet properties of server and client objects can be read or written via ADS. If a client is accessed via ADS, the ADS accesses are converted to "Write_Property" BACnet requests and sent to the remote server.

FB_BACnet_WriteProp 1:

Use

The function block instance is created by the PLC program and called cyclically. The input BACnetDevicePort is assigned with the ADS port from the System Manager configuration (see Figure 1). Ports for servers and clients may vary, depending on the configuration.

By using the WriteProp function block for accessing the Present_Value, for example, WOC (Write On Change) to local BACnet server objects can be realized. In contrast to process data mapping the priority of the write access can be adjusted online. In addition, process data mapping to local server objects results in cyclic writing of the data, so that remote clients do not have access with the same priority as the local PLC.

FB_BACnet_WriteProp 2:
Figure 1: ADS port in the System Manager

The NetId (AMS NetId) of the BACnet device can also be read in the System Manager (see Figure 2).

FB_BACnet_WriteProp 3:

The NetID does not match the local NetID and always has to be specified - empty strings cannot be used!). Another possibility is to query the NetID from the device function block or adapter function block in the PLC (see Figure 3).

FB_BACnet_WriteProp 4:
Figure 2: AMS NetID of the BACnet device

For information on the operating principle of the adapter function block see FB_BACnet_Adapter.

FB_BACnet_WriteProp 5:
Figure 3: AMS NetID of the BACnet device

VAR_INPUT

BACnetDevicePort : UINT := 16#FFFF;
bExecute         : BOOL;
sNetId           : T_AmsNetId;
ObjectType       : E_BACnetObjectType;
PropertyID       : E_BACnetPropertyIdentifier;
Priority         : E_BACnetPriority;
DataType         : E_BACnetDataTypes;
ObjectInstance   : UDINT;
ptrValue         : POINTER TO BYTE;
nLenValue        : UDINT; (* byte size of value (SIZEOF) *)

BACnetDevicePort: ADS port under which the required object was created (see also under use).

bExecute: Rising edge at the input starts the read process. Falling edge deletes the output bDone.

sNetId: AMS NetID of the BACnet device (adapter) under which the server or client was configured.

ObjectType: Enumeration of the object type (AnalogValue, BinaryInput...).

PropertyID: Enumeration of the property ID (Present_Value, Status_Flags...).

Priority: Enumeration of the write access priority. The priority is required for write accesses to prioritisable properties (e.g. Present_Value). Access with priority x then generates an entry at location x in the corresponding Priority_Array.

ObjectInstance: Object number of the BACnet object (the lower 22 bits of the Object_Identifier).

ptrValue: Pointer to the variable from which the data to be written are taken (can be determined with ADR()).

nLenValue: Byte length of the variable from which the data to be written are taken (can be determined with SIZEOF()).

VAR_OUTPUT

bDone        : BOOL;
bBusy        : BOOL;
bError       : BOOL;
nErrID       : UDINT;

bDone: Writing of the data completed successfully. bDone remains set until bExecute is reset. If bExecute is reset before bDone is active, bDone is set for one cycle.

bBusy: The block is busy.

bError: Error during processing.

nErrID: ADS error code.

Example

FB_BACnet_WriteProp 6:
Fig. 4: Application example
FB_BACnet_WriteProp 7:
Fig. 5: Example for Write on Change (WOC)