Loading local progress…
PLC Gym
PLC Gym homeLevel 1, 0 XP · your progress
Mission 89 · PRO (needs Pro)

One alarm block for every alarm: PLC SCADA training exercise

New, seen, cleared: one loop takes every alarm through the same states and marks the one that came first.

Write the alarm block behind the factory's alarm list: one loop that takes each of five alarms through new, seen and cleared, counts what is active and unacknowledged, reports the top priority and marks the alarm that came first.

This mission is part of ProCreate a free account: every account gets a free Pro trial until 5 December.

No card. Nothing to pay. Nothing to cancel.

Official release: 5 December. Top the leaderboard on the day and win 3 months of Pro, plus 2 weeks of Pro to give a friend. 2nd place wins 4 weeks. 3rd place wins 2 weeks. Rules

  • Every Coaching lesson, from zero
  • Every mission and lesson, as you level up
  • A practical test for every title, with a certificate
  • Rewind any test, one scan at a time
  • Worked solutions when you're stuck
  • The code converter, as much as you like
The 3D model factory this mission runs onPRO (needs Pro) mission
How the test runs

New, seen, cleared

Test 1 of 6
Set by the testChecked by the testStep 8 of 8 · 1.9 s
Level
Expert
Time
About 45 min
Reward
+800 XP
Rig
3D model factory
Siemens editors
SCL
Rockwell editors
Structured Text
Beckhoff editors
Structured Text
Stage
44. SCADA 2: one alarm block for every alarm
Required behaviour

One alarm block for every alarm: what your code must do

The plant control, the five alarm conditions Cond[0] to Cond[4] and their priorities Prio[0] to Prio[4] are written. Write one FOR loop over the five alarms that keeps AlarmState[0] to AlarmState[4]: 0 Normal, 1 New (active, not acknowledged), 2 Seen (active, acknowledged), 3 Cleared, not seen. From 0, the condition coming on gives 1. In 1, a press of Ack gives 2; the condition going off gives 3. In 2, the condition going off gives 0. In 3, a press of Ack gives 0; the condition coming back gives 1. Each alarm makes at most one move a scan, and Ack acts on the press, not while it is held. ActiveCount is how many alarms are in state 1 or 2. UnackCount is how many are in state 1 or 3. TopPriority is the most urgent priority among the alarms not in state 0: 1, 2 or 3, or 0 for none. FirstOut is the number of the alarm that started the trouble, counting from 1: when an alarm leaves state 0 while FirstOut is 0, FirstOut becomes its number. If two start in the same scan, the one earlier in the table wins. FirstOut goes back to 0 only when every alarm is in state 0 again. On the Operator screen tab, choose how the list treats a cleared alarm, the first alarm and the states.

States
0 Normal, 1 New, 2 Seen, 3 Cleared, not seen.
Ack
On the press: 1 becomes 2, and 3 becomes 0.
Totals
ActiveCount: states 1 and 2. UnackCount: states 1 and 3. TopPriority: the most urgent not in 0.
First out
Set by the first alarm to leave 0; cleared when all are 0 again.
Tag table

One alarm block for every alarm: inputs and outputs

Your program reads 19 inputs and sets 20 outputs. One more input drives the simulation or shows a reading, for you to test with. The names are the same in every maker’s editor.

