How to support parametric tool numbers

It is a common practice in many shop floors to use variables instead of hard-coded numbers for CNC program data such as feed rates, drilling cycle parameters or even tool numbers. This method allows operators to make quick changes to the program by simply altering the values of a few parameters.

The example below illustrates this technique on a FANUC control, where tool numbers are replaced by variables #101, #102, etc.







    #101=1 (1.5 IN FACE MILL)


    #102=32 (1 IN FLAT END MILL)


    #103=15 (1/2 IN FLAT END MILL)


    #104=6 (NO 4 CENTER DRILL)


    #105=4 (1/8 IN SPOT DRILL)


    #106=3 (3/16 IN DRILL)


    #107=7 (5/16 IN DRILL)


    #108=28 (3/8-16 TAP RH)


    #109=12 (1/4 IN 30 DEGREE ENGRAVING TOOL .06 TIP)




    N100 T[#101] (1.5 IN FACE MILL)


    N110 M6




    N1290 T[#102] (1 IN FLAT END MILL)


    N1300 M6




    N1860 T[#103] (1/2 IN FLAT END MILL)


    N1870 M6



With an ICAM post-processor, you can set up your posts to support this method automatically. All it takes is a slight change to the Machine Description / Tool Change questionnaire section responses and two relatively simple macros as outlined below.

1. Machine Description / Tool Change questionnaire

Questions #28 and #29 must be answered as follows, so that CAM-POST does not output the tool change T and M codes, since these are instead going to be output in the tool change shutdown macro.

    Question #28 – Tool number in tool register: None


    Question #29 – Tool change (M) code: NA

2. Machine Startup Macro:

The following macro, run once at the start of the program, uses the PPFUN/25 command to scan the entire program looking for all tool change information, which is loaded into the $TLTAB array. We then loop through all entries in the tooling table (skipping entry #1, which is for the dummy tool), outputting a block in the form: #variable=tool (description)

    $$ Build tool list








    INSERT/’#!(3)=!(s9) (!(A))’,%L01+99,$TLTAB(1,%L01),$TLTAB(20,%L01)



3. Toolchange Shutdown Macro

The following macro, run following each tool change, outputs the tool change T code and the tool description. The $TI post-processor variable points to the $TLTAB tooling table entry for the tool that was just loaded. The output is as follows: T[#variable] (description)

    $$ Parametric tool change code


    INSERT/’T[#!(3)] (!(A))’,$TI+99,$TLTAB(20,$TI)



Benefit to User
Output tool numbers using variables, allowing operators to make quick changes to the program.

For more information or comments, please do not hesitate to contact Phil at