4.11.5.2 M97: Internal Subprogram Call
1. M97: internal subprogram call L_ times
Format:
M97 P_ L_
In the editor execution mode, the M97 instruction is used to call the internal auxiliary program L_ times. This internal subprogram is the same as the main program in a CNC file.
This internal subprogram is placed after the main program and has the subscript name "Oxxxx". This "xxxx" is four digits, which is the P_ value in the M97 instruction; the subprogram must end with M99 (returned by subroutine) .
Example 1:
program SAMPLE97.CNC explain
___________________________________________________________
;SAMPLE OF M97 CALL ;Main program
G50 X0 Y0 Z0 ;
M03 ;
M97 P1005 L3 ;Call executive subprogram O1005 three times
M97 P2001 ;Call executive subprogram O2001 once
M05 ;
... ...
M02 ;Main program end
O1005 ;subprogram O1005 begin
... ...
M99 ;subprogram O1005 end
; ;
O2001 ;subprogram O2001 begin
... ...
M99 ;subprogram O2001 end
Example 2:
program SAMPLE97.CNC explain
___________________________________________________________
;SAMPLE OF M97 CALL ;Main program
G50 X0 Y0 Z0 ;
... ...
M97 P1005 L3 ;Call executive subprogram O1005 three times
... ...
M30 ;Main program end
; ;
O1005 ;subprogram O1005 begin
... ...
M97 P2001 ;caling subprogram O2001
... ...
M99 ;subprogram O1005 end
; ;
O2001 ;subprogram O2001 begin
... ...
M99 ;subprogram O2001 end
2. M97 function
The M97 function is described as follows:
Format:
M97 Pp Qq xxxx #yyyy zzzz
.
.
.
Op
.
.
.
M99
among them,
p: |
The subprogram name of the call definition function. |
q: |
In the Op subprogram, the starting number of the macro variable to substitute for the function input value. (Followed by digits or macro variables, and can only have both, there can be no other instruction values, and up to 10 groups of numbers or macro variables can be set) |
xxxx, zzzz (number) : Input value of function p.
#yyyy (Macro variable value) : Input value of function p.
Op : p subprogram.
In the M97 function, the function input value is substituted into the defined function by a macro variable to perform an operation. The function definition is written as an internal subprogram and is executed by the M97 instruction call.
When executing this M97 function instruction, the system will substitute xxxx into #q, the value of macro variable yyyy will be substituted into #(q+1), zzzz will be substituted into #(q+2), and so on, for Op functions to perform operations.
Example program:
How to write the program:
#30=-146.999
#31=10.000
#71=#31*COSD(#30)
#72=#31*SIND(#30)
Use the M97 function to rewrite the program to:
<Rewrite 1>
M97 P301 Q30 -146.999 10.000
.
.
.
O301
#71=#31*COSD(#30)
#72=#31*SIND(#30)
M99
In the above example, the M97 command line will set #30 to -146.999, #31 to 10.000, and then call the O301 subroutine.
<Rewrite 2>
(This is a script to demonstrate how to handle input values using macro variables.)
#50=-146.999
M97 P301 Q30 #50 10.000
.
.
.
O301
#71=#31*COSD(#30)
#72=#31*SIND(#30)
M99
In the above example, the first line will first set -146.999 to #50, and the M97 line will set #30 to the value of #50, -146.999, #31 to 10.000, and then call the O301 Program.
Note: |
The input values can be separated by a comma (,), which means that the input values can be separated by spaces or commas (,), such as: |
M97 Pp Qq xxxx,#yyyy,zzzz,…………