TagData typeYour codeWhat it means on the machine
StartBOOLReadsAn input your code needsStart the factory
StopBOOLReadsAn input your code needsStop the factory where it is
ResetBOOLReadsAn input your code needsReset after an emergency stop or a light-curtain trip
EStopBOOLReadsAn input your code needsEmergency stop pressed
CompressorFaultBOOLReadsAn input your code needsTry it: the compressor trips
AirPressureREALReadsAn input your code needsAir receiver pressure, bar
SteamPressureREALReadsAn input your code needsBoiler steam pressure, bar
VesselLevelREALReadsAn input your code needsMixing vessel level, %
VesselTempREALReadsAn input your code needsBatch temperature, °C
SugarAddedREALReadsAn input your code needsSugar the weigh feeder has added to this batch, kg
BufferLevelREALReadsAn input your code needsFiller buffer tank level, %
BadBottleBOOLReadsAn input your code needsCamera: a bottle with no label is passing
GateEyeBOOLReadsAn input your code needsA bottle is in front of the reject gate
AccumFullBOOLReadsAn input your code needsThree packs are waiting for the robot
CurtainClearBOOLReadsAn input your code needsLight curtain beams unbroken
PalletFullBOOLReadsAn input your code needsA full pallet is waiting or on its way to the wrapper
PalletOnWrapperBOOLReadsAn input your code needsA pallet is on the wrapper turntable
WrapDoneBOOLReadsAn input your code needsThe pallet on the wrapper is wrapped
AckBOOLReadsAn input your code needsScreen button: acknowledge the alarms
PersonInCellBOOLNot neededFor testing or watching; your code can leave it outTry it: someone walks into the robot cell
CompressorBOOLWritesAn output your code setsRun the air compressor
BoilerOnBOOLWritesAn output your code setsSwitch the boiler on
WaterValveBOOLWritesAn output your code setsWater into the mixing vessel
FeederBOOLWritesAn output your code setsRun the sugar weigh feeder
AgitatorBOOLWritesAn output your code setsRun the agitator
SteamValveBOOLWritesAn output your code setsSteam to the vessel jacket
TransferPumpBOOLWritesAn output your code setsPump the batch to the buffer tank
LineRunBOOLWritesAn output your code setsRun the bottling line
RejectGateBOOLWritesAn output your code setsFire the reject gate
RobotEnableBOOLWritesAn output your code setsLet the robot palletise
PalletOutBOOLWritesAn output your code setsMove the full pallet to the wrapper
WrapBOOLWritesAn output your code setsRun the stretch wrapper
AGVCallBOOLWritesAn output your code setsCall the AGV to collect the wrapped pallet
GreenLampBOOLWritesAn output your code setsStack light: producing
AmberLampBOOLWritesAn output your code setsStack light: starting or waiting
RedLampBOOLWritesAn output your code setsStack light: emergency stop or light-curtain trip
ActiveCountINTWritesAn output your code setsAlarm list: alarms whose condition is on
UnackCountINTWritesAn output your code setsAlarm list: alarms nobody has acknowledged
TopPriorityINTWritesAn output your code setsAlarm list: most urgent priority showing, 1 to 3, or 0
FirstOutINTWritesAn output your code setsAlarm list: the alarm that came first, 1 to 5, or 0

In Siemens SCL, write a block’s own tags with # in front, as TIA Portal does: #Start. Rockwell and TwinCAT use the name on its own: Start.

Automatic tests

One alarm block for every alarm: what the tests check

  1. Every alarm follows the same four states: 0 Normal, 1 New, 2 Seen, 3 Cleared, not seen.
  2. An alarm that clears before Ack stays on the list as 3 until Ack; one that comes back before Ack is New again.
  3. Ack acts on the press: a held Ack does not acknowledge an alarm that arrives later.
  4. ActiveCount, UnackCount and TopPriority match the list on every .
  5. FirstOut names the alarm that came first and holds it until the list is empty.
  6. The list keeps a cleared alarm until it has been seen, marks the first one and says each state in words.
  1. Try it Use the buttons below the model and watch the rig respond.
  2. Test solution Every check runs on your code in one press.
  3. Rewind PRO (needs Pro) If one fails, step back through it one scan at a time to see why.

Stuck on this mission? Ask the members in the Locker Room.

Why it matters

Where you’d see this on site

A plant's SCADA server holds one alarm table, each line with a state, a priority and a time. The first out mark is what the day shift reads after a night of stops.

One trip can raise twenty alarms in a few seconds. Without states and a first out mark, the operator acknowledges them all to silence the horn and the cause is lost.

Where you'd find thisOne controller for a whole factory: when each machine may run, and what keeps it safe

A small drinks factory makes an orange drink. Sugar and water are batched and pasteurised, then pumped to a filler. Bottles are filled, capped, labelled and inspected, packed in sixes, stacked on pallets by a robot, wrapped and carried to the dock by a driverless forklift. Every machine has its own controls; the plant controller decides when each may run, hands work from one to the next, and stops everything safely.

  1. BatchMix and pasteurise
  2. FillFill, cap, label
  3. InspectReject bad bottles
  4. PackRobot stacks packsYou are here
  5. ShipWrap, AGV to dock
On a real site: places, parts and safety
  • Soft drinks and juice bottling halls
  • Sauces, dairy and liquid food plants
  • Household and personal-care liquids

An emergency stop is wired through a safety relay that cuts the power on its own. The program must then hold everything off and wait for a deliberate Reset and Start, so nothing moves by surprise.

Robot cells are fenced. Light curtains and interlocked doors stop the robot when someone goes in, and a restart needs a reset from outside the cell, in the spirit of ISO 10218 and ISO 13849.

The sizes, timings and cutaways are teaching choices, not a drawing of any one real installation.

Keep going

Next on the road