Skip to main content

Section: alg.Alarm

The section SEC alg.Alarm describes a module alarm. A module alarm essentially corresponds to an alarm of the CODESYS alarm management that has been configured in an alarm group. However, a module alarm still contains module-specific additions.

For more information, see the Module Declaration chapter and Object: Alarm Group

Specification

SEC alg.Alarm                                       //optional: yes, modifier: [UPDATE]
    SEC SetAlarm <alarm identifier>                 //optional: yes, modifier [UPDATE]
            Class := <class name>;                    //optional: no, type: ID
            Message := <TextlistEntry>;                 //optional: no, type: TextListEntry
            LatchVar1 := <LatchVariable1>;              //optional: yes, type: InstancePath
            LatchVar2 := <LatchVariable2>;              //optional: yes, type: InstancePath
            Deactivation := <DeactivationVariable>;     //optional: yes, type: InstancePath
            PendingTime := <PendingTime>;               //optional: yes, type: LiteralOrConstant
            PendingTimeParameter := <string>            //optional: no, type: literal/string
            HigherPrioAlarm := <HigherPrioAlarm_ID>;    //optional: yes, type: ID
            ModuleCalls := <ModuleCallFlags>;           //optional: yes, type:  ModuleCallFlag
            SEC Messages : <alarm identifier>           //optional: yes, modifier: [UPDATE]
                    Message := <TextlistEntry>;             //optional: no, type: TextListEntry
                    Number := <ColumnNumber>;               //optional: no, type: Literal
            END_SEC
            SEC LatchVar <latch var identifier>         //optional: yes, modifier [UPDATE]
                    LatchVar := <LatchVariable>;            //optional: no, type: InstancePath
                    Number := <LatchVarNumber>              //optional: no, type: LiteralOrConstant
            END_SEC
            SEC UpperLimit                              //optional: yes, modifier: [UPDATE]
                    Expression := <Expression>;             //optional: no, type: Literal/String
                    IncludeBorder := TRUE/FALSE;            //optional: no, type: FlagBool
                    UpperExpression := <UpperExpression>;   //optional: no, type: Literal/String
                    Hyteresis := <HysteresisValue>;         //optional: yes, type: LiteralOrConstant
            END_SEC
            SEC LowerLimit                              //optional: yes, modifier: [UPDATE]
                    Expression := <Expression>;             //optional: no, type: Literal/String
                    IncludeBorder := TRUE/FALSE;            //optional: no, type: FlagBool
                    LowerExpression := <LowerExpression>;   //optional: no, type: Literal/String
                    Hyteresis := <HysteresisValue>;         //optional: yes, type: LiteralOrConstant
            END_SEC
            SEC InsideRange                             //optional: yes, modifier: [UPDATE]
                    Expression := <Expression>;             //optional: no, type: Literal/String
                    AreaLow := <AreaLowValue>;              //optional: no, type: Literal/String
                    LowIncludeBorder := TRUE/FALSE;         //optional: no, type: FlagBool
                    HighIncludeBorder := TRUE/FALSE;        //optional: no, type: FlagBool
                    AreaHigh := <AreaHighValue>;            //optional: no, type: Literal/String
                    Hyteresis := <HysteresisValue>;         //optional: yes, type: LiteralOrConstant
            END_SEC
            SEC OutsideRange                            //optional: yes, modifier: [UPDATE]
                    Expression := <Expression>;             //optional: no, type: Literal/String
                    AreaLow := <AreaLowValue>;              //optional: no, type: Literal/String
                    LowIncludeBorder := TRUE/FALSE;         //optional: no, type: FlagBool
                    HighIncludeBorder := TRUE/FALSE;        //optional: no, type: FlagBool
                    AreaHigh := <AreaHighValue>;            //optional: no, type: Literal/String
                    Hyteresis := <HysteresisValue>;         //optional: yes, type: LiteralOrConstant
            END_SEC
            SEC Digital                                 //optional: yes, modifier: [UPDATE]
                    Expression := <Expression>;             //optional: no, type: Literal/String
                    Equal := TRUE/FALSE;                    //optional: no, type: FlagBool
                    EqualsExpression := <Expression>;       //optional: no, type: Literal/String
            END_SEC
            SEC Change                                  //optional: yes, modifier: [UPDATE]
                    Expression := <Expression>;             //optional: no, type: Literal/String
            END_SEC
            SEC Event                                  //optional: yes, modifier: [UPDATE]
            END_SEC
    END_SEC
