You are on page 1of 25

What Is Parametric Programming?

The best kept secret of CNC! There are few CNC people that even know what parametric programming is -- and fewer still that know how to use it! Given the enhancements that this kind of programming brings, it is surprising that more machine tool builders, control manufacturers, and technical schools don't say more about it. In this short discussion, we'll explain what parametric programming is and show its main applications. What it is Parametric programming can be compared to any computer programming language like BASIC, C Language, and PASCAL. However, this programming language resides right in the CNC control and can be accessed at G code level, meaning you can combine manual programming techniques with parametric programming techniques. Computer-related features like variables, arithmetic, logic statements, and looping are available. Like computer programming languages, parametric programming comes in several versions. The most popular is Custom Macro B (used by Fanuc and Fanuc-compatible controls). Others include User Task (from Okuma), Q Routine (from Sodick), and Advanced Programming Language [APL] (from G& L) In addition to having many computer-related features, most versions of parametric programming have extensive CNC-related features. Custom macro, for example, allows the CNC user to access many things about the CNC control (tool offsets, axis position, alarms, generate G codes, and program protection) right from within a CNC program. These things are impossible with only normal G code programming techniques. Applications: Many companies have excellent applications for custom macro and don't even know it. Of course, if you don't even know you have an application for something, it's impossible to even consider using it. While these applications are covered in much greater detail during our video course and CD-rom course, applications for custom macro fall into five basic categories. Do any of these sound familiar? Families of parts Almost all companies have at least some applications for custom macro that fit into this category. Possibly you have prints dimensioned with variables right on the print. The programmer must reference a chart on the drawing to come up with values needed in the program. Or perhaps you consistently find yourself editing one CNC program to make another one. If you do, you have a perfect application for custom macro! User-created canned cycles Even if you don't have a perfect family of parts application for custom macro, surely you have at least some work pieces that require similar machining operations. Or maybe you find yourself wishing your CNC control had more (or better) canned cycles. With custom macro, you can develop general purpose routines for operations like thread milling, bolt hole patterns, grooving, and pocket milling. In essence, you can develop your own canned cycles! Complex motions There may be times when your CNC control is incapable of easily generating a needed motion. To perform accurate taper thread milling (taper threads), for example, your control must have the ability to form a spiraling motion in XY while forming a linear motion in Z (helical motion will not suffice in this case). Unfortunately, most CNC

controls do not have spiral interpolation. But, believe it or not, with custom macro you can generate this desired motion. In essence, custom macro, allow you to create your own forms of interpolation. Driving accessory devices Probes, post process gauging systems, and many other sophisticated devices require a higher level of programming than can be found in standard G code level programming. Custom macro is the most popular parametric programming language used to drive these devices. In fact, if you have a probe on one or more of your machines, you probably have custom macro! Utilities There is a world of things you can do with custom macro that you would never consider doing without it. Custom macro can help reduce setup time, cycle time, program transfer time, and in general, facilitate the use of your equipment. A few example applications that fit into this category include part counters, tool life managers, jaw boring for turning centers, using standard edge finders as probing devices, and facilitating the assignment of program zero. Benefits of parametric programming Fast turnaround in production is the most significant benefit of family of parts macros. More time is often needed to develop macro than a standard program.

.

When to program parametrically Large number of parts that are same shape but different in dimensions Large number of parts that are similar in shape Parts that repeat fairly frequently Parts that contain repetitive tool path Various machining patterns Parametric program is never a replacement for other methods. As soon as control is passed to another program. etc. Local variables are "local" to the program that is currently executing. When control passes back to the original program.5 (Y position of hole) #103=. If you watch the . rapid to approach Z position) G01 Z-#103 F [#105 / 2] Y [#102 + #107 / 2 .1 M30 There are 3 types of variables . its set of local variables is restored.0 (Diameter of end mill) #101=3. if you set variable #1 to 100 in the main program. You can set and use var #1 in the sub without overwriting the value of #1 in the main. This is useful because you can use local variables at will within subprograms without having to keep track of the local variables you are using in other programs for fear of overwriting them. They can be set and read only in that program. we show a simple example written in custom macro B for a machining center application. start spindle) G00 X#101 Y#102 (Rapid to hole center) G43 H#106 Z. It will machine a mill a hole of any size at any location.5 (Depth of counter bored hole) #104=400 (Speed in RPM) #105=3. Program O0001 (Program number) #100=1. read. in order to be economically efficient. var #1 retains its original value of 100. When you return to the main program.#100 / 2] F#105 G02 J-[#107 / 2 .0 (Diameter of counter bored hole) G90 G54 S#104 M03 (Select abs mode.#100 / 2] G01 Y#102 G00 Z.5 (Feed rate in IPM) #106=3.1 (Instate tool length compensation. There could be a significant investment in time spent on parametric macro program development. var #1 is now empty.it only enhances them. such as when a subprogram is called. that program has its own set of local variables which can be set.Local. coordinate system. Notice how similar this program is to a program written in BASIC. Example: To stress what can be done with parametric programming. The resulting benefits are must be tangible and measurable.0 (Tool length offset number) #107=2. For instance. then call a subprogram. Common and System variables.0 (X position of hole) #102=1.

