BACnet is a data communication protocol for Building Automation and Control Networks. Developed by the American Society of Heating, Refrigerating and Air-Conditioning Engineers (ASHRAE), BACnet is a national standard in more than 30 countries around the world, and an ISO global standard. It was created to have a unified communication system for different devices across different manufacturers.
The information in this page is targeted at the TS-7680. The TS-7680 was designed from the ground up to support many features common to BACnet networks, including RS-485, two 10/100 ethernet interfaces, and the ability to operate at 24 VAC or VDC input.
All of the material and information below should work without issue on every other Technologic System's product, as all of the tools are userspace applications that rely on the kernel only for ethernet or RS-485 data transport. However, be advised that there may be some hurdles along the way.
The BACnet protocol defines a number of different data link (physical) layers, with the two most common being BACnet/IP and BACnetMS/TP. BACnet/IP uses a IPv4 network as its backbone, while BACnetMS/TP uses RS-485 (half-duplex) to create a network of devices.
BACnet devices each have various Objects; many of which are pre-defined by the standard but vendors can also define proprietary Objects for use. Some standard Objects are Analog Input, Analog Output, Binary Input, Binary Output, Command, Device, Group, and Schedule.
Each Object has various sets of Properties; like Objects, there are defined standards, but vendors may implement proprietary Properties as well. Standard Properties contain information like name, identifier, type, description, units, and value. The device Object itself has Properties that describe the whole device, while other Objects contained in the device have Properties that describe I/O or other status information.
Additionally, BACnet describes Services which are used for device to device communication. These allow for things such as alarm and event notification, file access, direct Object access, remote management, and even virtual terminal access.
2 The Devices
This demo uses two different BACnet devices, the iSMA-B-4I4O-H-IP for BACnet/IP, and the RIBTW2401B-BC for BACnetMS/TP.
The iSMA-B-4I4O-H-IP is a DIN rail mountable device, with 4 dry contact inputs and 4 output relays. It is powered from 24 V AC/DC, and includes 4 switches that can be used to manually override the output relays. The device supports MODBUS RTU, MODBUS ASCII, and of course BACnet/IP. While there is an RS-485 port, the -IP variant of the device is only set up to allow BACnet/IP or MODBUS TCP/IP; the RS-485 port is only set up to act as a MODBUS TCP/IP -> RS-485 gateway. Under the main cover is a set of DIP switches to select mode, baud, and set a factory reset.
In this demo, each relay output is used to close its respective dry contact input. Specifically, C1 (common for relay 1 and 2) is connected to G0 (common ground for inputs), with O1 (relay NO output 1) and I1 (dry contact input 1) tied together, and O2 and I2 connected. The same is repeated for C2/G0, O3/I3, O4/I4. Enabling Binary Output 0, will cause Binary Input 0 to activate, same for 1, 2, and 3.
The RIBTW2401B-BC is a much more simple device contained in a flat square enclosure. It has a single dry contact input, and a single output relay. It can be powered from 24 V AC/DC or 120 V AC. The output relay does have an override, however it is located on the internal DIP switch header and is not necessarily practical for ready use. The device support BACnetMS/TP vis RS-485. Inside of the unit is a set of DIP switches to set the baud rate, network address, and override current relay position.
This demo uses BACnet Stack 0.8.3, a userspace API for BACnet in linux.
Starting from our stock image, set up the software on the SBC to compile the API on the device itself:
apt-get update && apt-get install -y unzip build-essential
Download the bacnet-stack source zipfile, and unpack it with 'unzip'. Enter the newly unpacked directory and build as per instructions for IP or MS/TP below.
The devices themselves need to have their BACnet ID set up; refer to the specific device manual for information on doing this. Additionally, some BACnet/IP devices need to have an IP address manually set and will not use DHCP. BACnetMS/TP modules also need to have a known baud rate, they can either be set or the host interface set up to adjust to the specific baud rate. Ensure these parameters are all set to be valid for your specific TCP/IP network, or RS-485 settings.
In the demos below, our BACnet/IP ID is 31337, the BACnetMS/TP address is set to FINISH ME!, and the baud rate is set to 115200.
BACnet/IP is the default build for this tool. Ensure that the BACnet/IP device is set up correctly on the same TCP/IP network as the host. The ID can be discovered with the tools (shown further down), but in most situations would already be known.
make clean all
Once this is compiled, a set of libraries as well as some demo applications will be built. Functionality will first be checked with some of these demo tools. Note that all of the demo tools when called without arguments show a brief about their use, however if the only argument is "--help" then a much more in-depth output and description is given for all of the arguments.
First, lets scan the network for any devices, this is using the "Who-Is" Service.
root@imx28:~/bacnet-stack-0.8.3# ./demo/whois/bacwi Received I-Am Request from 31337, MAC = 10.10.10.231.186.192 ;Device MAC (hex) SNET SADR (hex) APDU ;-------- -------------------- ----- -------------------- ---- 31337 0A:0A:0A:E7:BA:C0 0 00 480 ; ; Total Devices: 1
Our device is detected, and is reporting itself on the network.
Next, the demo tools can be used to do some basic inquiry of the device. The BACnet Stack tools require the use of "magic numbers" to represent various objects and properties, see Appendix A for a table of these.
# Get the the device name root@imx28:~/bacnet-stack-0.8.3# ./demo/readprop/bacrp 31337 8 31337 77 "iSMA-B-4I4O-H-IP" # Get the state of the first input root@imx28:~/bacnet-stack-0.8.3# ./demo/readprop/bacrp 31337 3 0 85 inactive # Get the state of the first relay root@imx28:~/bacnet-stack-0.8.3# ./demo/readprop/bacrp 31337 4 0 85 inactive
With each output wired to close each input, setting the relay will also change the respective input:
# Check the first input root@imx28:~/bacnet-stack-0.8.3# ./demo/readprop/bacrp 31337 3 0 85 inactive # Set the first relay output root@imx28:~/bacnet-stack-0.8.3# ./demo/writeprop/bacwp 31337 4 0 85 0 -1 9 1 WriteProperty Acknowledged! # Check the first input again root@imx28:~/bacnet-stack-0.8.3# ./demo/readprop/bacrp 31337 3 0 85 active
Below, a simple demo application to check each input and output loopback in order. This will check the network with Who-Is and interact with the first device that reports back, additionally it will then use the Who-Has Service to determine the amount of inputs and outputs the device has, and dynamically walk through all of them to verify the loopback setup.
4 Appendix A, BACnet Stack "magic numbers"
Below are some of the "magic numbers" that BACnet Stack uses for various Objects or Properties. These are needed when specifying commands on the command line for the demo tools. Note that not every Object or Property is listed, only the common ones used in the examples above, or that may be useful to those using the demonstration.
|Data Type ||Num.|
- BACnet Stack also refers to this as "Tag"
- This is one of the more commonly used datatypes