You are on page 1of 91

CUSTOM MACRO

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:

3 Description Of This Course


5 Description Of Custom Macro
7 Some Applications For Custom Macro
10 The Two Versions Of Custom Macro
14 The Features Of Custom Macro
17 How To Activate A Custom Macro In Version 11 8 11 Format
20 How To Activate A Custom Macro In Version 11 A 11 Format
22 Introduction To Variable Techniques
28 Arithmetic Calculations In A Custom Macro
31 Introduction To The IF STATEMENT
37 Generating Loops
44 Preparation For Writing A Custom Macro
46 Debugging A Custom Macro At the Machine
49 Special 11 Machine Related 11 features of Custom Macro
59 Advanced Variable Techniques
67 Probe Techniques
71 Discussions of Custom Macro 11A 11
78 Appendix, Custom Macro 11 Aeal World 11 Examples

CNC Concepts, Inc. Custom Macro Programing Page 2


Chapter One Introduction

DESCRIPTION OF THIS COURSE

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.

The entire course will be presented in a "classroom environment". As mentioned,


we will be assigning several practice exercises. Upon completion of each practice
exercise, we will be asking you to enter the practice exercise programs into your own
control and run these programs to verify that you have written a correct Custom
Macro for the assignment.

CNC Conceprs, Inc. Custom Macro Programing Page3


Chapter One Introduction

DESCRIPTION OF CUSTOM MACRO

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.

CNC Concepts, Inc. Custom Macro Programing PageS


Chapter One Introduction

SOME APPLICATIONS FOR 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.

1. Families of parts. (or redundant operations on many parts)


2. Redundant difficult math calculations.
3. Method for "driving" machine option devices. (like the probe, in
process gaging, and post process gaging)

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.

Some good example applications of this category would include:

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

CNC Concepts, Inc. Custom Macro Programing Page7


Chapter One Introduction

DRIVING MACHINE OPTION DEVICES:


This category is not usually required of the end user. If your F ANUC controlled
machine has a probe or some option device that requires Custom Macro to drive it,
the manufacturer of the probe/machine should provide the Custom Macros to be
used with these devices. And usually, the end user will be simply utilizing previously
written Custom Macros to use the option device. That is not to say that you would
not have the ability to improve upon these previously written Custom Macros or
develop new Custom Macros for new applications of these option devices. Later in
the course, we will be looking at some of the special Custom Macro commands that
are related to the probe. While we will not be giving you any practice exercises
related to the probe or other option devices, we will show you enough to get you off
on the right foot. Extreme care should be exercised whenever developing new
Custom Macros for these expensive machine option devices so as not to damage
them.
o-rit.. ;'fi ~s

CNC Concepts, Inc. Custom Macro Programing Page9


Chapter Two The Two Versions of Custom Macro

THE TWO VERSIONS OF 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.

CNC Concepts, Inc. Custom Macro Programing Page 10


Chapter Two The Two Versions of Custom Macro

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.

Each type of calculation has a special "H" word


to represent the type of calculation.
This is the basic reason why we must write our version "A" Custom Macro in version
"B" format first. It is very difficult to read a version "A" format Custom Macro. It is
even more difficult to write a version "A" format Custom Macro without first writing
it in version ,B,. Each true version ,A, format Custom Macro command will include
a "G65" and an "H11 word. The 11H" word tells the control what type of Custom Macro
command we are making. For example, HOt specifies an equal statement, H02 is
used for addition, H03 is used for subtraction, H04 is multiply, H05 is divide, and so
on. You will be referring to a chart to get the ,translation H words,. (Note: In a
"G65, statement, the ,H, word had nothing to do with tool offsets.)

All variables to be "passed" to the Custom Macro must be


specified BEFORE the call statement.
We have not even discussed what a "call statement'' is yet, so bear with us. When we
see the first example, this will make more sense. With Custom Macro 11A", we must
specify the variables to be passed to the Custom Macro PRIOR to the call statement.
With Custom Macro "B" we are allowed to specify all variables to be passed right in
the call statement.

"G" "M" or "T" words cannot be created


' '
with Custom Macro "A".
This is a nice feature for-Custom Macro ,B" that is not possible in Custom Macro
"A".

CNC Concepts, Inc. Custom Macro Programing Page 12


Chapter Three The Features of Custom Macro

THE FEATURES OF CUSTOM MACRO


Before digging in too deep, lets take a quick look at the features of Custom Macro
that we are going to be studying about. As mentioned, there are two basic types of
features, "computer related" features and "machine related" features. The computer
related features are the ones that most resemble features you would find available
in any computer programing language like BASIC, FORTRAN, C LANGUAGE
and COBOL. The machine related features are features that are specific to CNC
equipment.
COMPUTER RELATED FEATURES:
Variable Techniques:
This feature of Custom Macro allows the programmer to do two basic things:

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.

CNC Concepts, Inc. Custom Macro Programing Page14


Chapter Three The Features of Custom Macro

Creation of new "G", "M", and "T" commands:


("B" version only)
For your most commonly used Custom Macros, you can actually create a new "G"
command that will "call" the Custom Macro. Machine tool manufacturers will
sometimes use this technique to "hide" the fact that the application is handled by a
Custom Macro.

Protection for Custom Macro programs:


Important Custom Macros can be protected from accidental deletion or editing.
Actually, any program can be protected, not just Custom Macros. You must name
the Custom Macro a number in the 8000 or 9000 series to allow this function.

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.

Practice exercise number two to be done at this time.

CNC Concepts, Inc. Custom Macro Programing Page 16


Chapter Four How to Activate a Custom Macro

HOW TO ACTIVATE A CUSTOM MACRO IN


VERSION .. B.. FORMAT

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.

CNC Concepts, Inc. Custom Macro Programing Page 17


Chapter Four How to Activate a Custom Macro

3. We will present later that part of the preparation to be done prior to


writing a Custom Macro will include coming up with a 11Wish list"
example call statement. This is the "wouldn't it be nice if" list that
helps you to analyze just what the macro has to 11 know 11 to do the
job.
The actual body of the Custom Macro will not be shown yet. We will show the entire
Custom Macro for a bolt hole circle a little later. But the format for the body of the
Custom Macro is very similar to a sub program. We begin a Custom Macro with a
program number (0 word, just like a sub program), and end the Custom Macro with
an "M99" word (also just like a sub program). But we will find that, unlike a sub
program, we can utilize the variables coming from the call statement to make the
Custom Macro "behave" differently based on the call statement. We will also be able
to do many other things like arithmetic right in the body of the Custom Macro.

CNC Concepts, Inc. Custom Macro Programing Page 19


Chapter Four How to Activate 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.

CNC Concepts, Inc. Custom Macro Programing Page 21


Chapter Five Introduction to Variable Techniques

INTRODUCTION TO VARIABLE TECHNIQUES

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.)

