Improve CNC Productivity with Parametric Programming

Similar documents
Course outline. Know Your Machine From A Programmer s Viewpoint 11 If you ve had experience with conventional (non-cnc) machine tools 11

G10 Data Setting Command

FAGOR CNC 8055 ia-mc Control

Radius Compensation G40, G41, & G42 (cutter radius compensation for machining centers, tool nose radius compensation for turning centers)

Easy Machining Center Setup

Proficiency Test For Machining Center

ME 1355 CAD/CAM LABORATORY CNC MILLING PROGRAM. Study of G Codes and M Codes to Write Manual Part Programming for Fanuc Control Systems

Mach4 CNC Controller Mill Programming Guide Version 1.0

Sample. CNC Programming product family... CNC Programming: Basics & Tutorial Textbook. & CNC Programming: Reference Book. CNC Programming: Workbook

G and M Programming for CNC Milling Machines. Denford Limited Birds Royd Brighouse West Yorkshire England HD6 1NB Tel: +44 (0)

3300M CNC Control Editing, Part Programming and Running simple program

Shop-Talk Cad/Cam The language between man and machine!

Week 13 Trigonometric Form of Complex Numbers

Computer-Aided Numerical Control (CNC) Programming and Operation; Lathe Introduction, Advanced Mills

Custom Macro Programming

Mill Series Training Manual. Haas CNC Mill Programming

CNC Applications. Tool Radius Compensation for Machining Centers

Section 1.5 Exponents, Square Roots, and the Order of Operations

MITSUBISHI CNC M700V Series, M70 Series Simple programming function NAVI MILL / NAVI LATHE

5. Tutorial. Starting FlashCut CNC

Lesson 1 Basic Machining Practices Required For CNC Machining Centers

Lead Screw Backlash and Mach3, version 2

Summary Of GCODE Commands By Category (HTT0196)

CNC Programming. Lecture 25. Engineering 475 Automated Production Systems

In mathematics, there are four attainment targets: using and applying mathematics; number and algebra; shape, space and measures, and handling data.

Everything you wanted to know about using Hexadecimal and Octal Numbers in Visual Basic 6

Teaching with Fanuc Certified Education CNC Training On-Line Content

26 Integers: Multiplication, Division, and Order

If A is divided by B the result is 2/3. If B is divided by C the result is 4/7. What is the result if A is divided by C?

G C.3 Construct the inscribed and circumscribed circles of a triangle, and prove properties of angles for a quadrilateral inscribed in a circle.

Surface Machining. NATIONAL INSTITUTE FOR AVIATION RESEARCH Wichita State University. Revision 5.13 Copyright All rights reserved.

GSK928MA Milling Machine CNC System. User Manual. GSK CNC Equipment

Quick Reference ebook

CNC 8055 / CNC 8055i SELF-TEACHING MANUAL ( TC OPTION) (REF 0607) (Ref 0607)

SAT Subject Math Level 2 Facts & Formulas

Mathematics. What to expect Resources Study Strategies Helpful Preparation Tips Problem Solving Strategies and Hints Test taking strategies

Signature Norman Crepeau Special Condition Subject to prior sale Johnford ST60B. CNC Turning Center

The Basics of a Rotary Table with Cross Slide mounted on a Mill Table, Version 2

Geometry Notes PERIMETER AND AREA

Comp 255Q - 1M: Computer Organization Lab #3 - Machine Language Programs for the PDP-8

=

MATH 60 NOTEBOOK CERTIFICATIONS

From Wikipedia, the free encyclopedia

Queensborough Community College NSF Tech ASCEND

Making Soft Jaws for a Bison 3 Jaw Lathe Chuck

CNCTRAIN. Cnc Simulation Systems, 1985,2009

Thnkwell s Homeschool Precalculus Course Lesson Plan: 36 weeks

Chapter 11 Number Theory

Expense Management. Configuration and Use of the Expense Management Module of Xpert.NET

2 Session Two - Complex Numbers and Vectors

How do you compare numbers? On a number line, larger numbers are to the right and smaller numbers are to the left.

IPC-D-356 Simplified. Written by Rich Nedbal. DownStream Technologies, LLC IPC-D-356 Simplified Page 1

Presentation on CNC MACHINES. By: Hafiz Muhammad Rizwan

CALCULATIONS & STATISTICS

Digital System Design Prof. D Roychoudhry Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

TL-Series Sub-Spindle Operator s Addendum

Exponents and Radicals

Geometry Notes RIGHT TRIANGLE TRIGONOMETRY

Solutions to Homework 10

BENCHMAN -XT Machining Center

Unit 1 Number Sense. In this unit, students will study repeating decimals, percents, fractions, decimals, and proportions.

Graphing Calculator Workshops

Session 7 Fractions and Decimals

Optimized NC programming for machinery and heavy equipment. Summary NX CAM software redefines manufacturing productivity with a full range of NC

Microsoft Excel 2010 Part 3: Advanced Excel

The GED math test gives you a page of math formulas that

Expression. Variable Equation Polynomial Monomial Add. Area. Volume Surface Space Length Width. Probability. Chance Random Likely Possibility Odds

Trigonometric Functions and Triangles

Q&As: Microsoft Excel 2013: Chapter 2

SDC. Schroff Development Corporation PUBLICATIONS. MultiMedia CD by Jack Zecher

PROGRAMMABLE LOGIC CONTROLLERS Unit code: A/601/1625 QCF level: 4 Credit value: 15 OUTCOME 3 PART 1

UNIT 1 INTRODUCTION TO NC MACHINE TOOLS

Intro to Excel spreadsheets

Using Casio Graphics Calculators

Algebra. Exponents. Absolute Value. Simplify each of the following as much as possible. 2x y x + y y. xxx 3. x x x xx x. 1. Evaluate 5 and 123

TRIGONOMETRY FOR ANIMATION

