Jump to content

Welcome to eMastercam

Register now to participate in the forums, access the download area, buy Mastercam training materials, post processors and more. This message will be removed once you have signed in.

Use your display name or email address to sign in:

Custom code before tool change


Recommended Posts

Need to make a copy of your post and make your changes. Look in this snip and you will see the line I added. In between the "SPECIAL ADDED CODE" you need to replace and add your needed special codes. This is the simplest and easiest way. There are many ways to accomplish the task you are after, but this is a down and dirty get done method.

This is from the generic 3 Axis post.

psof$            #Start of file for non-zero tool number
      probe_head$
      pxformtype  #Set flag to indicate if G51/G68 is active based on transform type
      toolchng = one
      if ntools$ = one,
        [
        #skip single tool outputs, stagetool must be on
        stagetool = m_one
        !next_tool$
        ]
      pbld, n$, *smetric, e$
      pbld, n$, *sgcode, *sgplane, scc0, sg49, sg80, *sgabsinc, e$
      inhibit_probe$
      sav_absinc = absinc$
      if mi1$ <= one, #Work coordinate system
        [
        absinc$ = one
        pfbld, n$, sgabsinc, *sg28ref, "Z0.", e$
        pfbld, n$, *sg28ref, "X0.", "Y0.", e$
        pfbld, n$, sg92, *xh$, *yh$, *zh$, e$
        absinc$ = sav_absinc
        ]
      pcom_moveb
      pcheckaxis
      uninhibit_probe$
      c_mmlt$ #Multiple tool subprogram call
      ptoolcomment
      comment$
      pcan
      pbld, n$, "SPECIAL ADDED CODE", e$ #ADDED FOR SPECIAL CODE RDB 6-13-18      
      pbld, n$, *t$, sm06, e$
      if mi1$ > one, absinc$ = zero
      pcan1, pbld, n$, *sgcode, *sgabsinc, pwcs, pfxout, pfyout,
        [if nextdc$ <> 7, *speed, *spindle], pgear, strcantext, e$
      pbld, n$, sg43, *tlngno$, pfzout, pscool, pstagetool, e$
      absinc$ = sav_absinc
      pbld, n$, sgabsinc, e$
      pcom_movea
      toolchng = zero
      c_msng$ #Single tool subprogram call

ptlchg$          #Tool change
      pxformtype  #Set flag to indicate if G51/G68 is active based on transform type
      toolchng = one
      if mi1$ = one, #Work coordinate system
        [
        pfbld, n$, *sg28ref, "X0.", "Y0.", e$
        pfbld, n$, sg92, *xh$, *yh$, *zh$, e$
        ]
      inhibit_probe$
      if prog_stop = 1, pbld, n$, *sm01, e$
      if prog_stop = 2, pbld, n$, *sm00, e$
      pcom_moveb
      pcheckaxis
      c_mmlt$ #Multiple tool subprogram call
      ptoolcomment
      comment$
      pcan
      result = newfs(15, feed)  #Reset the output format for 'feed'
      pbld, n$, "SPECIAL ADDED CODE", e$ #ADDED FOR SPECIAL CODE RDB 6-13-18
      pbld, n$, *t$, sm06, e$
      sav_absinc = absinc$
      if mi1$ > one, absinc$ = zero
      pcan1, pbld, n$, *sgcode, *sgabsinc, pwcs, pfxout, pfyout,
        [if nextdc$ <> 7, *speed, *spindle], pgear, strcantext, e$
      pbld, n$, sg43, *tlngno$, pfzout, pscool, pstagetool, e$
      absinc$ = sav_absinc
      pbld, n$, sgabsinc, e$
      pcom_movea
      toolchng = zero
      c_msng$ #Single tool subprogram call

Here is sample code so you see what I did and the results:

%
O0000(T-2)
(DATE=DD-MM-YY - 13-06-18 TIME=HH:MM - 16:34)
(MCX FILE - T)
(NC FILE - C:\USERS\RON\DOCUMENTS\MY MCAM2018\MILL\NC\T-2.NC)
(MATERIAL - ALUMINUM INCH - 2024)
( T290 | 1/2 FLAT ENDMILL | H290 )
( T291 | 17/32 FLAT ENDMILL | H291 )
( T294 | 3/4 FLAT ENDMILL | H294 )
N100 G20
N102 G0 G17 G40 G49 G80 G90
N104 SPECIAL ADDED CODE
N106 T290 M6
N108 G0 G90 G54 X-1.7526 Y.6107 S1069 M3
N110 G43 H290 Z.1
N112 G99 G81 Z0. R.1 F6.42
N114 G80
N116 M5
N118 G91 G28 Z0.
N120 M01
N122 SPECIAL ADDED CODE
N124 T291 M6
N126 G0 G90 G54 X.5805 Y-.6709 S1069 M3
N128 G43 H291 Z.1
N130 G99 G81 Z0. R.1 F6.42
N132 G80
N134 M5
N136 G91 G28 Z0.
N138 M01
N140 SPECIAL ADDED CODE
N142 T294 M6
N144 G0 G90 G54 X.8763 Y1.1364 S713 M3
N146 G43 H294 Z.1
N148 G99 G81 Z0. R.1 F6.42
N150 G80
N152 M5
N154 G91 G28 Z0.
N156 G28 X0. Y0.
N158 M30
%

Welcome to the Forum and hope that helps.

  • Thanks 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.

Join us!

eMastercam - your online source for all things Mastercam.

Together, we are the strongest Mastercam community on the web with over 56,000 members, and our online store offers a wide selection of training materials for all applications and skill levels.

Follow us

×
×
  • Create New...