What is a program safety line and why is it important?
A safety line is a piece of code that is placed before you program, this piece of code is important as it cancels out all of the modal codes that are currently active.
What is a modal code?
A modal code is a code that once it is "turned on" with a piece of code, it can not be turned off without a code. A modal code will stay active from program to program unless turned off.
This would be an a example of a safety line that I use in all of my programs
G00 G49 G17 G80 G50 M48 G90 G20
G00 (would cancel any codes that might be active), G49 (will cancel tool length offset that may be on from last program), G17 (will select my appropriate work plane XY), G80 (will cancel any canned cycles that may remain active), M48 (will enable feed rate override), G90 (set it to absolute in case incremental was used on last program), G20 (changes it to inches in case millimeters was used on last program).
I have found that the one that can tend to mess up most new users is forgetting to cancel canned cycles.
Here is a hole drill cycle and how it works,
G90 G81 X4 Y5 Z1.5 R2.8 F4.0
This will drill a hole @ x4.0 and 5.0 to a depth of - 1.5" and will retract to 2.8" when the hole is done @ 4imp.
If I wanted to drill multiple holes I could just add the hole location and it will remember the rest of the parameters,
(eg)
G90 G81 X4 Y5 Z1.5 R2.8 F4.0
x5y6
x6y7
x7y8
G80
This will drill holes in each of these locations, but if I forget to add the G80 after the holes are done it will continue to drill holes at whatever coordinate it receives after the fact. This could lead to some big crashes.
The Modal G Codes are:
Motion = {G00, G01, G02, G03, G38.2, G80, G81, G82, G84, G85,G86, G87, G88, G89}
(ie) G01 will stay active until any of the above codes are called.
For example, if I was using all G01 codes, I would not need to put the G code in front of the command as it is modal and will stay active until I cancel it,
(eg)
G01 x2.0
x3.0
x4.0
x5.0
rather than
G01 x2.0
G01 x3.0
G01 x4.0
G01 x5.0
Plane Selection = {G17, G18, G19} plane selection
Distance Mode = {G90, G91}
Feedrate Mode = {G93, G94}
Units = {G20, G21}
Cutter Radius Compensation = {G40, G41, G42}
Tool Length Offset = {G43, G49}
Return Mode in Canned Cycles = {G98, G99}
Coordinate = {G54, G55, G56, G57, G58, G59, G59.xxx} system selection
Path Control Mode = {G61, G61.1, G64}
M code can also have modal functions,
The Modal Groups for M Codes are:
Stopping {M0, M1, M2, M30}
Tool Change {M6}
Spindle Turning {M3, M4, M5}
Coolant {M7, M8, M9} (special case: M7 and M8 may be active at the same time)
Enable/Disable Feed and Speed Override Controls {M48, M49}
(copyright) Syil Canada 2009
Do not use with out permission
"Non-modal" codes have an effect only on the lines on which they occur.
(eg) G04 (dwell) is non-modal and is only good for the line that it is written on.