# Using Variables To Handle Cutting Condition Changes

Variations in workpiece material and/or cutting tools will often require operators to change cutting conditions (mostly spindle speed and feed rate) during a production run. Most manufacturing companies do allow their CNC people to make these changes as they are required to do so.

Variations in workpiece material and/or cutting tools will often require operators to change cutting conditions (mostly spindle speed and feed rate) during a production run. Most manufacturing companies do allow their CNC people to make these changes as they are required to do so. And for the most part, changing speeds and feeds in a program is relatively simple. Many tools have but one speed word (S) and one feed rate word (F) per tool. In this case, it is quite easy for an experienced operator to find and scan to the one or two words in the program that must be changed.

While an experienced operator may be able to change cutting conditions with relative ease, a novice may find it more difficult. And if the novice changes the speed or feed for the wrong tool, the results could be disastrous. If you expect operators to change cutting conditions on a regular basis, you should do everything you can to make the task as simple as possible.

Consider those machining operations that have more than one speed or feed word. Maybe an operator is plunging into a slot in the Z axis with an end mill at one feed rate, but when he must begin milling in the X and Y axes, he also must switch to another feed rate. This, of course, requires two feed rate words per slot.

If there are 50 slots to mill, that equals 100 feed rate words for this tool.

Changing the feed rate for this tool becomes much more difficult for the operator. One way to simplify the task of changing cutting conditions is to start the program with a series of variables that specifies the various spindle speeds and feed rate words for all tools in the program. Be sure to place a nice documenting message next to each variable to clarify what the variable represents. During each tool’s specification of speed and feed, you will simply reference the value of the appropriate variable. Here is an example given in the custom macro B format.

O0001 #100 = 1200 (Speed for center drill)
#101 = 3.5 (Feed rate for center drill)
#102 = 800 (Speed for 1/2" end mill)
#103 = 2.25 (Plunge feed rate for 1/2" end mill)
#104 = 5.5 (X, Y feed rate for 1/2" end mill)
#105 = 800 (Speed for 1/2" drill)
#106 = 7.0 (Feed rate for 1/2" drill)
N005 T01 M06 (Place center drill in spindle)
N010 G54 G90 S#100 M03 T02 (Select coordinate system and absolute mode, start spindle, and get next tool ready)
N015 G00 X1.0 Y1.0 (Move to first hole position in X, Y)
N020 G43 H01 Z0.1 (Instate tool length compensation and move to approach position in Z)
N025 G81 R0.1 Z-0.12 F#102 (Drill hole)
N030 G80 (Cancel cycle)
N035 G91 G28 Z0 M19 (Return to tool change position and orient spindle)
N040 M01 (Optional stop)
N045 T02 M06 (Place end mill in spindle)
N050 G54 G90 S#102 M03 T03 (Select coordinate system, absolute mode, start spindle, get next tool ready)
N055 G00 X3.5 Y2.0 (Move to first XY position)
N060 G43 H02 Z0.1 (Instate tool length compensation, move to approach position in Z)
N065 G01 Z-0.25 F#103 (Plunge first slot)
N070 X5.5 F#104 (Mill first slot)
N075 G00 Z0.1 (Retract)
N080 X3.5 Y3.0 (Move to second slot)
N085 G01 Z-0.25 F#103 (Plunge slot)
N090 X5.0 F#104 (Mill second slot)
N095 G00 Z0.1 (Retract)

Although this column only presents a portion of the program, it should be enough to illustrate how the technique works. Notice the list of variables that begin the program (#100 through #106 are variable specifications in custom macro B).

Next to each variable, there is a clarifying message specifying exactly what the variable represents. #100, for example, is the speed for the center drill. In line N010, notice that the S word references the current value of #100, which is 1,200. The spindle will start at 1,200 rpm. The same technique is used in line N25 for feed rate. Notice how easy this technique makes it for the operator to change cutting conditions, even for the end mill that must machine multiple slots.