KAS Controller Error Subprograms
Attached are two subprograms that can be imported to the Project Explorer of the KAS IDE software. They are companions to the built in GetCtrlErrors function block which has a Q output that lets the user know if there is an active Alarm or Error, and will populate two boolean arrays of size 100 to let the user know which specific Alarms and Errors are currently active. These additional subprograms will go through these large boolean arrays and output the first found active Error (or if no Errors are found the first listed Alarm) to make it easier for a user to report to an HMI the fault number and a string description.
The first subprogram is CtrlErrorNumber. As shown below, you can use the first bit of the Q output of the GetCtrlErrors function block which is True when there is an active Error or Alarm. You should also reuse the same boolean arrays for ActiveErrors and ActiveAlarms that are populated by GetCtrlErrors as inputs for the CtrlErrorNumber subprogram. The boolean Error and Alarm outputs are mutually exclusive, so they will let you know if the Number output is for an active Error or Alarm.
If you want not only the error/alarm number but also a string based description, you can take the outputs of the CtrlErrorNumber function block and tie them to inputs of the CtrlErrorDescription subprogram.