1. The volume of the object below is 186 cm 3. Calculate the Length of x. (a) 3.1 cm (b) 2.5 cm (c) 1.75 cm (d) 1.25 cm

Lathe Series Training Manual. Live Tool for Haas Lathe (including DS)

ALGEBRA. sequence, term, nth term, consecutive, rule, relationship, generate, predict, continue increase, decrease finite, infinite

VISUAL GUIDE to. RX Scripting. for Roulette Xtreme - System Designer 2.0

Indicator 2: Use a variety of algebraic concepts and methods to solve equations and inequalities.

Rational Exponents. Squaring both sides of the equation yields. and to be consistent, we must have

Mathematical Induction

Making Basic Measurements. Publication Number August Training Kit for the Agilent Technologies Series Logic Analysis System

Measurement with Ratios

AMSCO S Ann Xavier Gantert

Tom wants to find two real numbers, a and b, that have a sum of 10 and have a product of 10. He makes this table.

(Refer Slide Time: 2:03)

Lecture 2 Mathcad Basics

Copyright 1955by International Business Machines Corporation

National 5 Mathematics Course Assessment Specification (C747 75)

CAHSEE on Target UC Davis, School and University Partnerships

Integer Operations. Overview. Grade 7 Mathematics, Quarter 1, Unit 1.1. Number of Instructional Days: 15 (1 day = 45 minutes) Essential Questions

0.8 Rational Expressions and Equations

The Deadly Sins of Algebra

SOLVING TRIGONOMETRIC EQUATIONS

Multiplying and Dividing Signed Numbers. Finding the Product of Two Signed Numbers. (a) (3)( 4) ( 4) ( 4) ( 4) 12 (b) (4)( 5) ( 5) ( 5) ( 5) ( 5) 20

Creating Basic Excel Formulas

SOME EXCEL FORMULAS AND FUNCTIONS

Transcription:

Improve CNC Productivity with Parametric Programming Mike Lynch - CNC Concepts, Inc - 847-639-8847 - lynch@cnccicom Companion materials available for download at: http://wwwcnccicom/protect/product10/pmpapreszip User name: concept10 Password: machining Objective: To show how you can improve CNC machine tool utilization through the use of parametric programming Outline Introduction to parametric programming (FANUC Custom Macro) Five application categories Computer- and CNC-related features Part Family and user created canned cycles examples Suggestions to improve productivity o Program verification and optimizing o Sizing in the first workpiece on Swiss (sliding headstock) lathe o Use an edge finder like a spindle probe o Streamline tool length measurement on a machining center o Take calculations out of sizing adjustments o Eliminate program zero assignment o Centering the Y axis on live-tooling lathes o Use a universal program for jaw boring o Facilitate calculations for needed values

Introduction to parametric programming Parametric programming goes by many names FANUC (or any control manufacturer that claims to be FANUC-compatible) calls it Custom Macro Fadal calls it Macro Okuma calls it User Task Sodick calls it Q Routine Some control manufacturers have parametric programming capabilities but have not named it with any special name The focus in this text will be on FANUC's version, called Custom Macro While the variations from one version of parametric programming to another lead to differences in specific usage techniques, the broader applications-for and usage-of parametric programming remain remarkably similar This is evidenced by the fact that the majority of applications described in this text can be adapted to every version of parametric programming just mentioned Just as a given software application can be handled by a variety of computer programming languages, so can a given CNC application be handled with different versions of parametric programming Comparison to sub-programming The best way to get comfortable with any complex subject matter is to compare it to simpler topics with which you may already be familiar Custom Macro is no exception If, for example, you have worked with the sub-programming functions of your control, you have scratched the surface of what can be done with Custom Macro All CNC controls have sub-programming functions to allow commands within the CNC program to be repeated This minimizes the number of commands that must be given in the CNC program If, for instance, five identical pockets must be milled in workpieces during the same cutting cycle, it would be cumbersome to program each pocket independently Instead, you can program just one of the pockets and place the commands in a separate (sub) program These redundant commands can be executed five times to machine the five pockets, eliminating many cumbersome, lengthy, and error prone commands FANUC uses an M98 to call a sub-program A P word within the M98 specifies the sub-program number An L word specifies the number of executions of the sub-program Consider this command: N050 M98 P1000 L5 It tells the machine to execute sub-program O1000 five times As long as program O1000 contains the commands needed to correctly machine one of the pockets, the program s length can be shortened and the potential for mistakes will be reduced Sub-programming techniques can be very helpful However, if anything changes about the pocked from one pocket to the next (width, height, depth, etc), you cannot use sub-programming techniques Without Custom Macro, each pocket must be programmed independently In addition to giving the programmer the ability to repeat redundant commands, Custom Macro allows anything to change from one execution of the Custom Macro program to the next In the pocket example, if any pocket-attribute changes from one pocket to the next (width, height, depth, etc) these variations can be easily handled within the Custom Macro program In this sense, Custom Macro programming gives a programmer the ability to write a general purpose sub-program If you have ever found yourself wishing you had the ability to write general purpose sub-programs, you have an application for Custom Macro The things that change from one pocket to the next are called arguments Custom Macro lets you name the arguments in a logical manner You use a G65 command to call the Custom Macro PMPA National Conference 2016 2 Copyright 2016, CNC Concepts, Inc

