Using 'Safety Blocks' to begin the NC Code

While not all NC programmers will agree, Wahoo suggests that all NC programs should start with what are called 'Safety Blocks' of G and M codes at the start of the NC program. While it is true that some CNC controls will set motion and register defaults themself at program start, not all do and keep using whatever parameters were active when the last NC program was completed. It is also possible that someone else could change the defaults in the control without you knowing, and the results could be disasterous! If you simply make it a habit to include these defaults at the start of your files, or better yet set up your post processor in your CAM system to do it for you, there is a much less likely chance for surprises.

 

A complete listing on G and M codes are available at this site which discusses these codes is much more detail. For now, we will just talk a little about the ones that are recommended to be part of your 'Safety Block'. All G codes listed are for RS-274 compatible CNC controls. It is recommended that these defaults be programmed in your safety block:

1. Define the units of your program as either inch (G70 on most controls, occasionally G20) or metric (G71 on most, occasionally G21).
2. Define whether you are programming in absolute coordinates (G90) or incremental coordinates (G91). 'Absolute' means every coordinate is a distance from the Zero Location. 'Incremental' means that each location is the distance to be moved from the previous location.
3. Cancel any XY cutter compensation. This is usually achieved with a G40 command. Cutter compensation is the amount you want the CNC control to offset for the tool radius away from the programmed path. Using cutter compensation allows you to program to the part dimensions and have the CNC control automatically calculate the program to the tool center for you. It also lets you change the tool diameter without having to rewrite the NC program!
4. Cancel the tool length compensation, usually with a G49 command. The tool length command is used mostly for multiple tool NC programs so that each tool will cut to the correct depth, regardless of how far it extends out of the holder. Some machinists use it for single tool programs as well and always zero the Z coordinate using the tool length. Failure to cancel the previous tool length compensation carries a potentially high risk of crashing the tool.
5. Set the plane to the XY plane, almost always a G17 command. On most controls the plane selection effects how arc motions are cut. If the control is in the wrong plane, a broken tool and serious gouge could occur.
6. Some programmers, including Wahoo, like to cancel all cycles and coordinate modifications in the safety block. These codes are usually G80 to cancel any canned drill cycles and G53 to cancel any work coordinate shift. Additionally cancelling of any scaling and rotation functions can be added to the safety block. These codes vary greatly from CNC control to CNC control.
7. It is also good to add a default motion code inthe safety block. Most programmers will put a G00, rapid move, in the safety block since the initial move is almost always a rapid position move from the home location to the program start point.

So... a good safety block definition is:

G70 G90 G40 G49 G17 G80 G53 G00

Keep in mind, some controls have a limit to the number of G codes that can be on a line. These controls would need multiple lines for the afety block, in some cases a seperate linefor each code.

It is not usual for a CNC machine to need any default M codes in the safety block. If you machine has a programable brake and clamp through the M codes, you may want to add them as required.


Copyright 2000, Wayne and Anita Hohler
All rights reserved. Unauthorized duplication Prohibited.
Questions or Comments about this site?
Please send to webmaster@xmlcreate.com
See our Disclaimer