top of page

Eliminating calculations for offset entries

Almost every offset entry your operators make requires some kind of calculation to be done before an offset adjustment can be made. Say, for example, the mean value for a diameter to be turned is 3.2342 and its tolerance is plus or minus 0.001. After machining with the finish turning tool, the operator finds that the diameter being turned is 3.2351.

First of all, the operator must recognize that the diameter is getting dangerously close to its high limit (calculating the high limit for this diameter results in a value of 3.2352).

Second, the operator must know the target value. While most operators are told to shoot for the mean value of the tolerance band (3.2342 in our example), this may not always be the case. When you shoot for the mean value, of course, you’re only working with half the tolerance band – all parts will be at mean or above, never below the mean. For this reason, most manufacturing people would rather shoot for a value that allows a longer period of unattended operation. In this case, it would be a value closer to the low limit – below the mean. (Again, this is a single point turning tool – the external diameter it machines will grow as the tool wears.) Getting operators to understand and buy into this concept can be difficult, and it requires more effort and skill on the operators’ part.

Third, the operator must be able to calculate the deviation. This will be the actual amount of offset change. The value of the deviation can be calculated, of course, by subtracting the measured size (3.2351 in our example) from the target value (3.2342 if shooting for the mean value). In this case, of course, the deviation value will be 0.0009.

Fourth, the operator must be able to determine the polarity of the deviation. For most dimensions, subtracting the measured value from the target value will render the appropriate deviation. For our example, subtracting 3.2451 from 3.2342 renders a negative 0.0009. But of course, this may not always be the case. For turning centers with a reversed X axis (X plus is the direction toward the spindle center), the polarity for offsetting is also reversed. In any event, many entry-level operators struggle when it comes to determining the polarity of offset adjustments.

Wouldn’t it be nice if the operator could simply enter the measured value when they want an offset adjustment to be made? In our example, this value would be 3.2451. They would still have to be able to determine when the dimension is getting close to a tolerance limit, but nothing related to the target dimension, deviation, or polarity. This would dramatically simplify the task of making sizing adjustments – and would minimize the potential for entry mistakes (they would, of course, have to enter the measured value correctly – and in the right place).

How could this be done? Well, custom macro B gives us access to all offsets. It also gives us the ability to make arithmetic calculations. And it gives us the ability to set variables. We can even make tests to determine if entries are appropriate – and generate alarms if they are not. With these tools, we should be able to come up with a way to eliminate the task of making calculations before entering sizing adjustments.

One method of approaching this problem was shown in a CNC Tech Talk column some time ago. But it is somewhat crude, requiring very good communication between the programmer and operator. It is also a bit difficult to determine which workpiece attributes are controlled by each tool. While it does simplify the task of making sizing adjustments, the technique never really caught on.

I want to show it again, however, if for no other reason than to help you understand how the technique works.

Given our previous example, the target diameter to be turned on a turning center is 3.2342 inch. We’ll say that tool station number five holds the turning tool that machines this diameter. After machining – and determining that an adjustment must be made, the operator would normally adjust tool (wear) offset number five to input any discrepancy (by 0.0009 in our previous example).

But instead, our technique will allow the operator to enter the measured value (again, 3.2351) into a secondary offset. To determine the secondary offset number, the operator will add twenty to the tool station number.

The custom macro program will check to see if there is a value in the secondary offset (other than zero). If there is, the operator has just entered the actual size of the workpiece that is deviating from its target size. In this case, the program will calculate the deviation and its polarity, and adjust the primary offset for this tool accordingly (offset number five in our case).

In the main program, you can place this command at the beginning of every tool that requires the technique (note that this command must come before the turret index command). Remember, you only need this technique for tools for which an operator will have to make sizing adjustments. This means single point finishing tools.

  • .

  • N050 G65 P8002 T5. D3.2342 S3.22 B3.245 (Check to see if offset adjustment is necessary)

  • N055 T0505 (Finish turning tool)

  • .

In our example, line N050 will call the custom macro and specify the tool station number being used (with T) and the target value for the dimension that is being measured (with D). Note that our custom macro is even going to test the operator's input data to confirm that it is within allowable limits (maybe they measured the wrong diameter or entered the value incorrectly). If it is not, an alarm will be sounded. S specifies the small limit and B specifies the big limit.

Note that these values are not the tolerance limits. They are limits for allowable entry. The S value will be something smaller than the low limit of the tolerance band – the B value will be something bigger than the high limit.

In the custom macro, T is represented by local variable #20, D by #7, B by #2, and S by #19.

