Sei sulla pagina 1di 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- it only enhances them. There could be a significant investment in time spent on parametric macro program development. The resulting benefits are must be tangible and measurable, in order to be economically efficient. Example: To stress what can be done with parametric programming, we show a simple example written in custom macro B for a machining center application. It will machine a mill a hole of any size at any location. Notice how similar this program is to a program written in BASIC. Program O0001 (Program number) #100=1.0 (Diameter of end mill) #101=3.0 (X position of hole) #102=1.5 (Y position of hole) #103=.5 (Depth of counter bored hole) #104=400 (Speed in RPM) #105=3.5 (Feed rate in IPM) #106=3.0 (Tool length offset number) #107=2.0 (Diameter of counter bored hole) G90 G54 S#104 M03 (Select abs mode, coordinate system, start spindle) G00 X#101 Y#102 (Rapid to hole center) G43 H#106 Z.1 (Instate tool length compensation, rapid to approach Z position) G01 Z-#103 F [#105 / 2] Y [#102 + #107 / 2 - #100 / 2] F#105 G02 J-[#107 / 2 - #100 / 2] G01 Y#102 G00 Z.1 M30 There are 3 types of variables - Local, Common and System variables. Local variables are "local" to the program that is currently executing. They can be set and read only in that program. As soon as control is passed to another program, such as when a subprogram is called, that program has its own set of local variables which can be set, read, etc. When control passes back to the original program, its set of local variables is restored. For instance, if you set variable #1 to 100 in the main program, then call a subprogram, var #1 is now empty. You can set and use var #1 in the sub without overwriting the value of #1 in the main. When you return to the main program, var #1 retains its original value of 100. 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. If you watch the

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

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

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

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

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

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

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

a computer internal to machines 106, 108 and 110 convert the parametric program with the inputted MDF into a format readable by the individual machines, for example CNC programming instructions. The robots and the machines participate in the manufacturing, as commanded by the CNC programming instructions and to output the final product in step 210. Because the resident parametric program is a shell that integrates the entire functionality of the robots and machines, the parametric program is written for each production line device just once. 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 present invention is directed to a system and method for automating a robotically-controlled production line, that includes, but is not limited to, the production of electrical transformer tank enclosures, regardless of any specific description in the drawing or examples set forth herein. It will be understood that the present invention is not limited to use of any of the particular parts or assemblies discussed herein. Indeed, this invention can be used in any assembly or manufacturing line that requires robotic automation. Further, the system disclosed in the present invention can be used with the method of the present invention or a variety of other applications. While the present invention has been particularly shown and described with reference to the presently preferred embodiments thereof, it will be understood by those skilled in the art that the invention is not limited to the embodiments specifically disclosed herein. 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.

A custom macro for tool change format. (CNC Tech Talk). Source: Modern Machine Shop

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

placed in the spindle. Our macro will assume that the tool to be used after this one follows in sequence (tool three in this case). If it does not, a W word (for waiting station) can be included in this command to specify which tool is coming up next in the program. We've left W out, so we're letting the custom macro assume that the next tool will be station three. S specifies the spindle speed, and X, Y and Z specify the tool's first approach position. Here is the simple custom macro. O1000 (Tool change custom macro) IF [#23 NE #0] GOTO 1 (If W is included in call, 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, orient spindle) T#20 M06 (Place desired tool in spindle) G90 G54 S#19 M03 T#23 (Select absolute mode, fixture offset, 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, 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, W by #23, S by #19, X by #24, Y by #25 and Z by #26). We have also set a default value for W (#23) if it's left out of the call statement. Look at the first two commands of the custom macro. If W is left out of the call statement (as it is in our example), the result of the IF statement will be false (W is vacant), and the next command (the default setting command) will be executed. #23 will be set to a value of whatever T (#20) is plus 1. If W is included in the call statement, #23 will have a value (#23 will not be vacant), the IF statement will be true and the default setting command will be skipped. Though our example custom macro doesn't show it, you could also include words and commands in the tool change format custom macro to make your programs more fail-safe. For example, 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. Most manual programmers will not do this, because they assume they've programmed correctly. Right after the tool change command (M06), you could include some safety commands to confirm that certain modes are still in their initialized states. Consider these commands.

G17 G20 G40 (Set XY plane, inch mode, cancel cutter radius compensation) G64 G69 G50.1 (Set normal cutting mode, cancel rotation, cancel mirror image) G80 G94 (Cancel canned cycle, select feed per minute mode) Again, these commands can be placed in the custom macro right after the tool change and will ensure that the machine is in appropriate states. This is most important for the first tool the first time the program is run. What about rerunning tools? One important task that CNC setup people and operators must perform on a regular basis is rerun tools. Our tool change format custom macro still allows rerunning tools. Actually, it will simplify the task. The restart block for rerunning tools is simply the call statement (G65 command) for each tool change. Everything required for restarting tools, including a movement to the appropriate tool change position, is included in the custom macro. Also, if your setup people and operators are currently restarting tools by scanning to the T word, they have to scan twice (assuming you have a machine with a double arm tool changer). The first time they scan, they find the command in which the tool is being placed in the waiting station. The second time, they find where it is actually being placed in the spindle. With the tool change custom macro, only one scan is required.