program Letters of the alphabet can be included in this command to specify argument values Consider this G65 command: N050 G65 P1000 X20 Y15 W40 H20 D25 G65 is a Custom Macro call statement The P-word specifies the program number of the pocketmilling Custom Macro program Letter-addresses X and Y specify the lower left hand corner position of this pocket along the X any Y axis Letter-address W specifies the pocket width, H specifies the height of the pocket, and D specifies the pocket depth Notice how logical you can make the entry of input data (you name them) Anyone can easily recognize the meanings of letter-addresses X, Y, W, H, and D If another pocket of a different size must be machined, another G65 command can be easily specified that contains different argument values Comparison to canned cycles All CNC control manufacturers provide a series of programming features to minimize a programmer's work FANUC-controlled machining centers, for instance, come with a set of holemachining canned cycles (specified by G73-G89) Some machining center controls also have certain milling canned cycles like circle pocket milling, slot milling, thread milling, and face milling FANUC-controlled turning centers come with a set of multiple repetitive cycles for rough & finish turning and boring, grooving, hole machining, and threading It is likely that you are familiar with at least some of these cycles Let's compare what you know to Custom Macro Here are the commands to drill a series of holes on a FANUC-controlled machining center N065 G54 G90 S400 M03 (Select coordinate system, absolute mode, and start spindle) N075 G00 X10 Y20 (Rapid to first hole location) N080 G43 H01 Z01 (Instate tool length compensation, move to Z approach position) N085 G81 R01 Z-075 F45 (Drill first hole) N090 X30 (Drill second hole) N095 X50 (Drill third hole) N100 X70 (Drill fourth hole) N105 G80 (Cancel cycle) N110 G91 G28 Z0 M19 (Return to Z axis reference position) In line N085, the first hole is completely machined based upon FANUC's G81 function and the words included in the command (R, Z, F, etc) The machine will perform a series of previously planned motions based on the canned cycle s design With G81, the machine will, first, rapid a drill to the XY position Next, it will rapid the drill to the R plane, plunge the drill to the hole bottom, and retract the drill from the hole So with G81, four movements are generated with one command With other canned cycles (like peck drilling) even more movements are caused by one command Notice how similar the G81 command format is to that of the pocket milling example calling G65 command shown earlier The R-, Z-, and F-words in the G81 (or any canned cycle) are like the arguments being passed to the Custom Macro program You can think of all canned cycles as being like Custom Macro programs written and maintained by the CNC control manufacturer PMPA National Conference 2016 3 Copyright 2016, CNC Concepts, Inc

If your control does not have a needed canned cycle, or if you do not agree with how a given canned cycle functions, you can develop a Custom Macro program to handle the application In essence, you can create your own canned cycles If you have ever wanted the ability to create your own canned cycles, you have an application for Custom Macro Comparison to computer programming If you have had experience with any computer programming language, you already know much of what is available with Custom Macro There are many computer-related features of Custom Macro that closely resemble those found in computer programming languages These features include variables, arithmetic, logic, and looping For now, suffice it to say that most of what can be done in computer programming languages can be done within Custom Macro programs If you have had no previous computer programming experience, we again recommend that you pick up a beginner s book on computer programming It will reinforce the presentations we make about computer-related features of Custom Macro If you have ever found yourself wishing you could include computer-programming-like commands in your CNC program, you have an application for Custom Macro All programs can use Custom Macro functions You may be wondering if anything special must be done in order in order to utilize Custom Macro commands in a program When the Custom Macro option has been equipped on a machine, you have access to its function set that extends what you can do with normal G-code level programming These additional (Custom Macro) functions will be available for use from within CNC programs Custom Macro functionality can be utilized from within any CNC program, including main programs and sub-programs You do not have to do anything special to use Custom Macro functions in a program Programs can reside in CNC memory or on an external device, like a memory card or flash drive FANUC controls will interpret CNC commands a bit differently than Custom Macro (arithmetic and logic) commands If the SINGLE BLOCK switch is turned on, for example, the machine will stop after every CNC command Depending on a parameter setting, the machine may not stop after each Custom Macro command Application categories As stated in the preface, there are countless applications for Custom Macro, and almost every CNC user has at least some good applications In this discussion, we organize all applications for Custom Macro into five basic categories Part-families Many CNC users machine a series of very similar workpieces Groups of similar workpieces are called part-families Generally speaking, all workpieces in a part-family closely resemble one another and require a similar (if not identical) machining process In classic part-families, only workpiece size changes Bolts, screws, nuts, washers, and pins, for example, are made in a variety of sizes to suit the needs of industry The hex-shaped sockets a hand tool manufacturer makes are made in various sizes to accept changing bolt and nut sizes The rings a piston ring manufacturer makes are made in various sizes and used with a variety of piston sizes The list of common part-families is virtually endless PMPA National Conference 2016 4 Copyright 2016, CNC Concepts, Inc

How are your drawings dimensioned? Some companies utilize variable dimensioning techniques for dimensioning a family-of-parts A design engineer will dimension values that change with a letter of the alphabet Any person viewing the drawing will determine the value of a given dimension by referencing a chart included on the drawing By knowing the workpiece s part number, anyone can find the values of each variable dimension The next illustration shows an example of this kind of part-family dimensioning If your company uses variable dimensioning techniques, you have a part-family application for Custom Macro A part-family application for Custom Macro Notice that dimensions are specified with letters (A, B, C, etc) Custom Macro often allows you to designate the value of each argument with the same letters that are used on the drawing For example, here is one way to specify that part number SC-0875 is to be made from the previous illustration: N060 G65 P1000 A1375 B0875 C0437 D01875 In this example, notice how arguments A, B, C, and D directly correspond to print dimensions (D specifies the counter-bored hole-diameter, which in turn, determines how the rest of the hole must be machined) Though there may be other changing attributes to be handled for this application (speed & speed variations, tool station numbers, etc), this example command should nicely stress how easy it can be to specify which workpiece in a family is being machined The more workpieces in a part-family, the easier it is to justify Custom Macro programming techniques Keep in mind, however, that Custom Macro programs do take longer to write than conventional CNC programs From a strictly programming-time-based justification standpoint (not considering program maintenance issues), it may be difficult to justify writing a Custom Macro program for part-families having but a few workpieces Even for simple part families, it can take PMPA National Conference 2016 5 Copyright 2016, CNC Concepts, Inc

