Programming with Macros on the Haas CNC Dave

  • Slides: 28
Download presentation
Programming with Macro's on the Haas CNC Dave Wolf Haas Automation October 26, 2000

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

I. Goals of this class n n Understand the differences between a macro and

I. Goals of this class n n Understand 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 skills Learn to analyze G-code programs with which you may come in contact. 2

I. a. Topics of Discussion n n n Macro’s- What are they? How are

I. a. Topics of Discussion n n n Macro’s- What are they? How are they used? G-codes that are useful for macros- a review Aliasing a macro to a G- or M-code. The elements of macro programming- variables, operators, functions, expressions, and statements. System macro variables The effect of settings on macros 3

II. Macro’s- what are they? n n Definition - Any program that performs a

II. Macro’s- what are they? n n 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? - Macro’s provide flexibility. Macro parameter bit- Required before loading of any macro statement. 4

Problem #1 - Macro Enable parameter n n Setup- Get the simulator ready for

Problem #1 - Macro Enable parameter n n Setup- Get the simulator ready for programming. Begin by creating and editing program O 9000. 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. 5

III. G-codes that are useful for macros- a review n The following are some

III. G-codes that are useful for macros- a review n The following are some G-codes that are of particular interest to the macro programmer. u M 98 Pxx - Sub Program Call. u G 65 Pxx - Macro subprogram call. Allows passing of variables. u M 97 Pxx - Local Sub Routine Call. u M 96 Pxx Qxx - Conditional Local Branch when Discrete Input Signal is 0. u M 00, M 01, M 30 - Stop Program. u M 99 - Sub Program Return or Loop. u G 04 - Dwell. 6 u G 103 - Block Lookahead Limit. No cutter comp

Problem #2 - Program stop n n The purpose of this exercise is to

Problem #2 - Program stop n n The 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 M 30, M 00, and M 99 as well as without any end statement. 7

Problem #3 - Program lookahead n n n The purpose of this exercise is

Problem #3 - Program lookahead n n n The purpose of this exercise is to demonstrate the effects of program lookahead. Observe the effects of G 103 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. 8

IV. Program syntax n Parentheses - ( ) u Are used to enclose comments.

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

V. Aliasing a macro to a Gor M-code n n Aliasing is assigning a

V. Aliasing a macro to a Gor M-code n n Aliasing is assigning a G-code name to a program. Aliasing takes the place of a G 65 or M 98. The assignment takes place through parameters 81 -100. Only programs O 9000 -9019 may be aliased. 10

Problem #4 - Sub-program calls n n n The purpose of this exercise is

Problem #4 - Sub-program calls n n n The purpose of this exercise is to demonstrate the usage of sub-program calls. Create a program(O 0010) that will call the program created previously (O 9000) Use any method of sub program call- M 98, G 65, or aliasing 11

VI. The elements of macro programming n n n Variables Operators Functions Expressions Statements

VI. The elements of macro programming n n n Variables Operators Functions Expressions Statements 12

VI. a. The elements of macro programming - Variables n A variable is a

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

VI. b. The elements of macro programming - Operators n Operators are symbols and

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

Problem #5 - Counters n n The purpose of this exercise is to demonstrate

Problem #5 - Counters n n The purpose of this exercise is to demonstrate the usage of variables. Add a counter to program O 0010. 15

VI. c. The elements of macro programming - Functions n n Functions are complex

VI. c. The elements of macro programming - Functions n n Functions 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. 16

VI. d. The elements of macro programming - Expressions n Expressions are defined as

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

Problem #6 - Working with Macro variables n n n The purpose of this

Problem #6 - Working with Macro variables n n n The purpose of this exercise is to integrate the use of macro expressions with standard G-codes. Add machine moves to program O 9000. 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. 18

VI. e. The elements of macro programming - Statements n Statements are complete commands

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

Problem #7 - Conditional Statements n n n The purpose of this exercise is

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

VII. System macro variables n n n n #709 variable) #3000 #3001 #3004 #3006

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

Problem #8 - System Variables n n The purpose of this exercise is to

Problem #8 - System Variables n n The 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. 22

VIII. The effect of settings on macros n n n 237475 - 9 xxxx

VIII. The effect of settings on macros n n n 237475 - 9 xxxx Progs Edit lock 9 xxxx Progs Trace 9 xxxx Progs Single Block 23

IX. Conclusion n Use macro’s to simplify operation for the operator Use macro assignments

IX. Conclusion n Use macro’s to simplify operation for the operator Use macro assignments to manually test or troubleshoot Use macro’s to control complex sub-assemblies that involve discrete I/O 24

Problem #9 - Final exam Dog dish problem n n n This is the

Problem #9 - Final exam Dog dish problem n n n This 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 25 dimensions, material (3 max, determines feedrate,

Problem #10 - Final Exam (optional) - Tool changer problem n n This exercise

