0
749views
SUBROUTINE | Rules
1 Answer
0
4views

General rules:

  1. You can call subroutines (within the same program) and subprograms (separate file on disk) using either M98 or M97 using the same syntax.

  2. A subprogram can start with either N or O. Both codes are supported as a sub program number.

  3. Repetitions can be given using the L word or as the first digits of the P word (last four digits are always program number).

  4. If a subroutine number is missing in program the simulator will attempt to find a disk file with the format O####.cnc in the same folder as the main program or in the user defined CNC folder.

  5. A subprogram can also be called with the alternative syntax M98 “mySubProgram.cnc” L…

  6. Return from subprograms and subroutines can be done with either M17 or M99.

  7. The L word is optional. If omitted, one call will be executed only.

Example program

Single call to subroutine, no repeats

M98 P1000 O1000

M17 (or M99)

Standard call to subroutine, repeating 4 times

M98 P1000 L4

Call to subroutine on line number 555, repeating 2 times

N100 M98 P555 L2

N555 ….

N565 M17 (or M99)

Call to subroutine with repeats in the P address

M98 P51001 (Call O1001 five times) O1001

M17 (or M99)

Calling subprograms

If a subroutine within the same program is missing, the simulator will look for a separate program on disk. M98 O1099 L2

If there is no O1099 or N1099 in the program, the block above will call subprogram O1099.cnc

File name syntax

M98 “DrillHoles.cnc” L2

The block above will look for subprogram DrillHoles.cnc in the same folder as the main program, or in the user defined CNC programs folder.

Please remember to end all subprograms with either M17 or M99 for execution to continue in the main program.

Please log in to add an answer.