Machinery's Handbook, 31st Edition
CNC SUBROUTINES AND MACROS 1385 GOTOn Function: The “GOTOn” function is an unconditional branch and is pro grammed by itself in the block. the “n” is replaced by the block number to branch to. For example, GOTO901 will branch to block N901. The programming format is: GOTO901 WHILE function: The “WHILE” function is for looping—it also requires a specified condition to be true for the loop to be processed. The word “while” can be interpreted as meaning “as long as”. Its programming format is: WHILE [< this condition is true >] DOn The “ENDn” is the end of loop identification. There can be up to three levels of loop nesting. Each nested loop will have is own WHILE-ENDn. For a single loop, the ENDn is END1. Note—there is also IF-THEN method available on some control systems. If available, the programming is much more streamlined. The programming format is: IF [< this condition is true >] THEN [< argument >] The ‘THEN’ argument is a statement, normally a definition based on the condition being true: Example: IF [#1 EQ 1] THEN #33 = 0 All branching and looping functions are extremely powerful and are a fundamental part of effective use of macros. Macro Example.— A classic example of macro development is an equally spaced ar- rangement of holes along a circle—a bolt circle pattern, see Fig. 32. Many versions can be developed, depending on the actual needs
D
A
Y
H = Number of holes S = Start hole number
X
Fig. 32. Bolt Circle Macro Sample (MAIN PROGRAM—CALLS MACRO O7051 )
N1 G20 N2 G90 G00 G54 X0 Y0 S900 M03 N3 G43 Z1.0 H01 M08 N4 G99 G81 R0.1 Z-0.6 P250 F12.0 L0 N5 G65 P7051 X3.0 Y6.5 D4.5 H6 A5.0 S1
N6 G80 Z10.0 M09 N7 G28 Z10.0 M05 N8 M01 ... %
Copyright 2020, Industrial Press, Inc.
ebooks.industrialpress.com
Made with FlippingBook - Share PDF online