One advantage of any computer programming language is that you can use variables instead of hard-and-fixed numerical values. This can be especially helpful when the hard-and-fixed numerical value is repeated many times in the program.
One advantage of any computer programming language is that you can use variables instead of hard-and-fixed numerical values. This can be especially helpful when the hard-and-fixed numerical value is repeated many times in the program. If this value must be changed for any reason, the hard-and-fixed value must be changed in many places in the program. But if a variable is used instead, only one value in the program must be changed. A variable used for this purpose is commonly called a "system constant."
Think of how many times you use hard-and-fixed numerical values in CNC programs. Indeed, unless you're using custom macro techniques, every value in your programs is a hard-and-fixed value. Creating system constants may provide a way to minimize program editing at the machine when changes must be made. If applied for two or more CNC machines, you may even be able to make machines more compatible with system constants. Let's look at a few examples.
Rapid approach distance. Most programmers use a hard-and-fixed value for rapid approach distance. A common rapid approach distance is 0.1 inch (about 2.5 mm). This value is used for every approach (and retract or feed-off) in the program. Even for a short program, this value may be used several times.
If you decide to change the approach/retract distance, possibly to shorten program execution time, it's likely that you'll have many changes to make. But if you incorporate a system constant for approach/retract distance, only one value in the program needs to be changed. Here's an example:
O0001 (Program number)
#100 = 0.1 (Approach/retract distance)
N005 T01 M06 (Place tool one in spindle)
N010 G90 G54 G00 X1.0 Y1.0 S500
M03 T02 (Move to first position XY, start spindle)
N015 G43 H01 Z#100 (Instate tool length comp., move to first Z position)
Common variable #100 is the system constant for approach/retract distance and is currently set to 0.1 inch. In line N015 (and in all lines that require this value), we reference variable #100. If this is done throughout the program, changing rapid approach distance will simply require changing the value of variable #100 at the beginning of the program (one value).
Feeds and speeds. While many tools require only one speed and feed, there are tools that require more. Consider an end mill, for example, that plunges into a pocket at one feed rate and then machines the pocket at another. This requires two feed rate words in the program per pocket. If 50 pockets must be machined by this tool, changing the feed rate for this tool will require 100 commands to be changed. For this application, system constant can really help.
O0002 (Program number)
#100 = 2.0 (Plunging federate)
#101 = 4.0 (XY feedrate)
N150 T03 M06 (End mill)
N155 G90 G54 G00 X1.0 Y1.0 S600
M03 (Move to first XY position)
N160 G43 H03 Z0.1 (Instate tool length comp.)
N165 G01 Z-0.25 F#100 (Plunge into pocket)
N170 X2.0 F#101 (Start opening pocket in XY)
Machine compatibility issues. There is a more global application we'd like to share. Consider two similar machines that are made by different machine tool builders. Machine tool builders vary when it comes to M code numbering, even for identical functions. Say you have two turning centers. One uses M41 and M42 to select low and high spindle range. The other uses M23 and M25.
For this application, we'll use permanent common variables (#500 for low range and #501 for high range) in which to store the values related to range changing. For the machine that requires M41 and M42, we'll set #500 to a value of 41 and #501 to a value of 42. For the machine requiring M23 and M25, we'll set #500 to 23 and #501 to 25. Since we're working with permanent common variables, these values need only be set one time.
In each program, we'll use the word M#500 whenever the low range must be selected and M#501 whenever the high range must be selected. This allows the same program to be run on either machine.blog comments powered by Disqus