END_SEC

SEC SetAlarm

The subsections of SetAlarm define all the properties that are necessary or possible for an alarm. The target of SetAlarm identifies the alarm from the other alarms in the module and is used to reference it (mainly in the definition HigherPrioAlarm).

Class

Alarm class name, under which the alarm will be created.

If this alarm class already exists in the application, the alarm will be created under this class. If this class does not exist, an alarm class template object is searched for, which must be present in the POUs view. If no appropriate alarm class template object is found, an error is issued when the module is scanned.

Message

ID (of the form TextListenName.TextListenEintragID) of a text list entry for the alarm text

The message referenced by the ID can contain the same placeholders as the text in an alarm configuration. For example placeholders such as LATCH1 or LATCH2 can be used

If a specified text list entry cannot be found, a warning is issued during the scan.

Corresponds to the Message setting in the Alarm Group object.

LatchVar1

LatchVar2

Placeholder variables

In the present case of module-specific alarms, variables can only be specified directly from the module function block (just like variables are specified in the module declaration for e.g. parameters)

Corresponds to the settings Latch variable 1 / Latch variable 2 for placeholders <LATCH1> / <LATCH2> in the Alarm Group object.

Deactivation

Deactivation variable (BOOL).

TRUE: Deactivates the defined alarm, where only module function block variables can be used.

If the type of the variable that is entered is not BOOL, then an error is issued during the scan

Corresponds to the Deactivation setting in the Alarm Group object.

PendingTime

Minimal pending time. Defines the amount of time before the alarm actually goes off after reaching its limits.

Example: TIME#5S

Corresponds to the setting Min. pending time in the Alarm Group object.

PendingTimeParameter

Parameter to set the minimum pending time

The value which is assigned to the parameter is a string that can be interpreted as time. Or also as an expression which consists of module parameters and time literals.

. Example:
  • TIME#5S

  • 'NoVar'

  • 'WithVar'

  • 'WithVar - NoVar + TIME#5S'

HigherPrioAlarm

ID of the higher priority alarms

To identify the alarm under which the present alarm should be classified, a target ID of a SetAlarm section is specified for the existing module alarms. To find the SetAlarm section with corresponding target ID, a hierarchical search is performed from the own module upwards in the parent module instances for matching IDs among the alarm declarations. If no corresponding parent alarm is found, an error is issued during the generator check

Corresponds to the setting Higher prio. alarm in the Alarm Group object.

ModuleCalls

For module-specific alarm management, module FBs can offer specific interfaces that can be called if an module alarm occurs. The flags define in which cases this will happen.

. Available ModuleCallFlags:
  • NONE: No calls will occur

  • THIS: A call will occur for the alarms of the present module

  • PARENTS: A call will occur to all parent modules of the present module

  • ALL: A call will occur to all modules

Module FBs that will be called by this flag must implement the IModuleAlarming interface. The call is performed by the ConsumeModuleAlarm function of this interface

If the PARENTS flag was set for a toplevel module, a warning is displayed if a scan is executed (because this flags do not exist for toplevel modules).

SEC Messages

The subsection manage the same task as the Message parameter, but allows multiple messages for one alarm. For compatibility reasons the (old) parameter Message is still valid. The message can contain the same placeholders as the actual text in an alarm configuration. This means that also placeholders such as <LATCH1> and <LATCH2> can be used. If a specified text list entry cannot be found, a warning is issued during the scan.

Messages: Alarm text in form of a text list entry (of the form TextListenName.TextListenEintragID)

Number: Column in the alarm table the message is displayed.

SEC LatchVar

Latch variables. Up to 10 latch variables can be defined in this section.

If, in addition to this section, LatchVar1 or LatchVar2 is defined, the variable of this section will be used.

LatchVar: Latch variable

Number: Number to identify the latch variable.

SEC UpperLimit

SEC LowerLimit

Alarm conditions for alarms that trigger if upper or lower boundaries are crossed.

The section is allowed to occur only once below the SEC SetAlarm section. If this is not the case an error is issued during the scan.

Expression: IEC expression or value that is tested. In expressions, local variables of the module FBs as well as global constants, can be used.

IncludeBorder: TRUE corresponds to <= (UpperLimit) or >= (LowerLimit). FALSE corresponds to < (UpperLimit) or > (LowerLimit).