CNC Concepts, Inc. Custom Macro Programing Page22


Chapter Five Introduction to Variable Techniques

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

CNC Concepts, Inc. Custom Macro Programing Page24


Chapter Five Introduction to Variable Techniques

Using variables in arithmetic calculations:


The second use for variables is for arithmetic calculations. Many times, when you
wish to do a calculation in a Custom Macro it is helpful or necessary to use a variable
in which to store the answer to the arithmetic calculation. This variable can later be
referenced to accomplish what you are using the variable for. Before we show an
example, we want to show you the four different types of variables. We must point
out that the number of variables available is different on each F ANUC control type.
Also, on some controls, you can purchase more variables as an option. What we are
showing here are the variable ranges for the standard version "B" Custom Macro as
it would be equipped on the "standard" 11 series control.

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".

Local Variables: Jf ~IIVa.s


(#1-#33 on version "B". #1-#32 on version "A")
Local variables for version ''B" Custom Macro are the pound sign numbers that
represent the letter address arguments from the call statement. It is important to
know that they will only stay active in the body of the Custom Macro itself. At the
completion of the Custom Macro (M99), these variables will be set back to vacant
(empty).

Common Variables: oAI. ~1"'


(#100-#149 on version "B". #100-#131 on version "A")
Unlike local variables, common variables will be "remembered" even after the
Custom Macro has been completed. The "implications" of this will be discussed
later. All you have to know right now is that common variables will be used for your
"general purpose" calculations. We will show an example of this soon.

Permanent Common Variables:


(#500-#509 on version "B". #500-#531 on version "A")
This form of common variable is identical to the previously described common
variable, except that these variables will be remembered even after the machine is
turned off. Again, we will discuss the implication of this later.

System Variables: (#1000-#6000 for both versions)


These variables allow you access to the current states of the machine. There are
many types of system variables and we will introduce them later.

CNC Concepts Inc. Custom Macro Programing Page26


Chapter Six Arithmetic Functions

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:

Equality Sets the variable to the left of the #11 o = #1 01


equal sign equal to the variable or
constant to the right of the equal sign.
Add Sets the variable to the left of #11 0 = #1 01 + #1 02
the equal sign to the sum of what
is on the right of the equal sign.
Subtract Sets the variable to the left of #11 o = #1 01 -#1 02
the equal sign to the result of what
is on the right of the equal sign.
Multiply Sets the variable to the left of #11 0 = #1 01 * #1 02
the equal sign to the product of what
is on the right of the equal sign.
Divide Sets the variable to the left of #11 0 = #1 01 I #1 02
the equal sign to the result of the
right side of the equal sign.
Sine Sets the value to the left of #11 0 = SIN[30.]
the equal sign to the sine of the
specified angle.
Cosine Sets the value to the left of #110 = COS[30.]
the equal sign to the cosine of the
specified angle.
Tangent Sets the value to the left of #110 =: TAN[30.]
the equal sign to the tangent of the
specified angle.

CNC Concepts, Inc. Custom Macro Programing Page28


Chapter Six Arithmetic Functions

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.

Note for Custom Macro "A" programmers:


In most cases, Custom Macro "A" does not allow you to combine arithmetic calcula-
tions in one command. Therefore you must do one arithmetic calculation at a time.
This can be a little cumbersome, but this is the way that Custom Macro "A" demands
that you do it. While you are writing your Custom Macro in version "B" format for
the practice exercises, keep this in mind when developing you math calculations. If
you do one calculation at a time, it will make it easier to translate the "B" version
Custom Macro into "A" version format.

l
_j

J CNC Concepts, Inc. Custom Macro Programing Page30


Chapter Seven Introduction to the IF Statement

INTRODUCTION TO THE IF STATEMENT

Conditional branching (the IF STATEMENT) is what gives Custom Macro it's


"power". It gives the programer the ability to have a Custom Macro make decisions.
You can have the Custom Macro evaluate a situation and do one of two things based
on the result of the evaluation.

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.

CNC Concepts, Inc. Custom Macro Programing Page31


Chapter Seven Introduction to the IF Statement

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

CNC Concepts, Inc. Custom Macro Programing Page33


Chapter Seven Introduction to the IF Statement

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.

CNC Concepts, Inc. Custom Macro Programing Page35


Chapter Eight Generating Loops

GENERATING LOOPS

Looping is the process of repeating commands in a Custom Macro a specified


number of times. You will have many applications that require looping. If you find
the need to write a section of the Custom Macro more than once, it is probably a
good application for a loop. To look at some examples, loops will be helpful in the
following kinds of Custom Macros:

Machining center applicationr for looping:


1) Bolt hole circle Custom Macro
2) Pocketing Custom Macros
3) Face milling Custom Macro
4) Complex geometry Custom Macros (for sphere, cone, etc.)
5) Slot milling Custom Macro

Turning center applications for looping:


1) Multiple pass grooving Custom Macro
2) Deep hole drilling Custom Macro (with full pullout)
3) Multiple parts from one slug Custom Macro
There are many ways to develop loops in a Custom Macro, some more successful
than others. The method that we will show to develop loops is a "structured" method,
and will be successful about ninety nine percent of the time. There are others ways
to develop your loops, and all we can say to this is "It's hard to argue with success!".
Any Custom Macro that works properly is a good Custom Macro. But to develop
good programing habits (and to be able to repeat your successes in the future), we
recommend using the method we show in this course.

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.

CNC Concepts, Inc. Custom Macro Programing Page37


Chapter Eight Generating Loops

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

CNC Concepts, Inc. . Custom Macro Programing Page39


Chapter Eight Generating Loops

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.

Here is the "first attempt11 Custom Macro with full documentation:

01005 (Custom Macro for Bolt Circle - First attempt)

#1 01 = 1 (Initialize Counter)
Initialize #1 02 =(A) (Initialize 11 Current angle II to A)
=
#103 '36o (Initialize incremental angle)

