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
CmpBACnet
component 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 BACnet Server. To use BACnet2, add a BACnet2 server.
to insert aSelect the server object and click BACnet_Analog_Value object and a BACnet_Notification_Class object below it.
to insert aThe 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 Value
object.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 Value
and aBACnet Notification Class
. Now the configuration is set so that theBACnet Analog Value
will generate alarms as soon as itsPresent_Value
property reaches a value outside of [0; 10].In the
PLC_PRG
program of your application, define a variablelrVal
of typeLREAL
and 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_Value
of theBACnet Analog Value
object 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_Value
and variablelrVal
in the BACnet network.You can see how the BACnet property
Present_Value
is incremented and as a consequence the value of the variablelrVal
increases. As soon asPresent_Value
exceeds the value of 10, an alarm of the typeBACnet-NotificationClass
inserted 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