This article will not only introduce you to setting up a BACnet/Ip Server using a Beckhoff TF8040 and accessing it from Node-Red, but will also explain and expand your knowledge of BACnet a little.
Let’s get started!
BACnet?
BACnet is one of the many protocols now used in Building Automation worldwide and stands for Building Automation and Control Networks BACnet is a standardized communication protocol developed specifically for building automation and control systems (BACS) such as heating, ventilation and air conditioning (HVAC) systems, lighting, access control and other building management systems, It is a standardized communication protocol developed specifically for building automation and control systems (BACS) such as heating, ventilation and air conditioning (HVAC) systems, lighting, access control and other building management systems.
BACnet offers multiple parts or profiles to meet various networking needs. For example,
- BACnet/IP (using Internet Protocol for communication)
- BACnet MS/TP (for master-slave/token passing over twisted pair networks)
These features, through standardization, will make BACnet a widely adopted protocol in the building automation and control industry, resulting in more efficient and interoperable smart buildings.
Main Components
BACnet (Building Automation and Control Networks) is a complex protocol used in building automation systems, and this article introduces the Main component in it.
Objects
Objects refer to the various elements and components within a building automation system. These objects represent real-world entities and functions such as sensors, actuators, controllers, and data points.
Let’s take this air conditioner as an example. The air conditioner has a temperature sensor and the set point can be changed locally or remotely. Yet, it is a simple device that can switch between local and remote and reports whether there is an internal fault by reporting the status as normal/abnormal.
There is a Binary Input that turns the air conditioner on and off and a Binary Value that shows the current status of the air conditioner and an Analog Value that shows the current room temperature. There is also a Binary Value that indicates the current status of the air conditioner, an Analog Value that indicates the current room temperature, and a Binary Output that is the output of the Buzzer. All of these are Objects.
And in BACnet, common objects include
- Analog Input
- Analog Output
- Binary Input
- Binary Output
- Binary Value
- Analog Value
Instance
Each Object has an Instance number to avoid duplication for other objects of the same type. This concept is a little like Ethernet/IP.
As shown in the figure below, each Object actually has its own unique Instance number.
properties and services
Each object type in BACnet has a specific set of Properties and Services associated with it. For example, a “Binary Input” object can have Properties such as Current Value, Status, and Alarm Limit, and still have Services such as Read Property and Write Property.
Thus, BACnet defines a standardized set of object types and their properties, which, when understood and interacted with, allow different devices and systems to communicate efficiently.
Services
BACnet Services are actions or operations that Devices can perform on Objects. These Services allow Devices to request or manipulate the data and control functions of other devices on the network. The figure below shows typical BACnet Services.
Read Property
The service will be used to retrieve the value of a specific property from the Object of the Remote Device.
Write Property
The service will be used to set or change the value of a specific property from an Object in the Remote Device.
Who-Is
The service will be used to search for devices on the network.
I-Am
This will be the service that the device uses to announce its presence on the network.
Subscribe-COV (Change of Value)
The service will be used to get notified when the value of a property is changed.
LAN (Local Area Network) And Inter-Networking
BACnet can be used in many different types of networks, and these networks are Local Area Networks (LANs) LANs (Local Area Networks). For example,
- Ethernet
- ZigBee
- RS485
- RS232
- LonTalk
BACnet LAN (Local Area Network)
Physical Layer
BACnet can operate over a variety of physical media, including Ethernet, RS-485, and ARCNET. Ethernet is one of the most common choices for BACnet LANs due to its speed and versatility.
BACnet/IP
BACnet/IP is a profile of BACnet that uses P as the transport. It can carry BACnet messages over standard IP networks, including Ethernet and Wi-Fi.
Subnetting
The BACnet network can be divided into subnetworks to manage and segment large installations. Each subnet has its own BACnet Broadcast Management Device (BBMD) that Supports routing of BACnet messages between subnets. The purpose of subnetting may be used when dealing with complex building systems that span multiple physical locations or large buildings.
BACnet Inter-Networking
BACnet Routers
A BACnet router is a device that connects different BACnet networks or subnets. Routers facilitate communication between BACnet devices on separate networks and ensure that data flows seamlessly between them. Routers ensure that messages originating on one network reach their intended destination on another network.
Foreign Device Registration
If a BACnet device on one network wants to interact with a device on another network, it must register as a “Foreign Device” in the target network’s BBMD. This registration process allows devices on different networks to exchange data and services.
BACnet Broadcast Management Device (BBMD)
BBMD is essential to the internetwork; it stores information about devices on different networks and manages the delivery of broadcast and unicast messages to their proper destinations. BBMD ensures that BACnet messages intended for devices on remote networks are routed correctly to those networks. BBMD ensures that BACnet messages intended for devices on remote networks are routed correctly to those networks.
Global Services
Inter-Networking also allows global services such as “Who-Is” and “I-Am” to operate across different networks. Am” service is used to allow devices to announce their presence across multiple networks.
Wide Area Networks (WAN)
BACnet can be used in larger installations across multiple geographic locations; BACnet/IP can be transmitted over the Internet or a private wide area network to connect building automation systems in different locations. BACnet/IP can be transmitted over the Internet or private wide area networks to connect building automation systems at different locations. This allows centralized monitoring and control of building systems over long distances.
Summary
BACnet uses a structured approach where Objects represent the elements of the Bulding Automation System, Services define the Actions that devices can perform on these objects, and LANs and InterNetworks support communication of BACnet The LAN and InterNetwork adopt a structured approach to support communication of BACnet messages within and between networks. This standardized framework allows a variety of BACnet-compliant devices and systems to work together to provide an efficient Bulding Automation System and control.
BACnet And Beckhoff?
Beckhoff’s newly developed TwinCAT library Tc3_BACnetRev14 implements an object-oriented engineering and configuration process and provides convenient functionality for the Beckhoff BACnet Controller.
No OOP skills are required to use the TwinCAT library Tc3_BACnetRev14, but if you can grasp it, the architecture is flexible and extensible.
And in TwinCAT, when using the older library Tc2_BACnetRev12, the connection between PLC variables and BACnet supplements is established using an auto-mapping process. This feature may not be supported in future TwinCAT versions and should not be used.
Furthermore, it is not possible to use both libraries Tc3_BACnetRev14 and Tc2_BACnetRev12 in a single project.
Libraries
This is the basic structure of Beckhoff’s BACnet library.
Tc3_BACnetRev14
This library provides Function Block, Function, Data Type, and Parameters necessary for engineering BACnet objects.The Tc3_BACnetRev14 library is included in TwinCAT 4024.11 and later as a pre-compiled library (without source code).If you need uncompiled source code, please contact your local Beckhoff Office. (Also, importing uncompiled source code into a TwinCAT project can take some time.)
Tc3_BA2_Common
This library contains all Function Block, Function, Data Type, and Parameters commonly used in BACnet and TwinCAT3 Building Automation.For example, engineering units and PID controllers are available in this library.To use these options, add this library in addition to Tc3_BACnet_Rev14.
System Requirment
Target System: TwinCAT XAR 4024.17 or higher
Engineering-PC: TwinCAT XAE 4024.17 or higher.
Implementation
We will now explain the actual Beckhoff TwinCAT side and Node-Red side step by step.
Beckhoff Side
Add BACnet Driver
To add a BACnet Drive, go to I/O>Devices>Add New Item.
Select BACnet>BACnet IP Device>Ok.
Configure the network interface to be used as BACnet.
Done!BACnet IPs have been added.
If you open the Adapter’s Tab, you can also change the Network Interface.
Add BACNet Server
Now to add a BACnet Server, Device1>Right click>Add New Item.
Select BACnet Modules>BACnet Server>Ok.
Done!BACnet Server has been added.
You can configure BACnet Server settings.
Add PLC
Next, to add a PLC, right click on the PLC > Add New Item.
Select Standard PLC Project > Add to add a PLC project.
Add Library
To add a BACnet-specific library, go to References>Add library.
Search for Rev14 and add Tc3_BACnetRev14.
Add Program
One FB_BACnet_AV is defined in the MAIN program.
This BACnet variable will define the Analog Value Object of the BACnet.
Then programmatically run BACnet as described earlier.
PROGRAM MAIN VAR BACnet:FB_BACnet_AV; END_VAR BACnet(); |
Build Solution
Compile the project under Build>Build Solution.
Active Configuration
Download the project using Activate Configuration.
If you do not have enough licenses, you will be notified to generate a Trial license from TwinCAT and proceed with Yes.
Enter the magic code and press Ok to proceed.
Restart TwinCAT in Run Mode.
Login
Download the User program with Login.
Proceed with Yes.
Run
Finally, the Run button launches Runtime.
But?
But if I look at the Error List carefully, I get an error message that “AMS net-ID” is not Linked.
To resolve this error, when I compiled the project just now, an Instance was created for the PLC project that actually corresponds to TwinCAT. In it, there is a BACnet_AmsNedId in Plc Task Inputs.
Right-click on that Process Input>Change Link.
Let’s linkt to the BACnet Object we defined earlier.
Test with System Manager
First, check the connectivity of the BACnet/IP Server from System Manager.
Click the Scan button at Dynamic Object Management.
Done!MAIN.BACnet (BACnet Analog Value Object) has been added to BACnet Server.
Click on this Object to see the Property value of the Object.
If you open the BACnet variable in the MAIN program, you will see that bReady=True, which means that this Object is normal.
To change the Present Value of Analog Value, set bEnPgm to True and use fValPgm to enter the starting value.
Present Value changed to 3.14 as well!
Node red Side
Install Node
Install BACnet’s Node with the following command.
npm install node-red-contrib-bacnet |
BACnet-related Nodes are displayed from the Node Red Editor.
Configure BACnet Read Node
Add BACnet- Read Node to the Flow Editor.
Double-click on “Properties” to configure connection information and other settings.
Name
This is the name of the Node.
Type
Next, set the Type. Click ICON in the red frame to set the object you want to access, such as Analog INPUT.
The Drop List is displayed, and access objects such as ANALOG_VALUE and BINARY_INPUT can be set.
Instance
The next step is to set up the Instance to access the object you have just set up.
Click on the pencil ICON to set the Instance.
The Instance Propertoes screen will appear.
Name may be empty and Instance should be set to 10000.
This 10000 should match the Instance number of the AnalogValue Object set earlier on the Beckhoff side.
Property Id
The next step is to set the Property ID.
The Drop List is displayed.
Select PRESENT_VALUE.
Done!Property Id automatically changed to 85.
The Property Id of the Node is now 85. The 85 matches the Present ID on the TwinCAT side.
Device
Device will be the BACnet/IP Server to which Node-Red will connect.
Set to the IP address of the BACnet/IP Server to be connected in the Address field.
The IP address should match the IP address of the Network Adapter set up as a BACnet/IP Server.
Client
The next step is to set the Client Field.
Interface should be set to the IP address of the PC on which Node-Red is installed.
Finally, press the Done button to save the settings.
Done!
Deploy
Click the Deploy button to download the Flow.
Result
After clicking the Timestamp button, the data came back from Beckhoff’s BACnet/IP Server.
Write Node
To change the Object Property ID85 of Beckhoff’s BACnet/IP Server, let’s add a BACnet Write Node.
Type
Set TYPE=2, i.e., ANALOG_VALUE.
Instance
Instance accesses the same Instance number as before, so select the previously added Instance from the Instance’s Drop-List.
App-Tag
Sets the data type of the value to be written to the corresponding Node. 4=Real.
Value
Value is the value of the write.
Property
The property to be written this time is Present Value (85).
Device
Since the Device accesses the same BACnet/IP Server as before, select the Instance added in the previous step from the Device’s Drop-List.
Client
This is the same Client (Node-Red), so select the Client you just added.
Deploy
Click the Deloy button to update the Flow.
Done!I was able to change the current value of the Object in Beckhoff’s BACnet/Ip from Node-Red.