Supported M-functions

The supported M-functions are mapped in the SEW Robot Language by an IEC call function (CallFunction) as an event to be triggered. The machine-specific function in the IEC, such as enabling or disabling tools must be defined by the programmer. The names of the M-functions in the overview table are only for orientation to see 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 more information, refer to chapter IEC function call.

Before an M-function can be imported, it must be configured in Manual G-code import. There are 3 different behaviors available for switching time and continuation of the interpreter.

  • User code: The G-code import inserts only the command "CALLF" in the place of the M-function. The user can implement the exact time, wait for signals or values, or a specific behavior that performs 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 processing. By returning "FALSE", the user can prevent the interpreter from continuing, for example, to wait for a signal. The value CALL_FUNCTION must be set in the dialog for this purpose. See M1 Optional stop.
  • User code with stop point: The G‑code import inserts the "Wait MotionDone" command at the position of the M‑function, followed by "CallF". The interpreter stops at the wait command and in this way stops the feeding of further path segments. The interpreter executes the CallFunction only when standstill is reached. Here the behavior can be implemented as in option 1. In this way, the interpreter will not continue until the CallFunction "returns TRUE". The value EXACT_STOP_AND_CALL_FUNCTION must be set in the dialog for this purpose. See M0 Planned stop.
  • Path event: The G‑code import inserts a path event at the position of the M-function with the REG_PATH_EVENTREG_PATH_EVENT command, followed by the CallF command. As a result, the IEC call function is invoked at the beginning of the subsequent 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 more information, refer to chapter Path event. The value PATHEVENT_AND_CALL_FUNCTION must be set in the dialog for this purpose.

INFORMATION

Make sure that all the required indices of the M-functions have been implemented in the IEC as an IEC call function in the user program before executing the G-code. Furthermore, the implemented IEC function call for behavior 3 (path event) must return "TRUE" as a result during its first call. Otherwise, an error that will cause an emergency stop of the application will occur when triggering the path event.

The following example shows the implementation of G-code in the SEW Robot Language if all M-functions used have been configured with path event.

G1 X0 Y0

M3

G1 X350

M4

G1 Y350

M5

G1 X0

M543

G1 Y0

M30

Path events can be recorded using an activated pen (in the control panel of the 3D simulation). A ball marks the position on the path, on which the M-function was executed or the path event was triggered.

INFORMATION

If there is no travel command between the end of the program (END_PROG) and the end of a registered path event (REG_PATH_EVENT), the G-code import automatically adds an empty linear travel command (LIN_EXPLICIT without coordinates).
The empty linear travel command is needed so that a path event is permitted at the end of the program. This causes the point that was last entered (via X, Y, Z, A…) to be traveled to again and causes an exact stop.
If the imported G-code program is invoked as a subprogram via the SEW Robot Language command "CALL_PROG" and the aforementioned situation applies to this G-code program, an exact stop will be performed before exiting the subprogram. Avoid registering a path event at the end of a subprogram if no exact stop is to be performed upon exiting.

In the following example program, an empty travel command is required before exiting the program. Here is a path for which an action is enabled at the beginning and disabled at the end:

G1 X0

M3 ;Enable

G1 X250

M4 ;Disable

M30

For available M-functions, refer to chapter Overview of supported commands. (INFORMATION: The index 65535 is the maximum permitted index for M-functions.)

For M0, M1, M3..29, M31..47, M50..59, M61..M65535, the users 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 functions for G-code.