machine automation has become an important aspect of every product's assembly or manufacturing line. the present invention relates to providing flexibility to a robotically-automated production line through parametric programming techniques. Computer numerical control (CNC) machines are one type of common automated machinery. Instead. You can pass a value to a local variable when calling a subprogram with the G65 command. BACKGROUND OF THE INVENTION Over the past thirty years. Y. cutter comp and height offset. All of this should be in your operator manual. Thus. and bending. get one! The book is not always clear in its descriptions. while CNC automated a machine's individual functionality. or Z position of the machine (read only). System variables are special variables that represent values in various registers of the control. Set the variable in one program and all of the other programs see the same value. Therefore. There are system variables for reading the absolute X. an operator was required to place the first metal sheet in the press. a drill press operator who needs to drill three holes in a metal sheet no longer has to bring the press toward the sheet. the operator simply places the sheet on the drill press and a computer program commands the press to drill holes in the correct locations. it did not automate multiple independent tasks. We sometimes use this set of variables to read the machine position if we need to come back to that exact same point after a series of calculated moves which may have introduced rounding errors when executed. You can even create screen labels for some of them to make it easier for operators to set values. Always start out simple and work up to the complicated stuff. place the second metal sheet in the press. Some system variables are read only and cannot be set. including welding. CNC machines required individual programs for each specific task. One of the things that we use them for is when we have a choice of profiles on a part. to the desired profile number and then the program uses this to select the correct tool. If you don't have one. two distinct programs were needed in order to command a drill press to drill four holes in the middle of one metal sheet and four holes along the perimeter of another metal sheet. you can see the local variable sets change as control is passed from one program to another. you are referring to offset register 14. For instance. remove the first metal sheet. programmers consistently had to edit one CNC program to make . They can be set within a program or by the operator on the macro variable screen. The operator can set variable 500. drilling. load the first program. As a result. Until recently. The present invention relates to the field of robotically-automated production lines. so write a lot of little test programs until it is clear just how things work.macro variable screen as programs execute. More specifically. For example. laser cutting. The value of offset register 14 can be read or set by accessing system variable #2014. They are retained even after program execution stops. which may have a screen label of "PROFILE#". CNC machines can be directed by a computer program to perform any task that an operator could make a conventional machine perform. and load the second program. spindle. when you call H14. Common variables are "common" to all programs. For example.

a programmer simply may develop one program for a certain machine. . programming efforts are reduced significantly. human intervention (in the form of additional programming) still is required to permit the robotically-controlled line to manipulate the work piece in a different way. the program can be used with any corresponding data file to drill any size hole in any location.another. The advent of robotic manufacturing and assembly lines automated this process to a greater extent by eliminating manual movement of the work piece. As a result. Therefore. using the above example. For example. place the second metal sheet in the press. USER TASK™. repetitive looping and mathematical equations. The parametric program queues the operator to put in data sets for each individual task that the drill press must perform. complicated and complete programming revisions are necessary in order to vary the tasks of robotic lines. Therefore. for example a drill press. There are several parametric programming languages including CUSTOM MACRO B™. instead of loading a new program each time. no matter how closely related the tasks. the benefits of parametric programming have not been realized in this application. The operator then tells the machine when to begin each task. Parametric programming is a technique that allows a CNC programmer to vary the parameters of the task within one program. Specifically. Thus. parametric programming allows programs to be written using variable-designated parameters instead of fixed numbers. there is no current method for incorporating the flexibility of parametric programming into an entire robotically-controlled manufacturing or assembly line. Q ROUTINE™ and ADVANCED PROGRAMMING LANGUAGE™. However. although a manufacturing line may be automated robotically such that human intervention is not required to manipulate a work piece in a certain way. instead of writing an entirely new program each time the parameters are varied. Because there is no current method for incorporating parametric programming into an entire robotic line. In other words. Parametric programming has been developed to overcome the need for discrete programs for each independent task that a machine performs. the CNC-controlled machinery still requires discrete programs to perform different tasks. remove the first metal sheet when the CNC-controlled machinery has accomplished its task. These variables can be changed each time the program is called. As a result. if a parametric program is stored in a machine's memory to drill a bolt hole. robots are now able to place the first metal sheet in the press. Although parametric programming of individual robotic devices and machines is possible. and so on. Parametric programming also includes structures for conditional and unconditional program branching.

