Makers Blog Archive

OPC UA in IEC 61131-3: Alarms & Conditions

Sven Lemmens 19 December 2019 min. read
217 views 0 comments

The following functionality is based on the Alarms Dispatcher in PLCnext Technology.
It enables you to send alarms to other applications running on your PLCnext Control, whether it be a C++, Simulink®, IEC 61131-3 or an embedded OPC UA Server application.
I will explain some easy examples to make you familiar with this technology.

For more information about this topic: PLCnext Technology Info Center – Service Components – OPC UA Server

Example 1: Send information towards the OPC UA Server, acknowledgment and confirmation is not needed.

Program in PLCnext Engineer:

// The function block is used to register an alarm in the system.
// An alarm must always be registered before it can be used in the system.

ALM_REGISTER_1(ALARM := Alarm_1_State,
EXECUTE := xExecute_Alarm_1,
ALARM_ID := 'PumpStation_Drive_1',
ALARM_TYPE := 'Information',
SEVERITY := 100,
DONE => xDone_Register_Alarm_1);

// The function block is used to send alarm states to the OPC UA server.
// The ALM_STATE structure connected to ALARM holds the alarm state.

ALM_ALARM_1(ALARM := Alarm_1_State,
ACTIVE := xInformation, // Indicates whether the alarm condition is active.
MESSAGE := 'Engine running',
AUTO_ACK := TRUE,
AUTO_CONF := TRUE,
RESET := xReset_Alarm_1,
DONE => xDone_Alarm_1,
RETAIN_STATE => xRetain_Alarm_1);

The result in UaExpert:

Step 1

Example 2: Send a warning towards the OPC UA Server, acknowledgment and confirmation possible from the client

Program in PLCnext Engineer:

// The function block is used to register an alarm in the system.
// An alarm must always be registered before it can be used in the system.

ALM_REGISTER_2(ALARM := Alarm_2_State,
EXECUTE := xExecute_Alarm_2,
ALARM_ID := 'PumpStation_Drive_2',
ALARM_TYPE := 'Warning',
SEVERITY := 200,
DONE => xDone_Register_Alarm_2);

// The function block is used to send alarm states to the OPC UA server.
// The ALM_STATE structure connected to ALARM holds the alarm state.

ALM_ALARM_2(ALARM := Alarm_2_State,
ACTIVE := xWarning, // Indicates whether the alarm condition is active.
MESSAGE := 'Engine temperature higher than normal',
AUTO_ACK := FALSE,
AUTO_CONF := FALSE,
RESET := xReset_Alarm_2,
DONE => xDone_Alarm_2,
RETAIN_STATE => xRetain_Alarm_2);

// Extra information about this FB:

// With a rising edge at the RESET input an alarm can be acknowledged and confirmed
// by the alarm source (instead of the client).
// A new message with ACKED_STATE=FALSE and ACKED_CONFIRMED=FALSE
// (elements of the ALM_STATE structure; see below) is sent to inform the OPC UA server.

By calling the right function in UaExpert, you can confirm or acknowledge our test warning:

Step 2

Example 3: Send an error towards the OPC UA Server, acknowledgment and confirmation possible from the client and the PLC program

Program in PLCnext Engineer:

// The function block is used to register an alarm in the system.
// An alarm must always be registered before it can be used in the system.

ALM_REGISTER_3(ALARM := Alarm_3_State,
EXECUTE := xExecute_Alarm_3,
ALARM_ID := 'PumpStation_Drive_3',
ALARM_TYPE := 'Error',
SEVERITY := 300,
DONE => xDone_Register_Alarm_3);

// The function block is used to send alarm states to the OPC UA server.
// The ALM_STATE structure connected to ALARM holds the alarm state.

ALM_ALARM_3(ALARM := Alarm_3_State,
ACTIVE := xError, // Indicates whether the alarm condition is active.
MESSAGE := 'Engine temperature too high',
AUTO_ACK := FALSE,
AUTO_CONF := FALSE,
RESET := xReset_Alarm_3,
DONE => xDone_Alarm_3,
RETAIN_STATE => xRetain_Alarm_3);

// Extra information about this FB:

// With a rising edge at the RESET input an alarm can be acknowledged and confirmed
// by the alarm source (instead of the client).
// A new message with ACKED_STATE=FALSE and ACKED_CONFIRMED=FALSE
// (elements of the ALM_STATE structure; see below) is sent to inform the OPC UA server. 

// The function block is used to acknowledge an existing alarm.

ALM_ACK_3(EXECUTE := xAckAlarm_3,
ALARM_ID := 'PumpStation_Drive_3',
DONE => xDoneAckAlarm_3);

// The function block is used to confirm an existing alarm.

ALM_CONF_3(EXECUTE := xConfAlarm_3,
ALARM_ID := 'PumpStation_Drive_3',
DONE => xDoneConfAlarm_3);

Extra remark: UaExpert has also an event viewer.

event view

Note:

The Makers Blog shows applications and user stories of community members that are not tested or reviewed by Phoenix Contact. Use them at your own risk.

Discussion

Please login/register to comment
Login/Register
Newsletter
Never miss a new article
Sign up for the newsletter
Never miss news about PLCnext Technology
Get interesting content via newsletter four times a year
Receive exclusive information before all other users