(Part A) Machinerys Handbook 31st Edition Pages 1-1484

CNC SUBROUTINES AND MACROS Machinery's Handbook, 31st Edition

1381

Table 7. Macro B Argument List

Argument List 1

Macro Local Variable

Argument List 1

Macro Local Variable

Argument List 1

Macro Local Variable

Argument List 1

Macro Local Variable

A B C D E F

1 2 3 7 8 9

H

11

O Not assigned

V W X Y

22 23 24 25 26

I J

4 5 6

P Q R S T U

Not assigned

17 18 19 20

K L M

Not assigned

Z

13

G Not assigned 21 The above variables are LOCAL variables and can be used in arguments or in the macro. Note that there are five letters missing (not assigned)—they are G N O P L. These letters are reserved and cannot be used as arguments. The letter L is used for the number of macro repetitions. Variables #10, #12, #14, #15, #16, #27, #28, #29, #30, #31, #32 and #33 can only be used in a macro, not as an argument. Types of Variables.— There are four types of variables available for macros: N Not assigned Null Variable: Variable identified as #0 is a null variable. A null variable has no value—it is an empty variable, often called a vacant variable. This variable can be read by the macro program, but it cannot be assigned a value, which means data cannot be assigned to it. Local Variables: Local variables are temporary only—they are used in macro body and hold certain data. When the macro is called, the local variables are set to their assigned val­ ues. When the macro is completed and exits (using the miscellaneous function M99), or the control power is turned off, all local variables are set to null values—they will no longer exist. Common Variables: Common—or global—variables are still stored in the control memory when macro is completed. These variables are maintained by the system and they can be shared by several other macro programs. This group of variables is normally cleared by a specially designed macro program. System Variables: System variables are used for setting and/or changing default conditions and can read and write different CNC data, for example, a current status of a G-code mode, the current work offset, etc. Their numbers are assigned by the control system manufacturer. Variable Declarations and Expressions.— Variable data is not only defined in the argu­ ment section of the G65 macro call, variables can also be defined—or declared—in the macro body itself. Compare the two following declarations: #19 = 800 A value of 800 is assigned to variable number 19—it can be spindle speed (r/min) #9 = 15.0 A value of 15.0 is assigned to variable number 9—it can be a feed rate (mm/min, m/min, ft/min, in/min, etc.) Both declarations store values—the value of “800” is stored into the variable #19 and the value of “15.0” into the variable #9. Both values shown in the example are numbers, but they are two different types of a number. 800 is an integer, 15.0 is a real number. In macros, this distinction is important. Variables may also use special expressions. For example, the variable definition #9 = 15.0 can be redefined later, as #9 = #9 * 1.1, which returns 16.5. If #9 defines the cutting feed rate, the new feed rate will be F16.5. Expressions can also be nested, following the standard mathematical hierarchy of the order of calculations: #1 = 5.0 #2 = 8.5 #3 = 10.0 #4 = [#3 * #2] / #1; which returns 17.0 Note that brackets are used for nesting, not parentheses. Parentheses indicate a program comment or a message:

Copyright 2020, Industrial Press, Inc.

ebooks.industrialpress.com

Made with FlippingBook - Share PDF online