macro class

28
1 Programming with Macro's on the Haas CNC Dave Wolf Haas Automation October 26, 2000

Upload: ari-ercilio-farias-fereirra

Post on 15-Nov-2015

10 views

Category:

Documents


2 download

DESCRIPTION

haas

TRANSCRIPT

  • Programming with Macro's on the Haas CNCDave WolfHaas AutomationOctober 26, 2000

  • I. Goals of this classUnderstand the differences between a macro and a macro statement.Learn how to use macro statements to simplify CNC programming and to aid in troubleshooting.Improve G-code programming skillsLearn to analyze G-code programs with which you may come in contact.

  • I.a.Topics of DiscussionMacros- What are they? How are they used?G-codes that are useful for macros- a reviewAliasing a macro to a G- or M-code.The elements of macro programming- variables, operators, functions, expressions, and statements.System macro variablesThe effect of settings on macros

  • II. Macros- what are they?Definition - Any program that performs a common function and will be executed repeatedly within a g-code program.Macro statements - Any non-G-code command. Why? - Macros provide flexibility.Macro parameter bit- Required before loading of any macro statement.

  • Problem #1 - Macro Enable parameterSetup- Get the simulator ready for programming. Begin by creating and editing program O9000.The purpose of this exercise is to demonstrate the effects of the macro enable parameter.Attempt to load a macro statement both with and without the macro enable parameter enabled.Subsequent problems will build on the programs that are created in previous problems.

  • III. G-codes that are useful for macros- a reviewThe following are some G-codes that are of particular interest to the macro programmer.M98 Pxx - Sub Program Call. G65 Pxx - Macro subprogram call. Allows passing of variables.M97 Pxx - Local Sub Routine Call. M96 Pxx Qxx - Conditional Local Branch when Discrete Input Signal is 0. M00, M01, M30 - Stop Program.M99 - Sub Program Return or Loop. G04 - Dwell. G103 - Block Lookahead Limit. No cutter comp allowed.

  • Problem #2 - Program stopThe purpose of this exercise is to demonstrate the effects of various program end types.Programs in MDI do not require a program end.Observe the effects of the various program ends on the program counter (highlighted block)This exercise will use M30, M00, and M99 as well as without any end statement.

  • Problem #3 - Program lookaheadThe purpose of this exercise is to demonstrate the effects of program lookahead.Observe the effects of G103 on the timing of when the output is turned on and off.The goal of this exercise is to turn an output on, wait for 2 sec., then turn it off and stop.

  • IV. Program syntaxParentheses - ( )Are used to enclose comments.Not executed as a part of the program.Brackets - [ ]Are used to enclose macro expressions.Used to control the order of execution.Executed as part of the program.Line numbers - Nxxxx

  • V. Aliasing a macro to a G- or M-codeAliasing is assigning a G-code name to a program.Aliasing takes the place of a G65 or M98.The assignment takes place through parameters 81-100.Only programs O9000-9019 may be aliased.

  • Problem #4 - Sub-program callsThe purpose of this exercise is to demonstrate the usage of sub-program calls.Create a program(O0010) that will call the program created previously (O9000)Use any method of sub program call- M98, G65, or aliasing

  • VI. The elements of macro programmingVariablesOperatorsFunctionsExpressionsStatements

  • VI.a.The elements of macro programming - VariablesA variable is a symbol that can assume a changing value. They provide great flexibility in macro programming.Local variables - Local variables are not passed to other programs.Global variables - Global variables are general purpose. They are saved at power-down.System variables - System variables are global and are assigned a specific function in cnc software.

  • VI.b. The elements of macro programming - OperatorsOperators are symbols and commands that modify data.Arithmetic operators - Arithmetic operators perform simple math functions. They are +, -, *, /, and MOD. Logical operators - Logical operators work on binary bit numbers. They are OR, AND, and XOR. Boolean operators - Boolean operators are always evaluated as true(1) or false(0). They are EQ, NE, GT, LT, GE, and LE.

  • Problem #5 - CountersThe purpose of this exercise is to demonstrate the usage of variables.Add a counter to program O0010.

  • VI.c. The elements of macro programming - FunctionsFunctions are complex mathematical operations. They are SIN, ASIN, COS, ACOS, TAN, ATAN, SQRT, ABS, ROUND, and FIX. DPRINT is a special case. It is used for outputting data through the serial port. It is a stand-alone function.

  • VI.d. The elements of macro programming - ExpressionsExpressions are defined as a sequence of variables and values surrounded by brackets [ ]. Arithmetic Expressions - Arithmetic Expressions produce a floating point number or integer. Conditional Expressions - Conditional Expressions produce a value that is either true(1) or false(0).

  • Problem #6 - Working with Macro variablesThe purpose of this exercise is to integrate the use of macro expressions with standard G-codes.Add machine moves to program O9000. Use macro variables to set the position of these moves. Pass the move location or distance via local variables.Watch for correct formatting of the data.

  • VI.e. The elements of macro programming - StatementsStatements are complete commands that perform an action.Assignment Statements - Used to assign a value to a variable.Control Statements - Effect the order of execution of a program.Unconditional Branch - GOTOnnnn - always jump to line nnnn.Conditional Branch/Execution - IF [] THEN - Execute statement only if the condition is met.Looping - WHILE [] DOn; ; ENDn; - Loop while the condition is true.

  • Problem #7 - Conditional StatementsThe purpose of this exercise is to demonstrate the usage of conditional statements IF or WHILE.Stop calling program O9000 after n-times. Program will then stop execution.Use IF or WHILE to determine if the max number of times has been exceeded.

  • VII. System macro variables#709macro not complete (hidden variable)#3000programmable alarm#3001millisecond timer#3004feed hold override#3006programmable stop #4101-#4126last block address data#5021-#5026current machine positionDiscrete I/O #10xx=inputs, #11xx=outputs

  • Problem #8 - System VariablesThe purpose of this exercise is to demonstrate the usefulness of system variables.Measure how long it takes to perform the above test. Store this value in a variable.

  • VIII. The effect of settings on macros23- 9xxxx Progs Edit lock74- 9xxxx Progs Trace75- 9xxxx Progs Single Block

  • IX. ConclusionUse macros to simplify operation for the operatorUse macro assignments to manually test or troubleshootUse macros to control complex sub-assemblies that involve discrete I/O

  • Problem #9 - Final exam - Dog dish problemThis is the final exam. The purpose of this exercise is to use the knowledge gained earlier to create a complete macro. You may pick either problem #9 or #10.You are the owner of a dog dish factory. You make the size of the dish to suit the customer. Your machinist does not know how to program in G-code.Create a program(s) that will make any size of rectangular dog dish. For the purpose of this exercise, ignore the middle of the dish and tool diameter (cutter comp).The machinist is given the following information: x,y,z dimensions, material (3 max, determines feedrate, spindle speed, and z increment), and number of parts.

  • Problem #10 - Final Exam (optional) - Tool changer problemThis exercise is optional. The purpose of this exercise is to use the knowledge gained earlier to create a complete macro.You may pick either problem #8 or #9.You are an engineer creating a new tool changer. The motion for the carousel is complete in M39. You must complete the tool change shuttle motion and incorporate the M39. The shuttle works exactly the same as for a standard vertical.

  • Problem #9 - Final exam - Dog dish problem- SolutionO09001 (DOG DISH PROBLEM) (THE PROGRAM IS CALLED VIA G65 P9000 Xnn Ynn Znn Inn Jnn) (WHERE XYZ ARE DIMENSIONS, Inn IS THE MATERIAL TYPE,) (AND Jnn IS THE NUMBER OF PARTS TO BE MADE) (MATERIAL DATA IS IN #130.., #140..., AND #150...) (MATERIAL 1-PLASTIC, 2-ALUMINUM, 3-STEEL) (#100 IS COUNTER) (#110-120 ARE TEMP STORAGE) G103 P1 (LIMIT LOOKAHEAD) #100= 0 (RESET COUNTER) #110= #24 (STORE X) #111= #25 (STORE Y) #112= #26 (STORE Z) #113= #4 (STORE I) #114= #5 (STORE J) #116= [ #113 * 10 ] + 120 (this is the address location for the selected material)N10 #115= 0 (RESET DEPTH COUNTER) (ALARM IF TOOL LENGTH + Z DEPTH > MAX DEPTH) IF [ [ [ #[ #116 + 1 ] + #112 ] GT 4.5 ] THEN #3000= 1 (2 DEEP FOR TOOL) #100= #100 + 1 (INCREMENT COUNTER) M97 P999 (3 BLANK LINES) M06 T [ #[ [ #113 * 10 ] + 124 ] ] (GET CORRECT TOOL) G00 G53 G90 X0 Y0 Z0 (MOVE SPINDLE TO ZERO) M03 S [ #[ [ #113 * 10 ] + 120 ] ] (START SPINDLE) M97 P999 (3 BLANK LINES) #1124= 1 (TURN ON AIR BLAST) M97 P999 (3 BLANK LINES) WH [ #115 LT #112 ] DO1 (LOOP UNTIL DEPTH>MAX) #115= #115 + #[ [ #113 * 10 ] + 121 ] (ADD Z INCREMENT)

    IF [ #115 GT #112 ] THEN #115= #112 (IF NEW DEPTH>MAX THEN SET DEPTH=MAX) M97 P999 (3 BLANK LINES) G01 G53 G90 F [ #[ [ #113 * 10 ] + 122 ] ] Z [ - [ #115 ] ] (FEED TO NEW DEPTH) M97 P999 (3 BLANK LINES) M97 P300 (PERFORM XY MOVES) M97 P999 (3 BLANK LINES) END1 (END LOOP) #1124= 0 (TURN OFF AIR BLAST) M97 P999 (3 BLANK LINES) G00 G53 G90 X0 Y0 Z0 (MOVE SPINDLE TO ZERO) M97 P999 (3 BLANK LINES) IF [ #100 EQ #114 ] GOTO500 (END IF MAX PARTS REACHED) #3006= 1 (LOAD NEW PART) GOTO10 N300 (MILL OUT SQUARE) G01 G53 G90 F [ #[ [ #113 * 10 ] + 122 ] ] X [ - [ #110 ] ] G01 G53 G90 F [ #[ [ #113 * 10 ] + 122 ] ] Y [ - [ #111 ] ] G01 G53 G90 F [ #[ [ #113 * 10 ] + 122 ] ] X0 G01 G53 G90 F [ #[ [ #113 * 10 ] + 122 ] ] Y0 M99 N500 (NORMAL RETURN) G103 (ENABLE LOOKAHEAD) #3006= 1 (END OF RUN) M99 N999 (TAKE CARE OF LOOKAHEAD)

    M99

  • Problem #10 - Final exam - Tool Changer problem- SolutionO9001 (TOOL CHANGE EXAMPLE)G103 P1 (enable lookahead)M05 (spindle stop)M09 (coolant off)G00 G90 G53 Z0. (Z-axis to zero)M19 (orient spindle)M97 P999 (3 blank lines)#3001= 0 (reset millisecond timer)#1108= 1 (turn shuttle motor on)N10 IF [ #3001 GT 3000 ] GOTO200 (3sec timeout on motor)IF [ #1000 EQ 0 ] GOTO10 (wait for shuttle in condition)M97 P999 (3 blank lines)#1108= 0 (turn shuttle motor off)M97 P999 (3 blank lines)M82 (unclamp tool)M97 P999 (3 blank lines)G00 G53 G90 Z3.5 (move Z-axis out of the way)M97 P999 (3 blank lines)M39 T#4120 (rotate carousel to correct pocket#)M97 P999 (3 blank lines)G00 G90 G53 Z0. (Z-axis to zero)M97 P999 (3 blank lines)M86 (clamp tool)M97 P999 (3 blank lines)

    #3001= 0 (reset millisecond timer)#1109= 1 (turn shuttle motor on)N20 IF [ #3001 GT 3000 ] GOTO200 (3sec timeout on motor)IF [ #1001 EQ 0 ] GOTO20 (wait for shuttle out condition)M97 P999 (3 blank lines) #1109= 0 (turn shuttle motor off)N100 (normal end)G103 (turn off lookahead)M99 (return to main program)

    N999 (3 BLANK LINES)

    M99

    N200 (FAULT ROUTINE)#1108= 0 (turn shuttle motor off)#1109= 0 (turn shuttle motor off)#3000= 1 (TC FAULT)

    Introduce self including name and position in company and yearswelcome to class on macroshand out sheetsEveryone should share a sim, take turns entering dataturn on simulatorsdescribe how macros have been used to proto equipment and that is how I got involved with writing macrosAll of the examples are aimed at verticals. However, the same concepts apply to horizontals and lathes as wellremember to take a break

    The purpose of this class is to introduce you to macros.It is a whole new way of programming a cnc. They allow for incredible flexiblity.When finished with the class you should:Understand the differences between a macro and a macro statement.Know how to use macro statements to simplify CNC programming and aid in troubleshooting.Have improved your G-code programming skill.Know how to read and analyze any g-code programs that you may come in contact with.Topics covered in this class are:Definition of a macro and a macro statementHow to enable macrosUseful G-codes- a reviewAliasingThe individual element of macro programming-dont get hung up on the namesSystem macro variablesThe effects of settingsLets start with the definitions.Macros are any program that is run multiple timesmacro statements are block in G-code that contains something other than an alpha-numeric code. Ie. G00, M19 Why?- Macros provide great flexibility. They allow access to machine functions and data.Macro parameter bit-required before loading any macro statement, not for running them.Causes statements to change to comments or alarm depending on whether it is in a file or entered manuallyMagic number needed to enable

    This problem will demonstrate the effects of the macro enable parameter.Zero machinesgo to list programs and select O9000. Each program will build on the previous problemswitch to edit screen.Use mem mode and cycle start to run program. Be sure to press reset prior to running any program.

    Problem #1:Disable macros. Attempt to enter the following block to the end of the program: #1124=1. What happens? What messages/alarms show up?Enable macros. Attempt to enter the same block: #1124=1. What happens? What messages/alarms show up?The program will look like this when finished:O9000;#1124=1;

    Describe g-codes listed above.Explain differences in program stopuse board to diagram program flowdescribe the use of the Lnnor Pnn in M99Describe Lookahead in detailSee appendix A and B for complete list of codesThis example demos program stopsrepeat example several times using different program stops.The program at the end is given in handoutProblem #2:Add 3 end-of-blocks (;) to the end of program O9000. Run the program. What happens to the cursor (highlighted block)?Add M00 immediately after the #1124=1;. Run the program. What happens to the cursor (highlighted block)? What happens to the output?Change to M99. Run the program. What happens to the cursor (highlighted block)? What happens to the output?Change to M30. Run the program. What happens to the cursor (highlighted block)? What happens to the output?Delete the end-of-blocks at the end of the program. The program will look like this when finished:O9000;#1124=1;M30;

    Demo lookaheadShow where to look in diagnostics for the outputprogram needs G103 and 3 blank lines in order for the output to stay on for the dwellProblem #3:Add G04 P2.; #1124=0; immediately before the M30. What happened? When did the M21 output turn on and off?Add G103 P1; immediately after the O9000. When did the output turn on and off?Add 3 end-of-blocks (;) between the G103 P1 and the #1124=1. Add another 3 end-of-blocks (;) between the G04 P2. and the #1124=0. When did the output turn on and off?The program will look like this when finished:O9000; G04 P2.;G103 P1; ;; ;; ;; #1124=0;#1124=1; M30;Parentheses are for commentsBrackets are for expressionsLine numbers are line labels.Aliasing means asigning a M- or G- code to a programEvery time the code is used, the program will execute.Same as G65With an M-code, no variables may be passed. Demo of subroutine calls.Any method may be used.Describe where single block button is located and message on screen.

    Problem #4:Modify program O9000. Change the M30 to an M99.Start a new program, O0010. Using any sub-program call (aliasing, M98, or G65), write a line that will call program O9000. End this program with an M30.Enable single block mode. (press single block button).Step through program O0010 using cycle start. Is program O9000 called properly? What happens when the M99 in program O9000 is reached?

    Review elements-dont get hung up on names, they are only taken from manual.Variables are a symbol that can take on any value. Use example of X can have any value in different equations even though it is always X.Variables are always preceded by the pound (#) symbol. They are always numeric.Local variables are 1-33. They are used when passing from a G65. They are not saved at power down. Do not use these for permanent storage.See appendix C for list of local assignments. Explain about the two types of addressing (A-Z or ABCIJKIJK..) G65 P12 X1. T3 -> X=#24, T=#20.Global variables are 100-199 and 500-699. They are saved. System variables are used for pre assigned purposes. They may not be viewed directly, they must be inferred from other displays.Macro variables are visible on current commands display.Diagnostics show discretes.Explain rounding using looping program.Operators modify data. They are used to produce a result.Arithmetic-+-*/ and mod. Describe order of execution. Describe mod.Logical- and,or,xor. These will perform binary functions. Explain differences.Boolean- eq, ne, etc. Produce a true or false result (0,1). Can perform math functions on resultsExplain difference between = and eq.Demo counters and variablesuse = in math statementProblem #5:Turn off single block mode.Add a counter to program O9000. This counter should increment by one, every time the program is run. Use any variable in the range 100 to 199. A counter is a variable that increments by 1 every time the program is run. They typically look like: #100=#100+1.Run program O0010. Observe the value of the counter variable. Does it increment properly?

    Functions are kind of like a macro. They perform complex operations.Trig- brief descriptionABS- absolute valueFix- integer portion with no rounding.Round- round number to whole or to address precision. Explain about address precision.Dprint- used for outputting serial data. It includes methods for formatting data.Expressions are a sequence of operations surrounded by brackets. Brackets can be used for program execution order. Innermost brackets are evaluated first.Arithmetic- Produces a numerical result. Conditional- produces a result that is true or false. Uses boolean operators.Explain about movement commands G00 G90 G53 X__View position display.Problem #6:Modify program O0010 so that the sub-program call includes the ability to pass a variable. Duplicate this block twice. Use the values -2., -3., -4.5 for the passing variable.Modify the O9000 program to include some X-axis moves. Use G00 G53 G90 X_ for the move. Fill in the blank for the location value/variable.Run program O0010. Does the x-axis move to the correct spots? Is the counter incrementing properly?Modify the O9000 program to include some Y-axis moves. After the mill reaches the correct X location, copy this current location (#5021) to a macro variable in the range 100-199. Use the value in this variable to move the Y-axis by the same amount.Run program O0010. Do the X and Y-axes move to the correct spots? Is the counter incrementing properly?If done properly, this exercise should produce a stair-stepped motion. Did this occur?Statements are complete blocks. Use the elements described earlier.Assignment- Always use = sign. Show where = goes. No expression before =.Control statements- allow for program branching and looping.Unconditional - GOTO. Same as M99 Pnnn. Conditional - IF. Block is only executed if condition is true. Some parts are optional. If only optional if goto used.Looping- WHILE. Allows for conditional looping. Maximum of 3 nested loops. Abbreviated WH. Loop execute while condition is true.Demo conditional statements Be careful that program does not execute n+1 times.

    Problem #7:Reset the counter variable to zero (from problem #5).Delete 2 of the subprogram calls from program O0010. Replace them with a G28Modify the O0010 program so that it will run for a specific number of times. Use IF or WHILE to determine if this number of times has been exceeded. The program should stop after the program has run for the specified number of times. Use the value 5 for the number of times to be run. It is ok to use the counter in program O9000.Run program O0010. Was program O9000 performed the correct number of times?

    System variables are pre-assigned to specific functions. Some are read-only. None can be read directly. They allow access to the machines raw data.Describe how #3000 and 3006 must have an =1.Describe the use of the last block data for passing values in an M-code.These are only some of the variables.Describe how discrete I/O is numbered. Show on diagnostics.See appendix D for complete listUse #3001 millisecond timer.Be sure to reset timer.Outcome is around 16.6 sec.

    Problem #8:Reset the counter variable to zero (from problem #4).Modify the O0010 program so that the entire cycle (all 5 times) is timed. Store the value of the timer in a variable in the range 100-199. At the end of the cycle, display the message cycle complete.Run program O0010. How long did it take for the cycle? Was the message displayed?

    There are 3 settings that can effect macros. They only effect programs in the 9000 range.Edit lock- stops the user from seeing and editing programs. When all is saved, these will not save.Trace- shows individual block as they execute. When turned off, program is treated as a single block.Single block- disables the effect of the single block mode while these programs are being run. This can also be disabled by a system variable.Use macros to simplify operation for operatoruse them to troubleshoot. Ask if they understand how.Use macros to control new items that the customer may want to add.Use this handout and the manual for reference.Think through the process before beginning to code. What do you want to happen?Use your new knowledge to help customers improve their process.Review any macros that you may run across in order to remember what you learned as well as to possibly improve it. Analyze it.Use problem 10 for exampleProblem 9 or 10 can be done. Your choice.May leave when finished.Pick up solution for problem 9 before they leave.Material specs:PlasticAluminumSteelSpindle speed:3000 rpm2000100Z increment:0.5500.2450.09feedrate:300 in/min16025tool #:123tool length:1.1.3751.75

    Show how to use look up tablesShow how to think of safety. Use timeouts.Demo shuttle movement portion on board.Demo calls for blank lines. (M97 P999)

    Pass out this handout before they leavePass out this handout before they leave