SALARM
(FB)
FUNCTION_BLOCK SALARM
A Field Device can generate alarms to its associated Host Controller to inform it e.g. about certain process events or other events to state there are
some limitations of the capabilities of the Field Device for diagnostic reasons. The Host application may use the RALARM function block to receive these alarms.
The ID parameter identifies the slot of the Field Device the alarm is generated for. The ATYPE input shall contain the
alarm type. The ASPEC input shall contain the alarm specifier. The LEN input contains the length in byte of the additional
alarm information stored in the AINFO parameter.
The Variable given as AINFO parameter shall be at least of LEN byte.
If the alarm is transmitted successfully, the VALID output indicates that the alarm was received by the Host Controller.
If an error occurred, the ERROR output indicates an error and the STATUS output contains the error code.
Code-Example
PROGRAM SendAlarm
VAR
sender : CommFB.SALARM;
alarmPayload : ARRAY[0..3] OF BYTE := [0, 1, 2, 3]; // encoding for Profinet: USI (UInt16), ARRAY[0..n] OF BYTE;
ID : DWORD := CommFB.Constants.INVALID_ID;
END_VAR
ID := CommFB.SUBSLOT_ID(EN := TRUE, ID := PN_Device.DeviceID, SLOT := 2, SUBSLOT := 1);
sender.ID := ID;
sender.ATYPE := ProfinetCommon.AlarmType.PROCESS;
sender.ASPEC := 0; // 0 for process-alarm
sender.LEN := SIZEOF(alarmPayload);
sender.AINFO := ADR(alarmPayload);
sender();
IF(sender.DONE OR sender.ERROR) THEN
sender(REQ := FALSE);
END_IF
- InOut:
Scope
Name
Type
Comment
Input
REQ
BOOL
The function is invoked when the REQ input is equal to 1.
ID
DWORD
Handle of the slot of the alarm source
ATYPE
UINT
Type of the alarm
ASPEC
UINT
Specifier of the alarm
LEN
UINT
Length of AINFO data in bytes
AINFO
POINTER TO BYTE
Additional alarm information
Output
DONE
BOOL
Indicates that the alarm was received by the Host Controller
BUSY
BOOL
FB is busy
ERROR
BOOL
Error detected
STATUS
DWORD
Last detected status