May 04, 2024 Leave a message

CNC macro program call

 

There are four types of CNC macro program calling subroutines:

1, M98 call

2. G65 call

3. G66 call

4. Define G command call

5. Define M command call


2. Today I will share G65 calling subroutine


Format: G65P subroutine name address name

Let's look at P first. In fact, G65 and M98 subroutine calls are very similar. P is followed by the name of the subroutine.

For example, if there is subroutine O1234, then when the main program is called using G65, it can be written as G65 P1234 (the capital letter O is not needed)

Next it's time to talk about the very critical address name.

Variables in macro programs are divided into three categories (local variables, public variables, system variables)

Among them, #1~#26 are local variables. The corresponding relationship between local variables and address names A, B, C...Z is as follows.

picture
To put it bluntly, the address name is to transfer data to its corresponding variable.

For example, the letter A in the above table corresponds to #1. If A10, it is equivalent to passing the data 10 to variable #1. At this time, #1=10;

In the same way, if B20, then #2=20, if Z-26, then #26=-26.

This is a bit empty, let me give you a simple example to give you some inspiration, such as the following parts

picture
Milling M20x1.5 external thread

I randomly set several local variables #1, #26, #7, #17, and #11 from #1 to #26 to represent:

#1 (A) represents the blank size;

#26 (Z) represents thread depth;

#7 (D) represents the diameter of the thread mill;

#17 (Q) represents the initial Z value of the cutting point

#11 (H) represents pitch

Thread milling procedure:
picture
Take the above program as a subroutine and use G65 to call the subroutine as follows:

picture

When I use G65 to call program No. O2222, the data following the letters A, D, Z, Q, and H are passed to the corresponding variables.

at this time:
(#1) A represents the blank size;

(#26) Z represents thread depth;

(#7) D represents the thread milling cutter diameter;

(#17) Q represents the initial Z value of the cutting point

(#11) H represents pitch

If we process a similar part, we only need to write a main program and call a subroutine.

For example, M33x2.0 external thread (milling in two cutting tools)
picture
picture

The program call is as follows:
picture

Example two:

The cycle procedure of counting lathes for deep holes is as follows:

G65 P_K_B_ W_ C_ F_

illustrate:
P: represents subroutine number
K; depth
B: Backoff amount
W: depth of each feed
C: First feeding depth
F: Feed amount

for example:
G65 P1 K-20. B0.3 W1.2 C0.8 F0.05

Among them, 1 is the subroutine number, and the processing hole depth is 20. Each time the retreat is 0.3, each time the feed depth is 1.2, the first feed depth is 0.8, and each revolution feeds 0.05

The subroutine is as follows: (This program can be copied and saved in the machine tool)
O0001(DEEP DRILL)
IF [#5002LT0]GOTO 100
IF[#6GE0]GOTO 70
G00W0.0
#4=#5002
#3=ABS[#3]
#2=ABS[#2]
IF[#19EQ98]GOTO 1
#19=99
N1 G#19 F#9
#27=ABS[#23]
#28=ABS[#6]-ABS[#26]
#29=ABS[#26]
DO 1
IF[#27LE#3]GOTO 2
GOTO 3
N2 #27=#3
N3 IF[#27GE#28]GOTO 4
G00 Z[#2-#29]
G1 Z-[#29+#27]
G00 Z#4
G4 U#1
#28=#28-#27
#29=#29+#27
#27=#27*0.5
END 1
N4 G00 Z[#2-#29]
G1Z#6 F#9
G00Z#4
M99
N70 #3000=1(K MUST BE NEGATIVE)
N100
IF[#6LE#0] G0T0 170
G00W0.0
#4=#5002
#3=ABS[#3]
#2=-[#2]
IF[#19EQ98]GOTO 1
#19=99
N1G#19 F#9
#27=ABS[#23]
#28=ABS[#6]-ABS[#26]
#29=ABS[#26]
DO 1
IF[#27LE#3]GOTO 2
GOTO 3
N2 #27=#3
N3 IF[#27GE#28]GOTO 4
G00 Z[#2#29]
G1 Z[#29+#27]
G00 Z#4
G4 U#1
#28=#28-#27
#29=#29+#27
#27=#27*0.5
END 1
N4 G00 Z[#2+#29]
G1Z#6 F#9
G00Z#4
M99
N170 #3000=1(K MUST BE POSITIVE)


When we use this program, we only need to save the subprogram (such as O0001) in the machine tool memory. When drilling deep holes later, we only need to use G65 to call the subprogram.

For example, to drill a hole 100 meters deep, the procedure is as follows:
%
O0003
T0101
S1000M03
G0X0.Z2.
G65 P1 K-100. B0.3 W5. C1. F0.05
M30
%

Send Inquiry

whatsapp

skype

E-mail

Inquiry