Test N1 IF [ #101 Gl@)J GOTO 99 (Test if finished)


l
#110 =X+ [SIR[ #102] ~(Current X Pas)
Make Calculations #111 = Y + [COS[
.,:s,, #102] (Current Y Pas)

G[@ X#110 Y#111 R(y.1] Z-~ F


(Machine Hole)
Cutting Movements
GSO (Cancel cycle)

#1 01 = #1 01 + 1 (Step Counter)
Step Counters
#1 02 = #1 02 + #1 03 (Step Current Angle)
Go Back To Test GOT01

End Of Loop N99 M99


And Macro

CNC Concepts, Inc. Custom Macro Programing Page41


Chapter Eight Generating Loops

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.

Practice exercise number five to be done at this time.

CNC Concepts, Inc. Custom Macro Programing Page43


Chapter Nine Preparation for Writing a Custom Macro

PREPARATION FOR WRITING A


CUSTOM MACRO

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.

CNC Concepts, Inc. Custom Macro Programing Page44


Chapter Ten Debugging a Custom Macro

DEBUGGING A CUSTOM MACRO


Once a Custom Macro has been written and has been loaded into the machine, you
will be ready to verify the Custom Macro. We recommend testing a Custom Macro
much more cautiously than you would a standard CNC program. As mentioned,
many times the Custom Macro will be designed to handle a variety of conditions.
As the author of a Custom Macro, it will be your responsibility to verify that the
Custom Macro will"behave" properly under all conditions of the call statement.

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.

CNC Concepts, Inc. Custom Macro Programing Page46


Chapter Ten Debugging a Custom Macro

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.

Practice exercise number six to be done at this time.

_j CNC Concepts, Inc. Custom Macro Programing Page48


Chapter Eleven Machine Related Features

SPECIAL MACHINE RELATED FEATURES OF


CUSTOM MACRO

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.

CNC Concepts, Inc. Custom Macro Programing Page49


Chapter Eleven Machine Related Features

Access to fixture offsets: (Version "B" only)


In version "B" Custom Macro only, just as Custom Macro has access to tool offsets
Custom Macro also bas access to fixture offsets (G54-G59 coordinate systems). For
machines that have fixture offsets, you can have Custom Macro access the values in
these coordinate systems. We can't think of an application that you will need to do
this, but we present it for the sake of completeness. Here is a chart that shows the
list of system variables corresponding to fixture offsets:

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.

Whenever the control reads the statement:


#3001 =o or #3002 =0
It resets the counter and IMMEDIATELY begins counting time from that instant.

CNC Concepts, Inc. Custom Macro Programing Page 51


Chapter Eleven Machine Related Features

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.

CNC Concepts, Inc. Custom Macro Programing Page 53


Chapter Eleven Machine Related Features

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.

CNC Concepts, Inc. Custom Macro Programing Page 55


Chapter Eleven Machine Related Features

Creating new M codes: (Version "B" only)


In a similar way to G codes, the Custom Macro feature will allow you to create up
to at least three new M codes. (up to ten on 10, 11, 12, and 15 series.) There is one
major limitation to using this feature for creating new M codes. With an M code
activated Custom Macro, you will not be able to pass any arguments to the Custom
Macro.
Again the parameters will vary based on FANUC control type. On the 10, 11, 12,
and 15 series FANUC controls, here are the parameters involved:
set to
Parameter: M code: Custom Macro program number to call:
7080........ ...... 09020
7081 ........ ...... 09021
7082 ........ ...... 09022
7083 ........ . ..... 09023
7084 ........ ...... 09024
7085 ........ .. .... 09025
7086 ........ ...... 09026
7087 ........ ...... 09027
7088 ........ .. .... 09028
7089 ........ ...... 09029
The application for new M codes is quite a bit more limitted than for new G codes.
One time you may want to consider using this technique is on a machining center
for a tool change command (M06). As you know for a machining center, the Z axis
must be at the zero return position for a tool change. If you forget to send the Z axis
to zero return position prior to an M06, you will get some kind of alarm.

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.

CNC Concepts, Inc. Custom Macro Programing Page 57


Chapter Twelve Advanced Variable Techniques

ADVANCED VARIABLE TECHNIQUES

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.

Too/life management Custom Macro: (Version "B" only)


In this application, you could use a series #500 common variable to store the current
"time in the cut". Then, from day to day the control will always "know" how much
time your tooling has been used.
Pallet changing Custom Macro:
For machining centers with pallet changers that use sub programs to control the
pallet changer, we can use a #500 series common variable to store which pallet is
currently in the "work position". Then we can create a special"M" function to activate
the Custom Macro. This would allow you to activate the pallet changer with a simple
Meade.

CNC Conceprs, Inc. Custom Macro Programing Page 59


Chapter Twelve Advanced Variable Techniques

Using # 100 common variables from one macro to another:


There may be times when you want to keep certain common variables from one
macro to another. This may be the case when you have so many arguments in the
call statement, that there are not enough available letter addresses to complete the
call statement. In this case you could break your call statement down into two or
more call statements. You could store the "temporary" local variables from the first
call statement into "more permanent" # 100 series common variables. These # 100
series common variables could then be referenced in the following Custom Macro
since these variables are remembered from one Custom Macro to another.

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

CNC Concepts, Inc. Custom Macro Programing Page61


Chapter Twelve Advanced Variable Techniques

Argument assignment number two and Implied variable techniques:


(Version "B" only)
Our next discussion of advanced variable techniques involves argument assignment
number two and implied variables. This technique can be used when a variable to
be used itself is a variable. This may not make much sense yet so lets see if you can
evaluate the following Custom Macro commands:
#101 = 3. (No problem, this just sets #101 to 3.)
#1 02 = 1. (Still no problem. # 102 is set to 1.)
#103 = #[102] (What is the value of #103? Notice that there is no#
inside the bracket. Don't you agree that since the cu"ent value of#102
is 1., that #103 will be equal to 1.? Think about it!)
At this point, you are probably wondering what the application for this technique
could possibly be. Before we can show you, we want to introduce the second way of
assigning our arguments in the call statement, which is called argument assignment
number two.

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.

CNC Concepts, Inc. Custom Macro Programing Page63


Chapter Twelve Advanced Variable Techniques

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)

N1 IF [ #[ #1 01] EQ #0 ] GOTO 99 (If finished, the I value will be


vacant. And since the first time through, # 1 OJ = 4, I sub 1 should not
be vacant. But it will be after the last rise or fall)

Calculations and cutting commands

#101 = #101 + 3. (step #101 by 3, which co"esponds to next I)


GOTO 1 (Go back to if statement)
N99 M99

CNC Concepts, Inc. Custom Macro Programing Page65


Chapter Thirteen Probing Techniques

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.

CNC Concepts, Inc. Custom Macro Programing Page67


Chapter Thirteen Probing Techniques

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.

Remember X is #24, Y is #25, Z is #26, and D is #7.


01011
GOO X#24 V#25 (Move to center of hole)
Z[ #26 + .3] (Move to .3 above probe surface)
G01 z [ #26 - .25 ) F20. (Feed .25 into the hole)
G01 X ( #24 + [#7 1 2]- .2) (Fast feed plus in X to within .2 of
the surface to probe)
G31 X [ #24 + [ #7 12] + .4) F15. (Fast feed into the surface for
approximate position)
G01 G91 X-.03 (Fast feed off the surface)
G31 X.3 F.5 (Slow feed into the surface to get accurate probe)
G90 (Switch back to absolute mode)
#101 = #5061 (Attain current X position at right side of hole)
G01 X [ #24 - ( #7 12] + .2] F20. (Fast feed within .2 inch of the
left side)
G31 X [ #24 - [ #7 1 2) - .4] F15. (Fast feed into the left side of
the hole)
G01 G91 X .03 (Fast feed off the surface)
G31 X-.3 F.5 (Slow feed into the surface)
G90 (Switch back to absolute mode)
#1 02 = #5061 (Attain current X position at left side of hole)
G01 X#24 F20. (Go back to center in X)
G01 V [ #25 + [ #7 12 ) - .2]] (Fast feed within .2 of the surface
to probe In the plus v direction)
G31 V [ #25 + ( #7 12) + .4] F15. (Fast feed into the surface in
V plus)
G01 G91 V-.03 (Fast feed off the surface)

CNC Concepts, Inc. Custom Macro Programing Page69


Chapter Forteen Discussions of Custom Macro "A"

DISCUSSIONS OF CUSTOM MACRO 11A11

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.

CNC Concepts, Inc. Custom Macro Programing Page 71


Chapter Forteen Discussions of Custom Macro "A"

Here are some examples of how we translate version "B" commands to version "A"
commands:
Version "B" command: Version "A" command:

#101 = 1. G65 H01 P#1 01 01.


#102 = 2. + 4. G65 H02 P#102 02 R4
#103 = 5.- 1. G65 H03 P#103 05 R1
#104 = 4. * 3. G65 H04 P#104 04 R3
#105 = 6. I 2. G65 H05 P#105 06 R2
#106 = SORT[81.] G65 H21 P#106 081
#107 = ABS[-10.} G65 H22 P#107 0-10
#108 = [#108 * 6.] I 5. G65 H26 P#108 06 R5
#109 = SORT[[3*3] + [2*2]] G65 H27 P#109 03 R2
#110 = SORT[[3*3]-[2*2]] G65 H28 P#110 03 R2
#111 = 4 * SIN[30.] G65 H31 P#111 04 R3QOOO
#112 = 3 * COS[30.] G65 H32 P#112 03 R30.000
#113 = 5 * TAN[30.] G65 H33 P#113 05 R30000
#114 = ATAN2./4.] G65 H34 P#114 02 R4
GOT05 G65 H80 P5
IF[ #101 EO #102] GOTO 10 G65 H81 P10 0#101 R#102
IF[ #101 NE #102] GOTO 10 G65 H82 P10 0#101 R#102
IF[ #101 GT #102] GOTO 10 G65 H83 P10 0#101 R#102
IF[ #101 LT #102] GOTO 10 G65 H84 P10 0#101 R#102
IF[ #101 GE #102] GOTO 10 G65 H85 P10 0#101 R#102
IF[ #101 LE #102] GOTO 10 G65 H86 P10 0#101 R#102
#3000 = 501 (Problem exists) G65 H99 P501
(Note: Alarm number must be over 500)

CNC Concepts, Inc. Custom Macro Programing Page 73


Chapter Forteen Discussions of Custom Macro "A"

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

Version 11A" format call statement:


N050 G65 H01 P#112 015000 (jourplaceformat)
N060 G65 H01 P#113 023750 (jour place format)
N065 G65 H01 P#114 QO (no format for value of zero)
N070 G65 H01 P#115 015000 (jourplaceformat)
N075 G65 H01 P#116 QS (just number of holes)
NOSO G65 H01 P#117 045000 (note three place format for angle)
N085 G65 H01 P#118 QSOO (note two placeformatforfeedrate)
N090 G65 H01 P#119 Q81 (just cycle type, no need for format)
N095 G65 H01 P#120 010000 (notefourplaceformat)
N100 M98 P1005 (this is the actual command to activate the Custom
Macro.)

CNC Concepts, Inc. Custom Macro Programing Page 75


Chapter Forteen Discussions of Custom Macro "A"

Now you should be able to "follow along" with the version "A" Custom Macro for
this application.

01005 (Bolt Circle Macro in 11 A 11 Format)

Initialize G65 H01 P#1 01 Q1 (Initialize Counter)


G65 H01 P#102 H#117 (Initialize .. current angle 11 to
#117)
G65 H02 P#104 R#114 Q1000 (calculate rapid plane)
G65 H03 P#105 R#114 Q#120 (calculate z hole
bottom)
G65 H05 P#103 Q360000 R#116 (Initialize
incremental angle)

Test N1 G65 H83 P99 Q#1 01 R#116 (Test if finished)

Make Calculations G65 H31 P#125 Q#115 R#102 (temporary calculation)


G65 H02 P#110 Q#112 R#125 (Current X Pas)
G65 H32 P#125 Q#115 R#102 (temporary calculation)
G65 H02 P#111 Q#112 R#125 (Current Y Pas)

Cutting Movements G#119 X#11 0 Y#111 R#1 04 Z#1 05 F#118 (machine


hole)
GSO (Cancel cycle)

Step Counters G65 H02 P#101 Q#101 R1 (Step Counter)


G65 H02 P#102 Q#102 R#103 (Step current angle)

Go Back To Test G65 HSO P1

End Of Loop N99 M99


And Macro

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.

CNC Concepts, Inc. Custom Macro Programing Page 77


CUSTOM MACRO
PROGRAMING
APPENDIX
Example Custom Macros
This section of the manual will show you five relatively complicated Custom Macros.
Our intention with this appendix is to give you some of the "real world" techniques
used with Custom Macro. Each one of these examples is actually being used by a
CNC user in manufacturing today. While you may not agree with all of the techni-
ques used, these Custom Macros do function well in the application for which they
were designed.

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.

CNC Concepts, Inc. Custom Macro Programing Page 78


Appendix- Custom Macro Examples

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.

CNC Concepts, Inc. Custom Macro Programing Page SO


Appendix - Custom Macro Examples

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

CNC Concepts, Inc. Custom Macro Programing Page82


Appendix- Custom Macro Examples

VERSION .. B.. CUSTOM MACRO TO MILL A


CIRCULAR CAM
This Custom Macro completely machines a circular cam in one command. A cam
with up to ten rises and falls can be machined with this Custom Macro. This Custom
Macro uses a relatively complex technique to receive it's variables called argument
assignment number two. Notice that we use up to ten I and J variables in the call
statement to "pass" the "current" ending radius and incremental angle for each rise
or fall. Remember that the first I in the call statement is set to #4. The second to
#7, and so on. The same thing goes forK. In the Custom Macro, we use "implied
variable" techiques to test for the end of the input (last rise or fall). This Custom
Macro is rather complicated, but notice how short it is compared to the amount of
work it is doing!

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

VERSION .. B.. CUSTOM MACRO FOR MILLING


DOUBLE HEX SOCKETS
This "family of parts" Custom Macro allows very easy change over from one socket
size to another. It is quite simple, even though a lot of "trig" went into calculating
the positions. Notice that there are actually three tools involved. First, we rough
mill the outside of the double hex. Then we finish mill. And last, we plunge the
clearance diameter to allow the socket to fit on the bolt.

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

CNC Concepts, Inc. Custom Macro Programing Page86


Appendix - Custom Macro Examples

GO X#112 V#111 GO X-#112 V-#111


G1 Z-[#26] F#6 G1 Z-[#26] F#6
GOZ.2 GOZ.2
GO X#114 V#113 GO X-#114 V-#113
G1 Z-[#26] F#6 G1 Z-[#26] F#6
GOZ.2 GOZ.2
GOXOV#110 GO XO V-#110
G1 Z-[#26] F#6 G1 Z-[#26] F#6
GOZ.2 GOZ.2
GO X-#114 V#113 GO X#114 V-#113
G1 Z-[#26] F#6 G1 Z-[#26] F#6
GOZ.2 GOZ.2
GO X-#112 V#111 GO X#112 V-#111
G1Z-[#26] F#6 G1 Z-[#26] F#6
GOZ.2 GOZ.2 M09
GOX-#110VO G91 G28 XO YO ZO M19
G1Z-[#26] F#6 M99
GOZ.2

CNC Concepts, Inc. Custom Macro Programing Page88


Appendix- Custom Macro Examples

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:

08002 - Tools Macro


Var. Set To: Description:
A 1 Station number of 611 face mill
8 2 Station number of dovetail cutter
c 3 Station number of radius tool
D 4 Station number of chamfer tool
E 5 Station number of 1-1/4 rough end mill
F 6 Station number of 7/8 finish end mill

CNC Concepts, Inc. Custom Macro Programing Page90


Appendix - Custom Macro Examples

08003 CUTTING MACRO

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:

X Length of left die block


v Length of right die block
y Width of die blocks
u Distance from left die block to right die block
(end to end)
A -1 . This 11flag,. tells the Custom Macro whether to use
a right hand or left hand 6 .. face mill. It is preset to
right hand. If you want to use a left hand face mill,
set .. A.. to 1.
B .005 Amount of move over for the 6 11 face mill between
passes (for tool clearance).
c .200 Clearace for 6 11 face mill
D .250 Depth of cut for 6 11 face mill
E .66 Cutter overlap for 611 face mill
F .100 Depth of first dovetail cut
H .025 Depth of subsequent dovetail passes
M -1. This flag tells the Custom Macro whether to climb
mill or conventional mill with the dovetail cutter.
It is set to climb mill. To conventional mill,
set 11 M 11 to 1.
a .125 Chamfer size for ends of dovetail
A .25 Chamfer size for pockets
s 1. New die block or remachine. This flag tells the
Custom Macro whether to machine the pockets.
If S = 1., no pockets will be machined.
If S = -1., pockets will be machined.

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.

CNC Concepts, Inc. Custom Macro Programing Page92


Appendix - Custom Macro Examples

Tools Custom Macro:

08002 (TOOLS MACRO FOR DIE BLOCKS)


IF[#1 NE#O]GOT01
#1 = 1 (FACE MILL)
N1 IF[#2NE#O]GOT02
#2=2 (DOVETAIL MILL)
N21F[#3NE#O]GOT03
#3 = 3 (RADIUS MILL)
N31F[#7NE#O]GOT04
#7 = 4 (CHAMFER MILL)
N4 IF[#8NE#O]GOT05
#8 = 5 (ROUGH END MILL)
N5 IF[#9NE#O]GOT06
#9 = 6 (FINISH END MILL)
N6 #114=#1
#115=#2
#116=#3
#117=#7
#118=#8
#119=#9
M99

CNC Concepts, Inc. Custom Macro Programing Page94


Appendix - Custom Macro Examples

#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

CNC Concepts, Inc. Custom Macro Programing Page%


Appendix - Custom Macro Examples

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

CNC Concepts, Inc. Custom Macro Programing Page98


Appendix - Custom Macro Examples

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

CNC Concepts, Inc. Custom Macro Programing Page 100


Appendix - Custom Macro Examples

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

CNC Concepts, Inc. Custom Macro Programing Page 102


Appendix- Custom Macro Examples

Here is the list of the variables and their meanings:


Var.: Set to: Description:

#101 0 X coordinate of left radius center


#102 0 Y coordinate of left radius center
#103 none Radius of oval
#104 none Thickness of part
#105 .250 Incremental depth of cut in Z
#106 .500 End mill radius
#107 none Overall length of oval
#108 .125 Chamfer size
#109 .500 Chamfer tool radius
#110 5.01PM Roughing feedrate
#111 4.01PM Finishing feedrate
#112 7.01PM Chamfer tool feedrate

Example Main Program:


00200 (OVAL SHAPE MAIN PROGRAM
N1 0 G92 X1 O.Y1 O.Z1 0.
N20 G90 SSOO M03
N30 GOO XS. V5.
N40 GOOZ.1
NSO G65 H01 P#500 Q1 000
N60 G65 H01 P#501 Q50000
N70 G65 H01 P#502 QSOOOO
NSO G65 H01 P#503 Q-10000
N90 G65 H01 P#504 Q1250
N1 00 G65 H01 P#505 Q15000
N110 G65 H01 P#508 Q3750
N120 G65 H01 P#509 Q10000
N125 F6.
N130 M98 P1001
N140 G91 G28 XO VO ZO
N150 M30

CNC Concepts, Inc. Custom Macro Programing Page 104


CUSTOM MACRO
PROGRAMING
PRACTICE EXERCISES
This set of practice exercises has been designed to reinforce the learning environ-
ment, giving you a way to guage your progress. As the course goes on, the practice
exercises will get progressively more difficult. If you are having problems with the
practice exercises, it should be taken as a signal that you need to go back and review
the information again.

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"?

Custom Macro Practice Exercises - Page 1


PRACTICE EXERCISE NUMBER TWO
CUSTOM MACRO FEATURES
(pages 14-19)
1) What are the two basic types of Custom Macro features?

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?

5) What is a statement label? When would you need one?

6) What computer related feature allows redundant Custom Macro commands to


be repeated a specified number of times?

7) Name five machine related features.


A)_______________________________________________________~B~------------------------------------------------------------------------

C) _______________________________________________________~D~------------------------------------------------------------------------

~-----------------------------------------------------------------------------------------------------------------
8) In version "B" how do we pass arguments from the main program to the Custom
Macro? In version "A"?

Custom Macro Practice Exercises - Page 2


PRACTICE EXERCISE NUMBER THREE
VARIABLE TECHNIQUES
(pages 20-27)
1) What are the three main uses for a variable?
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 ..

c ... s ... w ... z ...


E ... T... X ...
5) Which type of variable will be "lost" (set back to vacant) at the completion of a
Custom Macro (in version "B" Custom Macro)? Which type will be remembered
even after the power is turned off to the machine? Which type allows access to many
machine current states? Which type do we generally use for general purpose
calculations?

6) Using the example on given in "introduction to variable techniques" as a "crutch"


write a custom macro for the application on the next two pages for your type of
machine. (in version "B" format):

Custom Macro Practice Exercises - Page 3


Prints For Machining Center Students:
Write a Custom Macro to mill
the square surfaces around
this part. T nMarked Upn Print
With Arguments:
Work Print :

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

Practice Exercise Number Three


Question number Six
Prints For Turning Center Students :
Write the Custom Macro to
finish turn this part . Only
the finishing. not the roughing.
"Marked Up" Print
Work Print: With Arguments:
I ~ 1/8 X45 Deg Chon I / H
. ".
~7 --~/
I
I I
I--
L - - L_
Q I'<"\ '\"\
UJ

~
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

D> I f.E !. 00 e- I k3- D ~


F = Feedrat e
~
Vt
~ ?.nn
2.00 ~ v
E -

Practice Exercise Number Three


Question Number Six (turning)
PRACTICE EXERCISE NUMBER FOUR
ARITHMETIC AND THE "IF STATEMENT"
(pages 28-36)
1) In version "A" format how many calculations are generally allowed per Custom
Macro command?

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: ~
----------

Custom Macro Practice Exercises - Page 6


Print for Machining Center Students:
B T
M
~
A Practice Exercise Number Five
(Question Number Six)
~a
a:
__cj
Q
0
~
~
r=. S = Number of Slots
R
F = Feedrate
l
~.
'"0
~
D

~---.(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)_________________________________________

Custom Macro Practice Exercises- Page 14


5) For your type of machine, write a Custom Macro to handle the application on the
next two pages.
Machining Center Students:
Write a Custom Macro to "circle mill" for the application shown on the next page.
No need to do too many "fancy" things in this Custom Macro. Just make the Custom
Macro make one pass in a clockwise (conventional milling) direction around the
circle.
Turning Center Students:
Write a Custom Macro to "peck drill" with full pullout between pecks. This Custom
Macro will require a loop to be developed for the number of passes required.

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:

A) Have the Custom Macro calculate the number of passes to be made:


#102 = FUP [#26 I #17] (This "rounds up" the number of
passes)
B) Then have the Custom Macro "recalculate" a new incremental depth
per peck based on the number of passes.
#1 03 = #26 I #1 02 (Recalculated depth per peck)
Using the above technique will have the Custom Macro make an even number of
equal depth passes into the hole to the desired depth.

Custom Macro Practice Exercises - Page 15


Practice Exercise Number Six
Print For Machining Center Students: (Question Number Five)
T(Tool Radius)

()
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:

To disble Feed Hold: _ _ _ _ _ _ _ _ _ _ __


To disable Feedrate Overide:
-------------------
4) For Custom Macro "B" format, what procedures would you follow if you wanted
to assign the G word "G101" to a often used Custom Macro?

Custom Macro Practice Exercises - Page 18


5) For the drawings given on the following pages, write a Custom Macro for your
type of equipment.
Machining Center Students:
You will be writing a Custom Macro to machine the complex shape in the form of a
sphere. We will admit that this is a tough one. You will be setting up a loop in the
Custom Macro to repeat a series of motion commands over and over.

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.

Custom Macro Practice Exercises - Page 19


Print for Machining Center Students :

"'///;:,~~ T(Tool Radius

~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

Practice Exercise Number Seven


(Question Number Five)
PRACTICE EXERCISE NUMBER EIGHT
DISCUSSION OF CUSTOM MACRO VERSION "A"
(pages 71-73)
1) What command will actually call the Custom Macro from the main program?

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: _ _ _ _ _ __

Greater Than: Less Than:


---- -----

Custom Macro Practice Exercises - Page 22


5) Translate the following Main Program and Custom Macro from version "B"
fromat to version "A" format:
Version "B .. Main Program: Version ..A.. Main Program:
00011 00011
NODS G50 X._ _ Z._ _ NODS GSO X:.-.._ Z._ _
N01 0 GOO T01 01 M41 N010 GOO T0101 M41
N015 G97 S300 M03 N015 G97 S300 M03
N020 #101 = 4. (HOLE DEPTH)
N025 #102 = .75 (PECK DEPTH)
N030 #103 = .1 (CLEARANCE)
N035 #104 = .005 (FEEDRATE)
N040 M98 P1011 N040 M98 P1011
N045 GOO X_ _ z__T0100 N045 GOO X_ _ Z_ _ T0100
N050 M30 NOSO M30
VERSION "B" CUSTOM MACRO: VERSION "A" CUSTOM MACRO
01011 01011
#108 = 1 (COUNTER)
#109 = #101 I #102 (PASSES)
#110 = #101 I #109 (PECK DEPTH)
#111 = #103 (CURRENT CLEAR POS)
#112 = #110 (CURRENT PECK DEPTH)
N1 IF [#108 GT #109] GOTO 99
GOO XO Z#111 (RAPID TO POSITION)
G01 Z-#112 F#104 (FEED TO CUR DEPTH) _ _ _ _ _ _ _ _ __
GOO Z#103 (RAPID OUT OF HOLE)
#108 = #108 + 1 (STEP COUNTER)
#111 = #111 - #110 (STEP RAPID POS)
#112 = #112 + #110 (STEP DEPTH)
GOTO 1 (GO BACK TO TEST)
N99 M99 (END OF CUSTOM MACRO)

Custom Macro Practice Exercises - Page 23


PRACTICE EXERCISE NUMBER NINE
DISCUSSION OF CUSTOM MACRO VERSION "A"
(pages 74-77)
1) What value does a common variable have when it has not been set in the call
statement (in version "A")?

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.

