Available M-functions

Number of M-functions

A total of 160 M-functions are available per channel

M function

Meaning

0..159

Freely definable M-functions (except 2, 17, 30)

2

Program end

17

End of subprogram

30

Program end with deletion of all fast M functions

All M-functions (apart from the 3 pre-defined M-functions - M2, M17, M30) are freely definable. This means that, depending on the machine type, M8 can be used to switch on a cooling medium or indeed for any other functionality, for example. The machine manufacturer can select the function as required.

Like any other rules, the rules for reserved M-functions are read when TwinCAT is started. Additionally, an internal code is generated for these functions in the interpreter, which is responsible for the behavior described. These 3 M-functions therefore do not have to be described in the table. It makes sense to parameterize M2 and M30, even if M-functions are used.

Available M-functions 1:

Priority of M-Functions in the TwinCAT 3 development environment

If M-functions are defined as well in the m_defs.t<xx> file as in the development environment, only those M-functions act that are defined in the development environment.

Types of M-functions

Basically, two signal exchange versions are available: fast signal bits, or transfer secured by handshake.

Secured Handshakes

M-functions that require feedback must be processed using bi-directional signal exchange between the NC and the PLC. If an M-function of type handshake is programmed, the velocity is reduced to 0 at this point. The PLC uses the ItpIsHskMFunc function to check whether an M-function with handshake is present, in which case the number of the M-function is determined via ItpGetHskMFunc. The NC is in a waiting state and will not process further NC commands until the PLC has acknowledged the M-function. Processing of the NC program continues once acknowledgement has been received from the PLC (ItpConfirmHsk).

This procedure permits the operation of the equipment controlled by the NC to be securely coordinated with the equipment controlled by the PLC. It is therefore advisable to acknowledge the M-function for starting the spindle (e.g. M3) once a minimum speed has been reached.

Since this kind of M-function involves synchronous functions, it is only ever possible for one M-function with handshake to be active in the NC program.

Fast signal bits

If no feedback is required from the PLC, fast signal bits can be used for activating M-functions. Since the NC does not have to wait for the PLC with these M-functions, look-ahead can combine the segments. In this way it is possible to apply an M-function without velocity reduction.

A fast M-function can be detected in the PLC via ItpIsFastMFunc. This makes it possible to start any action from the PLC during a movement (laser on/off, cutter on/off, …). Afterwards the M-function has to be reset with ItpResetFastMFuncEx. This makes it possible to use the M-function more than once.

A combination of fast signal bits and handshake is also possible. Since a handshake always requires acknowledgement from the PLC, the velocity has to be reduced to 0 in this case.