from 3-10 times longer to write the Custom Macro program than it will take to write one hard-andfixed CNC program for a workpiece in the part-family User-created canned cycles Even if your company s products contain no part-families, it is likely that you have at least some similar machining operations required on multiple workpieces Custom Macro can dramatically streamline the programming of repeated machining operations Many machining operations are similar in nature and can be easily handled by using Custom Macro programming techniques Here are some examples you should easily recognize Machining centers: Thread milling Round pocket milling Rectangular pocket milling Circle milling Face milling Keyway milling Slot milling Hole-machining (drilling, tapping, reaming, boring, etc) Hole-pattern machining (bolt-hole circle, grid pattern, window pattern, etc) Turning centers: Groove necking Tapping (some turning centers do not have this cycle) Deep hole peck drilling (some turning centers do not have this cycle) Knurling If you have ever found yourself wishing that your control s canned cycles worked differently, you have a user-created canned cycle application for Custom Macro In addition to modifying the method by which your current canned cycles work, you have the ability to create your own canned cycles with Custom Macro Most machining centers, for example, do not have a canned cycle for thread milling If you perform thread milling on a regular basis and if your machine does not have a thread milling cycle, you are likely writing many tedious, redundant, and error prone commands With Custom Macro, you can create your own thread milling canned cycle In similar fashion, most turning center controls do not include an adequate canned cycle to machine grooves If you must neck grooves in many workpieces and if your machine does not have a canned cycle for machining grooves, again, you must write many tedious, redundant, and error prone commands With Custom Macro, you can create your own grooving cycle Many companies perform unusual machining operations that are specific only to their own products and manufacturing processes, and no control manufacturer will consider creating canned cycles for machining operations that are not helpful to the majority of their users Relatively few machining center users, for example, machine dovetails This machining operation normally requires a number of successive milling passes with a dovetail cutter Utilities This application category tends to be the most overlooked Even people who consider themselves well versed may not be aware of the countless utility applications for Custom Macro There is a good reason why utility applications are not so well known Most incorporate lesser known CNC- PMPA National Conference 2016 6 Copyright 2016, CNC Concepts, Inc

related features of Custom Macro And before you can incorporate any new technique, of course, you must know it is possible to do so While we discuss CNC-related features of Custom Macro in during lessons six and seven, we wish to at least introduce you to some of the remarkable possibilities now Utility applications can reduce setup and program verification time, the can reduce production-run time, they can catch mistakes, they can make a CNC machine easier and safer to run, they can emulate costly options, and in general, they can in some way facilitate CNC machine tool usage In fact, any specific problem you are having with CNC machine tool utilization can probably be facilitated in some manner through the use of a utility Custom Macro program You say this sounds like a pretty bold statement? Let s look at some specific examples of utility applications that reinforce these claims Complex motions and geometric shapes Custom Macro programs can perform basic arithmetic functions like equality (substitution), addition, subtraction, multiplication, and division, as well as certain higher level functions like sine, cosine, tangent, square root, and rounding (among many others) Arithmetic, combined with the ability to perform logic and looping, give the Custom Macro programmer the power to create Custom Macro programs capable of machining highly complex geometric shapes Indeed, any shape that can be defined with an arithmetic calculation can be machined with a Custom Macro program While Custom Macro programs for standard shapes like spheres, pyramids, ellipses, and splines can be created with relative ease, the difficulty of writing Custom Macro programs for applications in this category is directly related to the complexity of the workpiece to be machined When it comes right down to it, it is usually easier to utilize a computer aided manufacturing (CAM) system for complex work However, you should know that Custom Macro programming for complex shapes (when feasible) has two advantages over even the most sophisticated CAM systems First, G-code programs for complex shapes that are generated by CAM systems tend to be very long It is not unusual for a program that simply machines a spherical shape to include hundreds (if not thousands) of commands The comparable sphere milling Custom Macro program (shown in lesson eight) will consist of about fifty commands Second, Custom Macro programming gives you the ability to create motions that are specific to your own application/s The Custom Macro program for the circular cam shown in the next illustration, for example, is very easy to use While there are CAM systems capable of creating CNC programs to machine a circular cam, there are also many that cannot, and of those that do, none make it as simple as a Custom Macro program developed specifically for this purpose PMPA National Conference 2016 7 Copyright 2016, CNC Concepts, Inc

A circular cam machined by a Custom Macro program No computer aided manufacturing system we know of makes it as simple for the user to input the values needed to machine the circular cam as this example command using Custom Macro s argument assignment number two (The Custom Macro program for this application is shown in lesson seven) N010 G65 P1002 A175 B-05 C01 I120 J175 I350 J1625 I1750 J11 I250 J175 I1140 J175 Driving accessory devices As stated earlier, there are certain devices associated with CNC machine tools that require a higher level of programming than can be found with standard G-code level manual programming Most touch-probing systems like spindle probes, for example, are programmed at G-code level yet require sophisticated programming functions When a touch-probe stylus contacts a surface, the program must have a way to locate the surface just contacted Once located, it is likely that some calculations will be necessary to determine if the surface is where it should be If it is not, possibly an alarm should be sounded Possibly an offset should be adjusted Possibly the machine should be made to stop PMPA National Conference 2016 8 Copyright 2016, CNC Concepts, Inc