The computer also may convert . in the context of electrical transformer tanks. 27. a robotic manufacturing line can manufacture only one size enclosure with a particular set of characteristics (e. high voltage bushing locations). for example robots and machines. SUMMARY OF THE INVENTION The present invention provides a system and method for creating products of varying characteristics on an automated production line. the user is able to submit orders.today's robotic manufacturing and assembly lines often are dedicated to manufacturing one type or size of a product. Each robot and machine is operated by a parametric computer program that may be stored locally with the production line devices. the system further comprises a computer coupled to the production line devices and to the data sources. Therefore. the line must be shut down and reprogrammed.. By minimizing human intervention in the production process. The system also comprises one or more data source(s) coupled to the production line devices. for example. an external user. 2000. The computer may route the inputted characteristics to each of the production line devices in a logical order. For example. like a customer or a field sales person. The data source provides characteristics of a desired product to the production line devices. Also.g. The user is able to configure the product and produce an on line price quotation. today's robotically-controlled manufacturing and assembly lines are dedicated to specific products or functions. If another enclosure size with a different set of characteristics is desired. for example. Because of the consequent labor-intensive effort to make such a change. the present invention facilitates a "lights out" factory for the production of distribution transformers.: PCT/US00/35268. The system includes one or more production line devices. The data source may be a local terminal or a remote terminal connected to the production line via the Internet. may orchestrate the entire production process to meet his or her requirements via the Internet. it would be advantageous to use the flexibility of parametric programming techniques in a robotic assembly or manufacturing line such that products of varying size and character can be manufactured without interruption in the line. International Filing Date: Dec. Specifically. review scheduling. and receive confirmation of the manufacture of the products in a manner similar to ordering a custom made personal computer over the Internet. Additional detail for the "lights out" factory is found in International Application No. In one embodiment.

3B is a drawing of a portion of an electrical transformer tank enclosure referred to in FIG. 2 is a flowchart detailing the operation of the robotically-automated electrical transformer tank manufacturing line. As shown in FIG. 5A and 5B are an exemplary MDF for use with the present invention for the manufacture of an electrical transformer tank.the characteristics into a formatted file readable by the parametric computer program. for example a machine data file (MDF). DETAILED DESCRIPTION OF PREFERRED EMBODIMENTS By using parametric programming for an entire robotic production line. the present invention permits the robotic line to produce similar products of different characteristics without interruption in the line. Reference will now be made in detail to a presently preferred embodiment of the invention. according to the present invention. BRIEF DESCRIPTION OF THE DRAWINGS FIG. . 3A. 3A is a table of a customer's individual desired features for an electrical transformer tank enclosure. FIG. according to the present invention. and FIGS. according to the present invention. For example. an example of which is illustrated in the accompanying drawings. 4B is an example of a MDF. FIG. according to the present invention. 1 is a block diagram of a robotically-automated electrical transformer tank manufacturing line. FIG. according to the present invention. according to the present invention. a data source 102 is coupled to a design database computer 104. 4A is a table indicating the machines and tools needed to perform a desired task. FIG. FIG. FIG. 1 is a block diagram of a robotically-automated electrical transformer tank manufacturing line 100. 1. according to the present invention. the present invention may allow a robotic manufacturing line to manufacture similar electrical transformer enclosures of varying sizes and various configurations.

Cell control computer 101 is coupled to terminal server 103. Cell one 112 houses laser cutter 106 and robot A 107. FIG. laser cutter 106. Although not shown. Terminal server 103 is coupled to robot A 106. for example. Alternatively. The terminology is consistent with that which is used in the art. and cell three 114. for example. The customer may specify the characteristics of the electrical transformer tank either by choosing a standard tank model number. it should be appreciated that manufacture of the electrical transformer tank may include additional cells housing additional robots and machines. Cell control computer 101 may be connected to master PLC 105 and terminal server 103 using LAN technology. Cell two houses embossing machine 108 and robot B 109. 2 is a flowchart detailing a method of operating the robotically-automated electrical transformer tank manufacturing line 200. the customer may specify a list of individual features by name or by part number with corresponding location designations. data source 102 may be a remote terminal coupled to design database computer 104 via the Internet. In this application the term "robot" refers a material moving device. The characteristics from data source 102 may be provided by a customer who is remote from the manufacturing line using an Internet connection. for example an Ethernet system operating on TCP/IP protocol. 1. and "machine" refers to a device that operates on and manipulates a workpiece. it should be appreciated that there may be more than one data source. Although FIG. 3A and 3B provide a table and corresponding drawing showing one . Master PLC 105 is coupled to the devices in cell one 112. Cell three houses robot C 111 and stud welder 110. and master programmable logic controller (PLC) 105. design database computer 104 may be a software component of cell control computer 101. Although one data source is shown in FIG. local to manufacturing line 100. cell two 113. Design database computer 104 may be connected to cell control computer 101 and data source 102 using local access network (LAN) technology. In step 201. robot B 107. according to the present invention. Alternatively. Alternatively. and robot C 111. Design database computer 104 is coupled to cell control computer 101. the tank's characteristics may be entered by an operator who is queried at a data entry terminal local to the manufacturing line. for example an Ethernet system operating on TCP/IP protocol. data source 102 provides the desired characteristics of a particular electrical transformer tank. 1 shows design database computer 104 separate from cell control computer 101.Data source 102 may be a data entry terminal. FIGS.

