Skip to main content

Managing Alarms in Libraries

As a library developer, you can define alarm conditions for a specific function block or structure type.

In concrete terms, this means that you create an alarm group template object for the variables of such POUs and configure alarm definitions in them. The alarm group template object for the POU object is then located in parallel in the POU tree or device tree. The alarm definitions from this are later instantiated in the application in the Alarm Configuration object in order to perform an alarm check at runtime.

As a user, you can use library POUs which include alarm definitions for the supported creation of an alarm configuration. By the way, you will also get support with the alarm configuration in your application during the entire development process. Below your application, add an alarm configuration. A special generation cycle then creates the alarms for the instances of function blocks with alarm definitions. To do this, execute the Create or update alarm instances command so that alarm instances are also created for all instances.

You can continue with the editing of the alarm configuration. For example, you can deselect individual alarm instances.

To keep the application code consistent with the alarm configuration, the completeness and correctness of the alarm instances is checked when the IEC code is compiled. The result is displayed in the message view so that you are always informed about the status of the alarm configuration. If you do not want this, then you can disable the Check alarm instances during compilation option in the alarm configuration.

You can use the alarm_creation_default attribute pragma to control how the default for this instance should be with regard to creation.

Figure 3. Alarm Configuration
Alarm Configuration


For more information, see: Alarm Group Template, Alarm Configuration, and alarm_creation_default

Defining alarm classes centrally in library

You can define alarm classes centrally in a separate library. The advantage of this is that you can centrally define, change, and manage the properties and behavior of the alarm classes. The alarm classes are then referenced in implementation libraries, which consist of function blocks with the respective alarm group templates.

Alarm classes from other libraries have to be listed with namespaces in order to avoid ambiguities with local alarm classes of the same name.

Because there is currently only one alarm memory, configuration in the alarm group is not necessary. The alarm class determines whether or not an alarm is saved.

_vis_img_library_alarmclass.png

The behavior of alarm classes can be centrally defined in libraries if library alarm classes are implemented, which can then be referenced in implementation libraries.

Note

The previously predefined Error, Info, and Warning alarm classes below the alarm configuration can be deleted if only alarm classes from libraries should be used.

Using function blocks with an alarm group template in a library

The alarm conditions for variables of the type can be defined in the alarm group templates.

  1. Select your application.

    Click Add Object → Alarm Group Template and specify a name in the Add Alarm Group Template dialog.

    The new alarm group template object AGT_FB_DoIT is created below your application.

    Hint: The object can also be stored under POUs.

  2. In Type for alarm definition, select the type (function block or structure) for which you want to define alarms.

    FB_DoIt

  3. Under Details, define an alarm for the type:

    • Under Details, program an alarm condition.

    • Under Class, specify an alarm class, ideally one from an alarm class library.

    _vis_img_alarm_group_template.png

Function block with inheritance

If you have a base function block which extends other function blocks, then you can also create an alarm group template for this base function block and define alarms there.

Alternatively, you could also create an alarm group template for a derived function block. It is also possible to access the variables of the base function block so that you can program alarm definitions for the inherited variables.

_vis_img_library_alarmgroup.png

Creating and renewing alarm instances

You can update the alarm configuration so that all declared instances across the application are listed there.

  1. In CODESYS, open the Alarm Configuration object below the application.

  2. Click the Create or update alarm instances button.

    All instances with alarm group templates of the application are currently listed in the Alarm Instances table.

Checking the project

You can enable or disable the generation of alarms for instances. By default, all alarm instances are added to the alarm configuration. Under the Create column, you can deselect individual instances so that no alarm evaluation is done for a specific instance.

If you want to divide the alarm instances into different groups, then you can make the assignment in the Alarm Group column. The alarm groups first have to be created below the alarm configuration.

For more information, see: Alarm Configuration, alarm_creation_default