Lesson Six Text
Lesson Six Text
1
Parametric Programming Lesson Six: System Variables
System variables
Most CNC related features of parametric programming are handled with system variables. Like
any other variable in parametric programming, most system variables contain numeric values.
However, each system variable has a fixed function, and can only be used to reference its related
function.
Generally speaking, system variables allow the parametric programmer to access many machine
functions right from within the parametric program. Offsets, machine position, alarm generation,
and current machine states are among the accessible functions. With custom macro B, system
variables range in the #1000 through #6000 series. With user task and Fadal’s macro, system
variables are addressed with special system variable names.
Unfortunately, there are two reasons why this text cannot completely address the specific
techniques needed to utilize every system variable for every version of parametric programming.
First, the actual names of system variables vary from one version to the next, as does the actual
usage for given system variables. This makes it difficult to give firm examples for every version.
Second, and more importantly, names and usage for certain system variables vary even among
control models within a given control manufacturer’s product line. With Fanuc’s custom macro
B for example, the control model and even how the control is equipped with certain control
options determine the actual names of system variables. This makes it next to impossible to
show an example for every possibility.
For this reason, you must be prepared to reference you own control manufacturer’s programming
manual to determine which system variables are available with your particular CNC control/s.
Even with this limitation, this presentation should still nicely demonstrate applications for the
various system variables we show. It will be left up to you to relate these application examples
to your particular control/s. This should require little more than a cross-check of your control
manufacturer’s manual to determine a pertinent system variable’s name.
2
Parametric Programming Lesson Six: System Variables
center controls to turning center controls. To complicate the problem, almost all models in the
Fanuc product line can be equipped with a variety of offset-related alternatives, further changing
the system variable naming structure related to tool offsets.
For this reason, all of our system variable related presentations will be directed at one specific
machining center control (the 15M) and one specific turning center control (the 15T) in Fanuc’s
product line. Additionally, our presentation will be limited to showing each control’s most basic
offset configuration. Rest assured that all techniques we show can be accomplished with any
Fanuc (or Fanuc-compatible) control equipped with custom macro B. If you understand our
presentations, it will be a relatively simple matter to cross reference the related system variable
names based on your own particular control model/s and offset configuration.
Tool length and cutter radius compensation offsets
With the most basic tool offset configuration of the 15M machining center control, there is one
offset value per tool offset. The CNC program determines how the offset value is used (as a tool
length and cutter radius compensation offset). For this offset configuration, you will be using a
series system variables in the #2000 series. #2001 is the value of offset number one. #2002 is
the value of offset number 2. This continues up until the total number of offsets in the control (if
the control has 199 offsets, #2199 is the value of offset number 199).
As stated, you can read and write to and from your tool offsets. The command
#100 = #2001
for example, places the current value of offset number one in common variable #100. On the
other hand, you can also write to your offsets. The command
#2001 = #100
enters the current value of common variable #100 into offset number one. You must, of course,
be careful not to overwrite a needed offset.
Fixture offsets
Another series of system variables is related to fixture offsets (also called work shift offsets).
For the 15M control, these system variables range from #5201 through #5335. This series of
system variables assumes your control has but six fixture offsets. If you have purchased the
option for more, a completely different set of system variables is involved.
As you know, each fixture offset has at least three values (one for X, one for Y, and one for Z).
If your machine has additional axes, there will be more values in each fixture offset. Here is a
chart that shows the fixture offset system variables for a three axis machining center controlled
by a 15M control equipped with six fixture offsets.
Fixture offset #0 (common) Fixture offset #4 (G57)
X - #5201 X - #5281
Y - #5202 Y - #5282
Z - #5203 Z - #5283
Fixture offset #1 (G54) Fixture offset #4 (G58)
X - #5221 X - #5301
3
Parametric Programming Lesson Six: System Variables
Y - #5222 Y - #5302
Z - #5223 Z - #5303
Fixture offset #2 (G55) Fixture offset #4 (G57) Fixture offset #6 (G59)
X - #5241 X - #5281 X - #5321
Y - #5242 Y - #5282 Y - #5322
Z - #5243 Z - #5283 Z - #5323
Fixture offset #3 (G56) Fixure offset #5 (G58)
X - #5261 X - #5301
Y - #5262 Y - #5302
Z - #5263 Z - #5303
As with tool offsets, you can read or write to or from any fixture offset. The commands
#5221 = -12.1263
#5222 = -12.2245
#5223 = -13.2247
enter the value of fixture offset number one’s X as -12.1263, fixture offset number one’s Y as -
12.2245, and fixture offset number one’s Z as -13.2247. On the other hand, the commands
#100 = #5221
#101 = #5222
#102 = #5223
store the current X, Y and Z values of fixture offset number one into common variables #100,
#101, and #102 respectively.
Turning center wear offsets
Each turning center wear offset contains four values (X, Z, R, and T). A different series of
system variables gives you access to each type. Here is a chart that shows the wear offset related
system variables for a 15T control.
Offset X Z R T
1 #2001 #2101 #2201 #2301
2 #2002 #2102 #2202 #2302
3 #2003 #2103 #2203 #2303
. . . . .
. . . . .
99 #2099 #2199 #2299 #2399
As with any other offset, you can read and write to and from any turning center wear offset. The
command
4
Parametric Programming Lesson Six: System Variables
#100 = #2101
stores the current Z value of wear offset number one in common variable #100. On the other
hand, the command
#2101 = #100
enters the current value of #100 into the Z value of wear offset number one.
5
Parametric Programming Lesson Six: System Variables
#100 is actually the tool length compensation offset number being given a value. In line N2, the
control will first add 2000 to #100, resulting in a value of 2001. The pound sign outside the
brackets specifies that system variable #2001 (the value of offset number one) is being
referenced.
In chapter two, an application is shown that can take advantage of this technique. Here is the call
statement to the right side milling macro shown in chapter two.
N025 G65 P1000 X0. Y0. Z0. W5.0 H3.0 T0.5 D1.0 F5.0 (Mill right side)
In this call statement, letter address argument D is being used to specify the actual diameter of
the milling cutter. However, if you use cutter radius compensation on a regular basis, it may be
more convenient to let D represent the tool offset number in which the milling cutter’s radius is
stored. This will more consistently reflect the method by which your operators normally use
cutter radius compensation offsets. Here is the new call statement, with the modified D word.
N025 G65 P1000 X0. Y0. Z0. W5.0 H3.0 T0.5 D31.0 F5.0 (Mill right side)
Note that the value of D is now 31. The operator must, of course, store the radius of the milling
cutter in offset number thirty-one (0.500 if a 1” diameter cutter is used) before this program can
be run. Here is the modified custom macro program which takes advantage of this new
capability.
6
Parametric Programming Lesson Six: System Variables
.
Note that similar techniques can be used with system variables for other offset types (fixture
offsets and all kinds of turning center offsets).
In Okuma’s user task 2
Names for system variables related to offsets remain much the same among the entire Okuma
control product line. About the only major difference you will notice is between machining
center and turning center system variable names. Though this is the case, we still recommend
that you reference your programming manual from Okuma to confirm the names of offset-related
system variables.
Tool length and cutter radius compensation
The system variable name for tool length compensation offsets is VTOFH. A number in
brackets to the right of the system variable name specifies the tool length compensation offset
number. As with any offset, you can read and write to and from the offsets with this variable.
For example, the command
VTOFH[1] = V1
enters the current value of common variable V1 into tool length compensation offset number
one. On the other hand, the command
V1 = VTOFH[1]
stores the current value of tool length compensation offset number one in common variable V1.
In similar fashion, another system variable (VTOFD) handles the cutter radius compensation
offsets. The command
VTOFD[1] = V1
enters the current value of common variable V1 into cutter radius compensation offset number
one. The command
V1 = VTOFD[1]
stores the current value of cutter radius compensation offset number one in common variable V1.
You must, of course, be careful not to overwrite a needed offset.
Fixture offsets
Three more system variables (VZOFX, VZOFY, and VZOFZ) give you access to your fixture
offsets. (Note: If your machine has more than three axes, more than three system variables are
involved.) The commands
VZOFX[1] = V1
VZOFY[1] = V2
VZOFZ[1] = V3
enter the current values of common variables V1, V2, and V3 respectively into the X, Y and Z
positions of fixture offset number one. On the other hand, the commands
V1 = VZOFX[1]
V2 = VZOFY[1]
7
Parametric Programming Lesson Six: System Variables
V3 = VZOFZ[1]
store the current X, Y, and Z values of fixture offset number one into V1, V2, and V3
respectively.
Turning center offsets
With turning centers, the X and Z value of each offset is available with system variables VTOFX
and VTOFZ. The command
VTOFX[1] = V1
enters the current value of common variable V1 into the X position of offset one. The command
V1 = VTOFX[1]
stores the current X value of offset number one in common variable V1.
In similar fashion, the tool nose radius compensation values of each offset are available through
system variables VNSRX and VNSRZ.
A trick with system variable numbers
You will often need to manipulate the value in brackets (the offset number) when working with
offset related system variables. Note that this number can be referenced with a variable.
Consider these commands:
N1 TLGT = 1
N2 VTOFH[TLGT] = 6.5573
In line N1, the value of local variable TLGT is being set to one. In line two, this value (one) is
being used as part of the system variable for a specific tool offset. With this technique, TLGT is
actually the tool length compensation offset number being set. In line N2, TLGT is used to
determine which offset is being referenced.
In chapter two, an application is shown that can take advantage of this technique. Here is the call
statement to the right side milling macro shown in chapter two.
N025 CALL O1000 XZER = 0 YZER = 0 ZZER = 0 WIDT = 5.0 HGHT = 3.0 THK =
0.5 TDIA = 1.0 FEED = 5.0 (Mill right side)
In this call statement, local variable TDIA is being used to specify the diameter of the milling
cutter. However, if you use cutter radius compensation on a regular basis, it may be more
convenient to let a local variable, say TLFF, represent the tool offset number in which the
milling cutter’s radius is stored. This will more consistently reflect the method by which your
operators normally use tool offsets. Here is the new call statement, modified to use local
variable TLFF as the offset number in which the cutter’s radius is entered.
N025 CALL O1000 XZER = 0 YZER = 0 ZZER = 0 WIDT = 5.0 HGHT = 3.0 THK =
0.5 TLFF = 5.0 FEED = 5.0 (Mill right side)
Note that the value of TLFF is 5. This indicates that the radius position of offset number five is
being used in which to store the cutter’s radius. The operator must, of course, store the radius of
the milling cutter in offset number five (0.500 if a 1” diameter cutter is used) before this program
is run. Here is the modified user task program which takes advantage of this new capability.
8
Parametric Programming Lesson Six: System Variables
.
.
.
TLFF = 1 (Initialize counter for loop to first offset number to one)
N1 IF[TLFF GT 99] GOTO N5 (Test if finished with loop)
VTOFH[TLFF] = 0 (Set current tool length offset value to zero)
VTOFD[TLFF] = 0 (Set current cutter radius offset to zero)
TLFF = TLFF + 1 (Step counter)
GOTO N1 (Go back to test to see if loop is finished)
N5 . . .
.
.
.
Note that similar techniques can be used with system variables for other offset types (fixture
offsets and all kinds of turning center offsets).
In Fadal’s macro
Fadal also uses a series of system variables to allow access to offset data.
Tool length and cutter radius compensation
For tool length compensation offsets, you use a series of H codes that correspond to the offset
number. For example, the command
#H01 = V1
enters the current value of V series variable V1 into tool length compensation offset number one.
On the other hand, the command
#V1 = H01
enters the value of tool length compensation offset number one into V series variable V1.
In similar fashion a series of D codes allow access to cutter radius compensation offsets. The
command
9
Parametric Programming Lesson Six: System Variables
#D01 = V1
enters the current value of V series variable V1 into cutter radius compensation offset number
one. On the other hand, the command
#V1 = D01
enters the value of cutter radius compensation offset number one into V series variable V1. You
must, of course, be careful not to overwrite a needed offset.
Fixture offsets
Another series of system variables is related to fixture offsets (also called work shift offsets). As
you know, each fixture offset has at least three values (one for X, one for Y, and one for Z). If
your machine has additional axes, there will be more values in each fixture offset.
FX1 through FX48 allow access to the X value of each fixture offset. FY1 through FY48 allow
access to the Y value for each fixture offset. FZ1 through FZ48 allow access to the Z value for
each fixture offset. If your machine has a rotary axis, FA1 through FA48 or FB1 through FB48
allow axis to the rotary axis value of each fixture offset. For example, the commands
#FX1 = V1
#FY1 = V2
#FZ1 = V3
enter the values of V series variables V1, V2, and V3 into fixture offset number one’s X, Y, and
Z positions respectively. On the other hand, the commands
#V1 = FX1
#V2 = FY1
#V3 = FZ1
enter the values fixture offset number one’s X, Y, and Z positions into V series variables V1, V2,
and V3 respectively.
A trick with system variable numbers
You will often need to manipulate the system variable number when working with offset related
system variables. Note that the number of the system variable can be referenced with a variable.
Consider these commands:
N1 #V1 = 1
N2 #H(V1) = 6.5573
In line N1, the value of V series variable V1 is being set to one. In line two, this value (one) is
being used as part of the system variable name for a specific tool offset. With this technique, V1
is actually the tool length compensation offset number being set. Note that this variable (or
arithmetic expression) must be placed in parentheses. In line N2, V1 is used to determine which
offset is being referenced.
In chapter two, an application is shown that can take advantage of this technique. Here are the
calling commands to the right side milling macro.
.
10
Parametric Programming Lesson Six: System Variables
.
.
N025 #V1=0 ‘Assign argument V1
N030 #V2=0 ‘Assign argument V2
N035 #V3=0 ‘Assign argument V3
N040 #V4=5.0 ‘Assign argument V4
N045 #V5=3.0 ‘Assign argument V5
N050 #V6=0.5 ‘Assign argument V6
N055 #V7=1.0 ‘Assign argument V7
N060 #V8=5.0 ‘Assign argument V8
N065 M98 P1000 (Mill right side)
.
.
.
In line N055, V series variable V7 is being used to specify the diameter of the milling cutter.
However, if you use cutter radius compensation on a regular basis, it may be more convenient to
let V7 represent the tool offset number in which the milling cutter’s radius is stored. This will
more consistently reflect the method by which your operators normally use tool offsets. Here are
the new calling commands, modified to use V7 as the offset number in which the cutter’s radius
is stored.
.
.
.
N025 #V1=0 ‘Assign argument V1
N030 #V2=0 ‘Assign argument V2
N035 #V3=0 ‘Assign argument V3
N040 #V4=5.0 ‘Assign argument V4
N045 #V5=3.0 ‘Assign argument V5
N050 #V6=0.5 ‘Assign argument V6
N055 #V7=5.0 ‘Assign argument V7
N060 #V8=5.0 ‘Assign argument V8
N065 M98 P1000 (Mill right side)
.
.
.
Note that the value of V7 is now 5. This indicates that the radius position of offset number five
is being used in which to store the cutter’s radius. The operator must, of course, store the radius
of the milling cutter in offset number five (0.500 if a 1” diameter cutter is used) before this
program is run. Here is the modified macro program which takes advantage of this new
capability.
11
Parametric Programming Lesson Six: System Variables
12
Parametric Programming Lesson Six: System Variables
As extra variables
The first application we present has little to do with actually needing offsets for a special
purpose. We just want to mention that if you run out of variables for your parametic
programming applications, your offset table makes an excellent place to find more. As long as
you do not over-write a needed offset, you can use your offsets as a kind of permanent common
variable (since offset values are not lost when you turn the power off). Depending upon the
control model and type, you may have many unused offsets.
Improving upon compensation types
As you know, offsets are normally used with some form of tool compensation. Machining
centers require offsets for tool length compensation, cutter radius compensation, and fixture
offsets. Turning centers require them for wear offsets, (possibly) geometry offsets, and tool nose
radius compensation. While all of these compensation types are very important and most are
relatively easy to use, all compensation types are quite inflexible in the way they must be used.
In certain applications, you may not agree with the method by which they must be used. Or it
simply may not be convenient to use the compensation type in its intended manner. With
parametric programming, you actually have the ability to improve upon your current
compensation types with utility programs.
Here is a specific example. Say your turning center operators are constantly making decimal
point entry mistakes when entering turning center wear offsets. If, for example, they determine a
wear offset entry should be 0.002 in, they sometimes make a mistake and enter the value as
0.200 instead. To begin to improve upon your current tool wear offset compensation type, you
may determine that offset values should never be over a given amount, say 0.150 in (in your own
opinion). If any wear offset is larger than 0.150 in, it is very likely that an entry error has been
made.
By having wear offset values available to your parametric program for testing, you can actually
develop a series of tests to determine if any of the current offset values are greater than 0.150 in.
If they are, an alarm can be sounded!
In custom macro B
We’ll say that this turning center has twelve turret stations and that wear offsets one through
twelve must be tested in this manner (both X and Z). Here is the series of commands that do the
testing. Note that a loop is used to minimize the number of required commands.
.
.
.
#100 = 1 (Counter for loop)
N1 IF[#100 GT 12] GOTO 5 (Test if loop is finished)
IF[#[2000 + #100] LT 0.15] GOTO 2 (Test if X offset is under 0.15 in)
#3000 = 100 (X OFFSET TOO BIG)
N2 IF[#[2100 + #100] LT 0.15] GOTO 3 (Test if Z offset is under 0.15)
#3000 = 101 (Z OFFSET TOO BIG)
N3 #100 = #100 + 1 (Step counter)
GOTO 1 (Go back to see if loop is finished)
N5 . . .
.
.
13
Parametric Programming Lesson Six: System Variables
.
In the second and third IF statements, notice again how the system variable related to each wear
offset is referenced using a common variable (#100). The expression #[2000 + #100] first adds
the value of #100 to 2000 (result: 2001, 2002, 2003, and so on). The pound sign outside the
brackets allows the system variable number itself to be a changing value, based on the value of
common variable #100.
In user task 2
We’ll say that this turning center has twelve turret stations and that wear offsets one through
twelve must be tested in this manner (both X and Z). Here is the series of commands that do the
testing. Note that a loop is used to minimize the number of required commands.
.
.
.
TLFF = 1 (Counter for loop)
N1 IF[TLFF GT 12] GOTO N5 (Test if loop is finished)
IF[VTOFX[TLFF] LT 0.15] GOTO N2 (Test if X offset is under 0.15 in)
VUACM[1] = `X OFFSET TOO BIG’
VDOUT[991] = 100
N2 IF[VTOFZ[TLFF] LT 0.15] GOTO N3 (Test if Z offset is under 0.15)
VUACM[1] = `Z OFFSET TOO BIG’
VDOUT[991] = 101
N3 TLFF = TLFF + 1 (Step counter)
GOTO N1 (Go back to see if loop is finished)
N5 . . .
.
.
.
In the second and third IF statements, notice how the system variable related to each wear offset
is referenced the local variable TLFF. The coding VTOFX[TLFF] renders the value of the offset
number equal to the current value of TLFF (offset 1, 2, 3, and so on).
Any other ideas?
Remember that almost any compensation type can be improved, based upon specific problems
you (or your operators) are having. Many machining center controls, for example, force the
operator to work with very large, cumbersome tool length compensation values. If workpiece
sizing must be done on a regular basis (possibly to bring a critical pocket to its correct depth), it
can be difficult for the operator to calculate the direction (plus or minus) and amount of offset
change. And once they do, the must then add or subtract this value from a very large tool length
value in order to come up with the correct value of the offset. This task takes time and is error
prone, even for experienced operators. For those tools that require this kind of critical and
cumbersome sizing, you could easily add a special sizing offset. The operator will simply enter
the small deviation between the desired and actual pocket depth in this offset, making it much
easier to size the pocket. In the positioning command that brings the tool to the bottom of this
critical pocket, you can easily reference the value of this secondary offset, making the tool go
precisely to its correct depth. The same techniques can be used for cutter radius compensation
when critical tolerances must be held when performing peripheral milling.
14
Parametric Programming Lesson Six: System Variables
Figure 5.1
The turning operations for this workpiece are done by a screw machine. When setup, the screw
machine will run about 500-600 workpieces before tool maintenance is required. Note the rather
open tolerance on the overall length of the workpiece (plus or minus 0.002 in). During tool
maintenance on the screw machine, the overall length of the workpiece will change slightly.
Though the change in workpiece length is very small, and though the overall length is still well
within the tolerance band, this change in workpiece length can wreak havoc with the subsequent
CNC machining center operation due to the nature of the setup being used. Figure 5.2 shows the
setup.
15
Parametric Programming Lesson Six: System Variables
Figure 5.2
Note that eight workpieces are sandwiched and clamped against one another in the fixture.
When machining the hole in the outside diameter of each workpiece, any change in workpiece
length will cause an accumulation of error in the hole locations being machined on the
machining center.
Remember, about 500-600 blank workpieces are machined by the screw machine with no
deviation in workpiece length. It is only when a new batch of blanks come through (about once
per shift) that the CNC machining center operator must deal with this problem.
Admittedly, this may be more a fundamental problem with fixture design than it is a
programming problem, and your tool designer may be able to design a fixture that eliminates the
problem altogether. However, this is a real world example of the kind of problem a CNC person
faces on a regular basis - one that no standard compensation type is designed to solve.
With your new ability to access offset values from within a CNC program, however, you can
easily overcome this problem. A special tool offset (we’ll use offset number ninety-nine) will be
used in which to store the deviation between the nominal workpiece size (0.500 in) and the
actual workpiece size. If, for example, a batch of workpiece blanks comes through as 0.5007 in
long, the operator will simply store a value of plus 0.0007 in offset number ninety-nine. If the
blanks coming through are 0.4994 long, the operator stores a value of minus 0.0006 in offset
ninety-nine.
Here is a portion of the program shown in custom macro B format that counterbores the eight
holes (you should now be able to easily convert this program to any version of parametric
programming). Program zero is the left most end of the stack in X and the center of the
16
Parametric Programming Lesson Six: System Variables
workpieces in Y and Z. Notice how every hole location in X references the value stored in offset
ninety-nine.
.
.
.
N225 T03 M06 (Place counterbore in spindle)
N230 G54 G90 S700 M03 T04 (Select coordinate system, absolute mode, turn spindle
on, get next tool ready)
N235 G00 X[0.25 + #2099/2] Y-1.0 (Move into position for first hole)
N240 G43 H03 Z1.25 (Instate tool length compensation, rapid up close in Z)
N245 G82 R1.25 Z0.25 F4.5 (Counterbore first hole)
N250 X[0.75 + #2099 + #2099/2] (Second hole)
N255 X[1.25 + #2099*2 + #2099/2] (Third hole)
N260 X[1.75 + #2099*3 + #2099/2] (Fourth hole)
N265 X[2.25 + #2099*4 + #2099/2] (Fifth hole)
N270 X[2.75 + #2099*5 + #2099/2] (Sixth hole)
N275 X[3.25 + #2099*6 + #2099/2] (Seventh hole)
N280 X[3.75 + #2099*7 + #2099/2] (Eighth hole)
N285 G80 (Cancel cycle)
.
.
.
You can easily determine whether enhancing current compensation types or developing new
ones can help by watching and talking to your CNC operators. What kinds of problems are they
having? Are they making the same mistakes over-and-over again when adjusting offsets for
sizing purposes? Are they taking additional time performing (error prone) calculations before
they can even enter the offset adjustment? Are they having problems understanding the rational
behind how certain offset values must be entered? Do they have to measure one attribute in
order to determine the offset setting of another (measuring over the pins after a threading
operation, for instance). If the answer to any of these questions is yes, you can likely simplify
the value and method of offset entry. As stated, only your own ingenuity will limit what can be
done!
Referencing offsets in program zero assigning commands
If you are using offsets to assign program zero (fixture offsets on machining centers or geometry
offsets on turning centers), you can skip this section. On the other hand, if you are assigning
program zero in the program (with G92 on machining centers or G50/G92 on turning centers),
you will find this section very interesting indeed.
One of the advantages of using offsets to assign program zero is that the program zero
specification is kept separate from the program. Program zero assigning values are entered into
offsets by the operator during setup. This is especially helpful on turning centers when the same
cutting tools are commonly used from one setup to the next. For tools that remain in the turret
from job to job, program zero assigning values need not be changed.
While there are exceptions to this statement based on your methods of assigning program zero, if
you are assigning program zero in the program, it is likely that the setup person must re-enter the
program zero setting numbers for every tool in every setup (even for tools used from one
17
Parametric Programming Lesson Six: System Variables
production run to the next). This will take time and is quite error prone since four values per tool
must be changed. Here is a portion of a turning center program (in Fanuc format) that uses G50
to assign program zero from within the program. Note that this is a very common technique with
Fanuc-controlled turning centers that do not have geometry offsets.
18
Parametric Programming Lesson Six: System Variables
6.8277 in the Z register of offset number twenty-one. With this technique, only two entries (one
for X and one for Z) are required per tool. And when going from one production run to the next,
these values need not be re-entered for tools that stay in the turret.
Note that this technique can also be used on machining centers if you are using G92 to assign
program zero in the program (it is especially helpful if you are repeating the G92 command at
the beginning of each tool). The command (given in Fanuc format)
N005 G92 X[#2097] Y[#2098] Z[#2099]
retrieves the value in offset number ninety-seven and uses it for the X value of the G92
command. The value in offset number ninety-eight is used for Y, and offset ninety-nine is used
for Z.
Remember that this techniques overcomes but one of the limitations of assigning program zero in
the program. The most severe limitation, however, still exists. If the machine is not in its proper
starting position when the program is activated (the machine is out of position), the control will
utilize an incorrect program zero assigning command - and the results can be disastrous. Later,
as we discuss access to the machine’s position, we will show how to refine this technique, and
minimize the potential for disaster.
19
Parametric Programming Lesson Six: System Variables
#5061 - Current X position relative to the program zero point in the current coordinate system at
the instant of probe stylus contact
#5062 - Current Y position relative to the program zero point in the current coordinate system at
the instant of probe stylus contact
#5063 - Current Z position relative to the program zero point in the current coordinate system at
the instant of probe stylus contact
Two axis turning center:
#5001 - Current X position relative to program zero in the current coordinate system
#5002 - Current Z position relative to program zero in the current coordinate system
#5061 - Current X position relative to the program zero point in the current coordinate system at
the instant of probe stylus contact
#5062 - Current Z position relative to the program zero point in the current coordinate system at
the instant of probe stylus contact
In user task 2
User task 2 allows you to access the current absolute position relative to the program zero point
in the current coordinate system (the current absolute position) in each axis. For a three axis
machine tool, three system variables are involved.
VSIOX - Current X position relative to the program zero point in the current coordinate system
VSIOY - Current Y position relative to the program zero point in the current coordinate system
VSIOZ - Current Z position relative to the program zero point in the current coordinate system
In Fadal’s macro
Macro allows you to access the current absolute position relative to the program zero point in the
current coordinate system (the current absolute position) in each axis. For a three axis machine
tool, three system variables are involved.
AX - Current X position relative to the program zero point in the current coordinate system
AY - Current Y position relative to the program zero point in the current coordinate system
AZ - Current Z position relative to the program zero point in the current coordinate system
Applications for axis position access
There are several times when it can be helpful to find the machine’s current position from within
a parametric program. Here we offer a few.
20
Parametric Programming Lesson Six: System Variables
21
Parametric Programming Lesson Six: System Variables
22
Parametric Programming Lesson Six: System Variables
assume that all tools to be measured, assembled and loaded into the machine’s tool magazine
prior to running this utility program. Fourth, we assume that the setup person uses a three inch
block to touch each tool. This block is placed directly on the table top prior to tool measurement.
And finally, we will assume that your setup people will always have a series of tools in
consecutive tool stations to measure.
In custom macro B format:
Prior to using this program for the first time, the distance from the table top to the machine
spindle nose must be measured. This value will be placed in permanent common variable #500.
Note that this measurement is taken with the machine resting at its zero return position.
23
Parametric Programming Lesson Six: System Variables
the tool tip touches the block, they place the machine back in the automatic mode and reactivate
the cycle. The command
#[2000 + #102] = #500 - 3 - ABS[#5023]
correctly calculates the tool length value and places it into the tool offset corresponding to the
current tool station number. Remember that system variable #5023 is the distance in Z from the
machine’s zero return position to its current position. Since this value will be a negative number
(in our case), the absolute function is being used to reverse its sign. When this value plus an
additional three inches (for the block height) is subtracted from permanent common variable
#500, the result will render the tool’s length. This value is then placed into the current offset
specified as #[2000 + #102].
The program will then back the tool off slightly, step the counter to get to the next tool, and go
back to the test. This process will then be repeated for each tool to be measured.
With the exception of the stop with message command, the techniques used in this program can
be easily adapted to any version of parametric programming (use an M00 to replace the stop with
message command). However, both Okuma and Fadal have very helpful built-in functions that
adequately help the operator measure and enter tool lengths. For this reason, we do not show
this example in user task 2 of macro.
To help with the measurement of program zero on machining centers
Just as we can access machine position for purpose of measuring tool lengths, so can we do so
for the purpose of measuring the location of the program zero point. For machining center
applications, nothing beats a spindle probe for this function. However, if you do not have a
spindle probe equipped on your machine, believe it or not, these functions of parametric
programming even allow you to use a standard conductivity-type edge finder to handle just about
any application a true spindle probe is designed to handle. (By conductivity-type, we mean an
edge finder that incorporates a light that will illuminate the instant it comes into contact with any
metallic surface.) The only major limitation is that the actual task of touching the edge finder to
each surface must be performed manually. This ability opens the door for you to develop a
series of very helpful utility parametric program to facilitate the measurement of program zero
based upon your own specific program zero point specifications. Again, anything that can be
done with a true spindle probe can be done with an edge finder!
A corner pickup utility (custom macro B version)
This example will locate the lower left corner of a rectangular workpiece in X and Y. It will also
locate the top surface of the workpiece in Z. It will assume the use of an easy-to-use
conductivity-type edge finder. Since this program is to be used on a regular basis, we will utilize
two system constants. The radius of the edge finder (0.100) is stored in permanent common
variable #500 and the length of this edge finder is stored in #501. Once each surface location is
found, the distance from the machine’s reference point to the program zero surface will be stored
in fixture offset number one. Prior to running this program, the setup person will manually
position the edge finder about 0.5 in in each direction from the corner to be picked up (0.5 to the
left of the corner in X, 0.5 below the corner in Y, and 0.5 above the corner in Z).
24
Parametric Programming Lesson Six: System Variables
25
Parametric Programming Lesson Six: System Variables
.
.
In line five, notice that offset number twenty one is being used in which to store the program
zero assigning values (referenced by system variables #2021 and #2121). Remember these offset
values are equal to the distance from program zero to the tip of each tool while the machine is
resting at its zero return position. To these values we add whatever distance the machine may be
from the zero return position. If the machine happens to be at the zero return position, the values
of #5021 and #5022 will be zero. If the machine is to the negative side of the zero return
position, the values of these system will be negative. If the machine is to the positive side of the
zero return position, the values of these system variables will be positive. So regardless of the
machine’s position, the program zero assigning command will be correct. Note that this
technique even allows one more benefit of geometry offsets. In line N040, notice that you no
longer have to send the machine back to a special tool change position. Instead, you can
minimize cycle time by moving the tool to any location at which the turret can safely index.
26
Parametric Programming Lesson Six: System Variables
27
Parametric Programming Lesson Six: System Variables
N350 CALL O9101 TTLC=1500. (Call part counter utility, specify that fifteen hundred
workpieces are to be run, one per cycle)
M02 (End of main program)
Part counting custom macro utility program:
28
Parametric Programming Lesson Six: System Variables
.
.
.
N350 #V1=1500. ‘Set number of parts to run to 1500
N355 #V2=1.0 ‘Set number parts per cycle
N360 M98 P9101 (Call part counter utility)
N365 M02 (End of main program)
Part counting macro utility program:
29
Parametric Programming Lesson Six: System Variables
30
Parametric Programming Lesson Six: System Variables
31
Parametric Programming Lesson Six: System Variables
32
Parametric Programming Lesson Six: System Variables
33
Parametric Programming Lesson Six: System Variables
34
Parametric Programming Lesson Six: System Variables
Again, this example involves only the letter address arguments. But keep in mind that any value
that, if changed, would affect the correctness of calculations and tests can be included in the
check sum test.
35
Parametric Programming Lesson Six: System Variables
Access to timers
System variables #3001 and #3002 allow you to access the control’s internal clock/timer. #3001
is a timer that is incremented in milliseconds while #3002 is incremented in hours. For newer
Fanuc controls, you will also have access to the current time and date, giving you even more
control of what you can do with timer related functions.
These timers within the control are always running. However, you can reset the milliseconds
timer and hour timer by setting them to a value of zero. For example, the command #3001 = 0
resets the milliseconds timer. #3002 = 0 resets the hour timer.
1,000 milliseconds, of course, is equal to one second. Here is a simple example showing how to
use the milliseconds timer to make the control to pause for two seconds (just as the G04 dwell
command would).
36
Parametric Programming Lesson Six: System Variables
37
Parametric Programming Lesson Six: System Variables
38
Parametric Programming Lesson Six: System Variables
For all intents and purposes, exact stop check can be controlled by other means (G09 and G61)
so you typically do not have to use system variable #3004 for this purpose. But as with
suppressing single block, #3004 can be very helpful when you need to control feed hold and
feedrate override. If you have applications that require that feed hold and feedrate override be
suppressed (like tapping with G01), you can give the command #3004 = 3 just prior to the
commands in question.
After giving the motion commands, don’t forget to set #3004 = 0 to reinstated control of feed
hold and feedrate override.
Stop with message
Earlier in this chapter we discussed the #3000 alarm generating system variable. As you know,
this system variable, if read, will put the control into alarm state and display a message on the
screen. In order to continue with the program, the operator must reset the alarm.
There are times when you wish to stop the machine and give the operator a message, but you
want the operator to be able to continue with the program by simply pressing cycle start. Most
programmers use the simple M00 program stop for this purpose. If, for example, you wish to
stop the machine so the operator can clear chips and add tapping compound, you could give this
command.
N050 M00 (BLOW CHIPS AWAY AND ADD TAPPING COMPOUND)
However, if the operator is not monitoring the program mode while running the program, the
message in parentheses will not be seen. The operator will have to switch display screen modes
in order to see the message. The programmer can force the message to appear with system
variable #3006. However, with system variable #3006, the operator will be able to continue with
the cycle by simply pressing the cycle start button. Here is an example of the syntax for the stop
with message system variable. Note how similar it is to the alarm generation system variable
(#3000).
Access to modal information
The #4000 series system variables give you access to currently instated modal information. Here
are the various system variables in this series as well as their meanings.
#4001 through #4021 specify the currently active G code within each G code group. The various
G code groups are listed in the beginning of your programming manual. For example, for
machining centers, G00, G01, G02, and G03 are in G code group number one. To attain the
currently instated G code in this group, you could give this command.
#101 = #4001
39
Parametric Programming Lesson Six: System Variables
Group number two is plane selection (G17, G18, and G19). Group number three is Absolute and
Incremental modes (G90 and G91). Again, to see the complete list of G code groups, look in
your programming manual.
Here are other system variables in the #4000 series that allow access to modal information:
#4102 - Currently instated B word
#4107 - Currently instated D word
#4108 - Currently instated E word
#4109 - Currently instated F word
#4111 - Currently instated H word
#4113 - Currently instated M word
#4114 - Currently instated N word
#4115 - Currently instated O word
#4119 - Currently instated S word
#4120 - Currently instated T word
An application
For the most part, these system variables are not commonly required by the typical parametric
programmer. However, there is one time when their use may be helpful. Say you wish to use
the incremental mode for motions within a custom macro, yet you are unsure of the machine’s
current state relative to incremental and absolute mode when the custom macro is activated. At
the end of your custom macro, you wish to leave the machine in the state you found it. Consider
these commands.
40