4A provides a sample table indicating the machines and tools needed to perform a desired task. T03) located in laser cutting machine 106 in order to create an oil fill hole.82 and Y2=24. Stated differently. and the machine and its tool necessary to create the feature. Referring back to FIG.e. Each of these features has a corresponding part number.g. in the first part of the table tool T03 of machine . a customer may require a switch hole. name and location in the table in FIG. In other words. Each of the characteristics shown in FIG. design database computer 104 carries forward the specified locations of each of the desired characteristics as designated by data source 102. The customer also may require two oil fill pads. A tool is a subcomponent of a machine on the manufacturing line. X-Y location) of the desired feature. For example. in step 202. In addition. As shown in FIG. part number 2A16124F01 may require the use of a plasma cutting head tool (e. feature)..51. Each part number has a corresponding list of machines and tools necessary to create the desired part (i. If the data entry simply specified a tank model number. 3B have a corresponding part number. a MDF may be created. As shown in FIG. FIG. according to the present invention. located at X1=19 and Y1=4.82 and X2=6. Once the machines and their tools have been selected.57 and a bend along the Y-axis at Y1=17..g. for example. which corresponds to the two oil fill holes specified by data source 102. The identified numbers represent the necessary machines and their tools needed to create the desired characteristics.example of a customer's individual desired features. 3A.32 and Y2=51. If the customer did not know the part number associated with each feature in step 201. Specifically. these locations will be generated automatically. 2. This process is repeated for each individual characteristic until a list of the necessary machines and tools is created as shown. the MDF lists the location (e. step 202 will map the part number to a corresponding desired feature. each part number has a corresponding list of machines and tools necessary to create the part.74.9 and Y1=6. For example. located at X1=16. the characteristic data corresponding to the desired electrical transformer tank provided in step 201 then enters design database computer 104 in step 202. as represented by part numbers. if the data entry included individually desired features. in FIG. 4B shows an example of a MDF. in step 202.. machine M04 and tool T03 may be used to create part number 2A16023F01. 4A. FIG. design database computer 104 creates a MDF by mapping each desired characteristic (or the desired tank model number) to a database of part numbers and corresponding machine and tool numbers. 4A. 4B.

Each file packet corresponds to a particular robot and machine. 5A and 5B. it may include a computer (not shown) that processes the MDF routed by cell control computer 106. In step 207. cell control computer 101 sends the parsed MDF for robots A 107. An exemplary MDF for use with the present invention for the manufacture of an electrical transformer tank is included in FIGS. and C 111 to terminal server 103. 108 and 110 to master PLC 105. Master PLC 105 then sequences the parsed MDF for each of machines 106. as shown FIG. Each of the machines and the robots receive the MDF into their resident parametric programs. Tool T243 of machine M05 then creates a bend along the y axis at x=0. The first hole is located at x=16.74. cell control computer 101 sends the parsed MDF for machines 106. in step 203. the order of each operation is logically arranged such that one machine may always operate on the electrical transformer tank enclosure before another machine. Unlike the other robots and machines. This is due to the added complexity of laser cutter 106 and consequent volume of information that must be processed by laser cutter 106. and 111 converts the parametric program with the inputted MDF into a format readable by the individual robots.32 and x=0. In addition. Then. Notably. The connection between laser cutter 104 and cell control computer 101 may be an RS-422 serial connection. In step 205. a computer internal to robots 107. because of the complexity of laser cutter 106.51. B 109.90 and y=24. robots A 107. hole cutting machine M04 and tool T03 will be operated before bending machine M05 and tool T243. Terminal server 103 then sequences the parsed MDF for the operation of robot A 107. cell control computer 101 parses the MDF into discrete file packets and transfers the packets to master PLC 105. . y=17.90 and y=6. and robot C 111 in accordance with the manufacturing line's process. machines 106. In step 208. The second hole is located at x=16.M04 will create two holes. 108 and 110 receive the relevant MDF from master PLC 105 in a logical sequence.82. 109. 2. for example CNC programming instructions. In step 204. it may be preferable for hole cutting machine M04 to operate on the electrical transformer tank enclosure before bending machine M05. robot B 109. tool T05 of machine M04 creates another hole at x=19 and y=4. for example. 4B. B 109. For example. terminal server 103 and laser cutter 106. In step 206. and C 111 receive relevant MDF from terminal server 103 in a logical sequence. Referring back to FIG. cell control computer 101 is coupled directly to laser cutter 106. 108 and 110 in accordance with the manufacturing line's process. For example.57. y=51. In step 209.

Those skilled in the art will appreciate that various changes and adaptations of the present invention may be made in the form and details of these embodiments without departing from the true spirit and scope of the invention as defined by the following claims. for example CNC programming instructions. that includes. the production of electrical transformer tank enclosures.a computer internal to machines 106. . as commanded by the CNC programming instructions and to output the final product in step 210. regardless of any specific description in the drawing or examples set forth herein. 108 and 110 convert the parametric program with the inputted MDF into a format readable by the individual machines. this invention can be used in any assembly or manufacturing line that requires robotic automation. The present invention is directed to a system and method for automating a robotically-controlled production line. but is not limited to. The inputted MDF is the mechanism that instructs the production line devices to perform differently depending on the particular characteristics of the desired product. The robots and the machines participate in the manufacturing. it will be understood by those skilled in the art that the invention is not limited to the embodiments specifically disclosed herein. While the present invention has been particularly shown and described with reference to the presently preferred embodiments thereof. the parametric program is written for each production line device just once. It will be understood that the present invention is not limited to use of any of the particular parts or assemblies discussed herein. the system disclosed in the present invention can be used with the method of the present invention or a variety of other applications. Because the resident parametric program is a shell that integrates the entire functionality of the robots and machines. Further. Indeed.

.

5 Y2. make your programs more fail-safe and make it easier for setup people and operators to rerun tools.1 (Make tool change) When the custom macro (O1000) is executed. fixture offset. ensure consistency for tool changing commands. rapid to first Z position) N090 M08 (Start coolant) Note that the structure of these commands will remain the same for every tool change you make. Of course. The techniques we show will simplify programming (especially for manual programmers). First. Source: Modern Machine Shop Publication Date: 01-AUG-03 Much of CNC manual programming is redundant.5 Y2. Consider this custom macro call statement that can be used to invoke a special tool change custom macro. it will cause the machine to do everything done in the previous series of tool change commands. Only the values of the numbers in bold italics will change from tool change to tool change. especially when tool changes must be made. the specific commands for your particular machine(s) will vary.A custom macro for tool change format. these commands are redundant and tedious to write. In our call statement. Similar commands will be required for turning centers (or any multi-tool CNC machine tool). you can simplify the commands required for tool changing. T represents the tool to be . Again. N060 G65 P1000 T02 S500 X1. (CNC Tech Talk). Because these commands are only similar (not identical).0 (Rapid to first X and Y position) N085 G43 H02 Z0. subprograms will not help when it comes to minimizing them. But if your control has custom macro B (or any version of parametric programming). start spindle and select next tool) N080 G00 X1.1 (Instate tool length compensation. orient spindle) N070 T02 M06 (Place desired tool in spindle) N075 G90 G54 S500 M03 T03 (Select absolute mode. you must consider how difficult it is for operators to run your programs. N060 M09 (Turn off coolant) N065 G91 G28 Z0 M19 (return to tool change position. Similar commands must be repeated on a fairly regular basis. Even if you program with a computer aided manufacturing (CAM) system. consider a typical series of commands that are needed when you make a tool change on a vertical machining center. It's easy for manual programmers to forget key words or commands.0 Z0.

placed in the spindle. you could also include words and commands in the tool change format custom macro to make your programs more fail-safe. #23 will have a value (#23 will not be vacant). W by #23. because they assume they've programmed correctly. skip default) #23 = #20 +1 (Set next waiting station tool to next number in sequence) N1 M09 (Turn off coolant) G91 G28 Z0 M19 (Return to tool change position. For example. S specifies the spindle speed. If it does not. orient spindle) T#20 M06 (Place desired tool in spindle) G90 G54 S#19 M03 T#23 (Select absolute mode. S by #19. #23 will be set to a value of whatever T (#20) is plus 1. fixture offset. If W is left out of the call statement (as it is in our example). . Most manual programmers will not do this. If W is included in the call statement. a W word (for waiting station) can be included in this command to specify which tool is coming up next in the program. X by #24. and the next command (the default setting command) will be executed. We have also set a default value for W (#23) if it's left out of the call statement. Here is the simple custom macro. O1000 (Tool change custom macro) IF [#23 NE #0] GOTO 1 (If W is included in call. Look at the first two commands of the custom macro. so we're letting the custom macro assume that the next tool will be station three. Consider these commands. the IF statement will be true and the default setting command will be skipped. Our macro will assume that the tool to be used after this one follows in sequence (tool three in this case). rapid to first Z position) M08 (Start coolant) M99 (End of custom macro) We've taken the set of tool change commands and replaced those hard-and-fixed values that change from tool change to tool change with local variables (T is represented by #20. Y by #25 and Z by #26). the result of the IF statement will be false (W is vacant). Y and Z specify the tool's first approach position. and X. Though our example custom macro doesn't show it. start spindle and select next tool) G00 X#24 Y#25 (Rapid to first X and Y position) G43 H#20 Z#26 (Instate tool length compensation. We've left W out. you could include G80 and G40 in line N1 (when the coolant is turned off) to ensure that canned cycles and cutter radius compensation have been canceled. you could include some safety commands to confirm that certain modes are still in their initialized states. Right after the tool change command (M06).

such as fixture creation and bolt circles. Actually. and other system parameters can be accessed and changed .G17 G20 G40 (Set XY plane. including a movement to the appropriate tool change position. Parametric programming also enables custom machining cycles.1 (Set normal cutting mode. and tailor the program to the machine it is running on. The first time they scan. A more recent advancement in CNC interpreters is support of logical commands. With the tool change custom macro. they find the command in which the tool is being placed in the waiting station. This is most important for the first tool the first time the program is run. The programmer can make if/then/else statements. The second time. is included in the custom macro. or create a stock part that can be scaled to any size a customer demands. select feed per minute mode) Again. subprogram calls. cancel rotation. if your setup people and operators are currently restarting tools by scanning to the T word. known as parametric programming. loops. while Okuma refers to it as User Task 2. The brevity of the program allows the CNC programmer to rapidly make performance adjustments to looped commands. breakage. GE Fanuc refers to it as Custom Macro A & B. they have to scan twice (assuming you have a machine with a double arm tool changer). and manipulate variables to create a large degree of freedom within one program. Our tool change format custom macro still allows rerunning tools. cancel mirror image) G80 G94 (Cancel canned cycle. they find where it is actually being placed in the spindle. Everything required for restarting tools. it will simplify the task. The machine will then drill and form the patterns required to mount additional vises or clamps at that location. perform various arithmetic calculations. cancel cutter radius compensation) G64 G69 G50. Parametric programs are also used to shorten long programs with incremental or stepped passes. Tool wear. inch mode. Haas Automation refers to parametric programs as macros. and in doing so remove a large amount of repetition in the program body. only one scan is required. What about rerunning tools? One important task that CNC setup people and operators must perform on a regular basis is rerun tools. For instance. The restart block for rerunning tools is simply the call statement (G65 command) for each tool change. An entire product line of different sizes can be programmed using logic and simple math to create and scale an entire range of parts. Because of these features. If a user wishes to create additional fixture locations on a work holding device. A loop can be created with variables for step values and other parameters. a parametric program is more efficient than using CAD/CAM software for large part runs. these commands can be placed in the custom macro right after the tool change and will ensure that the machine is in appropriate states. Also. Various manufacturers refer to parametric programming in brand-specific ways. the machine can be manually guided to the new location and the fixture subroutine called. Parametric programs incorporate both G-code and these logical constructs to create a programming language and syntax similar to BASIC.

..etc ... tool-change-point. T101 (REVOLVER 1 CORRECTION 1 TOOL CALL) G97 S1000 M3 (SPINDLE SPEED. -bolt circle radius -how many holes -center point of bolt circle Next build a subprogram that crunches the math. G43 .... When you are ready to drill or tap your holes.. common variable. allowing extensions and modifications to the functionality of a machine beyond what a manufacturer envisioned.. Common variable is used to hold data if machine switch off does not erase form data. There are three types of variables used in CNC systems: local variable. the logic is all similar . ROTATION DIRECTION) offset pickup. Typical logic to a parameter program is as follows.directly in the program. tool length.. in some cases (tool length pickup) #100=15 (RADIUS) #101=10 (HOW MANY HOLES) #102=50 (REJUMP-PARAMETER) #103=0 (CIRCLE-CENTER X) #104=-10 (CIRCLE-CENTER Y) G81 . Local variable is used to hold data after machine off preset value.. First define variables to start your program. The System variable this variable used system parameter this cannot use direct to convert the common variable for example tool radius..5 (RADIUS ROUND 2) #101=7 #102=51 GOTO 100 (JUMP TO SUBPROGRAM) N51 G80 (DEACTIVATE MODAL G81) M30 (SUBprogram) N100 (THIS LINE HERE IS USES AS A MARKER) #105=0 (INIT) N101 X[COS[#105]*#100+#103] Y[SIN[#105]*#100+#104] (REMEMBER YOUR G81 CODE IS MODAL) #105=#105+[360/#101] IF [#105 LT 360] GOTO 101 (IF #105 < 360 -> NEXT ROUND) GOTO #102 This is just a model to show the logic of programming. run the drill cycle off of your math in subprogram..... As all languages have some differences. (DRILL CYCLE) GOTO 100 (JUMP TO SUBPROGRAM) N50 (REUSE THE SUBprogramm) #100=7. and system variable. and tool height to be measured in millimeters or inches.

9] M5 M9 M2 .7(feed rate infeed Y axis) #8=.05(X start of spline) #5=5(X end of spline) #6=0(starting A position) #7=3(feed rate) #8=.ngc:) M6 T0 G43 H0 #1=27(number of splines) #2=[360/#1](angle to turn chuck) #3=-. Cutting Splines with Loops (Following is my generic-spline.ngc:) #1=25(number of teeth) #2=[360/#1](angle to turn chuck) #3=-.5 G0 Y#3 G0 X#4 #6=[#6+#2] G0 A#6 o200 while[#6 lt 359.1.088(depth of cut) G0 X#4 Y#3 G0 Z0 G0 A#6 M3 S200 M8 o200 do G1 Y#8 F#7 G1 X#5 G0 Y#3 G0 X#4 #6=[#6+#2] G0 A#6 o200 while[#6 lt 359.9] M5 M9 M2 Notice that it does a rough cut across then climb mills back for a finish cut.05(X start of cut) #5=2.2(X end of cut) #6=0(starting A position) #7=.1(y clearance) #4=-.04] F#7 G1 X#5 F#9 G1 Y#8 G1 X#4 F1. Ed 2.394(depth of cut) #9=15(feed rate across X axis) G0 X#4 Y#3 G0 Z0 G0 A0 M3 S70 M8 o200 do G1 Y[#8-. Cutting Gears with Loops (Following is my generic-gear.1(y clearance) #4=-.

00 (second step) #7=35 (safe circle) (first step) G0 Z1 G0 X[#5 * cos] Y[#5 * sin] G1 Z[#100 + 0.0 (incremental 3 axis move) G03 Z.020 (absolute move down to starting Z location) G91 G01 X.ngc % (mill grips on other side.0625 I-.similar to the gear but does all cutting in a single pass.30 (first step and start) #6=31.0625 I-.0 (optional free pass to remove any burrs) G90 G01 X0 F20. 12 deep) (params) #1=-15 (drill depth) #2=10 (retraction interval) #100=-12 (depth) (fixed) (speed) F80 (reset) G0 Z5 G0 X0 Y0 G4 P5 (start round) #8=0 (angle in degrees) #9=30 (angle increment in degrees) O101 while [#8 lt 360] #5=32.020 F50.0 (incremental move to finish location speeds and feeds will vary with materials being cut) G03 Z. Both are using a cutter on an arbor in a vertical spindle.0 (incremental move to finish location) G03 Z.0625 I-.0 (incremental 3 axis move creates right hand thread to establish Z movement divide 1 by thread pitch) ( 1 divided by 16 = .0 M2 4.0 (absolute move back to start location) G0 Z3.1275 F4.1275 F3.1275 F6. Thread Milling (3/4-16 thread milling) G0 X0 Y0 (rapid to location) Z.0625) G90 G01 X0 F20.1275 F6.1 G01 Z-1.1275 F10.0 (absolute move back to start location) G01 Z-1.06] G1 X[#7 * cos] Y[#7 * sin] (second step) G0 Z1 G0 X[#6 * cos] Y[#6 * sin] . 3/8mill=9. Ed 3.0 (your finish location will vary depending on conditions always start with a smaller cut until you establish exact finish location) G91 G01 X.5mm. Using a while loop to make circular indents in the side of a hand wheel cat 110_mill_grips.

Simple Turning example using IF (simple turning) (#100 = max Z = start Z > #101) (#101 = min Z) (#200 = max X = start X > #201) (#201 = min X) (#300 = feed) (#400 = step size) (Z) #100 = 200 #101 = 0 (X) #200 = 17 #201 = 14 (FEED) #300 = 120 (STEP) #400 = 1 (END OF PARAMETERS) (set feed) F#300 (set current X) #250 = #200 O501 while [#250 gt #201] #250 = [#250 .G1 Z#100 G1 X[#7 * cos] Y[#7 * sin] (increment angle) #8=[#8 + #9] (wait) (M0) O101 endwhile (end) G0 Z5 G0 X1 Y-1 G1 X0 Y0 G0 Z20 % 5. safety x 1mm) G0 X[#250 + #400 + 1] G0 Z#100 G0 X#250 G1 F#300 Z#101 O501 endwhile (retract to orig X) (END) G0 X[#200 + 1] M2 .#400] O502 if [#250 lt #201] #250 = O502 endif (goto start point.

That makes easier for the parser to know what it is doing and isn't a problem for the user. They may be called from other subroutines. it continues execution. Interpretation is turned back on (skipping is ended). When the interpreter scans a while. Introduction The O word was devised by Ken Lerman as a way to implement several branching routines into the EMC interpreter. As clarifications and documentation improvements made on this page are incorporated in the official documentation. The matching endif is ignored if the interpreter was skipping. When the interpreter scans a sub block. I have to admit. If the expression is true (values close to zero are treated as zero). If the expression was not true. it remembers the location of the next line in the file and associates it with the "O" number. that writing "call sub Onnnnn" seems more natural than writing "Onnnnn call sub". When the interpreter scans a return. 2. When it interprets an endsub. it treats it like a return. it pops the stack and continues interpretation where it left off. it ignores the endwhile). So if you start with o100 the block ends at the next o100 Subroutine declarations may NOT be nested. it pushes (saves) the current location in the input file (on a stack). they should be removed from this page. • • • • • • • • • • • . it restarts interpretation at the location of the remembered Onnnnn.1. (Assumng it wasn't skipping. If it was skipping. Note that each block must start and end with the same Onnnnn word. By using the O word a g code programmer can build subroutines. They may not overlap without nesting. When the interpreter scans a callsub. It then goes to the location in the file associated with the Onnnnn and starts interpretation there. The canonical documentation for O-words is in the emc2 documentation: [1]. Notes • Each of these control blocks begins with an Onnnnn word. When the interpreter scans an endwhile. and may be called recursively if it makes sense. and conditionals while taking advantage of the interpreter's use of variables and computation. if is treated exactly as while. It continues scanning. Subroutines may be called anywhere (but must be declared before they are called. it skips execution of all of the blocks until it finds the matching Onnnnn. though. loops. while and if may be nested. it remembers the location of the Onnnnn. skipping lines until it sees the matching Onnnnn endsub.

Sample 2 -. Sample 1 -.Subroutine Sample (ellipse) Code originally by jepler.25 (size of box) #2=. This code will machine an approximation to a ellipse. [emc2axis] I am sure the program could be simplified also not 100% sure the math is right.CUTTER RADIUS + RADIUS) G01X0Y0F10 o140 do #8 = [[SIN[#5]*#6]*SIN[45]] ( X AND Y POSISION) #9 = [0-[[1-COS[#5]]*#6]] (Z HIGHT) G1X[#8]Y[#8]F3 Z[#9] G18 G02 X[0-#8]Z[#9]I[0-#8]K[0-[#9+[#6]]]F5 G19 G03 Y[0-#8]Z[#9]J[0-#8]K[0-[#9+[#6]]] G18 G03 X[#8]Z[#9]I[#8]K[0-[#9+[#6]]] G19 G02 Y[#8]Z[#9]J[#8]K[0-[#9+[#6]]] #5=[#5+#4] o140 while [#8 LT [#1/2-#2-#3]] G1Z1 X0Y0 M30 3. 3. There is no error checking so you could create sphere that doesn't exist.[cube] #1=1.2.125 (size of box bars) #4=5 (degrees of resolusion) #5=#4 (COUNTER) #6=[[#1/2]+#2] (ACTUAL RADIUS OF CIRCLE . Here is emc2+axis running this program. (#1=xc #2=yc #3=xr #4=yr #5=subdiv #5=depth #7=rapid ht) o1000 sub (#10 = theta) (#11 = i) (#12 = x) (#13 = y) #14 = 360 #11 = 1 g0 x[#1+#3] y#2 g0 z#6 o1001 while [#11 LE #5] #10 = [#14 * #11 / #5] #12 = [#1 + [#3 * cos[#10]]] #13 = [#2 + [#4 * sin[#10]]] g1 x#12 y#13 #11 = [#11 + 1] o1001 endwhile g0 z#7 . Sample Programs These sample programs are offered without any warranty as to their suitability for any task whatsoever! Use these or model your program after these at your own risk. converted to gcode by KennethLerman (lerman). Here is 4 sides done .1.One side of a ball in cage Here is a short program that uses a ball end mill to create part of a sphere. fixed by jepler.3.0625 (cutter radius) #3=. The comments in the code explain what each variable does.

Here is example output of the below program.2 (deg of resolution) (check which of the R/r is bigger) o100 if [abs[#1] GT abs[#2]] #6=#1 (6 and 7 are temp locations for the R and r ) #7=#2 #8=1 o100 else #6=#2 #7=#1 #8=2 o100 endif (now we make them whole numbers if they are not.3.again not sure if everything is correct.o1000 endsub (call it like this) f10 o1000 call [0] [0] [1] [2] [200] [-1] [2] m2 3.{r+O}*cos{{{R+r}/r}*t} ) #2=2 ( r in above) #3=.6 ( O in above) #4=0 (starting t Deg) #5=. Sample 3 -.) #9=#6 #10=#7 #11=2 o150 while [[fix[#6] NE #6] or [fix[#7] NE #7]] #6=[#9*#11] #7=[#10*#11] #11=[#11+1] o150 endwhile (now lets figure out if we can simplify the R/r fraction) (this is using Euclidean algorithm to get the gcd) #12=#6 #13=#7 o200 do #14=[#12 mod #13] #12=#13 #13=#14 o200 while [#13 NE 0] (#12 is now the gcd) (the Number of times around in degrees) (using the correct denominator.1 ( R in this formula {R+r}*cos{t} .loops/math example (spirograph) I did this on a whim just to see if it could be done with the current math and loop abilities of emc2. #1=3. I creates pretty big files . [spiro].) o225 if[#8 eq 1] . Use at your own risk :).) (this is the start of figuring the number of degrees) (it has to go to do a complete cycle.

load tool and set feed first.[#2+#3]*COS[[[#1+#2]/#2]*#4]] #16=[[#1+#2]*sin[#4] .0625] o100 call [.) #7=[#6/2] (#7 is depth per circle = half of tool diameter) #8=#7 (#8 is current depth step) g0 z#3 (start above and right so we make a convex corner for entry to the ccw arcs) g0 x[#1 + [#7 * 2]] y[#2 + [#5 / 2]] g41 g0 x#1 y[#2 + [#5 / 2]] o101 while [#8 LT #4] (down toward the specified depth a bit at a time) g3 x#1 y[#2 + [#5 / 2]] i0 j[0 . a subroutine for helical hole milling using radius comp o100 sub (helical hole milling. then use like so:) (o100 call [x pos] [y pos] [safety height] [hole depth] [hole dia] [tool dia]) (tool dia doesn't have to be specified exactly.4.#14=[[#7/#12]*360] o225 else #14=[[#6/#12]*360] o225 endif (here is the actual cutting .125] [.[#5 / 2]] z[0 .25] [0] [.125] [.[#5 / 2]] y#2 i0 j[0 .01] [.I don't have any z in it yet) o250 do #15=[[#1+#2]*COS[#4] .[#2+#3]*sin[[[#1+#2]/#2]*#4]] g1 x[#15]y[#16]f200 #4=[#4+#5] o250 while [#4 LE #14] m30 3.#4] (full circle at the actual depth) g3 x#1 y[#2 + [#5 / 2]] i0 j[0 .#8] #8=[#8 + #7] o101 endwhile (down to the actual depth) g3 x#1 y[#2 + [#5 / 2]] i0 j[0 .5] [.[#5 / 2]] (nice quarter-circle helical exit move) g3 x[#1 .125] [.[#5 / 2]] z[0 .0625] t0 m6 m2 . Sample 4.01] [.[#5 / 2]] z#3 g40 o100 endsub (here is the actual usage: T1 is a 1/16th end mill) g20 g64 g17 g90 t1 m6 s1000 m3 f5 o100 call [0] [0] [.