Getting Started
The following instruction guide you to a simple application that uses two BACnet objects in order to 1) write an analog BACnet value at runtime and 2) sound an alarm according to a BACnet notification class when the current BACnet value is outside of a specific range.
The CODESYS BACnet2 SL package is installed.
The runtime supports BACnet. For this to work, the
CmpBACnetcomponent has to be entered and configured in the configuration file of the runtime.
In CODESYS, create a standard project with a PLC device which supports BACnet.
Select the PLC object in the device tree and click to insert a BACnet Server. To use BACnet2, add a BACnet2 server.
Select the server object and click to insert a BACnet_Analog_Value object and a BACnet_Notification_Class object below it.
The inserted BACnet objects are displayed in the Devices view.

Double-click the BACnet_Analog_Value object to open its configuration editor.
On the BACnet Parameter tab, you see the initial configuration of the
BACnet Analog Valueobject.Modify the object properties in the Value column as follows:
AckedTransitions: '111 'NotificationClass: 1HighLimit: 10LimitEnable: '11'LowLimit: 0
Now your application provides a
BACnet Analog Valueand aBACnet Notification Class. Now the configuration is set so that theBACnet Analog Valuewill generate alarms as soon as itsPresent_Valueproperty reaches a value outside of [0; 10].In the
PLC_PRGprogram of your application, define a variablelrValof typeLREALand insert the following code: Hint: You can also press the F2 key to get the function block instances of the BACnet objects from the Input assistant (Instance Calls category).BACnet_Analog_Value.PresentValue := BACnet_Analog_Value.PresentValue + 0.0001; lrVal := BACnet_Analog_Value.PresentValue;
Generate the code (F11), download the error-free application to the controller, and start the application.
The BACnet property
Present_Valueof theBACnet Analog Valueobject is incremented.Start an external BACnet client (for example, Innea BACnet Explorer Free) that runs at a different network address than the runtime (for example, using a virtual machine). Use it to monitor the values of BACnet property
Present_Valueand variablelrValin the BACnet network.You can see how the BACnet property
Present_Valueis incremented and as a consequence the value of the variablelrValincreases. As soon asPresent_Valueexceeds the value of 10, an alarm of the typeBACnet-NotificationClassinserted in the application is generated on the BACnet server device.
This is an example of how you can access the BACnet properties of a BACnet object at runtime. If no explicit property is provided by the BACnet object function block, then at least it provides auxiliary functions for accessing certain or all BACnet properties.
For more information, see: BACnet Configuration in the Runtime and BACnet Configuration in the CODESYS Project