Use of M-functions

The supported M-functions are illustrated in the SEW Robot Language by an IEC call function (CallFunction) as an event to be triggered. The machine-specific functionality, such as switching tools on or off, must be specified in the IEC program for the application. The names of the M-functions in the overview table are only to provide orientation about which functionality is assigned to the M-function in the respective dialect. The G-Code import transfers the specified number of M-functions to the index of the IEC call function. For further information, refer to chapter IEC function call.

Before an M-function can be imported or exported, it must be configured in the Manual G-code import/export menu. There, the following behaviors are available regarding the switching time and the continuation of the interpreter.

  • User code: The G-code import inserts only the "CALLF" command in the place of the M-function. The user can applicatively implement the exact time, waiting for signals or values, or a very specific behavior that executes the machine-specific functionality. The CallFunction is called as soon as the SRL interpreter reaches the command line. If the user code returns "TRUE" as return of the CallFunction, the interpreter continues with the processing. If "FALSE" is returned, the user can prevent the interpreter from continuing, for example to wait for a signal. For this, the CALL_FUNTION value must be set in the dialog. See M1 Optional stop.
  • User code with stop point: The G-code import inserts the "Wait MotionDone" command followed by "CallF" in the place of the M-function. The interpreter stops at the Wait command and thus stops the supply of further path segments. The interpreter does not execute the CallFunction until an idle state is reached. Here, the behavior can be implemented as in option 1. Thus, the interpreter does not continue until the CallFunction returns "TRUE". For this, the EXACT_STOP_AND_CALL_FUNCTION value must be set in the dialog. See M0 Planned stop.
  • Path event: The G-code import inserts a path event with the REG_PATH_EVENT command followed by the CallF command in the place of the M-function. As a result, the IEC call function is invoked at the beginning of the execution of the following path segment. The number of executable M-functions in a path segment is limited to 64. Additional M-functions can be called only in the following path segment. For further information, refer to chapter Path event. For this purpose, the PATHEVENT_AND_CALL_FUNCTION value must be set in the dialog.

For available M-functions, refer to chapter Overview: G-code commands supported in the SRL program. (INFORMATION: The index 65535 is the maximum permissible index for M-functions).

For M0, M1, M3..29, M31..47, M50..59, M61..M65535, the user themselves must program the desired action (e.g. a certain freely selectable output) in the IEC CallFunction. The corresponding IEC code examples can be imported. See also chapter Call function for G-code.