Feature types There are computer-related and CNC-related features in Custom Macro They provide tremendous programming capabilities to help improve CNC productivity Computer related features These are features that are similar to those found in computer programming languages Variables One of the most important features of any programming language, including any version of parametric programming, is the ability to incorporate variables Though the syntax and structure for variable usage changes from one version of parametric programming or computer programming to another, the general applications remain remarkably similar If you have experience with computer programming, you know what variables are The use and application of variables in Custom Macro are much the same as they are in any programming language However, people that have no computer programming experience may find it somewhat difficult to understand the concept of variables For this reason, we begin with two simple analogies to help you understand variables Arguments Arguments specify input data (values that can change from one time the Custom Macro program is used the next) They tell the Custom Macro program how to behave right now - or this time They are especially helpful in part-family and user-created canned cycle applications There are actually two ways to use arguments in Custom Macro based on which of these two these application categories is being developed Local variables Local variables have two purposes The primary purpose for local variables is to represent letteraddress arguments that are specified in a G65 command The secondary purpose is for use in general purpose calculations (just like common variables which are described a little later) Local variables with argument assignment number one As you now know, when a Custom Macro program is called with a G65 command, arguments take the form of letter-addresses And again, allowable letter-address arguments with argument assignment number one include: A, B, C, D, E, F, H, I, J, K, M, Q, R, S, T, U, V, W, X, Y, and Z Though it may be a little confusing, you are not allowed to directly reference an argument within the Custom Macro program with its letter-address If you try to do so, the machine will confuse the argument name (A, B, C, X, Y, Z, etc) with the actual CNC meaning for the letter-address For this reason, you must reference arguments in the Custom Macro program by their corresponding local variables Like all variable types in Custom Macro (except letter-address arguments), local variables begin with a pound sign and are specified with a number The next table shows the list containing all allowable letter-address arguments and their corresponding local variable numbers This is the most popular form of argument assignment, called argument assignment number one PMPA National Conference 2016 9 Copyright 2016, CNC Concepts, Inc

Letter Local Variable A #1 B #2 C #3 D #7 E #8 F #9 I #4 J #5 K #6 M #13 Q #17 R #18 S #19 U #21 V #22 W #23 X #24 Y #25 Z #26 H #11 T #20 Letter-address arguments and their representing local variables when using argument assignment number one When a G65 command is executed, two things will happen First, all local variables that have corresponding letter-address arguments in the G65 command will be set Second, the Custom Macro specified by the P word will be executed During the execution of the Custom Macro, local variables will contain the values of arguments specified in the G65 command Within the Custom Macro, local variables must be used whenever you need to reference argument values specified in the G65 calling command As an example, consider this command: N025 G65 P1000 X0 Y0 Z0 W50 H30 T05 D10 F50 (Mill right side) It first sets the local variables corresponding to letter-addresses X, Y, Z, W, H, T, D, and F In this case, local variables will be set as follows: #24 (for X) set to 0 #25 (for Y) set to 0 #26 (for Z) set to 0 #23 (for W) set to 50 #11 (for H) set to 30 #20 (for T) set to 05 #7 (for D) set to 10 #9 (for F) set to 50 Second, the machine will execute program O1000 When the programmer needs to reference the value of argument X within the Custom Macro program, #24 must be used Common variables Common variables are introduced during the discussion of arguments used in part-family applications Again, common variables range in the #100 series and at least fifty are available, from #100 through at least #149 It is likely that your machine has more If your machine has two hundred common variables, for instance, they will range from #100 through #199 As the name implies, common variables remain active even after the execution of the Custom Macro program Most FANUC CNCs are set to retain common variable values (again, in the #100 series) until the power to the machine is turned off, at which time they are set back to vacant Permanent common variables These variables range in the #500 series FANUC CNCs will have at least ten permanent common variables (from #500 through #509) Most have many more, possibly ranging from #500 through #999 As the name implies, these variables are retained even after the power is PMPA National Conference 2016 10 Copyright 2016, CNC Concepts, Inc

turned off In this sense, they are much like tool offsets And like tool offsets, most CNCs let you modify the values of permanent common variables through the MDI panel keyboard and display screen Since some CNCs have so few permanent common variables (again, as few as ten), be sure to reserve their use for those applications when it is necessary to retain data from day to day One example is a with utility Custom Macro program for part counting Say you wish to set up a part counter The machine will run 750 workpieces and then halt the machine (this application is shown in lesson six) As you begin running production, your Custom Macro based part counter will begin counting workpieces It isn t very likely that you will finish all 750 workpieces before the end of the day/shift It will more likely take several days to complete the production run In this case, you will need your part counting Custom Macro program to remember where it left off from day to day (after the power is turned back on) If you store the current part count in a #500 series permanent common variable, the part count value will not be lost when the power is turned off System variables Many of the CNC-related features of Custom Macro are accessed with system variables These variables range from #1000 through about #12000 Many can also be referenced by names that are easier to remember than the system variable numbers (like [#_DATE] instead of #3011 System variables allow you to access many CNC functions, including current axis position, current values of offsets, alarm generation, and much more Arithmetic Anything that can be done on a scientific calculator can be done in a Custom Macro program Basic functions As stated, Custom Macro allows equality (substitution), addition, subtraction, multiplication, and division The characters used to represent each basic arithmetic function are universally accepted, they are used by all computer programming languages The equal sign (=) is used for equality, the plus sign (+) for addition, the minus sign (-) for subtraction, the asterisk (*) for multiplication, and the slash code (/) for division The use of these basic arithmetic functions should be familiar, since applications for their use are shown in lesson two Advanced functions As stated, most versions of parametric programming allow much more than simple equality, addition, subtraction, multiplication and division Here we introduce those functions supported by Custom Macro Trigonometry functions Custom Macro provides enough trigonometry functions to handle even the most complex rightangle trigonometry problems The next table shows Custom Macro trigonometry functions including their names, syntax, a simple example, and the answer: Function Syntax Example Value of #100 PMPA National Conference 2016 11 Copyright 2016, CNC Concepts, Inc

