Back to top

The following video goes through the steps needed to create a subprogram (sometimes called User Defined Function Block or UDFB), call the UDFB in another PLC program, and monitor code inside the UDFB while a project is running. This is useful for when similar or identical code needs to be called in multiple locations or for multiple axis.

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.

A user found that when passing  structure to a sub-program (UDFB) that the data is shifted within the structure. All values are shifted down by one variable. This is an  IDE display (animation) issue.  The actual underlying data is correct.   The problem only occurs with the first Retain variable.  The immediate work around is to either create a dummy variable as the first Retain variable or if the first Retain variable is a structure, don’t pass it to a UDFB.

  1. The attached kUDFB named MLFB_AKDFAULT_5 will report up to 5 errors when called with an AKD servo axis using PipeNetwork Motion.

The following code shows calling the kUDFB then reading the  present drive faults of 2 different AKD drives:

The outputs to a function block call can also be looked at in the IDE watch window: