Alarms and Events

Alarm: Alarms represent warnings of process conditions that could cause problems, and require an operator response.

Examples can be many, like suppose a Tank water level has increased beyond the desired value and that time SCADA system should give Alarm. Some other examples could be for example:

Download the sample Project done by Beckhoff.

=>Circuit breaker tripped

=>Battery low

=>Leak detected

The intention of an alarm is to signal that something has gone wrong, or that a particular stage of processing has been reached. For example, an alarm might indicate that a boiler has exceeded a safe temperature limit.

Event: Events represent normal system status messages, and do not require an operator response. An event is defined as a detectable occurrence, which may or may not be associated with an alarm. So event means something interesting happened to the system that may be an indication of an unwanted state or some info that we are interested in.

For example, in our yard gate example, whenever the user has opened the gate from our HMI that we can log as an event. This can be used for reporting. But say, nobody commanded to open the gate but the gate opened by itself due to a bug in the software that can be treated as an alarm, say our motor has burned and we commanded to open the gate and it did not open, this is an alarm. If an alarm occurs then the operator needs to do something.

The central event system is integrated into the TwinCAT HMI server. It is possible to manage events from the HMI server and its extensions. The TcHmiEventlogger extension can be connected with the TwinCAT 3 event logger from local or remote real-time systems.

 TwinCAT HMI architecture of the event system is shown in the following image.

According to TwinCAT architecture, events are generic terms. Events are divided into Messages and Alarms.

The event system has been built as an extension. The extension can be loaded automatically when a project is created or can be installed via NuGet packages. When we install the NuGet package we might encounter a computability problem as the interface may not match.


The Event Grid Control is a control for the tabular display of alarms and messages. It automatically displays the alarms and messages of the target systems addressed in the event logger extension. Alarms can be confirmed directly in the control.

The Event Grid Control is located in the Toolbox under the category Beckhoff, from where you can insert it into an HMI page by drag-and-drop. We shall use the same sample here as references.


How to install NuGet packages:

Visual Studio project | Manage NuGet Packages, then select the desired version as shown in the following images.

TC_EVENTS constants:

TC_EVENTS is a global TwinCAT system variable list (GVL). Each constant in this list represents an event class that is available on a TwinCAT system. The instances of the event classes are structured data types. Their member variables are instances of individual events. The events can be used, for example, in a PLC project or in a PLC library for logging the most diverse messages. The TwinCAT system has several predefined event classes. Further event classes are brought along by the integrated PLC libraries (functions) or defined by the user in the PLC application. The Global Variable List of the event classes is automatically created and updated by the TwinCAT system. The number of available event classes can vary from system to system as a result.


How do we add own event types in PLC System:

=>In TwinCATproject, select SYSTEM | Type System (double click), it will insert a NewEventClass (TMC Editor), if it does not open then right click and select new from the context menu.

=>It will bring NewEventClass (rename this one as you like)

=>Give a suitable Name (for example, I gave TestClass for testing) and Description

=>In the left pane, under Events add, remove and reorder Events (that you are going to raise), as shown in the following figure.

=>We can rename the Event to actual event that we are going to raise.

=>Event (as shown in the following image can be renamed to suitable one, example Contactor_Broken, note space is not allowed)

=>Give an Id, Display Text (translatable) and Severity level.

 In the PLC code, the event can be raised by the following way.
IF NOT bIsInitalized THEN
bIsInitalized := TRUE;
fbAlarm.CreateEx(TC_Events.TestClass.Event, TRUE, 0);
IF bAlarm THEN
bAlarm := FALSE;
IF bClearAlarm THEN
bClearAlarm := FALSE;
fbAlarm.Clear(0, TRUE);

Set the AMS net id for the ADS and TcHmiEventLogger if you are using real PLC. For simulator we don’t need to set it.


01: If we have some data logger are stored in the DB file that can interfere with the visual studio project, you may not find the data in the solution and wonder from where it was coming, actually it can come from the DB file (good to remove from the DB file.)


Download the sample from the link given above.

Next, let’s try to understand what is a recipe at

Ask questions related to Hemelix sample code and design at Google group