How to use Macro to program parabola on Fanuc

1. Features of user macro programming

The biggest feature of user macro programming is the use of variables, and arithmetic and logical operations can be carried out between variables. Therefore, when a certain batch of workpieces with the same shape but different sizes or composed of cavities, curved surfaces, curves, etc. are processed by the CNC machine tool, programming with the user macro program function can reduce program duplication, reduce the number of characters, and save memory. Programming is more convenient and easier.

2. Use of variables

FANUC system variable "#" and numbers are combined to indicate. When writing user processing programs for logic and function calculations, local variables #1~#33 or public variables #100~#199 can usually be used.

Public variables #500~#999 and the system variables after #1000 are usually provided to the machine tool manufacturer for secondary development and cannot be used casually. If used improperly, it will cause the collapse of the entire CNC system.

4. Parts analysis

The part profile is composed of paraboloids. When processing, take the X-direction equidistant dispersion method. According to the accuracy requirements, set the X-axis step of the parabola in the figure to 0.05MM. By selecting the X-axis step, the parabola is divided into several line segments, and its mathematics The equations respectively calculate the Z coordinate of each point on the contour, until Z=-16, the fitting processing of the corresponding contour is finished.

5. Parabolic surface finishing program segment

. . . . . . . .

#1=0; (X coordinate condition variable)

#2=0; (coordinate calculation variable)

N10G1X【2*#1】Z【#2】; (parabolic processing cycle body)

#1=#1+0.05; (X-direction radius variable)

#2=-[#1*#1/16]; (Calculation equation of parabola Z coordinate after X-radius conversion)

IF【#1LE16】GOTO10; (parabolic processing condition jump)

6. Processing method one:

This method is to use G73 compound cycle command for processing

The disadvantage of this method is that there are more empty cuts. . .

Processing program one

O0001;

M03S900;

T0101;

G00X100Z100;

X35Z0;

G1X0F0.15;

G00X32Z2;

G73U16R8;

G73P1Q20U0.5W0.1S1000F0.3;

N1G0X0S1200F0.15;

G1Z0;

#1=0;

#2=0;

N10G1X【2*#1】Z【#2】;

#1=#1+0.05;

#2=-[#1*#1/16];

IF【#1LE16】GOTO10;

N20G0X32Z2;

G0X100Z100;

M30;

7. Processing method two

This method is to use the FANUC system WHILE statement.

This method is the same as G73, with more air cuts

Format: WHILE【Expression】DOm;(m=1,2,3)

.........

END m

Processing program two

O0002;

M03S900;

T0101;

G00X100Z100;

X35Z0;

G1X0F0.15;

G00X32Z2;

#3=16;

WHILE【#3GE0】DO1;

#1=0;

#2=0;

N10G1X【2*【#1+3】】Z【#2】;

#1=#1+0.05;

#2=-[#1*#1/16];

IF【#1LE16】GOTO10;

G0Z2;

#3=3-1;

END1;

G0X100Z100;

M30;

8. Processing method three

The method is to use conditional statements to determine whether it has reached the size of the hair embryo

This processing method better overcomes the shortcomings of the first two methods

Processing program three

O0003;

M03S900;

T0101;

G00X100Z100;

X35Z0;

G1X0F0.15;

G00X32Z2;

#3=16;

WHILE【#3GE0】DO1;

N1#1=0;

#2=0;

N5#4=#1+#3;

N10G1X【2*#4】Z【#2】;

#1=#1+0.05;

#2=-[#1*#1/16];

#4=#1+#3;

IF【#1LE16】GOTO10;

G0Z2;

#3=3-1;

END1;

G0X100Z100;

M30;

9. Processing method four

This method is the layer cutting method, that is, the Z coordinate is obtained by the change of the X coordinate, so as to cut the approximate parabola step, and finally the parabola is finished

This method has the shortest processing route and higher efficiency

Processing program four

O0004;

M03S900;

T0101;

G0X34Z0;

G1X0F0.15;

G0X32Z2;

#3=16;

N5#4=-[#3*#3/16];

G0X【#3】;

G1Z【#4】F0.25;

G1U1;

G0Z2;

#3=3-1;

IF【#3GE0】GOTO5;

S1200F0.15;

#1=0;

#2=0;

N10G1X【2*#1】Z【#2】;

#1=#1+0.05;

#2=-[#1*#1/16];

IF【#1LE16】GOTO10;

G0X100Z100;

M30;

10. Summary

Correctly understand mathematical equations

Precise assignment

The use of conditional statements, especially expressing conditions