A more recent advancement in CNC interpreters is support of logical commands, known as parametric programming. Parametric programs incorporate both G-code and these logical constructs to create a programming language and syntax similar to BASIC. Various manufacturers refer to parametric programming in brand-specific ways. For instance, Haas Automation refers to parametric programs as macros. GE Fanuc refers to it as Custom Macro A & B, while Okuma refers to it as User Task 2. The programmer can make if/then/else statements, loops, subprogram calls, perform various arithmetic calculations, and manipulate variables to create a large degree of freedom within one program. An entire product line of different sizes can be programmed using logic and simple math to create and scale an entire range of parts, or create a stock part that can be scaled to any size a customer demands. Parametric programming also enables custom machining cycles, such as fixture creation and bolt circles. If a user wishes to create additional fixture locations on a work holding device, the machine can be manually guided to the new location and the fixture subroutine called. The machine will then drill and form the patterns required to mount additional vises or clamps at that location. Parametric programs are also used to shorten long programs with incremental or stepped passes. A loop can be created with variables for step values and other parameters, and in doing so remove a large amount of repetition in the program body. Because of these features, a parametric program is more efficient than using CAD/CAM software for large part runs. The brevity of the program allows the CNC programmer to rapidly make performance adjustments to looped commands, and tailor the program to the machine it is running on. Tool wear, breakage, and other system parameters can be accessed and changed

directly in the program, allowing extensions and modifications to the functionality of a machine beyond what a manufacturer envisioned. There are three types of variables used in CNC systems: local variable, common variable, and system variable. Local variable is used to hold data after machine off preset value. Common variable is used to hold data if machine switch off does not erase form data. The System variable this variable used system parameter this cannot use direct to convert the common variable for example tool radius, tool length, and tool height to be measured in millimeters or inches. Typical logic to a parameter program is as follows;
First define variables to start your program. -bolt circle radius -how many holes -center point of bolt circle Next build a subprogram that crunches the math. When you are ready to drill or tap your holes, run the drill cycle off of your math in subprogram. tool-change-point..... T101 (REVOLVER 1 CORRECTION 1 TOOL CALL) G97 S1000 M3 (SPINDLE SPEED, ROTATION DIRECTION) offset pickup,etc ..... G43 ..... 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 ..... (DRILL CYCLE) GOTO 100 (JUMP TO SUBPROGRAM) N50 (REUSE THE SUBprogramm) #100=7.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. As all languages have some differences, the logic is all similar

1. Cutting Gears with Loops


(Following is my generic-gear.ngc:) #1=25(number of teeth) #2=[360/#1](angle to turn chuck) #3=-.1(y clearance) #4=-.05(X start of cut) #5=2.2(X end of cut) #6=0(starting A position) #7=.7(feed rate infeed Y axis) #8=.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-.04] F#7 G1 X#5 F#9 G1 Y#8 G1 X#4 F1.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. Ed

2. Cutting Splines with Loops


(Following is my generic-spline.ngc:) M6 T0 G43 H0 #1=27(number of splines) #2=[360/#1](angle to turn chuck) #3=-.1(y clearance) #4=-.05(X start of spline) #5=5(X end of spline) #6=0(starting A position) #7=3(feed rate) #8=.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

similar to the gear but does all cutting in a single pass. Both are using a cutter on an arbor in a vertical spindle.

Ed

3. Thread Milling
(3/4-16 thread milling) G0 X0 Y0 (rapid to location) Z.1 G01 Z-1.020 F50.0 (your finish location will vary depending on conditions always start with a smaller cut until you establish exact finish location) G91 G01 X.1275 F3.0 (incremental move to finish location speeds and feeds will vary with materials being cut) G03 Z.0625 I-.1275 F4.0 (incremental 3 axis move creates right hand thread to establish Z movement divide 1 by thread pitch) ( 1 divided by 16 = .0625) G90 G01 X0 F20.0 (absolute move back to start location) G01 Z-1.020 (absolute move down to starting Z location) G91 G01 X.1275 F6.0 (incremental move to finish location) G03 Z.0625 I-.1275 F6.0 (incremental 3 axis move) G03 Z.0625 I-.1275 F10.0 (optional free pass to remove any burrs) G90 G01 X0 F20.0 (absolute move back to start location) G0 Z3.0 M2