Sine #i=sin[#j] #100 = SIN[300] 05 Cosine #i=cos[#j] #100 = COS[300] 0866025 Tangent #i=tan[#j] #100 = TAN[300] 0577350269 Arc Sine #i=asin[#j] #100 = ASIN[05] 300 Arc Cosine #i=acos[#j] #100 = ACOS[0866025] 300 Arc Tangent (method 1) Arc Tangent (method 2) Arc Tangent (method 3) #i=atan[#j] #100 = ATAN[0577350269] #i=atan[#j]/[#k] #100 = ATAN[05]/[0866025] #i=atan[#j,#k] #100 = ATAN[05,0866025] 300 300 300 Trigonometry functions in the current version of Custom Macro Rounding functions Custom Macro allows the rounding of real numbers (values that include a decimal portion) ROUND will round a number to the next closest integer (up or down) FIX will round a number down to the next lower integer FUP will round a number up to the next higher integer The next table shows the rounding function, their syntax, an example, and the answer Function Syntax Example Value of #100 Round #i=round[#j] #100 = ROUND[32] 30 Round down #i=fix[#j] #100 = FIX[38] 30 Round up #i=fup[#j] #100 =FUP[32] 40 Rounding functions in Custom Macro Other arithmetic functions There are other arithmetic functions available in Custom Macro Some may be quite important to you while others may be seldom, if ever, used An understanding of mathematics is required to understand them all, and your own ingenuity may inspire times when they can be useful We will introduce each, show its syntax, and if possible, provide an example of its use Square root As the name implies, this function (specified with the Custom Macro word SQRT) returns the square root of the specified value or expression Consider this example: #100 = 50 (Short side of triangle) #101 = 80 (Long side of triangle) #102 = SQRT[[#100 * #100] + [#101 * #101]] (Hypotenuse of triangle) PMPA National Conference 2016 12 Copyright 2016, CNC Concepts, Inc

All higher level functions (including square root) allow arithmetic expressions to be performed internal to the brackets of the function In this case, everything in brackets will be calculated prior to the square root function You may recognize this example as Pythagorean's Theorem (calculating a triangle's hypotenuse length by applying the square root to the side-adjacent squared plus the side-opposite squared) Absolute value This function, specified with ABS, returns the magnitude value (without polarity) of any value or expression specified within its brackets While it may not be the most appropriate use, absolute function has the effect of ensuring that a value that cannot be negative Power This function provides the ability to multiply a number times itself a specified number of times Here is the syntax #100 = POW[40,20] Natural logarithm and exponent using base e (2718 ) Though we do not provide any applications (frankly because I cannot think of any) for logarithms and exponents using base e in Custom Macro), it is possible to use them within Custom Macro programs Again, with your situation and ingenuity, you may come up with suitable applications So you should at least know it is possible to incorporate natural logarithms and exponents in your Custom Macro programs The syntax for natural logarithm is as follows: #100 = LN[30] Binary and binary coded decimal conversions We do not provide any applications for these functions, but they are available should you find a need The function BIN converts a binary coded decimal value to binary format The function BCD converts a binary value (made up of eight digits of zeros and ones) to binary coded decimal format Reading parameter values This is a relatively new feature in Custom Macro and is not available in all older versions (like Custom Macro B) We consider the ability to read parameter values from within Custom Macro programs to be a CNC-related feature of Custom Macro However, FANUC includes this function in the list of arithmetic functions so we include a brief introduction here Rest assured that more information will be provided when we address CNC-related features of Custom Macro in lesson six Priority of arithmetic operations As stated earlier, you must understand the order by which arithmetic operations are performed in order to develop expressions that combine arithmetic operations Custom Macro follows the same priority as any computer programming language Now that we have shown all of the arithmetic functions, we can show the complete priority of arithmetic operations from highest priority to lowest 1) Operations in brackets PMPA National Conference 2016 13 Copyright 2016, CNC Concepts, Inc

2) Higher level functions (SIN, COS, TAN, SQRT, etc) 3) Multiplication then division 4) Addition then subtraction While it will not have any bearing on the outcome of the expression, the control will always work through the expression at a given level (1-4) from left to right If performing at level three (multiplication then division), for example, it will perform multiplication from the left to right in the expression Then it will perform division from left to right As stated earlier, if you are in doubt about operation execution order, you can always use brackets to force the order of execution you need Remember that when you do so, however, you will be wasting nest levels if you "force" the machine to perform the calculation in the same order it would have otherwise done Logic and program flow control The general flow (order of execution) for a normal CNC G-code level program is from beginning to end When a program is activated, the control will read, interpret, and execute the very first command in your program It will then proceed to the second command Read, interpret, and execute Then it will move on to the third command, then the next, and then the next It is by this sequential order that CNC programs are normally executed With Custom Macro programming, you have the ability to change the order of program execution You can have Custom Macro programs make tests to determine which of two or more possible outcomes it will follow You can even make the machine repeat a series of commands until some criteria is/are satisfied We ll call this powerful ability to change the order of program execution program flow control There are several commands in Custom Macro that are related to program flow control In this lesson, we will introduce program flow command types and then show examples of when they are used Statement labels Some program flow commands require a unique marker to designate a position in the program that is to be used to control program flow We call these markers statement labels Statement labels specify points in the program where the CNC is told to continue executing the program FANUC uses sequence numbers (N words) as statement labels This text shows a sequence number in almost every command of most programs for the purpose of documentation However, we recommend in your own Custom Macro programs, that you only include sequence numbers when they are required as statement labels This will make them stand out It will be easier to find a statement label being referenced It will also reduce the length of your Custom Macro programs, conserving some CNC memory To further simplify statement label usage when they are required, use small sequence number (like N1, N2, N3, etc) near the beginning of the Custom macro program Use sequence numbers around fifty in the middle of the program Use sequence numbers close to 99 near the end of the program And if possible, keep sequence numbers in ascending order This way, when you need to find a given statement label in a lengthy Custom Macro program, you will know where to look PMPA National Conference 2016 14 Copyright 2016, CNC Concepts, Inc