Here is the custom macro program.

  • O8002 (Custom macro to calculate and set offsets)

  • IF [ #[2020 + #20] EQ 0 ] GOTO 99 (If operator has not entered a value, exit)

  • IF [ #[2020 + #20] GT #19] GOTO 5 (If offset value is greater than small limit, go to N5)


  • N5 IF [ #[2020 + #20] LT #2] GOTO 10 (If offset value is less than big limit, go to N10)

  • #3000 = 101 (DIMENSION OFFSET TOO BIG)

  • N10 #[2000 + #20] = #[2000 + #20] + [#7 - #[2020 + #20]] (Adjust primary offset)

  • #[2020 + #20] = 0 (Set secondary offset back to zero)

  • N99 M9

Admittedly, the custom macro requires further explanation. The first IF statement determines whether a measured value has been entered. If there is no value in the secondary offset register (as will normally be the case), the operator does not want to make a sizing adjustment at this time – and the control will skip the rest of this program (going to line N99). Only when a value has been placed in the secondary offset will this first IF statement be false, and the program will move on to the next command.

For Fanuc controls, system variables in the 2000 series represent wear offsets. The current value of #20 (T coming from the call statement) is five. So the result of #[2020+#20] is #2025, which is value in wear offset number twenty-five – the register in which the operator will enter the measured value if an adjustment must be made.

The next two IF statements are testing to confirm that the entered value is within appropriate limits. If it is not, an alarm will be sounded. System variable #3000 is the alarm generator. If it is executed, an alarm will sound. But of course, if the entered value is above the small limit (S) and below the big limit (B), these commands will not be executed – and the control will end up at line N10.

Line N10 performs the deviation calculation (including polarity) and modifies the primary wear offset by the amount of the deviation. Notice that there is no longer a question about the target value (D from the call statement, which is represented by #7 in the custom macro). The target value is now programmed, meaning everyone will be shooting for the same value.

Finally, the command before M99 sets the secondary offset back to zero, so the next time the custom macro is executed, it will not try to make an adjustment.

This technique simply adds to your current abilities. That is, your people can still enter sizing adjustments with wear offsets just as they have always done. Your setup people or more experienced operators may elect to do so. But entry level operators will surely find this method of offset entry easier, faster, and less error prone than your current methods.

This may be all you need, but as stated, it can be a little complicated when more than one or two tools require regular sizing adjustments. Also, there is nothing that marries the workpiece attribute to be sized to the tool station number, meaning there is still plenty of room for making mistakes. And worst of all, incorporating this technique with current programs will require a lot of program editing – the more programs you have, the more programs there will be to modify.

So let’s build on the method just shown. Consider these two programs:

  • O0200 (Setup program – this program tells the control which dimensions are involved)

  • SETVN 501 [DIM A]

  • SETVN 502 [DIM B]

  • SETVN 503 [DIM C]

  • SETVN 504 [DIM D]

  • #521 = 3 (Station related to #501)

  • #522 = 5 (Station related to #502)

  • #523 = 6 (Station related to #503)

  • #524 = 8 (Station related to #504)

  • #531 = 3.25 (Target dimension related to #501)

  • #532 = 1.875 (Target dimension related to #502)

  • #533 = 2.75 (Target dimension related to #503)

  • #534 = 1.227 (Target dimension related to #504)

  • #541 = 0.1 (Entry error tolerance amount)

  • #542 = 4 (Number of dimensions – max is ten)

  • M99

  • O9000 (Macro called by T word)

  • #101 = FIX [#149/100] (Acquire station number)

  • #102 = 1 (Counter for loop - station number)

  • (Determine if tool is related to adjustments)

  • N1 IF [#102 GT #542] GOTO 99 (Test if finished)

  • IF [#101 NE #[520+#102]] GOTO 15 (Test for active tool offset number for adjustment)

  • IF [[#[500+#102] EQ 0 ] GOTO 99 (If operator has not entered a value, exit)

  • IF [#[500+#102] GT [#[530+#102]-#541] ]GOTO 5 (If offset value is greater than small limit, go to N5)


  • N5 IF [ #[500 + #102] LT [#[530+#102]+#541]] GOTO 10 (If offset value is less than big limit, go to N10)


  • N10 #[2000 + #101] = #[2000 + #101] + [#[530+#102] - #[500 + #102]] (Adjust offset)

  • #[500 + #102] = 0 (Set entry variable back to zero)

  • GOTO 99 (Exit)

  • N15 #102 = #102 +1 (Step counter)

  • GOTO 1 (Go back to test)

  • N99 T#149 (Index turret)

  • M99

The first program (O0200) is a setup program. You’ll have a different setup program for each job – and of course, this program is created by the programmer. It must be run once before the job can be run. This program tells the machine which adjustments you will be having operators entering with the new method. The maximum (with this example) is ten total adjustments. The SETVN commands (for set variable name) will place a short message (up to eight characters) next to the related #500 series variables. The operator will now be entering the dimension values into #500 series permanent common variables – and there will be a nice message to tell them which dimensions are involved.

Variables from #521 through #530 specify the tool station related to each dimension (meaning operators won’t even have to know which tools will be machining the given dimensions).

Variable #541 specifies the allowable deviation from the target dimension for entry. If the operator enters too big or too small a value, an alarm will sound. Variable #542 specifies how many dimensions are related to the current job.

The second program (O9000) will be automatically executed whenever a T command is specified in the program. In order for this to work, you must first change a parameter. This parameter is documented in your Fanuc Operator’s Manual in the custom macro section and is described in the next article of this newsletter. Again, once this parameter is set, the control will set common variable #149 to the tool station number (T word) and then execute program O9000. Notice that at the very end of this program a T word is specified to actually index the turret.

This custom macro determines if the current tool station is one that is involved with the critical dimensions specified with #501 through #510. If not, this program does nothing but index the turret. But if the tool station is one that requires entry, it makes the appropriate adjustment. It behaves much like the program shown earlier.

While this example has its limitations (it only works for X offset adjustments – though Z adjustments could be easily added), you should be able to see how this technique can really simplify the task of making offset adjustments for holding size – especially for very long production runs.

314 views0 comments

Recent Posts

See All
bottom of page