Programming with Macro's on the Haas CNC - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Programming with Macro's on the Haas CNC

Description:

Title: Programming with Macro's on the Haas CNC Author: Dave Wolf Last modified by: Dave Wolf Created Date: 10/6/2000 6:39:09 PM Document presentation format – PowerPoint PPT presentation

Number of Views:498
Avg rating:3.0/5.0
Slides: 29
Provided by: DaveW178
Category:

less

Transcript and Presenter's Notes

Title: Programming with Macro's on the Haas CNC


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

2
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.

3
I.a.Topics of Discussion
  • Macros- 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

4
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.

5
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.

6
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.

7
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.

8
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.

9
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

10
V. Aliasing a macro to a G- or M-code
  • 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.

11
Problem 4 - Sub-program calls
  • The 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

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

13
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.

14
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.

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

16
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.

17
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).

18
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.

19
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 ltconditional
    expression gt THEN ltstatementgt - Execute
    statement only if the condition is met.
  • Looping - WHILE ltconditional expressiongt DOn
    ltstatementsgt ENDn - Loop while the condition
    is true.

20
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.

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

22
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.

23
VIII. The effect of settings on macros
  • 23- 9xxxx Progs Edit lock
  • 74- 9xxxx Progs Trace
  • 75- 9xxxx Progs Single Block

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

25
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.

26
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.

27
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 gt MAX DEPTH)
  • IF 116 1 112 GT 4.5 THEN
    3000 1 (2 DEEP FOR TOOL)
  • IF 115 GT 112 THEN 115 112 (IF NEW
    DEPTHgtMAX THEN SET DEPTHMAX)
  • 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

28
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 T4120 (rotate carousel to correct pocket)
  • 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)
Write a Comment
User Comments (0)
About PowerShow.com