Custom Macro Practice Exercises - Page 24


Turning 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- "D" (Small diameter of groove)
# 121 - "B" (Diameter to be grooved)
# 122 - "W" (Width of the groove)
#123- "T" (Width of the grooving tool)
#124 - "C" (Chamfer size)
#125 - "H" (Clearance amount)
# 126 - "F" (Feed rate for grooving)
#127 - uzu (Position of left side of groove in Z)
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.

Custom Macro Practice Exercises - Page 25


CUSTOM MACRO
PROGRAMING
ANSWER PROGRAMS
This package of answer programs is intended to be used to check your own Custom
Macro practice programs against. Please do not be too quick to give up and look at
the answer program for the problem you are working on. Always give it your "best
shot" before looking at these answers. Also, please remember that there will always
be more than one correct answer to any one application.

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

PRACTICE EXERCISE NUMBER THREE


ANSWER PROGRAMS
A) Machining Center answer program for milling the outside
square shape from question number six.

Explanation and method:


This relatively simple Custom Macro will mill around the outside square shape for
any size square. We are not doing anything "fancy", just driving the tool around the
square shape. This practice exercise is intended to aquaint you with just how a
Custom Macro is developed.

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)

CNC Concepts, Inc. Page 1


Custom Macro Programing Answer Programs

