Repeat initialized words at the beginning of all programs
As you probably know, initialized words those that are automatically instated at power up. Most are modal G codes that select the most common or desired choice for the modal state. And since there are many choices for modal states, many G codes are initialized.
As an example, consider the current motion type. G codes G00, G01, G02, and G03 control the most basic motion types – and all are modal. With many machines G00 (rapid motion mode) is initialized, meaning right after the power is turned on and before any other commands are given, any axis motion specifications (X, Y, and/or Z) will be executed at rapid.
There are some rather obscure – or at least not commonly thought of – G codes that are also initialized. And there correct setting is crucial to the successful running of the program. If the machine is not in the correct mode, the results could be disastrous. Consider the measurement system mode selection (Imperial or Metric). If you work in the Metric measurement system, your machine will initialize to the Metric mode – specified with G21 with many machines.
Many programmers assume that certain initialized words are still in effect when their programs are run. This can be a terrible – and often dangerous – mistake. With this example (Metric system selection), the programmer may not be including a G21 close to the beginning of the program. Again, they’re assuming the machine is still in the Metric mode from power up. But if someone has selected the Imperial (inch)measurement system mode – possibly by running a program since power up that required it – the machine will be in the imperial system mode when the program requiring the Metric measurement system mode is run.
In this case, the machine will take the millimeter specified coordinate in the program as inches. 200.0 mm will be accepted as 200 inches. All commanded motions will travel much further than intended. At the very least, the machine will probably over-travel in one of the axes. Worse, the machine may cause a tool to go crashing into a workpiece or fixture.
For this reason, we urge programmers to include a series of commands at the beginning of all program to ensure that initialized modes are still in effect when the program is run. I call them safety commands since they are of paramount importance to safely running programs. Here is an example for a machining center.
N001 G17 G20 G23 (Select XY plane, inch mode, cancel stored stroke limit)
N002 G40 G50 G64 (Cancel cutter radius compensation, cancel scaling, select normal cutting mode)
N003 G67 G69 G80 (Cancel modal custom macro call, cancel rotation, cancel canned cycle)
Note that many controls allow only three compatible G codes per command, which is why multiple safety commands are given.