M-Functions (M)

M

M<v>

Triggers the M-function v. The timing and behavior depends on the definition of v in the development environment of TwinCAT.

M2 and M30 are internally defined. Both functions trigger a synchronization with the NC-channel. (See wait()-function, chapter Synchronization.) Both functions stop the execution of the GST-program. Due to this order the interpreter waits for the completion of the NC-channel before it stops.

In addition, M30 also resets all fast M-functions and H, S, T.

M-Functions (M) 1:

There must not be more than one M-function of type handshake in a block.

M-Functions (M) 2:

The M-functions M2 and M30 do not have to be defined by the user in the development environment of TwinCAT.

Example:

This example assumes the following definitions of M-functions:

M10:

 

Fast before move.

 

M11:

 

Fast after move.

 

M12:

 

Fast before move, auto-reset, reset M10, M11.

 

M20:

 

Handshake before move.

 

M21:

 

Handshake after move.

 

M02:

Program end.

Figure “ExampleM10M11M12M20M21” visualizes the programmed path and the activation of M-functions. The fast M-functions M10, M11 are reset by M12, which itself is reset automatically.

N10 G01 X10 F6000
N20 X30 M10 M20
N30 X50 M11 M21
N40 X70
N50 X90 M12
M02
M-Functions (M) 3:

Figure “ExampleM10M11M12M20M21”.