4. Using a while loop to make circular indents in the side of a hand wheel
cat 110_mill_grips.ngc % (mill grips on other side, 3/8mill=9.5mm, 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.30 (first step and start) #6=31.00 (second step) #7=35 (safe circle) (first step) G0 Z1 G0 X[#5 * cos] Y[#5 * sin] G1 Z[#100 + 0.06] G1 X[#7 * cos] Y[#7 * sin] (second step) G0 Z1 G0 X[#6 * cos] Y[#6 * sin]

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. 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 - #400] O502 if [#250 lt #201] #250 = O502 endif (goto start point, 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

1. Introduction
The O word was devised by Ken Lerman as a way to implement several branching routines into the EMC interpreter. By using the O word a g code programmer can build subroutines, loops, and conditionals while taking advantage of the interpreter's use of variables and computation.

The canonical documentation for O-words is in the emc2 documentation: [1]. As clarifications and documentation improvements made on this page are incorporated in the official documentation, they should be removed from this page.

2. Notes
Each of these control blocks begins with an Onnnnn word. That makes easier for the parser to know what it is doing and isn't a problem for the user. I have to admit, though, that writing "call sub Onnnnn" seems more natural than writing "Onnnnn call sub". Note that each block must start and end with the same Onnnnn word. So if you start with o100 the block ends at the next o100 Subroutine declarations may NOT be nested. Subroutines may be called anywhere (but must be declared before they are called. They may be called from other subroutines, and may be called recursively if it makes sense. while and if may be nested. They may not overlap without nesting. When the interpreter scans a sub block, it remembers the location of the next line in the file and associates it with the "O" number. It continues scanning, skipping lines until it sees the matching Onnnnn endsub. When the interpreter scans a callsub, it pushes (saves) the current location in the input file (on a stack). It then goes to the location in the file associated with the Onnnnn and starts interpretation there. When the interpreter scans a return, it pops the stack and continues interpretation where it left off. When it interprets an endsub, it treats it like a return. When the interpreter scans a while, it remembers the location of the Onnnnn. If the expression is true (values close to zero are treated as zero), it continues execution. If the expression was not true, it skips execution of all of the blocks until it finds the matching Onnnnn. When the interpreter scans an endwhile, it restarts interpretation at the location of the remembered Onnnnn. (Assumng it wasn't skipping. If it was skipping, it ignores the endwhile). if is treated exactly as while. The matching endif is ignored if the interpreter was skipping. Interpretation is turned back on (skipping is ended).

3. 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. 3.1. Sample 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. The comments in the code explain what each variable does. There is no error checking so you could create sphere that doesn't exist. Here is emc2+axis running this program. [emc2axis] I am sure the program could be simplified also not 100% sure the math is right. Here is 4 sides done - [cube]
#1=1.25 (size of box) #2=.0625 (cutter radius) #3=.125 (size of box bars) #4=5 (degrees of resolusion) #5=#4 (COUNTER) #6=[[#1/2]+#2] (ACTUAL RADIUS OF CIRCLE - 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.2. Sample 2 -- Subroutine Sample (ellipse)

Code originally by jepler, converted to gcode by KennethLerman (lerman), fixed by jepler. This code will machine an approximation to a ellipse.
(#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

o1000 endsub (call it like this) f10 o1000 call [0] [0] [1] [2] [200] [-1] [2] m2

3.3. Sample 3 -- 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. Here is example output of the below program. [spiro]. I creates pretty big files - again not sure if everything is correct. Use at your own risk :).
#1=3.1 ( R in this formula {R+r}*cos{t} - {r+O}*cos{{{R+r}/r}*t} ) #2=2 ( r in above) #3=.6 ( O in above) #4=0 (starting t Deg) #5=.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.) (this is the start of figuring the number of degrees) (it has to go to do a complete cycle.) #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.) o225 if[#8 eq 1]

#14=[[#7/#12]*360] o225 else #14=[[#6/#12]*360] o225 endif (here is the actual cutting - I don't have any z in it yet) o250 do #15=[[#1+#2]*COS[#4] - [#2+#3]*COS[[[#1+#2]/#2]*#4]] #16=[[#1+#2]*sin[#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. Sample 4, a subroutine for helical hole milling using radius comp
o100 sub (helical hole milling, load tool and set feed first, 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.) #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 - [#5 / 2]] z[0 - #8] #8=[#8 + #7] o101 endwhile (down to the actual depth) g3 x#1 y[#2 + [#5 / 2]] i0 j[0 - [#5 / 2]] z[0 - #4] (full circle at the actual depth) g3 x#1 y[#2 + [#5 / 2]] i0 j[0 - [#5 / 2]] (nice quarter-circle helical exit move) g3 x[#1 - [#5 / 2]] y#2 i0 j[0 - [#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] [.01] [.125] [.125] [.0625] o100 call [.25] [0] [.01] [.125] [.5] [.0625] t0 m6 m2

Potrebbero piacerti anche