Answer program to practice exercise number three (cont.)

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)

CNC Concepts, Inc. Page3


Custom Macro Programing Answer Programs

Answer programs to practice exercise number four: (continued)

A) Turning Center answer program for tapping a hole on


a turning center from question number seven.
Explanation and method:
This Custom Macro will include the tests requested from the practice exercise to
make the Custom Macro a little more "fool proof'. We are stressing two of the basic
uses of the "IF STATEMENT' in this exercise. This is intended to make you see
some of he "power" of the "IF STATEMENT'.
Main Program:
00004 (PROGRAM NUMBER)
N005 G50 X Z._ __
N01 0 GOO T01 01 M41
N015 G97 S400 M03
N020 G65 P1004 D.75 T12. (CALL STATEMENT NOTE THAT "T'' IS
THE NUMBER OF THREADS, NOT THE PITCH OF THE
THREAD!)
N025 GOO X Z T01 00
N030 M30
Custom Macro:
01004 (CUSTOM MACRO TO TAP A HOLE ON A TURNING CENTER)
IF [#3 NE #0] GOTO 5 (TEST"C" FOR VACANCY)
#3 = .25 (IF "C" IS VACANT, PRESET "C" TO .25)
N5 IF [#7 NE #0] GOTO 10 (TEST "D" FOR VACANCY)
#3000 = 101 (D MISSING) (GENERATE ALARM IF "C" IS VACANT)
N10 GOO XO Z[#3] (RAPID TO POSITION)
G01 Z-[#7] F[1 I #20] (FEED INTO HOLE NOTE FEEDRATE IS
CALCULATED PITCH PITCH= ONE DIVIDED BY NUMBER
OF THREADS)
M05 (STOP SPINDLE)
M04 (REVERSE SPINDLE)
G01 Z[#3] (FEED BACK OUT OF HOLE)
M03 (SPINDLE BACK TO CLOCKWISE)
M99 (END OF CUSTOM MACRO)

CNC Concepts, Inc. PageS


Custom Macro Programing Answer Programs

Answer to practice exercise number five (continued)

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)

CNC Concepts, Inc. Page?


Custom Macro Programing Answer Programs

Answer program to practice exercise number five (continued)

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)

CNC Concepts, Inc. Page9


Custom Macro Programing Answer Programs

PRACTICE EXERCISE NUMBER SIX


ANSWER PROGRAMS
A) Machining Center answer program for milling a circle
around the inside of a counterbored hole.

Explanation and method:


This Custom Macro should be relatively simple for you to write at this point of the
class. We just asked you to mill around the inside of this hole in a clockwise direction.
No looping is required in this Custom Macro.

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

CNC Concepts, Inc. Page 11


Custom Macro Programing Answer Programs

PRACTICE EXERCISE NUMBER SEVEN


ANSWER PROGRAMS
A) Machining Center answer program for milling a complex shape
in the form of a sphere.