Flexible use of macro programming

The biggest feature of user macro programming is the use of variables, and arithmetic and logical operations can be carried out between variables. Therefore, when a certain batch of workpieces with the same shape but different sizes or composed of cavities, curved surfaces, curves, etc. are processed by the CNC machine tool, programming with the user macro program function can reduce program duplication, reduce the number of characters, and save memory. Programming is more convenient and easier.

2. Use of variables

FANUC system variable "#" and numbers are combined to indicate. When writing user processing programs for logic and function calculations, local variables #1~#33 or public variables #100~#199 can usually be used.

Public variables #500~#999 and the system variables after #1000 are usually provided to the machine tool manufacturer for secondary development and cannot be used casually. If used improperly, it will cause the collapse of the entire CNC system.

4. Parts analysis

The part profile is composed of paraboloids. When processing, take the X-direction equidistant dispersion method. According to the accuracy requirements, set the X-axis step of the parabola in the figure to 0.05MM. By selecting the X-axis step, the parabola is divided into several line segments, and its mathematics The equations respectively calculate the Z coordinate of each point on the contour, until Z=-16, the fitting processing of the corresponding contour is finished.

5. Parabolic surface finishing program segment

. . . . . . . .

#1=0; (X coordinate condition variable)

#2=0; (coordinate calculation variable)

N10G1X【2*#1】Z【#2】; (parabolic processing cycle body)

#1=#1+0.05; (X-direction radius variable)

#2=-[#1*#1/16]; (Calculation equation of parabola Z coordinate after X-radius conversion)

IF【#1LE16】GOTO10; (parabolic processing condition jump)

6. Processing method one:

This method is to use G73 compound cycle command for processing

The disadvantage of this method is that there are more empty cuts. . .

Processing program one

O0001;

M03S900;

T0101;

G00X100Z100;

X35Z0;

G1X0F0.15;

G00X32Z2;

G73U16R8;

G73P1Q20U0.5W0.1S1000F0.3;

N1G0X0S1200F0.15;

G1Z0;

#1=0;

#2=0;

N10G1X【2*#1】Z【#2】;

#1=#1+0.05;

#2=-[#1*#1/16];

IF【#1LE16】GOTO10;

N20G0X32Z2;

G0X100Z100;

M30;

7. Processing method two

This method is to use the FANUC system WHILE statement.

This method is the same as G73, with more air cuts

Format: WHILE【Expression】DOm;(m=1,2,3)

.........

END m

Processing program two

O0002;

M03S900;

T0101;

G00X100Z100;

X35Z0;

G1X0F0.15;

G00X32Z2;

#3=16;

WHILE【#3GE0】DO1;

#1=0;

#2=0;

N10G1X【2*【#1+3】】Z【#2】;

#1=#1+0.05;

#2=-[#1*#1/16];

IF【#1LE16】GOTO10;

G0Z2;

#3=3-1;

END1;

G0X100Z100;

M30;

8. Processing method three

The method is to use conditional statements to determine whether it has reached the size of the hair embryo

This processing method better overcomes the shortcomings of the first two methods

Processing program three

O0003;

M03S900;

T0101;

G00X100Z100;

X35Z0;

G1X0F0.15;

G00X32Z2;

#3=16;

WHILE【#3GE0】DO1;

N1#1=0;

#2=0;

N5#4=#1+#3;

N10G1X【2*#4】Z【#2】;

#1=#1+0.05;

#2=-[#1*#1/16];

#4=#1+#3;

IF【#1LE16】GOTO10;

G0Z2;

#3=3-1;

END1;

G0X100Z100;

M30;

9. Processing method four

This method is the layer cutting method, that is, the Z coordinate is obtained by the change of the X coordinate, so as to cut the approximate parabola step, and finally the parabola is finished

This method has the shortest processing route and higher efficiency

Processing program four

O0004;

M03S900;

T0101;

G0X34Z0;

G1X0F0.15;

G0X32Z2;

#3=16;

N5#4=-[#3*#3/16];

G0X【#3】;

G1Z【#4】F0.25;

G1U1;

G0Z2;

#3=3-1;

IF【#3GE0】GOTO5;

S1200F0.15;

#1=0;

#2=0;

N10G1X【2*#1】Z【#2】;

#1=#1+0.05;

#2=-[#1*#1/16];

IF【#1LE16】GOTO10;

G0X100Z100;

M30;

10. Summary

Correctly understand mathematical equations

Precise assignment

The use of conditional statements, especially expressing conditions

Flexible use of macro programming