PLC library: TcBACnet.Lib
The functionality of the PLC library "TcBACnet.lib" is described below. The library offers convenient access to objects of a BACnet configuration from a PLC program.
The application of the library is not compulsory.
The data (properties) of the BACnet objects can be accessed in two ways:
- The function blocks or self-declared variables are linked with the aid of "synchronous" process data mapping (linking of the PLC with the hardware configuration in the System Manager). For this purpose the function blocks of the PLC include the allocation as input or output data ("bValue AT%I* : BOOL" or "bValue AT%Q* : BOOL"). The advantage is that the data are updated cyclically. All values are written or read synchronous with the PLC cycle.
- Object data are read or written asynchronously with the aid of ADS. Data to be written/read are sent to the corresponding address with the aid of ADS blocks (NetID, port, index group and offset --> object type, instances and property ID) (FB_BACnet_WriteProp) or read by it (FB_BACnet_ReadProp). This method has the advantage that it is possible to write data only if an actual change has occurred. However, in cases with frequent changes unforeseeable delays may occur. The maximum delay is 5 seconds ("tBACnet_ADSTimeOut : TIME :=t#5s"). After this time the block returns an error code.
. The library (tcbacnet_1.2.4.zip) can be downloaded from here.
Installation: The contents of the ZIP archive must be copied into the TwinCAT folder (default: "C:\TwinCAT") under "\PLC\Lib".
Overview
The PLC library TcBACnet-Lib is a collection of function blocks for programming a BACnet controller. For each BACnet object function blocks are available that are read and written via the selected properties. In general, a distinction is made between function blocks for server and client objects. Function blocks for client objects have the prefix "Remote“ since they enable access to remote BACnet objects on other devices. The BACnet object function blocks ascertain whether process data are valid and the BACnet controller is ready for operation (bReady).
The function block FB_BACnet_Adapter represents a BACnet device and therefore the access point to the BACnet network via a network card. This block enables the existence of a link to be verified, for example. To make the PLC program more transparent, the BACnet adapter is created as a global variable within the TcBACnet-Lib, since in the majority of the projects a single BACnet adapter is used.
Depending on the client and server functionality, the function blocks FB_BACnet_Device or FB_BACnet_RemoteDevice can be used to link state and control information for the BACnet client and server. The operational readiness of the BACnet objects is determined via the client and server status and the property System_Status for the respective device or remote device object. Each BACnet object function block must therefore transfer a reference to the instance of the corresponding FB_BACnet_Device or FB_BACnet-RemoteDevice, in order to enable the status evaluation (bReady).
The following figure shows an overview of the function blocks of TcBACnet-Lib and the corresponding links with the BACnet modules. The linking between a PLC program based on TcBACnet-Lib and the BACnet modules of a configuration can be automated via the function "PLC automapping".
Block names The block names refer to the block versions with maximum process data (extension "_EX"). The standard blocks contain a minimum set of process data, to avoid performance impairment in large configurations. In addition there are function blocks for objects with commandable properties Present_Value which realise write access via ADS (extension "_ADS"). This has the advantage that the process data are not copied cyclically but are only written to the object in the event of changes. This also enables repeated write access to local objects (writing with identical priority). Function block variants with extension "_RAW" provide access to the raw value of the corresponding object. Using this module variant, the property Present_Value is not mapped to the terminal hardware but in the PLC program. This allows for example to connect BACnet values with values of sub bus systems. An example is shown in the block description. |