Explanation and method:


We asked you to machine an entire sphere in this Custom Macro. We gave you some
pretty good hints in the question to this exercise. At first glance, this appears to be
a monumental task. But you may be supprised at how short the actual Custom Macro
to do this is.

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)

CNC Concepts, Inc. Page 13


Custom Macro Programing Answer Programs

Answer program to practice exercise number seven (continued)

B) Turning Center answer program for the family ofparts


drawing shown using multiple repetitive cycles.

Explanation and method:


This Custom Macro will completely rough and finish turn any workpiece in the family
shown on the drawing. We use the multiple repetitive cycles (G70-G71) to help.
We machine both the rough and finish turning with the same tool (to keep it simple).
Main Program:
00010 (PROGRAM NUMBER)
N005G50X Z
---
N010 GOO T0101 M41
N015 G96 S300 M03
N020 G65 P1010 A1. B2. C3. D1. E1. F3. H.125 M.125 Q10. R.125 T.12
(CALL STATEMENT)
N025 GOO X Z T01 00
N030 M30

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)

CNC Concepts, Inc. Page 15


Custom Macro Programing Answer Programs

PRACTICE EXERCISE NUMBER NINE


ANSWER PROGRAMS
Note that there was no practice program to write for practice exercise number eight!

A) Machining Center answer program for translating practice exercise


