Professional Documents
Culture Documents
PROGRAMING
CUSTOM MACRO "A"
and
CUSTOM MACRO "B"
L.......__~___..
[_______ X__J H= Number
of holes
Copyright 1988, CNC Concepts, Inc.
Table of Contents
TABLE OF CONTENTS:
Page: Description:
It is the intention of this video course to give the sru.dent as many of the techniques
as possible for the successful use of Custom Macro as it relates to the FANUC
control. We will be showing many possible applications for this powerful program-
ing tooL We should point out, however, that Custom Macro should be considered
one of the advanced programing features, and we assume that the student bas a good
understanding of manual programing for the FANUC control prior to viewing this
course. This assumed understanding should include an knowledge of tool radius
compensation and all canned cycles.
Also, Custom Macro is NOT a standard feature on most FANUC controls. It must
usually be purchased as an option. If you do not currently have Custom Macro on
your control, remember that it can be added as a "field installable" option at any time
on most FANUC controls (Series 0, 3, 6, 7, 9, 10, 11, and 15 controls) by calling
FANUC at (312) 364-9115 and ordering Custom Macro.
This course will include information on the two different versions of Custom Macro
available from F ANUC, the ''A" version and the "B" version. The entire course for
both versions is ten hours long. The first eight hours (or so) will discuss Custom
Macro "B". The last two hours of the course will discuss Custom Macro "A". Since
many of the techniques for both versions of custom macro are very similar, and since
Custom Macro "A'' requires that the programer first develop the program in "B"
format, Custom Macro "A" programers should view the entire course, while Custom
Macro "B" programers will be finishing the course after the first eight hours.
Generally speaking, the control series number will determine which version of
Custom Macro will apply. The series 0 and 3 (OT, OM, 3T, and 3M) will only allow
Custom Macro "A" to be used. Series 6, 7, 9, 10, 11, 12, and 15 will allow either
version, but usually these controls will be utilizing Custom Macro "B" if the custom
macro option is purchased. The "B" version is, by far, the more "powerful" and easier
to use version of Custom Macro. If you are adding Custom Macro to a machine, we
would suggest that the "B" version be chosen if possible.
At several points during the course, we will be asking you to turn off the VCR and
do practice exercises. We urge you to do each practice exercise to get the most from
the class. The answers will be given on video tape, so you can easily evaluate how
you are doing.
Custom Macro can be related to one of the standard features of the F ANUC control,
the Sub program technique.
From your previous experience with programing for the F ANUC control you should
remember what the sub program (or sub-routine) technique is. You may already
know that sub program techniques (M98, M99, P word, and L word) allow the
programer to keep from having to program many "redundant" commands over and
over in a program. However, the sub program technique bas one major limitation.
If ANYTHING in the sub program is not totally redundant, the sub program
technique cannot be used.
You can think of Custom Macro as having the sub program technique with the ability
to perform tasks that are not totally redundant. That is, you will have the ability to
pass "variables" to the Custom Macro that inform the Custom Macro of the areas
that are not totally redundant. You can prepare what could be considered more
"general purpose" sub routines. Custom Macro also allows many other "computer
related" features that make it much more helpful than the Sub Program technique
that is a standard control feature.
We should point out that the original intention from FANUC for Custom Macro
was NOT to give the USER (you) this powerful programing aid. The original
intention was to give the MACHINE TOOL BUILDERS a way to add several
options that would not otherwise be possible without Custom Macro. The probing
system, in process gaging, and tool length measurement are among the features that
the machine tool manufactures could not have supplied without Custom Macro. It
may be helpful to keep this original intention in mind as you learn Custom Macro.
If you encounter problems in learning this sophisticated tool, this may help you
understand why custom macro is not extremely "user friendly".
Even though this is the case, Custom Macro, when understood, makes an extremely
valuable tool. It is really quite amazing what can be done with this feature. But
Custom Macro is not for everyone. It takes a person with the right mental attitude
to successfully work with Custom Macro. You really have to like working with
Custom Macro to be effective.
We often relate Custom Macro to many of the "high level" computer languages like
BASIC, FORTRAN, C LANGUAGE, and PASCAL. Many of the techniques
available in these languages are also possible in Custom Macro. If you already know
one or more of these languages, you are well on your way to learning Custom Macro.
If you do not know one of these languages, we would strongly recommend that you
purchase a beginners book on BASIC to help you understand Custom Macro.
Without some form of computer programming experience in your background, it
will be more difficult to learn Custom Macro.
Knowing these things about Custom Macro, lets take a look at some of the most
popular applications for Custom Macro. Good applications for Custom Macro can
be broken into three basic categories.
FAMILIES OF PARTS:
The first category is probably allows the most opportunity for the end user (you). If
you find yourself programing many similar parts on a daily basis, you probably have
a good application for Custom Macro right off the bat. Custom Macro allows you
to write a "general purpose" program that will "behave" differently based on the
values you have given the Custom Macro for the workpiece. The distinct advantage
of this technique is in a reduction in programing time. Many times the operator of
the machine can simply fill in a set of "variables" instead of having to prepare the
entire program. By using this technique, programing time can be kept to a minimum.
The difficult question to answer with this application will always be related to the
extra programing time required to prepare the Custom Macro. For an experienced
Custom Macro programer, it will generally take about three to four times as long to
prepare a Custom Macro that will handle all possibilities related to the family of
parts than it will to prepare an actual CNC program to machine one part. So you
can see that if you have a limited number of variations on the parts (not a large
enough family of parts), it may not always be wise to write a Custom Macro.
Machining centers:
1) Bolt hole pattern Custom Macro
2) Pocket milling Custom Macros (round and rectangular)
3) Face milling Custom Macro
4) Circle milling Custom Macro
As mentioned earlier, there are two formats for Custom Macro: Custom Macro "A"
and Custom Macro "B". The first thing to know is which version you will be working
with. Generally speaking, if you company owns a 0 series or 3 series F ANUC control
(OT, OM, 3T, or 3M), you will be working with the "A" version. If your company owns
a 6 series, 7 series, 9 series, 10 series, 11 series 12 series, or 15 series F ANUC control,
you will be working with version "B". There are some exceptions to this rule, so we
will now give a test that you can perform at the machine to determine which version
your company owns. Please perform this test now if there is any question about
which version you have.
One easy way to test for Custom Macro "B" is to simply press the key corresponding
to "SET' or "SETIING" on the control panel several times. As you press this key
the second or third time, the control will show the "LOCAL VARIABLES" page on
the display screen if you have Custom Macro "B".
To test for Custom Macro "A", press the key corresponding to "OFFSET'. Then
press the "PAGE FORWARD" (down arrow) key until you are past all the offsets.
On the page following the last offset page, you will see the "VARIABLES" page.
If both of these tests are unsuccessful, this particular machine does not have Custom
Macro. You will have to purchase this feature from "FANUC" if you want to attain
the Custom Macro option.
Please perform these tests now to determine which version of Custom Macro your
company owns.
Now lets look at some of the differences between Custom Macro "A" and Custom
Macro "B". If your company owns only machines that has Custom Macro "B" we still
recommend that you pay attention to our discussion here of Custom Macro "A". This
will give you a good appreciation of Custom Macro "B" and make it easier to relate
when we get to the Custom Macro "B" discussions.
If your company owns a machine with Custom Macro "A", you really must be
acquainted with both versions of Custom Macro to be truly effective. This may
sound a little funny, but we will find that to prepare a version "A" Custom Macro
program, it is easier (and almost mandatory) to first write a "B" version Custom
Macro program and then translate it to "A" version format.
Lets look at good comparison of the actual limitations of both versions. This will
help you see why we say that the "B" version is much more "powerful". Some of the
terms may not be fully understood at this point in the course, but rest assured that
we will cover them completely as the course goes on.
Using version "A" format, you must break this down into two commands. For
example, add 2 to 3 as one command. Then subtract 2 in another command. This
will make it easier to translate the "B, version Custom Macro into "A" version. If
this does not make complete sense at this time, please bear with us until we see our
first example a little later.
First, you can "pass" variables from the "main program" to the Custom Macro. When
you do this the variable that is being passed is called an "argument" of the call
statement. As previously stated, this allows you to develop a "general purpose"
Custom Macro that will "behave" differently based on the "arguments" (variables)
set in the call statement. In the Custom Macro we can reference the arguments in
any required way to make the Custom Macro function properly.
Second, you can use variables in the Custom Macro to do arithmetic calculations.
Many times you will be using this technique to have the Custom Macro do the math
that is required for the application.
There are four different types of variables to Custom Macro; local variables,
common variables, permanant common variables, and system variables. Later, we
will be talking about the four types of variables at length.
Arithmetic Calculations:
This feature of Custom Macro allows the programer to do almost anything that can
be done on a scientific calculator right in the Custom Macro. Among the many things
we can do are: 1) Add, 2) Subtract, 3) Multiply, 4) Divide, 5) Sine, 6) Cosine, 7)
Tangent, and 8) Arctangent. This give you the capability to do quite complex
calculations in the Custom Macro to come up with axis coordinates, feedrates, arc
radii, and any value that must be calculated.
Conditional Branching:
This feature gives the Custom Macro it's decision making capability. We will be
calling this feature the "IF STATEMENT'. You can set up tests in the Custom Macro
to test for just about anything, and you will find many uses for the "IF STATEMENT'.
If you are familiar with BASIC, you will find that the "IF STATEMENT' in Custom
Macro is not as flexible as the one in BASIC, but you can structure your IF
STATEMENTS to accomplish just about any task required.
As you can see, Custom Macro has MANY very nice features to open the door to
more advanced programing techniques. Now that you have a basic understanding
of what Custom Macro is, and have been introduced to some of it's features, lets
start looking at how you program Custom Macro.
You will find that activating a Custom Macro in version "B" is very similar to
activating a sub program. If you have Version "A", please pay attention since we will
build on the information we present here in the next section.
You should remember that the "M98" command "calls" a sub program.
Example:
N050 M98 P1 000;
This command calls subprogram number 01000. As you know, when the control
reads this command, it "jumps" to program 01000 and continues executing from
there until the control reads an "M99" command which sends it back to the main
program.
To call a Custom Macro, we will substitute the "G65" word for the "M98" word.
(Custom Macro "B" version only)
So the command:
N050 G65 P1 000;
Would do exactly the same thing as:
N050 M98 P1 000;
However, the "G65" command will allow us to also "pass" variables to the Custom
Macro. Variables being "passed" to the Custom Macro are represented by letter
addresses and their corresponding values. Not all letters can be used as ,variables.
Some are "reserved" for only their primary function. Here is a list of the variable
letters that CANNOT be passed to a Custom Macro:
G, L, N, 0, and P
For reasons that we will discuss quite a bit later, we also recommend NOT using I,
J, and K as letter addresses to pass variables to a Custom Macro.
A full example of the entire "call statement" from the previous bolt circle example
in the last session follows.
Variable: Description:
#101 X position to the center of the bolt hole circle
#102 Y position to the center of the bolt hole circle
#103 Top surtace of the part in "Z"
#104 Radius of the bolt hole circle
#105 Number of equally spaced holes on the bolt circle
#106 Starting angle for first hole
#107 Feedrate to machine
#108 Cycle type (81 = drill, 84 = tap, etc)
Version "B"
Equivalent: Version 11A" format call statement:
#101 = 1.5 N050 G65 H01 P#1 01 015000 (four place
format)
#102 = 2.375 N060 G65 H01 P#1 02 023750 (four place
format)
#103 = 0 N065 G65 H01 P#1 03 QO (no format for value of
zero)
#104 = 1.5 N070 G65 H01 P#1 04 015000 (four place
format)
#105 = 8. N075 G65 H01 P#1 05 as (just number of holes)
#106 = 45. NOSO G65 H01 P#1 06 045000 (note three
place format for angle)
#107 = 5. NOSS G65 H01 P#1 07 Q500 (note two place
format for feedrate)
#108 = 81. N090 G65 H01 P#1 08 Q81 (just cycle type, no
need for format)
N095 M98 P1 000 (this is the actual command to
activate the Custom Macro.
For now, this is all we will present for version "A". Hopefully, if you work with version
"A", this is making sense. If not yet, please remember that tape number five will
cover this further.
As mentioned earlier, one of the more helpful features of Custom Macro is the
ability to use variables. We said you can develop a general purpose Custom Macro
that will behave differently based on the current setting of the variables. Generally
speaking, you will be using variables for three different purposes:
1) To pass .. arguments,. (variables) from the ,.main program .. to the
Custom Macro.
2) To have a 11 Storage place,. for the answers to arithmetic calculations.
3) To allow access to machine related 11 Current states,..
Passing arguments from the main program to the Custom Macro:
Lets begin by looking at how you will be passing arguments to be used by the Custom
Macro from the main program to the Custom Macro. In the last handout, we gave
some information related to how to activate a custom macro. You saw that a "G65"
statement commanded that the Custom Macro be called. The "P11 word told the
control which Custom Macro to call. Following the "P" word you can have a set of
letter address "arguments11 that will be passed to the Custom Macro for this particular
call statement. The Custom Macro will behave differently based on the arguments
in the call statement.
In the Custom Macro, you will be referencing these arguments to get the Custom
Macro to do what you want it to. However, in the Custom Macro itself, you will not
be allowed to refer to the argument as the letter address. This is because the control
would think it was an actual CNC command. So, in the Custom Macro, we must
"translate" the letter address of the argument into the ''pound sign" ( #) number
corresponding to the letter address. Nate that ALL variables in the body of a Custom
Macro are represented by "pound sign" ( #) numbers.
Here is a chart that shows how the Custom Macro arguments in the call statement
are represented in the Custom Macro: (This is "argument assignment" number one.
This is the most commonly used assignment type. Later we will look at argument
assignment number two and discuss it's purpose.)
Lets "mark up" the print to show the actual argument names (letter addresses) we
wish to name the variables in the call statement.
-W-
..
I
I
)
A
11
y l X
-
~~
I
I
I
+
D z L I
'
An example program that would use this Custom Macro could look something like
this:
00001
NOOS G92 X1 0. Y1 0. Z1 0.
N015 G90 8400 M03
N020 GOO XO YO
N025 G43 H01 Z1. MOB
N030 G65 P1000 XS. YO. ZO. 01. A4. T.S (Call statement)
N035 G91 G28 ZO
N040 G28 XO YO
N045 M30
The "first attempt" at the Custom Macro to do this could be:
01000
GOO x@-(!)1 Y-(!)+.11
z-@+.11
G01 Y@(!) + .1] FS.
Gooz@t.sJ
M99
You can easily test to see how many variables are on your particular machine by
looking at the variable pages on the control. (By pressing the "SET' or "SETTING"
key several times for version "B" or the "OFFSET' key and page down key for version
"A".
ARITHMETIC CALCULATIONS IN A
CUSTOM MACRO
We have stated that you can do almost everything that is possible on a scientific
calculator right in a Custom Macro. This means that very complex math calculations
can be combined in a Custom Macro to accomplish almost any math related task.
This section of the course will be devoted to showing you how to do this. First, lets
look at the different math operations that can in a Custom Macro. We must point
out that different control types from F ANUC will have different capabilities related
to math operations. What we show here is common to all FANUC controls. You
might want to check with your F ANUC operation manual to see if you have more
features than we are showing here. Also, we are showing the format for the "B"
version of Custom Macro here. In the last video tape we will be showing the format
for version "A".
Operation: Description: Example:
So, knowing this priority, you should be able to evaluate this set of Custom Macro
instructions:
#100 = 6
#101 = 15
#102 = 9
#103 = [#100 + #101] I SQRT[#102]
In the last statement, first the control will add #100 to #101 (6 + 15 or 21) since it
is in brackets. Then it will attain the square root of# 102 (square root of 9 is 3). Last
it will divide the result of #100 + #101 (21) by 3. And the result of this combined
expression will be 7. Please study this if it is not entirely clear.
One last point to make about variables at this time. For Custom Macro version "B",
if a variable has not been set to a value, it is referred to as "vacant". That is it has no
value. Please do not confuse this with the variable having a value of zero. Zero is a
value. But when a variable is vacant, it is ''blank" or "empty". It's value is not zero.
The Custom Macro representation for vacant is #0. At this point we know this
cannot be entirely clear, but when we look at the IF STATEMENT a little later, we
will show a time when this will be important.
For Custom Macro version "A" programmers, there is no such thing as vacant. If a
variable has not been set to a value, it's value is zero.
l
_j
For example, if you are developing a Custom Macro that is designed to use a right
hand or left hand tool, one of the arguments in the call statement can be used to
"inform" the Custom Macro as to which type of tool you are currently using. An IF
STATEMENT can be used in the Custom Macro to test what the value is for the
testing argument. If the argument is set for a right hand tool, you can have the
Custom Macro tum the spindle on in a clockwise direction (M03). If the argument
is set for a left hand tool, you can have the Custom Macro tum the spindle on in a
counter clockwise direction (M04 ).
The IF STATEMENT can be used for many different applications, but there are
only a limited few categories of applications for the if statement:
1) Testing for ..flags .. from the call statement and internal to the Custom
Macro.
2) .. Presetting .. variables from the call statement.
3) Testing for erroneous information in the call statement to generate
an alarm.
4) Generating .. loops ...
Before we show some applications for these categories, lets first look at the correct
format for the IF STATEMENT.
True
>
IF[ variable condition variable ] GOTO sequence number
tFalse
The IF STATEMENT will always allow for two possible results. Either the IF
STATEMENT will determine that the condition is true or false. If the condition is
true, the IF STATEMENT will cause the Custom Macro to branch to the sequence
number specified. If the IF STATEMENT determines the condition to be false, the
next line in the Custom Macro will be executed.
You can have the Custom Macro test for a variety of conditions. You can test for
equal to, not equal to, greater than, less than, greater than or equal to, and less than
or equal to.
There are many ways to set up your tests in the if statement using the EQ, NE, LT,
GT, LE, and GE conditions for the test that will work. Here is another section of a
Custom Macro that will generate the same end result:
01001
IF [ #7 GT 0 ] GOTO 5
M04
GOTO 10
N5M03
N10 ...
M99
Note that this version is just as correct as the previous example. There are some
general recommendations we make to make you IF STATEMENTS more estheticly
correct:
1) Try not to test against equality. Sometimes the processor of any
computer will become a little confused and the values you are
testing will never truly be equal. To the control a value of 1. may
be taken as 1.0000000000001 . For all intents and purposes, the
value is one, but a test for equality against 1.0 will never be true.
2) Always set up your IF STATEMENT in a way that the control can
nget outn of the test. It is possible to set up an IF STATEMENT in
a way that it gets 11 Stuck 11 More on this later.
Now lets look more closely at the different categories for the IF STATEMENT.
There may be more than we are discussing here, but these are the most basic ones.
Testing for ''flags" from the call statement or internal
to the Custom Macro.
Many times, you will be passing "flags" from the call statement to the Custom Macro
to inform the Custom Macro as to how to "behave". The previous clockwise/counter
clockwise application is an example of this. Other examples would include:
Machining_center:
1) Climb or conventional milling
2) Allowing extra "stock 11 for milling
3) Clockwise/counter clockwise spindle direction
The first IF STATEMENT tests #7 ("D") for vacancy. If #7 is not vacant, this means
it has been included in the call statement and the next command in the Custom
Macro ( #7 = 1.) will be skipped. If #7 is vacant (not included in the call statement)
this test will not be evaluated as true so the next statement in the Custom Macro will
be executed and the value of #7 will be 1. (for clockwise). The rest of the Custom
Macro is identical to what has been shown earlier.
This type of test can be repeated in the Custom Macro for all arguments to be preset.
As you get deeper into Custom Macro programing, you will find that many of your
arguments in the call statement can be preset.
Testing for erroneous information in the call statement
to generate an alarm:
Even a well written Custom Macro will behave poorly (and possibly dangerously) if
the person using the Custom Macro makes a mistake in the call statement. Many
times, tbe author of a good Custom Macro can test the information in the call
statement for mistakes. If a bad condition exists, the Custom Macro can actually
generate an alarm (put the machine in alarm state) and print an alarm message on
the display screen.
To do this we must understand one of the "system variables", the #3000 system
variable. This variable, if read, will put the machine in alarm state. Lets look at an
example to get the idea.
Say for example that you are developing a Custom Macro for grooving on a turning
center. And two of the arguments to be included in the call statement are the width
of the groove (as "W") and the width of the tool (as 'T'). The width of the groove
must (of course) be equal to or greater than the width of the tool. As the author of
this Custom Macro, you could make a test at the beginning of the Custom Macro to
guarantee this.
GENERATING LOOPS
Here is our recommended structure for a loop. Some of these steps may not be
necessary for all loops, but try to stick to this basic structure.
1) Initialize all necessary variables, counters and constants.
2) If necessary, make original positioning moves.
3) Test to see if the function being accomplished by the loop is
completed.
4) If necessary, make any required calculations that will be changing
from one pass through the loop to the next.
5) Make any cutting movements that are to be accomplished in each
pass through the loop.
And since eleven (finish) minus one (start) is ten, the loop will be repeated ten
times. As you develop your own Custom Macros, you will be prone to having the
loop repeated one too many or one too few times. This mistake is very easy to correct
at the machine by changing the counter initialization by one in the desired direction
(higher or lower).
Hopefully you can understand what is going on in the previously example. But if
not, please study it until it makes sense.
Now lets look at a much more complicated example. This example will really take
everything we have talked about so far and "put it all together".
In this example, we will show (from planning to writing) all that is required to write
a Custom Macro for machining a bolt hole circle. Obviously, this is a machining
center example, but turning center people should also pay close attention to the
structure of the loop. Part of planning to write a Custom Macro is to make a drawing
of the application (Or "mark up" an existing drawing). This provides much of the
necessary documentation for others using your Custom Macros.
y
H= Number of Holes
o..r------=-- - - - - - ' C=Cycle Type (C8l. =Drill)
~- X-~a-~1 F = Feedrate for Cycle
I j I I
.I I
0 I ' I
dJ
I 'I
d.J
Another small problem that may not be apparent yet, but we will also have to come
up with the "incremental angle" between the holes. Hopefully you agree that if we
divide 360 by the number of holes to machine, we will come up with the incremental
angle between the holes. This will be included in the structure of our Custom Macro.
Knowing this, we can feel confident that our most basic solution is correct and we
can begin writing our "first attempt11 at the Custom Macro.
#1 01 = 1 (Initialize Counter)
Initialize #1 02 =(A) (Initialize 11 Current angle II to A)
=
#103 '36o (Initialize incremental angle)
#1 01 = #1 01 + 1 (Step Counter)
Step Counters
#1 02 = #1 02 + #1 03 (Step Current Angle)
Go Back To Test GOT01
2) Always 11 desk check 11 your loop one more time prior to entering it
into the machine. It is easy to make a mistake and get the control
11
hung upu or 11 Stuck 11 in the loop if the logic in the loop is incorrect.
3) Sometimes, when you are really having trouble coming up with a
complex loop, you may be ready to give up before getting started.
When you are ready to give up, we recommend that you WRITE
SOMETHING! It is always easier to tell when a Custom Macro
WON'T work than it is to tell when it will. By having something in
writing in front of you, even if it is wrong, it may give you a clue to
help you do it right. Experienced computer programers may be
laughing at this point, saying, uveah I've had to do that beforel 11
This is a technique (not very well respected) that is considered
11
hackingu away at a program.
4) If you have studied the FANUC operation manual about Custom
Macro, you may have noticed a statement called the WHILE
STATEMENT. This command is intended for looping, but we do
not recommend using it for two reasons:
A) There is a limitation of three WHILE STATEMENTS
in a Custom Macro, meaning you could only have
three loops. There is no limitation to the number of
IF STATEMENTS in a Custom Macro.
B) It is just as difficult to develop a WHILE STATEMENT
loop as it is to develop an IF STATEMENT loop. You
still have to initialize a counter and step the counter.
We refer you to the FANUC manual if you want more
information on the WHILE STATEMENT.
Now that we have given most of the "raw tools" available in Custom Macro, we want
to present several recommendations regarding some finesse techniques. It is almost
impossible to sit down and write a complex Custom Macro without prior prepara-
tion. If you follow these techniques, you will "set yourself up for success". Without
these preparations, you will find that you will often times be duplicating effort
correcting mistakes that could have been avoided with some good planning.
There are three "levels" of mistakes that you can make when you write a Custom
Macro. Preparation can help you avoid alll three levels of mistakes.
1) Basic .. syntax" mistakes: This type of mistake could be simple typing
mistakes or a simple misunderstanding of the format required of a
particular command. These mistakes are very easy to find and
correct.
2) Simple evaluation: mistakes An example of this type of mistake
would be a counter problem in a loop where the loop is not
repeating the correct number of times. Or maybe you referred to
the wrong variable in a calculation. This kind of mistake is a little
more difficult to find, but the basic Custom Macro is going to work.
3) Basic mistakes in your solution to the problem: This is the most
difficult kind of mistake to correct. Preparation will really help keep
you making this kind of mistake. These mistakes occur when you
THINK that your solution to the Custom Macro will work, but it
won't. Usually this kind of mistake requires that you start all over,
and you will have wasted all the time that you have in the Custom
Macro so far.
Knowing these things about the kinds of mistakes you can make, you can see why we
stress preparing to write a Custom Macro so strongly. Lets look at the recommen-
dations. They are given in the correct step by step order:
1) Limit the Custom Macro. Before starting. get it clear in your head
as to what the Custom Macro really has to do. It is very easy to get
.. carried away" and have the macro grow into a 11 monster" that will
be almost impossible to write. Take some time to really study the
application. Nothing is more frustrating than getting halfway
through writing the Custom Macro. and then finding some 11 extra 11
feature the Custom Macro must handle that you haven't planned
for.
For complex Custom Macros the verification procedure could be quite difficult.
Sometimes it will be difficult to determine what is wrong with an "almost right"
Custom Macro. FANUC allows a two almost "hidden" ways to help you verify
Custom Macros. One of these ways involve parameter settings. Each version of the
FANUC control will have different parameters, so we will not be able to be too
specific about exactly which parameters are involved. But we will at least "point you
in the right direction".
Once a Custom Macro is ready to run, we recommend the following procedure:
1) Do a "machine lock dry run" to make sure that the control can at
least understand your Custom Macro.
2) With the arguments in the call statement set to the most simple
possible condition, dry run the Custom Macro to check axis
motions.
3) Manipulate the arguments in the call statement to become
progressively more complex, doing dry runs for each condition.
4) Run the Custom Macro one more time without dry run to verity that
cutting motions are where they should be.
5) Cautiously run your first workpieces with the Custom Macro.
This set of procedures assumes that everything is going well and that there are no
"fatal errors" in you Custom Macro. But more often than not, you will have some
problems that will cause you to take a close look at the Custom Macro again. When
this occurs, there are some things you should know about to make this task a little
easier.
1) You have the1ability to view local and common variables while the
Custom Macro is being run. To do this with version "B" Custom
Macro, press the key corresponding to "SET" or "SETTING" several
times until the "LOCAL VARIABLE" page is shown on the display
screen. Then use "PAGE FORWARD" and "PAGE BACK" (arrow
up and arrow down) to see the various variable pages.
The machine lock dry run will turn up any 11 syntax" mistakes. These are mistakes that
cause the control not to be able to recognize your Custom Macro. They are usually
easy to locate and correct. With this kind of mistake the control will always give you
an alarm number that will give you a good clue to what is wrong.
Simple evaluation mistakes will be a little more difficult to find. This is because the
control WILL be executing your program and not generating any alarms. But still,
strange things are happening. For example, you could have set up a loop improperly,
and the control is "stuck" in the loop. It just goes on and on, and never finishing.
This is a time when the access to viewing your variables will be handy. You could
monitor the "counter.. variable and see if it is changing.
And the last type of mistake is almost "fatal". It is a time when your Custom Macro
is doing exactly what you told it to do but it is not working. Maybe you set up a
calculation that you thought was correct, but it was not. These are the most difficult
kinds of problems to find and correct. Sometimes, you will have to "go back to the
drawing board 11 and start over from scratch.
As mentioned much earlier in the course, you have access to many 11 machine related"
features with Olstom Macro that would not be possible without Custom Macro. Not
all of these features will be of immediate need to you. In fact, this is the point in the
class that you will hear us say often that "It is more important to know that these
features are possible than it is to know exactly how to use them". In the future, if
you come up with an application that requires the use of one of these features,
hopefully you will recognize it.
Most of these features involve what are called "system variables". The only system
variable we have introduced so far was the #3000 alarm generating system variable.
Now we want to present more system variables. You might also want to refer to your
FANUC operation manual for more on system variables. What we will show will be
more related to the "implications" of when the system variables would be used than
to actual in depth examples.
Interface system between Custom Macro and option devices:
The first machine related feature we will discuss (briefly) is an elaborate interface
system to the machine using OJstom Macro. For most of us, this system is so
complicated and difficult to use that we will never be using it. Also, you will probably
never need to. This system is used to interface option devices like the probe,
in-process gaging, and post process gaging to the machine. If such a device is included
on your machine, all of the "dirty work" of developing the interface by Custom Macro
will have already been completed by the machine tool builder or the manufacturer
of the option device.
This system allows "input and output signals" to be transmitted back and forth
between the option device and OJstom Macro. For example, with the probe,
whenever the probe contacts something, a signal must be sent to the Custom Macro
to let the OJstom Macro "know" that contact bas been made. These signal "input
and "output" positions are actual connector "pin locations" on a printed circuit board
internal to the control.
A Olstom Macro can "monitor" these "pin locations" by a set of system variables.
For "inputs11 to Custom Macro a series of #1000 system variables are assigned. For
"outputs" from Custom Macro, a series of# 1100 system variables are assigned. The
number of input and output signals available will vary from one version of the
FANUC control to another.
Please keep in mind that you will probably never have the application to use the
techniques for the# 1000 and# 1100 series system variables in your Custom Macros.
But if you have one or more of these option devices, this may give you a little insight
into how these devices function.
G54 G57
x... #5221 x... #5281
Y... #5222 Y... #5282
2 ... #5223 2 ... #5283
8 ... #5224 8 ... #5284
G55 G58
x... #5241 x... #5301
Y... #5242 Y... #5302
2 ... #5243 2 ... #5303
8 ... #5244 8 ... #5304
G56 G59
x... #5261 x... #5321
Y... #5262 Y... #5322
2 ... #5263 2 ... #5323
8 ... #5264 8 ... #5324
These are the system variables corresponding to fixture offsets for the 10 and 11
series FANUC control. We recommend that you consult your FANUC operation
manual if you have a different control type just to be sure.
Access to clock timer: (Version "B" only)
For version "B" only, another nice feature to keep in mind for future use is the clock
timer. This feature will come in handy if you are developing a Custom Macro that
requires that you keep track of elapsed time (Uke a tool life management Custom
Macro). There are two different system variables related to the timer. #3001 counts
time in milliseconds. #3002 counts time in hours. There are 1000 milliseconds in a
second, 60000 milliseconds in a minute, and 3600000 milliseconds in an hour.
But you can use a Custom Macro to do this. System variable #3004 controls both
of these functions. Here is a chart of how this system variable can be set:
#3004 = 0 (feed rate overide and feed hold are effective)
#3004 = 1 (only feed hold is suppressed)
#3004 = 2 (only feed rate overide is suppressed)
#3004 = 3 (both feed hold and feedrate overide is suppressed)
Now lets look at a Custom Macro for tapping that uses these features. This Custom
Macro is very limited. We are only showing the suppression features:
01007
#3003 = 1 (disable single block)
#3004 = 3 (disable feed hold and feedrate overide)
G01 Z1. F22.0 (tap into hole)
MOS (stop spindle)
M04 (reverse spindle direction)
Z.25 (feed back out of hole)
#3003 = 0 (enable single block)
#3004 = 0 (enable feed hold and feedrate overide)
M99 (end Custom Macro)
Access to current state value of "G'~ "B'~ ''D", "E", "F~ "H~ "M~ "S'~
and "T' words: (Version "B" only)
Yet another nice feature (available with version "B" Custom Macro) is the ability to
attain the current state of almost any programing word available in CN C programing.
The implications of this feature are not extremely easy to understand. There are not
too many times you (as the end user) will need this function. But the manufacturer
of option devices (like the probe) who are supplying the Custom Macros to drive
the device to many different customers, are more interested in this feature. It lets
the programer attain the current state of the machine, change the machine's state in
the Custom Macro, and then put the machine back in the state it was found at the
completion of the Custom Macro.
The only example we will give relates to the G90 and G91 on a machining center
(absolute and incremental mode). Some CNC programers like to program in
absolute mode and others like to program (at least sometimes) in incremental mode.
Knowing this, the author of the Custom Macro can attain the current state (G90 or
G91) at the beginning of thte Custom Macro. Then sele:ct the mode required in the
Custom Macro. When finished, he can put the machine back in the state in which
it was found.
After the probe contacts a surface, the programer can attain the current X, Y, and
Z positions in the following way:
01008
G31 X... (G31 is the "skip cutting" commandfor the probe. It tells the control
to stop moving as soon as the probe makes contact. More on this later.)
#1 01 = #5061 (attains the cu"ent X position and stores it in variable
#101.)
. M99
Protecting Important Custom Macros:
When you have a Custom Macro that is extremely important, and you want to keep
from accidentally editing or deleting it, you can "protect" your most important
Custom Macros (and even CNC programs). To do this the name of the program
must be in the 8000 or 9000 series. By the way, you can "alter" the program number
at any time right at the machine.
This technique requires that you know the parameter number that controls the
protection of the two series of programs. You can find this in the list of parameters
in the F ANUC operators manual. If you are having trouble finding the parameter
for your particular control, feel free to contact CNC Concepts Inc. for help. (312)
882-9295.
Once the proper parameter has been set for protection, you can rest assured that
the programs in the 8000 or 9000 series of programs cannot be altered or deleted.
Creating new "G'~ "M~ and "T' codes with Custom Macro:
(Version "B" only)
Creating new G codes: (Version "B" only)
When you have often used Custom Macros, you may want to consider changing the
call statement format from "G65 P .... " to just a new G code. You can use any available
G code you want and the G code can even be in the 100 series (G101, G102, etc).
But you will want to be careful not to choose a G code that is already being used.
Always check your G codes Jist at the beginning of the F ANUC operation manual
when you want to use a G code under 100.
As a Custom Macro programer, you can create a new function for an M06. If you
set parameter 7080 (on 10, 11, 12, or 15 series) to six, whenever the control reads an
M06, it will execute program number 09020. You can load this Custom Macro into
the control as 09020 to guarantee that the Z axis will go to zero return position prior
to the tool change:
09020
G91 G28 ZO (go to zero return position in Z)
M06 (tool change)
M99
With the way Custom Macro works, the M06 that is in the Custom Macro will NOT
execute 09020 again, it will simply execute the tool change.
There is one more possible good application for this if you have a pallet changer that
is activated by subroutine. We will introduce this when we look at some advanced
variable techniques a little later.
At this point in the course, you should have a good understanding of some basic
techniques using variables. In our applications so far, you have been basically using
variables as a place to store the results of arithmetic calculations. And this really is
the primary use for variables. In this section, we would like to go a little further in
our discussion of variables.
If you are a beginner to computer programing, some of these discussions may not
make complete sense the first time through. You will want to review this several
times to get all of the "implications" of what we are saying.
Argument assignment number two: (Version "B" only)
To this point, all of the examples and practice exercises we have done have used
argument assignment number one. Earlier we gave you the "legal" letter address
arguments available. At this point it should be almost second nature to use this
argument assignment type. We know, with argument assignment number one, we
can choose A, B, C, D, E, F, H, I, J, K, M, Q, R, S, T, U, V, W, X, Y, and Z as our
arguments in the call statement.
But there is another way (less often used) to assign our call statement arguments.
This technique is helpful when the number of variables required in our call statement
is not the same from call statement to call statement. We take a closer look at this
feature a little later in this section.
Applications for #500 series common variable usage:
As mentioned earlier, the #500 series common variables will be "remembered" by
the control even after the power is turned off to the control. This makes a very nice
way to do many things with Custom Macro that will be continued from day to day.
The applications we discuss here are just the "skeletons" of the Custom Macros. We
just want to introduce the various possibilities.
When the end of program (M30) is read, they could be set back to vacant. (By the
way, a parameter controls whether the #100 series variables are set back to vacant
at the execution of an M30.)
Another application for this technique would be if you are trying to come up with a
special Custom Macro to control feeds and speeds or tools to be used in the
application. For example, if you had an application that uses three tools, you could
set up a Custom Macro to determine the proper feeds and speeds that are most
commonly used, but allow the programer using the Custom Macro to alter the feeds
and speeds or tools, if needed, right in the call statement. Please study this example
for a feeds and speeds Custom Macro, written in version "B" format to get the idea.
In call statement:
A ... Speed for first tool
B ... Feed for first tool
C ... Speed for second tool
D ... Feed for second tool
E ... Speed for third tool
F ... Feed for third tool
Main Program
00001
N005 G92 X1 0. Y1 0. Z1 0.
N010 G90
N015 GOO XO. YO.
N020 G65 P1008 (calls feeds and speeds Custom Macro and sets up
standard feeds and speeds)
N025 G65 P1009 (calls execution Custom Macro that uses previously
generated speeds and feeds)
M30
When using argument assignment number two, your call statement will not include
all available letter addresses in the alphabet. You will only be using A, B, C, I, J, and
K. Here is a chart that shows the pound sign numbers that correspond to the letter
address arguments from the call statement:
A. ........ #1 K sub 3... #12 J sub 7... #23
8 ......... #2 I sub 4... #13 K sub 7... #24
C......... #3 J sub 4 ... #14 I sub 8... #25
I sub 1... #4 K sub 4... #15 J sub 8... #26
J sub 1... #5 I sub 5... #16 Ksub 8... #27
Ksub 1... #6 J sub 5... #17 I sub 9 ... #28
I sub 2... #7 K sub 5... #18 J sub 9... #29
J sub 2... #8 I sub 6 ... #19 K sub 9... #30
K sub 2... #9 J sub 6 ... #20 I sub 10.. #31
I sub 3... #10 K sub 6... #21 J sub 10.. #32
J sub 3... #11 I sub 7... #22 Ksub 10.. #33
Notice that A, B, and C are just like you know them from argument assignment
number one. But you see a big difference with the rest of this chart. With argument
assignment number two, you will have ten sets of I, J, and K arguments. The first I
the control "sees" in the call statement will be assigned to local variable #4. The first
J in the call statement will be assigned to #5. The first K to #6. The second I the
control sees in the call statement will be assigned to local variable #7. Hopefully,
you are starting to get the idea (at least to how arguments are assigned in the call
statement.
Lets take this example a little further. We won't show the entire Custom Macro,
just enough to drive home our discussion of argument assignment number two.
(Note that the appendix shows the entire "Cam 11 Custom Macro.)
Here is an example call statement that would use argument assignment number two:
N050G65 P1010A2.5 81. C.112.0 J60.13. J120.13.5J60.12.5J120.
Where:
11
A11 represents the starting radius for the cam
11
8 11 represents the thickness of the part
ucu represents the incremental angle to calculate a new motion
command
11
1sub 111 is the ending radius for the first rise or fall
IIJ sub 111 is the incremental angle for the first rise or fall
11
1sub 211 is the ending radius for the second rise or fall
IIJ sub 211 is the incremental angle for the second rise or fall
11
1sub 1011 last ending radius
IIJ sub 10.. last incremental angle
Using argument assignment number two combined with "implied variables", we can
develop a Custom Macro to machine up to ten rises and falls.
Here is the "skeleton" of a Custom Macro to handle up to ten rises and falls:
01010
#1 01 = 4. (note that I sub 1 has is local variable #4)
PROBING TECHNIQUES
This section of the course will not apply unless your company owns a probe that is
attached to the machine. Even if your company does own a probe, you may never
have a need to develop Custom Macros to "drive" the probe, since most manufac-
tures who supply the probe will supply the Custom Macro programs to drive the
probe. Even though this is the case, this section of the course will give you a "behind
the scenes" look at how the probe is controlled.
Whenever you are developing Custom Macros for the probe, EXTREME CAU-
TION should be exercised while debugging the Custom Macro. It is very easy to
make a mist3:ke in the Custom Macro that will cause the probe to be damaged.
Lets begin our discussion of the probe by introducing the Custom Macro features
that pertain primarily to the probe. Some of these features have already been
introduced, so we will not spend too much time with them.
Control of Tool Offsets by Custom Macro Command:
As already mentioned, you can have a Custom Macro "access" your tool offsets in a
Custom Macro. Many probe applications require both "reading" and "writing" to and
from tool offsets. For example, you could develop a Custom Macro for probing the
width of a slot on a machining center. The Custom Macro could have the probe
measure the width of the slot and then test to see if the slot is to the desired size. If
not, the Custom Macro could access the proper tool radius offset to find out what
it's value currently is. Then a corrected value for the offset could be calculated and
that value could be "written" back into the proper tool offset. The next time the tool
cuts the slot, the slot would be on size.
Access to the Machine's Current Axis Position:
Also previously mentioned, a Custom Macro has access to the machine's current
axis position in all axes. The system variables for this that are related to the probe
are:
#5061 .... Current X position after the probe makes contact with the
surface.
#5062 .... Current Y position after the probe makes contact with the
surface.
#5063 .... Current Z position after the probe makes contact with the
surface.
It may be wise to check you F ANUC operation manual to confirm these system
variable numbers for your particular control.
Here is the call statement that would activate the probing cycle:
N015 G65 P1 011 XO. YO. ZO. 03.0
Where:
X: The X value is the X coordinate where the center of the hole 11 Should
be 11
Y: TheY value is theY coordinate where the center of the hole should
be.
Z: The Z value is to the top surface of the part. The probing Custom
Macro will go .2500 inch below this surface to probe.
D: The D value is the diameter of the hole.
Now lets look at the Custom Macro: This example is for a machining center, but the
same things will apply to a turning center.
Custom Macro "B"programers have really finished the course at this point. Now we
are going to talk exclusively about version "A". If you do not have this version of
Custom Macro, the only reason to view this portion of the course would be just to
get an idea of how Custom Macro "A" is programed.
By our previous discussions during the course, you have been introduced to some of
the techniques of using Custom Macro "A". We have seen that Custom Macro "A"
is more difficult to work with than Custom Macro "B". This is not to say that you
don't have a powerful programing tool with Custom Macro "A" when you understand
how to work with it. The most severe limitations with Custom Macro "A" stem from
it's limitations related to "machine related" features. But when it comes to basic
Custom Macro techniques, almost anything you can do with Custom Macro "B", can
be done with Custom Macro "A".
As previously mentioned, each version "A" Custom Macro command will include a
G65 and an H word to 11tell" the control what kind of command you are making. The
hardest thing to get used to is relating all of the various H words to what they mean.
This is the reason we recommend that you write the Custom Macro in version "B"
format first, arid then "translate" it to version "A".
The P, Q, and R words that are included in each Custom Macro statement tell the
control the variables or constants that are involved with the command. Some
statements will only require a upn word, others require "P" and "Q", and still others
require "P", "Q", and "R". The format for each type of command will be given later.
While you are writing the "first version" of the program in version "B", you must also
be aware of the arithmetic limitations of Custom Macro "A". You will usually only
be allowed to make one calculation per command. You should keep this in mind
while writing you version "B" first attempt to keep it simple to translate to version
"A".
One other point to make before we dig deeper into Custom Macro "A". You are not
allowed to make calculations in a motion command as you can in version tiB". You
must make all calculations to be used in motion commands PRIOR to making
motion commands. We mentioned earlier that this is actually the better way of doing
it since calculations do take a certain amount of time for the control to execute.
Here are some examples of how we translate version "B" commands to version "A"
commands:
Version "B" command: Version "A" command:
You can continue this technique for as many calculations as required in the Custom
Macro making as many combined calculations as required.
Lets take a look at the 11 translated11 version of the bolt circle Custom Macro shown
earlier during our discussion of Generating loops:
Variable: Description:
#112 X position to the center of the bolt hole circle
#113 Y position to the center of the bolt hole circle
#114 Top surface of the part in nzn
#115 Radius of the bolt hole circle
#116 Number of equally spaced holes on the bolt circle
#117 Starting angle for first hole
#118 Feedrate to machine
#119 Cycle type (81 = drill, 84 = tap, etc)
#120 Depth of holes
Now you should be able to "follow along" with the version "A" Custom Macro for
this application.
As you can see, it is going to take quite a bit of practice to become completely
confident with Custom Macro "A". But stick with it, as it will be to your long term
programing advantage to understand this very powerful programing tool.
Some of the techniques used will be a little difficult for the beginner to follow. For
this reason, the documentation that accompanies each example is more oriented to
you, as the student, than to the people actually using the Custom Macro. Please
study these examples and make an honest attempt to understand what is going on.
Here is a list of the Custom Macros included in this appendix and a brief description
of what they do:
Page -81- Version "A" Custom Macro for helical thread milling (inside)
This Custom Macro allows a feature (helical motion) that is not even
possible on the standard OM and 3M controls (even as an option). You
will see that many very small X Y Z movements are generated by this
Custom Macro to "simulate" a helical movement that is required for
thread milling.
Page -84- Version "B" Custom Macro to machine a screw machine cam
This "complex shape" Custom Macro will completely machine a circular
cam in one command. A whole series of small X Y movements is
generated. This example shows the technique to use "Implied Variables"
and ''Argument Assignment Number Two".
Page -86- Version "B" Custom Macro for machining "Double Hex" Sockets
This Custom Macro is being used by a major tool manufacturer to mill the
double hex sockets when the sockets are larger than 1.5 inches in diameter
when production quantities do not justify broaching. This is a very good
example of ''family of parts" Custom Macro programing. Programing
time is almost nothing since the operator will simply change a few
variables to go from one size to another.
Page -89- Version "B" Custom Macro for remachining forging die block shanks
This elaborate Custom Macro is used to machine a pair offorging die block
shan/a. If the user's shan/a crack due to stress on the shank, they can
easily remachine the shank and use the forging die again. This Custom
Macro shows the technique to have your Custom Macro "system"
remember common variables from one Custom Macro to another.
Notice how ''feeds and speeds" and "tooling" Custom Macros have been
developed to minimize the amount of variables required in the call
statements.
Page -103-Version "A" Custom Macro to machine an oval shaped part
This Custom Macro allows an oval shape to be machined. Notice how two
loops have been set up to allow the user to make multiple passes in X
and Y as well as in Z.
As you will see, if you spend some time and study these Custom Macros, they will
really help you when you have to do similar tasks.
Here is the Main Program. Notice the technique to set each variable and also notice
the decimal format for each variable:
02003 (MAIN PROGRAM FOR HELICAL THREAD MILLING)
N10 G92 X10. Y10. Z3.
N20 G90 5200 M3
N30 GOO XS. YS.
N40 GOOZ0.1
NSO G65 H01 P#SOO Q1 000
N60 G65 H01 P#501 QSOOOO
N70 G65 H01 P#502 QSOOOO
NSO G65 H01 P#503 Q-10000
N90 G65 H01 P#504 Q1250
N100 G65 H01 P#505 Q15000
N11 0 G65 H01 P#508 Q3750
N120 G65 H01 P#509 Q1 0000
N125 F30.
N130 N130 M98 P1001
N140 G91 G28 XO YO ZO
N150 M30
Print:
l(l)
C=lrD'eEutal ~le f[J" Calrulatim
I'
L
B ---tw. .
,...
ft1
= -----
'
CNC Concepts, Inc. Custom Macro Programing Page84
Appendix - Custom Macro Examples
Print:
D(Hole Size)
Other Variables:
F = Finish Tool Diameter
S = Plunging Tool Diameter
R= Rough Tool Diameter
V= Rough Tool Speed
U= Finish Tool Speed
T=Plunging Tool Speed
E= Rough Tool Feed Rate
H= Finish Tool Feed Rate
8 = Plunging Tool Feed Rate
.I
rz I
I
I
I
.II
'
I
I
I
I
I
M= Stock Allowed On Side
Q= Stock Allowed On Bottom
I I I
f I
L - - - -
I
- j- - - - -
I
_j
I
.Ii
.I
) (
I
I
As you can see, this is quite an elaborate process for the Custom Macro.
Now lets take a look at the varius programs involved with the system:
05555 (Main Program)
08002 (fools Custom Macro)
08001 (Feeds and Speeds Custom Macro)
08003 (Part Cutting Custom Macro)
08004 (Sub Program to Rough Pockets)
08005 (Sub Program to Finish Pockets)
08006 (Sub Program to 11 Loop 11 Dovetail)
08007 (Sub Program to 11 Loop 11 Dovetail)
This is an example of the main program that would machine the entire die block
shank. Note how short it can be:
05555 (Main Program)
N005 G92 X15. Y12. Z13. (Set Program Zero)
N010 G65 P8001 (Set all Feeds and Speeds)
N015 G65 P8002 (Set all Tools)
N020 G65 P8003 X12. V12. Y14. U28. (Cut Part)
N025 M30
In block N020, this is the most basic command to machine the die blocks. There are
many 11 preset11 variables that are set in the most commonly used ways.
Here is a description of each Custom Macro in the system and what each variable
is:
This is the Custom Macro that actually machines the part. There are some "man-
datort variables that must be in the call statement (if they are not, an alarm is
generated). There are also several preset variables that can be manipulated if the
need arises. Here is a list of all variables available:
Var: Set To: Description:
As you can see, this application allows for many possible changes when the part is
run. It shows good planning prior to even starting to write the Custom Macro. The
user determined just exactly what he needed control of, and then wrote the Custom
Macro accordingly.
#2=.005
N10 IF[#3NE#O]GOT015 (CLEARANCE)
#3=.2
N151F[#7NE#O]GOT016 (Z DEPTH OF CUT)
#7=.25
N16 #144=#[2000+30+#114] (TOOL RADIUS)
#143 = [ #25/2]3.5 (CUT AREA)
#145= 1. (PRESET TO 1 XV PASS)
#146=0 (PRESET TO NOV SHIFT)
IF[[#8*[ #.144*2)]GT#143]GOT020
#145= FUP#143/[#8*#144*2]] (NUMBER OF V PASSES)
#146=#143/#145 (INCREMENTAL V MOVE)
#140= #143-#146*#145-#144 (CURRENT V PASS)
GOT023
N20 #140=#143-#144 (CURRENT V PASS)
N231F[#1EQ-1.]GOT025
#142=-[#3+#144] (STARTX)
#141 =#21 +#3+#144( FINISH X)
GOT050
N25 #142=#21 +#3+#144 (START X)
#141 =-[#3+#144] (FINISH X)
NSO #148= FUP[1.747/#7] (NUMBER OF Z PASSES)
IF[#136EQ1.]GOT051
#135=1.747/#148 (CURRENTZ DEPTH)
N51 #147=0 (COUNTER FOR XV PASS)
IF[#136EQ1.]GOT052
#139=0 (COUNTER FOR Z PASS)
N52 #138=#135 (INCREMENTAL Z)
IF[#136EQ1.]GOT0501
S#100 F#101
N501 GOO X#142 V#140
G43 H#114 Z.5
MOS
N45 WHILE[#139LT#148]D01 (LOOP Z)
N40 WHILE[#147LT#145]D02 (LOOP XV)
GOOV#140
GOOZ-#135
G01 X#141
GOOZ.5
GOO X#142 V#140
#147 = #147 + 1 (STEP XV)
IF[#137EQO]GOT034
#140 = #140.#146 (STEP V POSITION)
GOT036
N1051F[#13EQ-1.]GOT0110
#136 = -[ #3 + #144)
#137= [#21 +#3+#144]
GOT0111
N110 #136= [#21 +#3+#144)
#137 = -[#3 + #144)
N111 GOOX#136Y#146 (FIRST CUT)
G43 H#115 Z.5
G01 Z-1. 767 F30. M08
G01 X#137 F#1 05
GOOZ.5
#146 = #146 + #142
#138 = 0 (COUNTER FOR LOOP)
M98 P8006
N120 GOO X#137 Y#147
Z-1.767
G01 X#136
GOOZ.5
#147= #147-#142
#138=0
M98 P8007
N130 G91 G28 ZO M19
M01
N3000 T#116
M06
(RADIUS MILL)
G90 S#1 06 F#1 07 M03
IF[#19EQ1.]GOT01205
T#118
GOT01206
N1205T#117
N1206 #144=#[2000+30+#116]
GOO X[#21 + #3 + #144 + .5] Y[ #25/2 + 3.5 + #144]
G43 H#116ZO
M08
G01 X-[ #144 + #3 + .5]
GOOZ.75
M09
G91 G28 ZO M19
M01
IF[#19EQ1.]GOT01202
N300 IF[#18NE#O]GOT0301
#18=.25
N301 GOOX[#17 -#144] Y[ #25/2 + 3.5 + #3/2 + #144]
GOO G43 H#117Z-.25
MOB
G01 Y[ #25/2-3.5-#3/2-#144]
GOOZ.5
GOO X#24-#17 + #144)
z-.25
G01 Y#25/2+3.5+#3/2+#144]
GOOZ.75
X[#21-#22 + #17-#144]
z-.25
G01 Y[#25/2-3.5-#3/2-#144]
GOOZ.75
X[#21-#17 +#144)
z-.25
G01 Y[ #25/2 + 3.5 + #3/2 + #144)
GOOZ.75
IF[#19EQ1.]GOT01203
X[#21-#24/2 + .875 + .25-#144]
Z-.25
G01 Y[ #25/2 + 3.5-2.5 + #144)
X[ #21-#24/2-.875-.25 + #144]
Y[ #25/2 + 3.5 + #3/2 + #144]
GOOZ.75
X[#24/2 + .875 + .25-#144]
z-.25
G01 Y[#25/2 + 3.5-2.5 + #144)
X#24/2-.875-.25 + #144]
Y[#25/2 + 3.5 + #3/2 + #144]
GOO Z.75
N1203 M09
G91 G28 XO YO ZO M19
GOT01000
N997 #3000= 103(0FFSET DATA MISSING)
N998 #3000=102(X+VTOO GREAT)
N999 #3000=101(1NPUT DATA MISSING)
N1000 M99
Sub Program for loop dovetail: (You may be questioning why we needed these two
looping programs for the dovetail. Since this Custom Macro is so long and stnce
these loops occur toward the end of the Custom Macro, the execution time is
dramatically reduced by creating a separate program for these loops. The way the
control processes an IF STATEMENT determines whether you need to use this
technique to reduce execution time. When the control reads a GOTO statement, it
begins its search for the statement label (N word) from the BEGINING OF THE
CUSTOM MACRO. This means that if the Custom Macro is extremely long, as this
one is, the GOTO statement could take as much as 3-5 seconds to find the statement
label. With these two short looping Custom Macros, the execution time is almost
instantaneous.)
08006 (SUPPORT CUSTOM MACRO FOR DIE BLOCKS)
N1151F[#138GE#141]GOT0120
GOO X#136 Y#1-46
Z-1.767
G01 X#137
GOOZ.S
#146 = #146 + #142
#138=#138+1
GOT0115
N120 M99
Sub Program for loop dovetail
08007 (SUPPORT CUSTOM MACRO FOR DIE BLOCKS)
N125 IF[#138GE#141)GOT0130
GOO X#137 V#147
Z-1.767
G01 X#136
GOO Z.S
#147=#147-#142
#138=#138+1
GOT0125
N130 M99
The answers to all of the questions asked will be given right on the video tape as
soon as you continue in the course. But we will not show the actual answer Custom
Macros on tape. You have a set of answer programs to give you a way to judge how
well you are understanding how to write Custom Macros. As we state several times
during the course, there are many ways to develop a Custom Macro to handle any
one application. Just because your Custom Macro does not perfectly match our
answer program, does not mean your Custom Macro is not correct. If you feel that
your have written a Custom Macro properly, we urge you to go out to your machine
and try it.
PRACTICE EXERCISE NUMBER ONE
INTRODUCfiON
(pages 1-13)
1) What was Fanuc's main intension in designing Custom Macro?
2) What are the names for the two different versions of Custom Macro? Which is
the more "powerful" version? Which is easier to work with?
3) What are the three categories of applications introduced for Custom Macro?
A)-------------------------------------------------------
B)-------------------------------------------------------
q _____________________________________________________
4) Name some specific applications for the type of machine for which you will be
using Custom Macro?
5) What are the main differences between Custom Macro "A" and Custom Macro
"B"?
2) What computer related feature allows you to create a general purpose Custom
Macro that could behave differently from call statement to call statement?
3) What computer related feature allows math to be done in your Custom Macro?
4) What computer related feature allows the Custom Macro to make decisions?
C) _______________________________________________________~D~------------------------------------------------------------------------
~-----------------------------------------------------------------------------------------------------------------
8) In version "B" how do we pass arguments from the main program to the Custom
Macro? In version "A"?
c
2) What character precedes a variable in ALL Custom Macro commands?
3) For the following letter address arguments, look up the corresponding "pound
sign" numbers that would be used to represent them in the Custom Macro:
4) What are the four types of variables that can be used in a Custom Macro? What
is the range for their corresponding pound sign numbers?
A ... F ... V ... Y ..
l
""'v ""'v"
~I 2.oo
\ \
~
J
0
a
=::
Q bl /' I bt /' -
0
~
~
C'.
H
~
.25 Typical w
......__ X
~-{
~
1
I
?._._'-3.00
1'
i
~
' 125
F = Feedrate
~
I
L- - ~ t l 00
I
L
~
~ 2.00
~ c
\
:::
~ I-- f- - - D 1.oo ~ r--- --- 1--------i
VA '-
B
'
a'P. w
r "' r "'
ff I I
~ - 1/:.'
...
VI
r - I "'
1.,.
1--
I I
I
2) What Custom Macro arithmetic functions allow the Custom Macro to attain:
A) The positive value of any variable? - - - - - - - - - -
B) The next higher integer? - - - - - - - - - - - - -
C) The next lower integer? - - - - - - - - - - - - - -
D) The closest integer? - - - - - - - - - - - - - - -
3) For Custom Macro "B'', list the priority of combined arithmetic expressions:
First:
--------------
Second:
--------------
Third:
----------------
Forth:
----------------
4) In version "B" Custom Macro, when a variable has no value, what term did we use
to describe it's condition?
5) Name the four basic catagories for applications of the "IF STATEMENT':
A: C:
---------------
B: _____________________ D: _ _ _ _ _ _ _ _ ___
6) Name the six "conditions" the "IF STATEMENT' can test against and show the
way Custom Macro "B" requires them to be stated:
A: D:
B: _____________ E: _ _ _ _ _ _ _ _ __
-----------
C: ~
----------
~---.(I)
1-0
1-0
_!
Practice Exercise Number Five
(Question Number Six)
Print for Turning Center Students:
n
c
"'
H
~ T w
~
.,...
I
0
0
I
Sl
.,o
0
B
a
~ - D
9
.,"'
I
~
~
F = Feedrate
w
I4SO z r:=. I
PRACTICE EXERCISE NUMBER SIX
PREPARATION FOR AND DEBUGGING A
CUSTOM MACRO
(pages 44-48)
1) What are the three catagories of mistakes that can be made in a Custom Macro?
A) ___________________________________________
B) ___________________________________________
C) ___________________________________________
2) Name the seven steps given to successfully approach your Custom Macros.
1\) .
B) __________________________________________
C) _________________________________________
D)__________________________________________
E)__________________________________________
F) __________________________________________
G) _________________________________________
3) Name the five steps given to debug your Custom Macros at the machine.
A) ________________________________________
B)__________________________________________
C)__________________________________________
D)__________________________________________
E)__________________________________________
4) Name the two different machine related techniques designed to help you debug
your Custom Macros.
A) __________________________________________
B)_________________________________________
Again, we do not want you spending too much time coming up with the solution to
this problem. So we give you a little help with the solution:
()
r;;
....
0
8
::
I
Q
.,....
0
I
a.g I y
.,....
0
11
.
"'.,
~I B
IE X
F = Feedrate
I
~-----
I
-1------I ~
I
I 1 I
z
PRACTICE EXERCISE NUMBER SEVEN
MACHINE RELATED FEATURES
(pages 49-57)
1) Name the nine machine related features of Custom Macro that we discussed in
this section.
A) ________________________________________
B)_________________________________________
C) ________________________________________
D) _________________________________________
) ________________________________________~
F) _________________________________________
G) ________________________________________
H) ________________________________________
!)________________________________________
2) Give the correct Custom Macro statement to set common variable #105 equal to
the value of offset number one in Custom Macro "B" format:
3) Give the Custom Macro version "B" command to disable single block:
The actual motions for each pass will be including a simple circle to move around
the sphere one time at the current "Z" position. Then the Custom Macro loop will
step the "Z" (up), recalculate the new position in "X" for the new circle, and make
another pass.
The math that is required in this Custom Macro includes calculating the current "X"
position for the beginning and end of the current circular motion. We can use the
"Pithagorean Theorem" to help us calculate this position. You may remember that
this theorem states that "A" squared plus "B" squared equal"C' squared. So the "X"
position for any current pass will be the following formula:
#1 09 = Current "Z" distance from tool position to center of the
sphere.
#110 = SQRT[ [ #18 * #18 1 [ #109 * #109 1 1
Another problem you will have is related to how to set up the number of passes
through the loop. We recommend having the Custom Macro calculate the number
of passes. Then having the Custom Macro recalculate the incremental Z move
between passes (C). Here are the two formulae that can be used to do this:
#103 = FUP[ [#18- #261 I #31 (number of passes)
#104 = [#18- #26] I #103 (recalculated incremental step)
Hopefully this is making sense and you are ready to start.
Good luck!!
Turning Center Students:
You will be writing a Custom Macro to completely rough and finish turn the "family
of parts" workpiece shown in the drawing. This requires a knowledge of the multiple
repetitive cycles (G70-G71) on the FANUC control. If you do not have experience
with these cycles, it will be impossible for you to do this exercise. But please study
the answer program to try to get an understanding of what is going on. This is a very
powerful technique that allows you to "marry" the power of the multiple repetitive
cycles to the power of Custom Macro to make family of parts programming almost
simple.
~a
~
Q Program Zero
0
...
"tt
1:1)
n
c:r.
g
Practice Exercise Number Seven
~
~ (Question Number Five)
~I
"tt
~
~
z Program Zero
~ - -
F = Feedrale
XOist = SORT [( R* R l I [l * Zll
Print For Turning Center Students:
M(#13) Radius
R(#18) Radius
H(#11) X45 Cham
.---L--,--. - I- - - - - - - gl ~1] l_- - -1---
I
-----'----~
I
I
c (#3)
B(#2)
~
0
a
:::
Ill
a
~
n....
ff
~ L-----,--....J- - - - - - -- - - - - - - - - - - - -
c
a
en
D( #7)
T(#20) =Roughing
~
' E ( #8)
~
0 Depth Of Cut
N
..... IE F ( #9) ---6-l
2) What two words will be included in EVERY true Custom Macro command?
3) What does the "H" word specify in a Custom Macro version "A" command?
4) Give the "H" word for the following types of Custom Macro commands:
Addition: Multiplication: _ _ __
Subtraction: Division:- - - - - -
-----
Square Root: _ _ __ Absolute Value:
----
Sine:
- - - - - - - Cosine: - - - - - - -
Arc Tangent: _ _ __ GOTO: _ _ _ _ _ __
2) What is the "end result" value of common variable #110 at the completion of this
series of commands?
G65 H01 P#1 01 QS
G65 H01 P#1 02 Q3
G65 H02 P#110 Q#101 R#102
G65 H03 P#11 0 Q#11 0 R#1 02
G65 H04 P#110 Q#110 R#101
3) Go back to practice exercise number five and translate the program you wrote
(or our answer program) from version "B" to version "A" format.
Machining center students:
Instead of the letter address arguments shown on the print, use these #100 series
common variables for your call statement and to be used in the Custom Macro body:
#120 - 11 M11 (Inside diameter of ring)
#121 - 11 8 11 (Outside diameter of ring)
#122- ..A .. (Starting angle)
#123- ucu (Clearance value)
#124- 11T11 (Tool radius)
#125- ugu (Number of slots)
#126- 11 0 11 (Depth of slots)
#127 - up (Feedrate for milling)
Since the version "B" program you originally wrote may be doing multiple arithmetic
calculations, use the technique we gave to use the same "temporary" variable to
repeat calculations.
We will be careful to label each answer program with which practice exercise it
corresponds to. Also, we will try to document each answer program thoroughly to
help you follow along with how we solved the problem.
Each practice exercise that requests you to write a practice Custom Macro (or
Custom Macros) will actually have two posibilities related to the type of equipment
you will be using Custom Macro for. These two types of machines include Turning
Centers and Machining Centers. We will always be showing the answers to the
Machining Center Custom Macros first.
We will always present an example MAIN PROGRAM that could use the Custom
Macro. This main program will be shown first, and will include the CALL STATE-
MENT that activates the Custom Macro.
The first portion of these answer programs are related to Custom Macro Version
"B". Later in this package of answer programs, we will give the answers to what is
requested of you during tape number five for Custom Macro version "A".
Custom Macro Programing Answer Programs
Main Program:
As with all"MAIN PROGRAMS" shown in the answer programs, this main program
uses format that you may not agree with. Please pay the most attention to the format
of the CALL STATEMENT in this main program.
00001 (PROGRAM NUMBER FOR MAIN PROGRAM)
NOOS G92 X10. Y10. Z10. (JUST DUMMY NUMBERS TO SETUP ZERO
POINT}
N010 G90 S300 M03 (ABS MODE, TURN SPINDLE ON AT 300 RPM)
N015 GOO XO YO (MOVE TO XO AND YO)
N020 G43 H01 Z.S (USING TOOL LENGTH COMP, MOVE TO .5 IN Z)
N025 G65 P1001 X3.0 Y2.0 D.125 W.25 T.S FS.O (CALL STATEMENT}
N030 G91 G28 ZO (GO HOME IN Z)
N035 G28 XO YO (GO HOME IN X AND Y)
N040 M30 (END OF MAIN PROGRAM)
Main Program:
As with all"MAIN PROGRAMS" shown in the answer programs, this main program
uses format that you may not agree with. Please pay the most attention to the format
of the CALL STATEMENT in this main program.
00002 (PROGRAM NUMBER FOR MAIN PROGRAM)
NOOS G50 X Z (SETS UP THE COORDINATE SYSTEM)
N01 0 GOO T01 01 M42 (CHANGES TOOLS AND SELECTS HIGH RANGE)
N015 G96 S300 M03 (TURNS SPINDLE ON AT 300 SFM)
N020 G65 P1002 A1. 82. C3. D1. E2. H.125 F.006 (CALL STATEMENT)
N025 GOO X Z._ _ _ T01 00 (GO TO INDEX POSITION AND
CANCEL OFFSET)
N030 M30 (END OF MAIN PROGRAM
Custom Macro:
As with all Custom Macros, this is just one Custom Macro that will handle the
problem. Your Custom Macro may vary, but hopefully you understand what is going
on.
01002 (CUSTOM MACRO TO FINISH TURN THE PRACTICE PART)
GOO X[#1- [2 * #11]] Z.1 (RAPID UP TO PART)
G01 ZO F[#9] (FEED TO FACE OF PART)
X[#1] Z-[#11] (FEED THROUGH FIRST CHAMFER)
Z-[#7] (TURN FIRST DIAMETER)
X[#2- [2 * #11]] (FEED UP FIRST FACE)
X[#2] Z-[#7 + #11] (FEED THROUGH SECOND CHAMFER)
Z-[#8] (TURN SECOND DIAMETER)
* #11]] (FEED UP SECOND FACE)
X[#3 - [2
X[#3] Z-[#8 + #11] (FEED THROUGH LAST CHAMFER)
X[#3 + .2] (FEED OFF PART)
M99 (END OF CUSTOM MACRO)
Custom Macro:
01005 (CUSTOM MACRO FOR MILLING ANGULAR SLOTS IN
CIRCULAR PART)
IF [ #3 NE #0 ] GOTO 5 (TEST C FOR VACANCY)
#3 = .1 (IF CIS VACANT, SET TO .1)
N51F [#20 EQ #0] GOTO 97 (IF TIS VACANT, GIVE ALARM)
IF [#13 EQ #0 1GOTO 97 (IF MIS VACANT, GIVE ALARM)
IF [#2 EQ #0] GOTO 97 (IF B IS VACANT, GIVE ALARM)
IF [#1 EQ #0 1GOTO 97 (IF A IS VACANT, GIVE ALARM)
IF [#7 EQ #0] GOTO 97 (IF DIS VACANT, GIVE ALARM)
IF [#19 EQ #0] GOTO 97 (IF SIS VACANT, GIVE ALARM)
IF [#9 EQ #0] GOTO 97 (IFF IS VACANT, GIVE ALARM)
IF [ #13 GT #2] GOTO 98 (IF MIS GREATER THAN B, GIVE ALARM)
#1 01 = 1 (INITIALIZE LOOP COUNTER)
#1 02 = #1 (INITIALIZE CURRENT ANGLE)
#103 = 360 I #19 (CALCULATE INCREMENTAL ANGLE)
GOO XO YO (MOVE TO CENTER OF PART)
N20 IF [#101 GT #19] GOTO 90 (TEST IF FINISHED)
#110 = COS[#102] * [[ #13 I 2]- #3- #20] (INSIDE X POS)
#111 = SIN[#102] * [[ #13 I 2]- #3- #20] (INSIDE Y POS)
#112 = COS[#102] * [[ #2 I 2] + #3 + #20] (OUTSIDE X POS)
#113 = SIN[#102] * [[ #2 I 2] + #3 + #20] (OUTSIDE Y POS)
GOO X[#110] Y[#111] (MOVE TO START POSITION)
Z-[#7] (MOVE DOWN IN Z)
G01 X[#112] Y[#113] F[#9] (CUT SLOT)
GOO Z.5 (RAPID ABOVE PART)
#1 01 = #1 01 + 1 (STEP LOOP COUNTER BY ONE)
#1 02 = #1 02 + #1 03 (STEP CURRENT ANGLE BY I NCR. ANGLE)
GOTO 20 (GO BACK TO TEST)
N90 GOTO 99 (SKIP ALARMS)
N97 #3000 = 102 (DATA MISSING) (ALARM FOR DATA MISSING)
N98 #3000 =
103 (M TOO LARGE) (ALARM FOR M TOO LARGE)
N99 M99 (END OF CUSTOM MACRO)
Custom Macro:
01006 (CUSTOM MACRO FOR GROOVING ON A TURNING CENTER)
IF [ #11 NE #0 1 GOTO 5 (TEST H FOR VACANCY)
#11 = .1 (IF HIS VACANT, SET TO .1)
N51F [#20 EQ #0 1 GOTO 97 (IF TIS VACANT, GIVE ALARM)
IF [#3 EQ #0 1 GOTO 97 (IF CIS VACANT, GIVE ALARM)
IF [#2 EQ #0 1 GOTO 97 (IF B IS VACANT, GIVE ALARM)
IF [#7 EQ #0 1 GOTO 97 (IF DIS VACANT, GIVE ALARM)
IF [#23 EQ #0 1 GOTO 97 (IF W IS VACANT, GIVE ALARM)
IF [#26 EQ #0 1 GOTO 97 (IF Z IS VACANT, GIVE ALARM)
IF [#9 EQ #0 1 GOTO 97 (IFF IS VACANT, GIVE ALARM)
IF [ #20 GT #23 1 GOTO 98 (IF TIS GREATER THAN W, GIVE ALARM)
#101 = FUP[ #23 I [#20 -.02]] (CALCULATE NUMBER OF PASSES)
#102 = #23- #20 (REMAINING STOCK AFTER 1ST PASS)
#1 04 = 1 (INITIALIZE COUNTER)
#103 = #102 I [#101 11 (INCREMENTAL MOVE OVER AMOUNT)
#105 = -[ABS[#26]] (INITIALIZE CURRENT Z POSITION)
GOO X[ #2 + [2 * #11]] Z[#1051 (MOVE TO START POSITION)
IF [ #23 GT #20 1 GOTO 25 (MORE THAN ONE PASS)
G01 X[#7] F[#91 (ONE PASS ONLY)
G04 X.5 (HALF SECOND DWELL)
GOO X[#2 + [ 2 * #11]] (RAPID OUT)
GOTO 50 (SKIP MULTIPLE CUTS)
N251F [#104 GT #101] GOTO 50 (TEST IF FINISHED)
Z[#1051 (MOVE TO CURRENT Z POSITION)
G01 X[#7] F[#9] (PLUNGE GROOVE)
G04 X.5 (HALF SECOND DWELL)
Main Program:
00007 (Program Number)
N005 G92 X1 0. Y1 0. Z1 0.
N01 0 G90 S400 M03
N015 GOO XO YO
N020 G43 H01 Z.5 MOS
N025 G65 P1007 X2. Y2. D2.5 T.75 ZO. B.5 F5. (CALL STATEMENT)
N030 G91 G28 ZO
N035 G28 XO YO
M30
Custom Macro:
01 007 (Custom Macro for circle milling)
GOO X[#24] Y[#25] (RAPID TO CENTER)
Z[#26 + .1] (RAPID ABOVE COURSE)
G01 Z[#26 - #2] F[#9] (FEED TO BOTTOM)
X[#24- [ #7 I 2 ] + #20] (FEED TO LEFT SIDE OF CIRCLE)
G02 I[[ #7 I 2] - #20] (MILLS FULL CURCLE)
G01 X[#24] F[ #9 *2] (FAST FEED BACK TO CENTER OF THE HOLE)
GOO Z[ #26 + .1 ] (RAPID OUT OF THE HOLE)
M99
Hopefully, even if you had difficulty in preparing this Custom Macro, you are starting
to see that almost anything is possible with Custom Macro as long as you have an
understanding of how to solve the problems related to any one application.
Main Program:
00009 (PROGRAM NUMBER)
N005 G92 X1 0. Y1 0. Z1 0.
N015 G90 S500 M03
N020 GOO XO YO
N025 G43 H01 Z2.5 (BE CAREFUL WITH THIS APPROACH MOVE!)
N030 G65 P1009 R2. Z1. T.5 F5. C.005 (CALL STATEMENT)
N040 G91 G28 ZO
N045 G28 XO YO
N050 M30
Custom Macro:
01009 (CUSTOM MACRO TO MACHINE ENTIRE SPHERE)
#1 01 = 1 (LOOP COUNTER)
#102 = FUP[ [#18- #26] I #3] (NUMBER OF PASSES)
#103 = [#18- #26] I #102 (RECALCULATED INCREMENTAL STEP)
#1 04 = 0 (CURRENT Z POSITION)
#105 = #26 (CURRENT VALUE FOR Z CALCULATION)
GOO X[#18 + #20 + .5] YO (RAPID TO CLEARANCE POSITION)
N1 IF [ #101 GT #102] GOTO 99 (TEST IF FINISHED)
Custom Macro:
01010 (CUSTOM MACRO FOR FAMILY OF TURNED PARTS)
#1 01 = #3 + .2 (CLEARANCE POSITION IN X)
#102 = #2- [(TAN[#17] * #8) *2] (BEGINNING POINT OF ANGLE)
GOO X#1 01 Z.005 (RAPID UP TO PART)
G01 X-.0625 F.015 (ROUGH FACE)
GOO Z.1 (RAPID AWAY IN Z)
X#3 (RAPID FLUSH WITH STOCK DIA IN X)
G71 P1 Q2 U.04 W.005 D#20 F.015 (ROUGH TURN ENTIRE PART)
(FINISH TURN DEFINITION)
N1 GOO X[ #1 - [2 * #11]] (RAPID TO X OF FIRST CHAMFER)
G01 ZO (FEED TO FACE OF PART)
X#1 Z-#11 (MAKE FIRST CHAMFER)
00050(049 SUB)
#101=1
#102=#1
#103=360/#11
#104=#26+.1
#105=#26-#7
N1IF[#101GT#11]GOT099
#110=#24+[COS[#l02]*#18]
#111=#25+[SIN[#1 02]*#18]
G[#3]X#110Y#111R[#104]Z[#105]F[#9]Q#17
080
#101=#101+1
#102=#102+#103
GOrOl
N99M99
%0