Unconditional branching As the name implies, the unconditional branching Custom Macro command will cause the machine to branch (jump) from one location in the program to another location in the same program The location to which branching is done must be marked with a statement label (sequence number) You specify an unconditional branching statement in Custom Macro with a GOTO statement Here is the syntax for the GOTO statement: GOTO 50 (Branch to statement label N50 Note no N word) N50 G00 X (Statement label N50) Conditional branching Just like conditional branching in any computer programming language, conditional branching in Custom Macro provides a decision-making capability The Custom Macro programmer can make the program perform tests The program can be executed differently based upon test results The purposes for testing are extremely varied and we cannot over-stress the importance of conditional branching for testing purposes You can test just about anything within your Custom Macro program And based upon the results of your test, you can make the program execute differently This feature has fantastic, nearly limitless, implications Syntax for conditional branching statements Before we show specific applications for conditional branching, you must understand its syntax Custom Macro uses an IF statement for conditional branching And Custom Macro as it is equipped on current FANUC controls allows great flexibility regarding how IF statements can be written Older versions of Custom Macro (like Custom Macro B), on the other hand, do not support all of the variations we show You may be limited to the most basic (universal) format for IF statements Rest assured that even though it is more difficult to create the needed conditional branching (IF) statements with only the most universal IF statement, all conditional branching applications can be handled The conditional expression All IF statements require at least one conditional expression The result of the conditional expression/s will be either true or false If the result is true, the Custom Macro command to the right of the IF statement is executed If the result is false, the command after the IF statement is executed This is how Custom Macro programs can make decisions With each conditional branching statement, the result will cause the program to do one of two things, again: execute what is to the right of the IF statement or execute the next command Conditional expressions require conditional operators There are six conditional operators in Custom Macro: PMPA National Conference 2016 15 Copyright 2016, CNC Concepts, Inc

1) Less than (LT) 2) Less than or equal to (LE) 3) Equal to (EQ) 4) Greater than (GT) 5) Greater than or equal to (GE) 6) Not equal to (NE) The six conditional operators allow great flexibility in the method by which you develop conditional branching commands In most cases, the same test can be written in several ways (as many as six ways, corresponding to the number of available logical operators) While this flexibility is good, it can sometimes be confusing, especially when you are testing with the not equal to (NE) conditional operator Always remember that the test within the conditional branching statement is to determine whether the conditional expression is true or false When testing against a negative condition, it is easy to make evaluation mistakes The universal conditional branching command format Newer FANUC control models allow much more flexibility with conditional branching than older models You must consult your FANUC manual to determine whether newer features are available You can rest assured that all FANUC controls allow this universal conditional branching command format As stated, if the conditional branching statement is true, the command to the right of the statement is executed With the universal conditional branching command format, you are limited to placing a GOTO statement to the right of the IF statement Consider this example: You wish to write a grooving Custom Macro program for your turning center that can use right hand or left hand tooling You wish to include a special argument in the call statement, say H for hand, to specify the hand of tooling style Your documentation criteria states that if H is set to one, right hand tooling is being used If H is set to zero (or any value other than one), left hand tooling is being used If, of course, right hand tooling is being used, the spindle must be running in a forward (M03) direction If left hand tooling is being used, the spindle must be running in a reverse direction (M04) Here is a portion of the Custom Macro program that performs the appropriate test and starts the spindle in the correct direction Letter-address H is represented by local variable #11 in the Custom Macro program Study these commands that will be included in the Custom Macro program when the spindle is started: IF [#11 EQ 10] GOTO 5 M04 GOTO 6 N5 M03 N6 PMPA National Conference 2016 16 Copyright 2016, CNC Concepts, Inc