Problem #10 - Final Exam (optional) - Tool changer problem n n This 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 M 39. You must complete the tool change shuttle motion and incorporate the M 39. The shuttle works exactly the same as for a standard vertical. 26

Problem #9 - Final exam Dog dish problem- Solution O 09001 (DOG DISH PROBLEM)

Problem #9 - Final exam Dog dish problem- Solution O 09001 (DOG DISH PROBLEM) (THE PROGRAM IS CALLED VIA G 65 P 9000 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) G 103 P 1 (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) N 10 #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) M 97 P 999 (3 BLANK LINES) M 06 T [ #[ [ #113 * 10 ] + 124 ] ] (GET CORRECT TOOL) G 00 G 53 G 90 X 0 Y 0 Z 0 (MOVE SPINDLE TO ZERO) M 03 S [ #[ [ #113 * 10 ] + 120 ] ] (START SPINDLE) M 97 P 999 (3 BLANK LINES) #1124= 1 (TURN ON AIR BLAST) M 97 P 999 (3 BLANK LINES) WH [ #115 LT #112 ] DO 1 (LOOP UNTIL DEPTH>MAX) IF [ #115 GT #112 ] THEN #115= #112 (IF NEW DEPTH>MAX THEN SET DEPTH=MAX) M 97 P 999 (3 BLANK LINES) G 01 G 53 G 90 F [ #[ [ #113 * 10 ] + 122 ] ] Z [ - [ #115 ] ] (FEED TO NEW DEPTH) M 97 P 999 (3 BLANK LINES) M 97 P 300 (PERFORM XY MOVES) M 97 P 999 (3 BLANK LINES) END 1 (END LOOP) #1124= 0 (TURN OFF AIR BLAST) M 97 P 999 (3 BLANK LINES) G 00 G 53 G 90 X 0 Y 0 Z 0 (MOVE SPINDLE TO ZERO) M 97 P 999 (3 BLANK LINES) IF [ #100 EQ #114 ] GOTO 500 (END IF MAX PARTS REACHED) #3006= 1 (LOAD NEW PART) GOTO 10 N 300 (MILL OUT SQUARE) G 01 G 53 G 90 F [ #[ [ #113 * 10 ] + 122 ] ] X [ - [ #110 ] ] G 01 G 53 G 90 F [ #[ [ #113 * 10 ] + 122 ] ] Y [ - [ #111 ] ] G 01 G 53 G 90 F [ #[ [ #113 * 10 ] + 122 ] ] X 0 G 01 G 53 G 90 F [ #[ [ #113 * 10 ] + 122 ] ] Y 0 M 99 N 500 (NORMAL RETURN) G 103 (ENABLE LOOKAHEAD) #3006= 1 (END OF RUN) M 99 N 999 (TAKE CARE OF LOOKAHEAD) 27 M 99

Problem #10 - Final exam Tool Changer problem. Solution O 9001 (TOOL CHANGE EXAMPLE)

Problem #10 - Final exam Tool Changer problem. Solution O 9001 (TOOL CHANGE EXAMPLE) G 103 P 1 (enable lookahead) M 05 (spindle stop) M 09 (coolant off) G 00 G 90 G 53 Z 0. (Z-axis to zero) M 19 (orient spindle) M 97 P 999 (3 blank lines) #3001= 0 (reset millisecond timer) #1108= 1 (turn shuttle motor on) N 10 IF [ #3001 GT 3000 ] GOTO 200 (3 sec timeout on motor) IF [ #1000 EQ 0 ] GOTO 10 (wait for shuttle in condition) M 97 P 999 (3 blank lines) #1108= 0 (turn shuttle motor off) M 97 P 999 (3 blank lines) M 82 (unclamp tool) M 97 P 999 (3 blank lines) G 00 G 53 G 90 Z 3. 5 (move Z-axis out of the way) M 97 P 999 (3 blank lines) M 39 T#4120 (rotate carousel to correct pocket#) M 97 P 999 (3 blank lines) G 00 G 90 G 53 Z 0. (Z-axis to zero) M 97 P 999 (3 blank lines) M 86 (clamp tool) M 97 P 999 (3 blank lines) #3001= 0 (reset millisecond timer) #1109= 1 (turn shuttle motor on) N 20 IF [ #3001 GT 3000 ] GOTO 200 (3 sec timeout on motor) IF [ #1001 EQ 0 ] GOTO 20 (wait for shuttle out condition) M 97 P 999 (3 blank lines) #1109= 0 (turn shuttle motor off) N 100 (normal end) G 103 (turn off lookahead) M 99 (return to main program) N 999 (3 BLANK LINES) M 99 N 200 (FAULT ROUTINE) #1108= 0 (turn shuttle motor off) #1109= 0 (turn shuttle motor off) #3000= 1 (TC FAULT) 28