number five from version "B" to version ''A".

Main Program Version 11 B11 : Main Program Version 11A 11 :

00005 (PROGRAM NUMBER) ............... 00005 (PROGRAM NUMBER)


N005 G92 X10. Y10. Z10 ......................... N005 G92 X10. Y10. Z10.
N010 G90 S500 M03 ............................. N010 G90 S500 M03
N015 GOO XO YO .................................... N015 GOO XO YO
N020 G43 H01 Z.5 MOB ......................... N020 G43 H01 Z.5 MOB
N025 G65 P1005 M3. B5. A45 ............... N025 G65 H01 P#120 030000
0.5 C.1 S8. T.5 F1 0 .
..................................... .... ....................... N030 G65 H01 P#121 050000
................................................................ N035 G65 H01 P#122 045000
................................................................ N040 G65 H01 P#123 01000
................................................................ N045 G65 H01 P#124 05000
................................................................ N050 G65 H01 P#125 08
................................................................ N055 G65 H01 P#126 05000
................................................................ N060 G65 H01 P#127 01000
................................................................ N065 M98 P1005
N030 G91 G28 ZO .................................. N070 G91 G28 ZO
N035 G28 XO YO .................................... N075 G28 XO YO
N040 M30 .............................................. NOBO M30
Custom Macro Version nan: Custom Macro Version nAn:
01005 (Slot milling) ................................ 01005 (Slot milling)
IF [ #3 NE #0] GOTO 5 ........................ G65 H82 P5 0#123 RO
#3 = .1 ................................................. G65 H01 P#123 01000
N51F [#20 EO #0] GOTO 97 ............... N5 G65 H81 P97 0#124 RO
IF [#13 EO #0] GOTO 97 ..................... G65 H81 P97 0#120 RO
IF [#2 EO #0] GOTO 97 ....................... G65 H81 P97 0#121 RO
IF [#1 EO #0] GOTO 97 ....................... G65 H81 P97 0#122 RO
IF [#7 EO #0] GOTO 97 ....................... G65 H81 P97 0#126 RO
IF [#19 EO #0] GOTO 97 ...................... G65 H81 P97 0#125 RO

CNC Concepts, Inc. Page 17


Custom Macro Programing Answer Programs

Answer program to practice exercise number nine (continued)

B) Turning Center answer program for translating the grooving


Custom Macro from practice exercise number five from
version ''A" format to version "B" format.

Main Program Version 11 8 11 : Main Program Version 11A11 :


00006 (PROGRAM NUMBER) ............... 00006 (MAIN PROGRAM)
N005 G50 X Z ............... N005 G50 X z___
N010 GOO T0101 M41 ............................ N010 GOO T0101 M41
N015 G96 S400 M03 .............................. N015 G96 S400 M03
N020 G65 P1006 C.025 T.125 W.25 ....... N020 G65 H01 P#120 012500
21.0 01.25 81.5 H.1 F.005
............................................... ................. N025 G65 H01 P#121 015000
N030 G65 H01 P#122 02500
................................................................ N035 G65 H01 P#123 01250
................................................................ N040 G65 H01 P#124 00250
................................................................ N045 G65 H01 P#125 01000
................................................................ N050 G65 H01 P#126 00050
................................................................ N055 G65 H01 P#127 010000
.......... ...................................................... N060 M98 P1 006
N025 GOO X Z T0100 ..... N065 GOO X Z T0101
N030 M30 .............................................. N070 M30
Custom Macro Version 11 8 11 : Custom Macro Version 11A11 :
01006 (GROOVING) .............................. 01006 (GROOVING)
IF [ #11 NE #0] GOTO 5 ...................... G65 H82 P5 0#125 RO
# 11 = .1 ................................................ G65 HO 1 P# 125 R1000
N51F [#20 EO #0] GOTO 97 ............... N5 G65 H81 P97 0#123 RO
IF [#3 EO #0] GOTO 97 ....................... G65 H81 P97 0#124 RO
IF [#2 EO #0] GOTO 97 ....................... G65 H81 P97 0#121 RO
IF [#7 EO #0] GOTO 97 ....................... G65 H81 P97 0#120 RO
IF [#23 EO #0] GOTO 97 ..................... G65 H81 P97 0#122 RO
IF [#26 EO #0] GOTO 97 ..................... G65 H81 P97 0#127 RO
IF [#9 EO #0] GOTO 97 ....................... G65 H81 P97 0#126 RO
IF [ #20 GT #23] GOTO 98 .................. G65 H83 P98 0#123 R#122

CNC Concepts, Inc. Page 19


Custom Macro Programing Answer Programs

Answer program for practice exercise number nine continued

Z-[#26- #23- #3 + #20] ..................... G65 H03 P#119 0#127 R#122


................................................................ G65 H03 P#119 0#119 R#124
................................................................ G65 H03 P#119 0#119 R#123
................................................................ Z-#119
G01 X[#2] .............................................. G01 X#121
X[#2-[2*#3]] Z-[#26-#23+#20] ......... G65 H03 P#130 0#127 R#122
.......... ...................................................... G65 H02 P#130 0#130 R#123
................................................................X#118 Z-#130
GOO X[#2 + [2 * #11]] .......................... GOO X#115
GOTO 99 ................................................ G65 HSO P99
N97 #3000- = 101 (DATA MISSING) ..... N97 H99 P501
N98 #3000 = 102 (TOOL TOO WIDE) .. N98 H99 P502
N99 M99 ................................................ N99 M99

CNC Concepts, Inc. Page21


Custom Macro Handy Reference Card
Version A Custom Macro

General Information: Arithmetic Functions:


Format for a Custom Macro statement: H31 . Sine function
G65 Hxx Pxxx Qxxx {Rxxx) H32 . Cosine function
Evety Custom Macro statement MUST have a G65. The H H33 . Tangent function
word describes the kind of Custom Macro statement. P, Q, H34 . Arc tangent function
and (sometimes) R allow the expression of the ~tutemellt.
To set a variable In the main program: H21 . Square root function
H22 .. . Absolute value function, always plus
G65 H01 P#101 01000
Where P represents the variable to be set and Q is tile actual H23 . Truncate
value (no decimal points allowed). H26. . . Combined multiplication and division
To Call: M98 Pxxxx H27 . Combined square root 1
Note that variables MUST be set PRIOR to tlte M98 state- H28 . Combined square root 2
ment
Custom Macro Format:
Conditional Branching:
Oxxxx (Letter 0, not zero)
H81 through H86
H81 . Equal to
H82 . Not equal to
H83 . Greater than
M99
H84 . Less than
H85 . Greater than or equal to
Variables:
H86 . . Less than or equal to
Common Variables: #100- #149
(standard, you can buy more as an opti01a) Example:
Permanent Common Variables: #500 - #549 G65 H83 P5 0#101 R#102
(JF{#lOl GT #102) GOTO 5)
(standard)
Iftrue, ajwnp to the sequence numberspecified by the P word
Commonly Used System Variables: is executed. Iffalse, the next statement in the Custom Macro
#1 through #64 (Tool Offsets) is executed.
Alarm Generation: H99
Arithmetic G65 H99 P101
H01 . Equality 111is command generate.t all a/ann. The machine will stop
and go into alam1 state. 17e a/ann number 101 will appear
.
H02 . Addition 011 the screen .
H03 . . . Subtraction
H04 . Multiplication
H05 . . . Division
s.
00049(BOLT HL MACRO)
(0.500 DRILL)
G65P7900(SAFE START/END)
090055
N010GOOXOYO
N015043H10Z.1
N020G65P50X3.Y2.5ZO.R1.75D.75AOH4.C73.F5.Q.1
G65P7900
N035M30

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

You might also like