Skip to main content

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.

. Requirements:
  • 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.

  1. In CODESYS, create a standard project with a PLC device which supports BACnet.

  2. Select the PLC object in the device tree and click Insert Device to insert a BACnet Server. To use BACnet2, add a BACnet2 server.

  3. Select the server object and click Insert Device 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.

    _bacnet_img_device_tree.png
  4. 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.

  5. Modify the object properties in the Value column as follows:

    • AckedTransitions: '111 '

    • NotificationClass: 1

    • HighLimit: 10

    • LimitEnable: '11'

    • LowLimit: 0

    Now your application provides a BACnet Analog Value and a BACnet Notification Class. Now the configuration is set so that the BACnet Analog Value will generate alarms as soon as its Present_Value property reaches a value outside of [0; 10].

  6. In the PLC_PRG program of your application, define a variable lrVal of type LREAL 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;
  7. Generate the code (F11), download the error-free application to the controller, and start the application.

    The BACnet property Present_Value of the BACnet Analog Value object is incremented.

  8. 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 variable lrVal in the BACnet network.

    You can see how the BACnet property Present_Value is incremented and as a consequence the value of the variable lrVal increases. As soon as Present_Value exceeds the value of 10, an alarm of the type BACnet-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