Programming with Macro's on the Haas CNC

Download Report

Transcript Programming with Macro's on the Haas CNC

Programming with
Macro's on the
Haas CNC
Dave Wolf
Haas Automation
October 26, 2000
1
I. Goals of this class




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






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?




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




Setup- 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.
5
III. G-codes that are useful for
macros- a review

The 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.
6
Problem #2 - Program stop




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 M30, M00, and M99 as well as without any
end statement.
7
Problem #3 - Program lookahead



The 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.
8
IV. Program syntax

Parentheses - ( )
 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
9
V. Aliasing a macro to a G- or Mcode




Aliasing 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.
10
Problem #4 - Sub-program calls



The purpose of this exercise is to demonstrate the usage of subprogram calls.
Create a program(O0010) that will call the program created
previously (O9000)
Use any method of sub program call- M98, G65, or aliasing
11
VI. The elements of macro
programming





Variables
Operators
Functions
Expressions
Statements
12
VI.a.The elements of macro
programming - Variables

A 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.
13
VI.b. The elements of macro
programming - Operators

Operators 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.
14
Problem #5 - Counters


The purpose of this exercise is to demonstrate the usage of
variables.
Add a counter to program O0010.
15
VI.c. The elements of macro
programming - Functions


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

Expressions 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).
17
Problem #6 - Working with Macro
variables



The 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.
18
VI.e. The elements of macro
programming - Statements

Statements 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 [<conditional expression
>] THEN <statement> - Execute statement only if the
condition is met.
 Looping - WHILE [<conditional expression>] DOn;
<statements>; ENDn; - Loop while the condition is true.
19
Problem #7 - Conditional
Statements



The 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.
20
VII. System macro variables








#709
#3000
#3001
#3004
#3006
#4101-#4126
#5021-#5026
Discrete I/O
macro not complete (hidden variable)
programmable alarm
millisecond timer
feed hold override
programmable stop
last block address data
current machine position
#10xx=inputs, #11xx=outputs
21
Problem #8 - System Variables


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



237475-
9xxxx Progs Edit lock
9xxxx Progs Trace
9xxxx Progs Single Block
23
IX. Conclusion



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





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 dimensions,
material (3 max, determines feedrate, spindle speed, and z
increment), and number of parts.
25
Problem #10 - Final Exam
(optional) - Tool changer problem




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 M39. You must complete the tool
change shuttle motion and incorporate the M39.
The shuttle works exactly the same as for a standard vertical.
26
Problem #9 - Final exam - Dog
dish problem- Solution
O09001 (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
27
Problem #10 - Final exam - Tool
Changer problem- Solution
O9001 (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)
28