Once you know where you are heading, you can start defining your alarms. I usually classify alarms into six groups.
The first group is
Discrete Alarms. These are alarms whose condition come solely from the presence (or loss) of a discrete signal. Loss of signal is almost always best, for safety reasons. E-stops, "high" level switches, "Drive Failure" inputs are examples of this type. If my PLC memory permits it, I allocate 1 alarm coil for
every discrete input point, even if that DI isn't a discrete alarm. And I'll reserve some coils for future input modules. This allows me to
know just where an alarm is going to be, no matter how the system changes over the course of the project, or its life cycle.
In addition to each alarm coil, I also have a corresponding bit for "Alarm Enable" This bit allows me to disable an alarm on the fly. Usually, there is no coil setting the bit, just a value in the data table.
But sometimes I'll program the bit to eliminate "nuisance alarms" when certain conditions are true.
The usual code for Discrete alarms is dirt simple:
HI_LEVEL HI_LEVEL_ALM_ENABLE HI_LEVEL_ALM_COIL
I:3/1 B211:3/1 B210:3/1
-------| |-------------| |-------------------( )
`
To be more efficient, and because, as I said, I've reserved one alarm for EVERY DI, I might do it this way:
Move with Mask All DIs into Alarm Coils. Mask=Alarm Enable Bit
+--------- MVM ---+
-----------------------| Source: I:3.0 |
| Mask: B211:3 |
| Dest: B210:3 |
+-----------------+
`
To be even more efficient, I'll indirect the above, and put it in a For-Next loop (LBL/LMP pair). Usually not, though. It can be tough enough tracking the alarm bit through the word move. Adding indirect means that the maintenance department must KNOW what I'm doing, which means I must know before I write the code that I'll be spending some quality time with them.
=========
The second group of alarms are the
Analog Input alarms. These alarms occur when an analog input value crosses the alarm threshold (above or below). For these, I usually allocate four alarm bits per Analog input point: "High-high", "High", "Low", and "Low-Low". Depending on the customer, and the PLC, I might increase the number to six, adding "Out-of-range, High" and "Out-Of-Range, Low" (if those conditions aren't covered by "High-High" and "Low-Low").
In order to prevent "nuisance alarms", I set a deadband for each alarm. Usually it's enough just to have a common deadband for all the alarms associated with a given point, but if need be, I can make each individual alarm have it's unique deadband.
Typical analog alarm logic looks like this (only HIGH and LOW logic shown):
High Level Alarm
TEMP_HI_ALM_ENABLE
B211:10/6 +------------ COMPARE --+ +---------------- COMPARE ------+ T224:6
-------| |---+--| TEMP TEMP_HI_LIMIT |--+--| TEMP TEMP_HI_LIMIT TEMP_DB |---+-----(TON)
| | F31:1 >= F215:6 | | | F31:1 >= F215:6 - F215:9 | |
| +-----------------------+ | +-------------------------------+ |
| | | TEMP_HI_ALM_COIL
| TEMP_HI_ALM_COIL | | T224:6/DN B210:10/6
+----------| |----------------+ +-----| |--------( )
Low Level Alarm
TEMP_LO_ALM_ENABLE
B211:10/7 +------------ COMPARE --+ +---------------- COMPARE ------+ T224:7
-------| |---+--| TEMP TEMP_LO_LIMIT |--+--| TEMP TEMP_LO_LIMIT TEMP_DB |---+-----(TON)
| | F31:1 =< F215:7 | | | F31:1 =< F215:7 + F215:9 | |
| +-----------------------+ | +-------------------------------+ |
| | | TEMP_LO_ALM_COIL
| TEMP_LO_ALM_COIL | | T224:7/DN B210:10/7
+----------| |----------------+ +-----| |--------( )
`
Again, all of the above can be put into a For-Next loop (there's a special trick for timers) and so for a large system will 100 analog input points, with 4 alarms each, the entire analog alarm code consists of 7 lines of code!
For small systems, or where indirect addressing is not allowed, I use Excel to auto-generate the code.
===========
The Third classification of alarms are the
Discrete Output alarms. These alarms are triggered when the expected DIRECT feedback from a discrete output doesn't occur within a set period of time. These are your valve and motor faults. I reserve two alarm bits for each DO: "Failed to Start/Open" and "Failed to Stop/Close", again, whether that point will be alarmed or not.
First, some code (for a valve with "Open" and "Closed" limit switches):
XV123_OPEN_ALM_ENABLE
B211:20/12 XV123 XV123_CLOSED T225:12
--------| |-------------| |--+-----| |----+-----+----(TON)
| | |
| XV123_OPEN | | T225:12/DN XV123_OPEN_ALM_COIL
+-----|/|----+ +----| |-------------( )
`
============
The fourth classification of alarms is the
Analog Output. These are rarely used, and generally not a good idea. The basic idea behind them is, like Discrete Output alarms, is to verify that the feedback is tracking the output.
The problem is that if the analog output is PID controlled (which it usually is), the output is fluctuating, and so even if you do have feedback on the control valve, you will have response lags and need to include a deadband since the feedback won't match exactly the value of the output. (Note: I'm referring to valve position, not process variable (temperature, pressure, flow rate) when I refer to feedback.
Usually what you are REALLY interested in is whether the valve opens at all, not whether the actual position is within ±10% of the commanded output. A simple check of "
If Valve Output > 10% start Timer. On Timer done, if Valve Position < 5%, then Alarm Coil" is sufficient.
=============
The fifth alarm class is what I call
Phase Alarms (after the S88 phase model). These are too general to able to provide much specifics on, but the idea is that the phase is attempting to try to control a process variable ("Heat to Temperature X", "Meter in Y gal of water"). When the phase is running, it should be given a certain amount of time, either to accomplish its goal, or to at least affect the system. If the totalized flow doesn't change for 15 seconds, then you should stop the phase. It could be that a manual valve is closed, or that the level sensor which is telling you that there's enough water is broken, or that water is flowing past the flowmeter without turning it, or ???. So you stop the process, and
TELL THE OPERATOR WHY you stopped it.
Sample Code:
PHASE03_RUNNING +----- EQU ---+ T227:3
--------| |------+---| PHASE03_PV |-----+-------(TON)
| | LAST_PV | |
| +-------------+ | T227:3/DN PHASE_ALM_COIL
| +-----| |----------( )
|
| +----- MOV ---+
+---------------------| PHASE03_PV |
| LAST_PV |
+-------------+
`
Other alarms might go in this category as well. For example, a Light Curtain DI may not be an alarm by itself, but "Light Curtain" + "Start PB" would be. That alarm might be programmed with the phase alarms, or I might put it in with the DI alarms
==============
The last catagory of alarms are the
PLC-specific alarms. These vary with PLC model capabilities. "Low PLC Battery" is the most common. Sometimes you can get the "Out-of-Range" analog input alarms from the PLC (example: AB PLC-5 BTR, words 2 & 3), and not need the extra code in the analog sectoin. I'm not going to go into details here. They could be considered a specialized type of DI alarm.