Safety feature for servo axis while running the CNC program

we are using a 4 CNC mapp Axis for the project (using MpCnc4Axis FB) and pneumatic units are controlled using the M-codes. while running the part program (G-code and M-code file)one of the cnc axis needs to be run when pneumatic unit is in reverse actuation condition. If the pneumatic unit is forward and cnc axis rotates it could damage the pneumatic cylinder. So we wanted a safety feature where , when the part program is running even if the pneumatic unit is actuated forward before the cnc axis movement then the cnc axis should not run or it should throw an error signal (we want to control the cnc axis externally for safety purpose).

M45 (Here pneumatic unit is triggered FWD)
G90 A50 F50 (Here Cnc axis run is programmed “it should not run the axis”)

Our CNC System does not have a special interface for such use-Cases.
The only general supervision is the Workspace Monitoring which can’t be used for such a Case.

I understood that you want to protect the machine, if a user does Programm a wrong CNC-File. Error Condition: “Cylinder is forward and Axis Rotating”.

1. Supervision in Application:
a.) Make a Task in the Application which runs in a high Priority (TC#1) and Throw an Error to the Axis, if the condition is violated. This will Stop the Axis an Throw also an Error to the CNC System.

CommandError.Execute := Gripper.Forward AND ABS(MC_ReadActualVelocity_0.Velocity) > 0.001; 
IF CommandError.Busy THEN 
CommandError.Execute := 0; 


There is also an MC_BR_GroupCommandError if you want to only use it for a AxesGroup. But i think in this case it is better to use the Axis one, as it will also work if no Group is moving. Cylinder is Forward and Someone causes SingleAxis movement.

b) If the error recovery is to difficult you can use other Interfaces to stop movement of the Axes-Group. But the issue is that they are normaly not used exclusive for “Safety” so there might be an issue that it causes conflicts with other functions.

  • MC_GroupSetOverride
    Override := MachineOverride * SafetyOverride;
    SafetyOverride [0.0 ; 1.0]

  • MC_GroupInterrupt

2. Programmed Checks via M-Function or similar
You can create a M-Function which is blocking as long as the condition is Error = TRUE

But this will need a good Programmer which can be trusted, and even then tested or reviewed Programms.

I think you actualy mentioned that this can’t be garanted.


An alternative you may consider is using SafeMC on the CNC axes. You would need a SafeMC drive, as well as a SafeLOGIC safety PLC, so it’s not without hardware requirements.
For example, a safe MC drive could implement the Safe Operating Stop (SOS) on the CNC axes when the pneumatic cylinder is forward. The Safe Operating Stop feature would cause a drive error if any of the axes tried to move while that condition is present.

See AS Help: B&R Online Help (