Create alarms, save to historical event file and email

Last updated:  June 9, 2003

Introduction
This document is one of five that describes the basic ICON program (skeleton.icn) which normally provides the framework for all ICON programs. This document describes the module type named "Alarms" which describes how to create an event or alarm, save to a historical event file and optionally email the result. If you wish to perform email functions, refer to the following sections:

  1. Configure email addresses and the IP address of your SMTP mail access point. Refer to the Connection section. Under general parameters, refer to Mail Server IP:, IP Email 1 (return address): and IP Email 2:. Under table parameters, refer to E-mail Address:.
  2. Configure an event file. Include an email address range if sending email.
This module takes exported data either directly from the first module (raw Modbus data) or converted and validated analog data from the second module type. This module can process up to 16 alarms from any combination of exported data. Add additional modules if more than 16 points must be processed. It is not recommended to do more than 16 in one module because the HMI gets too busy. Name the first module "Alarms 1", the second "Alarms 2", etc. Or you may pick other unique names. Each alarm is processed as follows:
  1. A Limit instruction creates the alarm or event.
  2. A Histevt instruction saves the result to a historical event file.
Finally all the individual alarms are combined into one global alarm for export. At the end of all the alarm modules is one master alarm module. This module has a single Alarm instruction that gathers up all the exported alarms from the Modbus module and all the alarm modules and creates the pop-up master alarm.

An HMI interface is created that allows the user to interface to the above program to:

  1. Set the alarm limits for each alarm.
  2. View the current value for each alarm.
  3. View the state of each alarm.
In the following sections the program is listed along with the configuration. The first line is the instruction and caption as would be listed when programming. This is followed by the general and table parameter configuration. Finally, a description of the purpose of the program is included if needed.

Module ALarm 1

Map Import alarm data
General Parameters
Array: alarm_in
Direction: To array
Table Parameters
Individual
#data1[1] An example of getting raw modbus data.
#sensor_avg1 An example of getting data from the first converted and validated module.
#sensor_avg1[2] (Remember, data values are in even numbered indexes and validity status in the next higher odd numbered index.)
#sensor_avg1[4]
#sensor_avg1[6]
#sensor_avg2 An example of getting data from the second converted and validated module.
#sensor_avg2[2]
#sensor_avg2[4]

The above instruction is entered only 1 time. The length is set to the number of alarms to process. The following 2 instructions are repeated for each alarm:

Limit Alarm 1
General Parameters
Parameter Example Description
Input: alarm_in The input for the alarm gathered from the Map instruction.
Result: alarm Create the first alarm.
Limit: Null Not used.
High: 4 Bit pattern is 0100 (See below).
Went high: 5 Bit pattern is 0101.
Window: 0 Bit pattern is 0000.
Went window: 1 Bit pattern is 0001.
Low: 2 Bit pattern is 0010h.
Went low: 3 Bit pattern is 0011h.
High limit: 95 This could be an example of a greenhouse temperature alarm. In the example the high alarm sets at 95 degrees.
High clear: 90 And clears at 90.
Low clear: 45 The low alarm clears at 45.
Low limit: 40 And sets at 40.
The status should be thought of as bit values. In the bit pattern dcba, a is bit 0, b is bit 1, c is bit 2 and d is bit 3. When bit 0 is set it causes the Histevt instruction to record an event to the event file. Notice bit 0 is set for Went high, Went window and Went low. Therefore a record will only be recorded to the event file on a change of alarm state. Bit 1 is set for a low alarm and bit 2 is set for a high alarm. Later, when you are printing reports from an event file, a status of "Low" will be printed for any records with a status which has bit 1 set. A status of "High" will be printed for any records with a status which has bit 2 set. A status of "Both" will be printed for any records with a status which has both bits 1 and 2 set.

Histevt Save alarm 1
General Parameters
Parameter Example Description
Data: alarm_in Save the alarm value.
Status: alarm Save the alarm status.
Event file: 1 Example of using event file 1.
Event number (1-128): 1 Example of saving the result in the first event field in the records of event file 1.
Whenever the value of status alarm is odd (bit 0 set to a 1) the current value of alarm_in, the value of status alarm, the date/time and event number are written to the next record in the event file 1.

The above 2 instructions must be repeated for each alarm. For the second alarm the data will be in alarm_in[1] and the alarm will be alarm[1]. Continue this sequence for all required alarms.

Alarm Export master alarm
General Parameters
Parameter Example Description
Master !alarm[2] The master alarm variable. (The Modbus input module used !alarm. Use !alarm[3], etc. for additional alarm modules.)
Alarm: alarm This is the array of individual alarms created above.
Number of alarms: 8 Enter the length of alarm array.
Notice only the module master alarm (!alarm[2]) is exported, not any of the individual alarms.

Creating the Master Alarm
The ICON HMI is designed to test the value of !System[3] automatically at run time. If the value of !System[3] is set to 1, the HMI screen associated with the last Module statement in the program (Module End) will pop up automatically. Therefore you must add the following module with the following program statement after the last alarm module to your program to control the value of !System[3].

Module Create master pop-up alarm

Alarm Pop-up master alarm
General Parameters
Parameter Example Description
Master !master_alarm_temp The global master alarm variable.
Alarm: !alarm This is the array of individual master alarms created from the Modbus module and each alarm module.
Number of alarms: 3 Enter the length of !alarm array. If there is one Modbus input module, one Modbus output module and one alarm module enter 3.

Constant Master alarm enable
General Parameters
Variable: !master_alarm_enable Value of 0 disbales automatic popup of master alarm window, 1 enables automatic popup of master alarm window.
Data type: Float
Mode: Capture
Table Parameters
No configuration necessary, set table length to 1
 

Expression set master alarm if enabled
Table Parameters
Result: Expression: Description
!System[3] !master_alarm_temp 'if' !master_alarm_enable If !master_alarm_enable is a 1 then set !System[3] to the value of !master_alarm_temp to cause automatic popup of master alarm window.
!System[3] 0 'if' (!master_alarm_enable==0) If !master_alarm_enable is a 0 then set !System[3] to 0 to prevent automatic popup of master alarm window.

Initially!master_alarm_temp will be 0. If any value in the !alarm array changes to a 1, the transition will set !master_alarm_temp to 1. You must add an object to the HMI screen for "Module End" to set the value of !master_alarm_temp to 0 to "acknowlege" the alarm. !master_alarm_temp will not set to 1 again until another alarm in the !alarm array transitions to 1 or the current alarm element in !alarm goes to 0 and then back to a 1. !master_alarm_temp will go back to a 0 automatically if all the values in !alarm go to 0.

You must also add two additional objects to the HMI screen for "Module End" for each alarm module. The first is an object to set the value of !alarm to 0 to "acknowlege" the module alarm. The second is a button to go to that module's alarm screen so a user can view which alarm caused the problem.