UpperExpresssion, LowerExpresssion: IEC expression or value against which the Expression is tested. In expressions, local variables of the module FBs as well as global constants, can be used.

Hysteresis: Alarm hysteresis in %.

Corresponds to the settings Upper limit / Lower limit for the observation types in the Alarm group object.

SEC InsideRange

SEC OutsideRange

Alarm conditions for alarms that trigger if an expression is in- or outside of a certain range of values.

The section is allowed to occur only once below the SEC SetAlarm section. If this is not the case an error is issued during the scan.

Hysteresis: Alarm hysteresis in %

  • Expression: IEC expression or value that is tested. In expressions, local variables of the module FBs as well as global constants, can be used.

  • AreaLow: Lower limits of the range (value or IEC expression). In expressions, local variables of the module FBs as well as global constants, can be used.

  • LowIncludeBorder: This boolean flag determines whether the lower limit itself is included in the range of comparison (corresponds to <=)

  • HighIncludeBorder: This boolean flag determines whether the upper limit itself is included in the range of comparison (corresponds to >=)

  • AreaHigh: Upper limits of the range (value or IEC expression). In expressions, local variables of the module FBs as well as global constants, can be used.

Corresponds to the settings Inside range / Outside range for the observation types in the Alarm group object.

SEC Digital

Alarm which is raised if two expressions are compared with one another.

The section is allowed to occur only once below the SEC SetAlarm section. If this is not the case an error is issued during the scan.

  • Expression: IEC expression or value that is tested. In expressions, local variables of the module FBs as well as global constants, can be used.

  • Equal: TRUE/FALSE: Expression will be checked for equality/inequality.

  • EqualsExpression: IEC expression or value which is checked against Expression. In expressions, local variables of the module FBs as well as global constants, can be used.

Corresponds to the observation type Digital in the Alarm Group object.

SEC Change

Alarm which is raised if an expression changes its value.

The section is allowed to occur only once below the SEC SetAlarm section. If this is not the case an error is issued during the scan.

Expression: IEC expression or value that is checked for changes. In expressions, local variables of the module FBs as well as global constants, can be used.

Corresponds to the observation type Change in the Alarm Group object.

SEC Event

Determines that the current alarm section creates an event alarm. This alarm can be triggered by the function RaiseModuleEvent() from the AC_Alarming library.

Example

Example 37. ValueRange
SEC SetAlarm : ValueRange
        Class := Error;
        Message := TL.Alarm_Temperature;
        LatchVar1 := rAlarmValueLow;
        LatchVar2 := rAlarmValueHigh;
        ModuleCalls := THIS | PARENTS;
        SEC Messages : msg2
                Message := TL.msg5_Message;
                Number := 5;
        END_SEC
        SEC OutsideRange
                Expression := 'rValue';
                AreaLow := 'rAlarmValueLow';
                LowIncludeBorder := TRUE;
                HighIncludeBorder := TRUE;
                AreaHigh := 'rAlarmValueHigh';
        END_SEC
END_SEC
Example 38. Section: PendingTime
SEC alg.Alarm
	SEC SetAlarm : NoVar
		Class := AlarmClassTemplate;
		Message := TL.NoVar_Message;
		PendingTimeParameter := 'NoVar';
		SEC Digital
			Expression := 'xAlarm';
			Equal := TRUE;
			EqualsExpression :='TRUE'; 
		END_SEC
	END_SEC
	SEC SetAlarm : WithVar
		Class := AlarmClassTemplate;
		Message := TL.NoVar_Message;
		PendingTimeParameter := 'WithVar';
		SEC Digital
			Expression := 'xAlarm';
			Equal := TRUE;
			EqualsExpression :='TRUE'; 
		END_SEC
	END_SEC
	SEC SetAlarm : SimpleMath
		Class := AlarmClassTemplate;
		Message := TL.NoVar_Message;
		PendingTimeParameter := 'WithVar - NoVar + TIME#5S';
		SEC Digital
			Expression := 'xAlarm';
			Equal := TRUE;
			EqualsExpression :='TRUE'; 
		END_SEC
	END_SEC	
	SEC SetAlarm : NoParam
		Class := AlarmClassTemplate;
		Message := TL.NoVar_Message;
		PendingTime := TIME#5S;
		SEC Digital
			Expression := 'xAlarm';
			Equal := TRUE;
			EqualsExpression :='TRUE'; 
		END_SEC
	END_SEC
END_SEC