1. What is a macro program?
Numerical control programming with variables
2. The difference between macro program and ordinary program.
Ordinary program
Macro program
Only constants can be used
You can use variables and assign values to variables
No operations between constants
Operations between variables
The program can only be executed sequentially, not jump
Program can jump
Three. Variables
#1~#33
Store data in the macro program and assign values to it in the program. Assignment is to assign a data to a variable. For example, #1=0 means that the value of #1 is 0, where #1 represents a variable, # is a variable symbol, and 0 is the value assigned to variable #1.
E.g
G0 X0 Y0; #1=100; #1=50;
G01 X100 F500; G0 X0 Y0; #2=50;
G01 X#1 F500; G0 X0 Y0;
G01 X[#1+#2]F500;
![]() ![]() ![]()
The concept of macro program
The so-called user macro program actually stores a group of subprograms with variables in the system memory in advance, and calls and executes this group of programs through the macro program call instructions in the main program.
%001
T0101
M03S600
G00X105Z2
G71U1R1P1Q2X0.2Z0.2
N1G01X0
Z0
#10=0
WHILE#10LE50
#11=2【SQRT【50#10】】
G01X【#11】Z【#10】
#10=#10+5
ENDW
G01X100Z-150
X104
Z-160
N2 G00X110
G00X110Z5
M30
![]() ![]()
General steps to compile a macro program
1. Determine whether to use a macro program for the curve
Curve type: straight line segment circular (arc) conic curve trigonometric function spline
CNC system type: HNC GSK SIEMENS FANUC
2. Establish curve equation (mathematical model)
Conic section trigonometric function
3. Matching curve equation and programming axis
The corresponding and the origin of the coordinate axis
4. Determine the variables
Number of variables Independent variable Dependent variable
5. Write a program
Precautions for programming macro program
1. The distinction between the origin of mathematical expressions and the origin of programming
2. Assignment of variable initial value
3. Sequence and integration in expressions and G codes
4. Diameter and radius value
5. "Positive" and "Negative" of programming coordinates
Macro program example
1. Example of coincident origin
2. Z-direction (X-direction) has a bias example
3. Both X and Z directions have offset examples
4. Examples of parameter method
![]() ![]() ![]()
Number of variables: CNC lathe X, Z axis (generally 2)
Parametric equations are 3
CNC milling X, Y, Z axis (generally 3)
Parametric equations are 4
Independent variable: 1. The independent variable is increasing or decreasing
2. The interval (extreme value) of the independent variable is easy to find, preferably a multiple of the step length
3. For difficult calculations, additional parameters can be set
Dependent variable: After the independent variable is determined, use the independent variable to change the dependent variable, the expression can be written, and the expression is easy to write.
![]() ![]() ![]() ![]() |