Note that brackets ([]) must be used to enclose the conditional expression This particular conditional branching statement uses the equal-to (EQ) logical operator, which makes it quite easy to evaluate the results of the test (true or false) If a person using this Custom Macro includes H10 in the call statement to the Custom Macro (the G65 command), the machine will evaluate the conditional branching statement as true In this case, the GOTO statement to the right of the IF statement will be executed In N5, the M03 will start the spindle in the forward direction (as is required for right hand tools) On the other hand, if the person using this Custom Macro program sets the value of H to zero (or anything other than one), the IF statement s conditional expression will be evaluated as false Now the command following the IF statement will be executed, starting the spindle in the reverse direction (as is required for left hand tools) Note the need for the GOTO 6 statement If the conditional expression is evaluated as false, and the spindle starts in the reverse direction, we need the CNC to skip the M03 command (the other possibility of the IF statement) This GOTO statement keeps the CNC from starting the spindle in the forward direction CNC related features (system variables) Most CNC-related features of Custom Macro programming are handled with system variables Like any other variable in Custom Macro, one way to reference them is with a pound-sign and a number (like #2001) But unlike other variables that can be used to represent just about anything, each system variable has a fixed function, and it can only be used to reference its related function System variables allow you to access many machine functions right from within the Custom Macro program Offsets, axis position, alarm generation, and current machine states are among the many accessible machine functions Access to tool offsets Custom Macro provides access to all tool offset registers within a FANUC control Though the specific system variable number/name may vary among control models, rest assured that you have access to every tool offset register You have the ability to read and write values to and from tool offset registers, meaning you can access their values for use within a Custom Macro program as well as enter them from within a program You probably already know that most controls give you the ability to write to the tool offset registers using standard G-code G10 is used for this purpose However, there is no standard CNC function (without Custom Macro) that allows you to read the value stored within a tool offset register and use it within your CNC program This ability to read offset register values has some pretty important implications But before we show applications, we will first show the related system variables and their syntax No GEOM (H) Number GEOM (H) Name WEAR (H) Number WEAR (H) Name GEOM (D) Number GEOM (D) Name WEAR (D) Number WEAR (D) Name 1 #2001 [#_OFSHG[1]] #2201 [#_OFSHW[1]] #2401 [#_OFSDG[1]] #2601 [#_OFSDW[1]] 2 #2002 [#_OFSHG[2]] #2202 [#_OFSHW[2]] #2402 [#_OFSDG[2]] #2602 [#_OFSDW[2]] PMPA National Conference 2016 17 Copyright 2016, CNC Concepts, Inc

199 #2199 [#_OFSHG[199]] #2399 [#_OFSHW[199]] #2599 [#_OFSDG[199]] #2799 [#_OFSDW[199]] 200 #2200 [#_OFSHG[200]] #2400 [#_OFSHW[200]] #2600 [#_OFSDG[200]] #2800 [#_OFSDW[200]] System variable numbering/naming for a 0iD control when there are four registers per offset and 200 total offsets (Tool Compensation Memory Type C - 200 offsets) Access to current position This CNC related feature of Custom Macro gives you the ability to determine the position of at any axis at any time (during the execution of a program) You can access current position in four ways: 1) Relative to the program zero point (absolute position without compensation) 2) Relative to the program zero point (absolute position with compensation) 3) Relative to the machine's reference (zero return) position (machine position), with compensation 4) Absolute position after skip signal of G31 (used with touch probes), with compensation We show the related system variables and their syntax before showing implications of when position access can be helpful Unlike system variables related to offset access that provide read and write access, positionrelated system variable only provide read capabilities You cannot write to them For a three axis machining center Here are the system variables for a three axis machining center: Current absolute position not modified by instated compensation #5001 or [#_ABSIO[1]] - X axis position in current coordinate system #5002 or [#_ABSIO[2]] - Y axis position in current coordinate system #5003 or [#_ABSIO[3]] - Z axis position in current coordinate system Current absolute position modified by instated compensation #5041 or [#_ABSOT[1]] - X axis position in current coordinate system #5042 or [#_ABSOT[2]] - Y axis position in current coordinate system #5043 or [#_ABSOT[2]] - Z axis position in current coordinate system Current machine position: #5021 or [#_ABSMT[1]] - X position relative to the machine s reference (zero return) position #5022 or [#_ABSMT[2]] - Y position relative to the machine s reference (zero return) position #5023 or [#_ABSMT[3]] - Z position relative to the machine s reference (zero return) position Skip signal position after touch-probe contact (absolute position): #5061 or [#_ABSKP[1]] - X position in current coordinate system at the instant of probe stylus contact PMPA National Conference 2016 18 Copyright 2016, CNC Concepts, Inc

#5062 or [#_ABSKP[2]] - Y position in current coordinate system at the instant of probe stylus contact #5063 or [#_ABSKP[3]] - Z position in current coordinate system at the instant of probe stylus contact Alarm generation Error trapping is the process of finding conditions that require the stoppage of a program s execution before something bad can happen During our discussion of conditional branching in lesson four, we introduce the alarm generation function of Custom Macro: There are the two ways to specify the alarm generating system variable: 1) #3000 2) [#_ALM] If the control executes a #3000 (or a [#_ALM]) command, an alarm will be sounded Like any program storage (PS) alarm, the alarm generated by the alarm-generating system variable will put the machine in a true alarm state You must press the RESET button to clear the alarm Here is the syntax for the alarm-generating system variable shown with both the number and the name: or #3000 = 100 (ARGUMENT MISSING IN CALL) [#_ALM] = 100 (ARGUMENT MISSING IN CALL) Again, if the control executes either of these commands, it will generate an alarm The value (100) is an alarm number (of your choosing) and can range from 0 to 200 (some FANUC control models allow other alarm numbers to be specified) The message in parentheses (all upper case) is the alarm documenting message It must be 60 characters and numbers or less If this command is executed, the display will switch to the alarm page and this alarm message will appear on the control screen: MC-100 ARGUMENT MISSING IN CALL With an understanding of the alarm-generating system variable, let's look at a few more examples of alarm generation (unrelated to error trapping) Then we will show how to minimize program execution time required for error-trapping Stop with message The stop with message system variable is similar to the alarm-generating system variable But instead of placing the machine in alarm state (requiring the cancelation of the cycle), the stop with message system variable places the machine in program-stop state (just like an M00 word) As with M00, it is possible to make the machine continue executing the program by pressing the CYCLE START button There are the two ways to specify the stop with message system variable: 1) #3006 2) [#_MSGSTP] PMPA National Conference 2016 19 Copyright 2016, CNC Concepts, Inc

If the control executes a #3006 (or a [#_MSGSTP]) command, it will place the machine in program-stop state You can reactivate the cycle by pressing the CYCLE START button, continuing from the point of the stop with message command Here is the syntax for the alarm-generating system variable shown with both the number and the name Notice how similar it is to the alarm generating system variable: or #3006 = 100 (TURN PART AROUND IN CHUCK) [#_MSGSTP] = 100 (TURN PART AROUND IN CHUCK) Again, if the control executes either of these commands, it will place the machine in programstop state The value (100) is a message-number of your choosing and can range from 0 to 200 (some FANUC control models allow other message numbers to be specified) The message in parentheses (all upper case) is the documenting message It must be 60 characters and numbers or less If this command is executed, the display will switch to the message page and this message will appear on the control screen: MS-100 TURN PART AROUND IN CHUCK Suppressing single block and waiting for auxiliary functions System variable #3003 or [#_CNTL1] allows you to take control of two important machine functions, single block and whether or not M-codes are awaited If #3003 or [#_CNTL1] is set to 0 (the initialized state), single block is not suppressed and the machine will wait for auxiliary functions (M-codes) to be completed before going on to the next command If #3003 or [#_CNTL1] is set to 1, single block will be suppressed and the control will wait for the completion of M-codes to continue with the program If #3003 or [#_CNTL1] is set to 2, single block is not suppressed, and the control will not wait for the completion of auxiliary functions If set to 3, single block is suppressed and M-codes will be awaited Newer versions of Custom Macro additionally allow you to control these functions separately [#_M_SBK] controls single block Single block can be suppressed by setting this system variable to one (zero for not suppressed) [#_M_FIN] controls whether or not M-codes are awaited (set to zero for awaited, one for not awaited) Access to timer and clock (date/time) Another set of system variables gives you the ability to time events and determine current date and time from within Custom Macro programs The next table shows the related system variable numbers and names Type Number Name Milliseconds #3001 [#_CLOCK1] Hours #3002 [#_CLOCK2] Date #3011 [#_DATE] PMPA National Conference 2016 20 Copyright 2016, CNC Concepts, Inc