|
Using Subroutines
When tool motions are created using PROFILE, POCKET or CLEAR, the identical sequence of tool movements is often repeated many times. In these cases, the Output Program File can be considerably shortened, by the use of subroutines.
Subroutines may not be created for sequences of tool movements which are created by other Cimatron NC machining functions. All lines of code for repeated sequences in those functions are included each time they occur.
To create subroutines for PROFILE, POCKET or CLEAR procedures, include the SUBROUTINE CALL block in the Post Processor Program File. If the SUBROUTINE CALL block is not included, then the Output Program File will include all the lines of code for every layer.
If the SUBROUTINE CALL is invoked, the first layer of a procedure will be written in a subroutine. When subsequent layers in the same procedure are encountered, they are skipped. There is no need to write them in the Output Program file again. The same process is repeated for all PROFILE, POCKET or CLEAR procedures in the toolpath.
These subroutines may be listed after the main program in the Output Program File in the order of their creation or in separate files. Question number 3 in section number 1 of the DFPOST questions asks if you want to write the subroutines in separate files. If YES is selected, the system automatically assigns a name to the file in which each subroutine is created. The name is the same as that of the Output Program File plus an extension consisting of the character S, and a number. Numbers are assigned in the order that subroutines are created.
Example:
Output Program File: |
<part>.<toolpath>.<post processor> |
First Subroutine: |
<part>.<tool path>.<post processor>.S1 |
Second Subroutine: |
<part>.<tool path>.<post processor>.S2 |
Executable statements may be included in the SUBROUTINE CALL block. These statements will be executed in the main program before a subroutine is called.
Statements to be executed at the beginning of a subroutine may be included in the BEGINNING OF SUB block. Statements may be executed after the layer is closed by including them in the END OF SUB block.
Statements to be included after returning to the main program, may be included in the SUBROUTINE RETURN: block.
Example:
SUBROUTINE CALL:
SUBNUM = SUB_NUMBER + 7999 ;
OUTPUT $ " G65 P" SUBNUM " Z" LAYER_Z ;
BEGINNING OF SUB:
SUBFLG = 1 ;
SET_ON ZDM ;
OUTPUT "%" ;
OUTPUT \J "O" SUBNUM ;
OUTPUT $ " G90 G" ZDM ;
SET_ON MCH_FEED ;
OUTPUT $ " G1 Z#26 F" MCH_FEED ;
END OF SUB:
OUTPUT $ " G40" $ " M99" ;
SUBFLG = 0 ;
SUBROUTINE RETURN:
SET_ON LIN_MOV CIRC_MOV MCH_FEED ;
SET_ON X_CURPOS Y_CURPOS Z_CURPOS ;
Note:
-
Subroutines are not created in the following cases:
- Functions that were changed in EDITTP/MANUAL
- PROFILE and POCKET functions with a DRAFT ANGLE
- PROFILE function with a STOCK WIDTH.
- PROFILE function with the option B-DIRECTION.
- The system variable NO_SUBROUT is SET_OFF.
|