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:

5 Axis tool repeat N number


Recommended Posts

Hi everyone,

  I'm now end up with 5-Axis machine and I would like to spit out as "N" repeat number.  I tried with the existing post of which I'd worked for years and now I tried to implement this feature into it and I didn't get it right.  Please help, I'm truly appreciate it.

 

================================

%:0001(TESTRIB)(Posted on JUL. 07th. 2016 at 15:46)(TESTRIB.MCAM)(testrib.NC)(ALUMINUM inch - 2024)(*)(T300|2 INCH FLAT ENDMILL |H300)(T162|1/2 DRILL |H162)(*)N300(PROFILE WITHOUT TOOLPATH EDITOR SETTINGS, CUT#1) ===============================> first TOOLG0 G17 G40 G80 G90 G94 G98G0 G28 G91 Z0.G0 G28 X0. Y0.T300 M6(2 INCH FLAT ENDMILL )G0 G54 G90 X-3. Y-3. C0. B0. S955 M3G43 H300 Z2. M8Z.3G1 Z-4. F6.42X-2. F38.2G3 X-1. Y-2. J1.G1 Y0.G1 Y-2.G3 X-2. Y-1. I-1.G1 X-3.G0 Z2.M9M5G0 G28 G91 Z0.G28M01(*)N300(PROFILE WITH TOOLPATH EDITOR FEEDRATE REDUCTION ON END WITH HEAVY STOCK, CUT#2) =============> SHOULD BE N301G0 G17 G40 G80 G90 G94 G98G0 G28 G91 Z0.T300 M6(2 INCH FLAT ENDMILL )G0 G54 G90 X-3. Y-3. C0. B0. S955 M3G43 H300 Z2. M8Z.3G1 Z-4. F6.42X-2. F38.2G3 X-1. Y-2. J1.G1 Y0.G2 X0. Y1. I1.G1 X-3.G0 Z2.M9M5G0 G28 G91 Z0.

===============================

# --------------------------------------------------------------------------

# General Output Settings# --------------------------------------------------------------------------
ToolSequenceNumber : 0

# -------------------------------------------------------------------------- # Toolchange / NC output Variable Formats # --------------------------------------------------------------------------

fmt 4 rpttl #counter for sequence number fmt 5 rpttl2 fmt "N" 4 ToolSequenceNumber # --------------------------------------------------------------------------

 

psof$ #Start of file for non-zero tool number

      ##### Custom changes allowed below #####      if ntools$ = one,        [        #skip single tool outputs, stagetool must be on        stagetool = m_one        !next_tool$        ]      if stagetool >= zero,        [        rc8 = t$        wc8 = t$        rpttl2 = t$        size8 = rbuf(8,0)        if rc8 <= size8, rpttl = rbuf(8,rc8)        rpttl = rpttl + 1        rpttl = wbuf(8,wc8)       ]      if rpttl > 2 & rpttl2 < 9, t$ = (rpttl - 1) + (rpttl2 * 100)      if rpttl > 2 & rpttl2 > 10 & rpttl2 < 100, t$ = (rpttl - 1) + (rpttl2 * 100)      if rpttl > 2 & rpttl2 > 100 & rpttl2 < 999, t$ = (rpttl - 1) + (rpttl2 * 1000)      ToolSequenceNumber = t$      #pbld, n$, *smetric, e$	  "(*)", e$	  *ToolSequenceNumber, comment$, e$      pbld, n$, *sg00, *sgplane, *sg40, "G80", *sg90, *sgfeed, *sg98, e$      sav_absinc = absinc$      absinc$ = one      prefreturn #xout, p_out not output here      absinc$ = zero      p_absinc_chng      #ptoolcomment      comment$      pcan      ##### Stop custom changes #####

ptlchg0$ #Call from NCI null tool change (tool number repeats)

      #Cancel check in case missed in ptoolend      if prv_n_tpln_mch <> n_tpln_mch, pg69      ##### Custom changes allowed below #####      comment$      # This call to 'pcan' has been commented out to avoid      # double output of canned text      #pcan      pbld, n$, sgplane, e$      pspindchng      pbld, n$, pscool, e$      ##### Stop custom changes #####      psof_tlchg_blck #Start position block      #Save the current brk_ in prv_brk_ for next loop      pupd_brk      toolchng = zero      ##### Custom changes allowed below #####      if stagetool >= zero,        [        rc8 = t$        wc8 = t$        rpttl2 = t$        size8 = rbuf(8,0)        if rc8 <= size8, rpttl = rbuf(8,rc8)        rpttl = rpttl + 1        rpttl = wbuf(8,wc8)       ]      if rpttl > 2 & rpttl2 < 9, t$ = (rpttl - 1) + (rpttl2 * 100)      if rpttl > 2 & rpttl2 > 10 & rpttl2 < 100, t$ = (rpttl - 1) + (rpttl2 * 100)      if rpttl > 2 & rpttl2 > 100 & rpttl2 < 999, t$ = (rpttl - 1) + (rpttl2 * 1000)      ToolSequenceNumber = t$

ptlchg$ #Tool change

      #Cancel check in case missed in ptoolend      if prv_n_tpln_mch <> n_tpln_mch, pg69      ##### Custom changes allowed below #####      pbld, n$, "M01", e$	  "(*)", e$	        if stagetool >= zero,        [        rc8 = t$        wc8 = t$        rpttl2 = t$        size8 = rbuf(8,0)        if rc8 <= size8, rpttl = rbuf(8,rc8)        rpttl = rpttl + 1        rpttl = wbuf(8,wc8)       ]      if rpttl > 2 & rpttl2 < 9, t$ = (rpttl - 1) + (rpttl2 * 100)      if rpttl > 2 & rpttl2 > 10 & rpttl2 < 100, t$ = (rpttl - 1) + (rpttl2 * 100)      if rpttl > 2 & rpttl2 > 100 & rpttl2 < 999, t$ = (rpttl - 1) + (rpttl2 * 1000)      ToolSequenceNumber = t$	        *ToolSequenceNumber, comment$, e$      pbld, n$, *sg00, *sgplane, *sg40, "G80", *sg90, *sgfeed, *sg98, e$

# --------------------------------------------------------------------------

#String and string selector definitions for NC output# --------------------------------------------------------------------------

# --------------------------------------------------------------------------

# Buffer 8 - Customized tool and sequence numbers# --------------------------------------------------------------------------rc8     : 1wc8     : 1init    : 0rpttl   : 0rpttl2  : 0size8   : 0fbuf 8 0 1 0 0          #Min / Max
Link to comment
Share on other sites

The easiest way to do this is to use a Lookup Table. The Lookup Table function allows you to defined two columns of numbers, the first (starting at "0") is the "number of times the tool has been used", and the 2nd column of numbers can be set to the actual "Tool Number". (some numbers omitted for ease of typing)

flktbl  3  30
        0  1
        0  2
        0  3
        .
        .
        .
        0  29
        0  30

Then, you can use the 'finc' function to return the "incremental" value of the tool number. In other words, "how many instances of this tool have been called at the tool change?"

 

The 'finc' function is also setup to "automagically" increment each value in the 1st column by "1" every time it is called.

 

You "call" the function using two parameters. The first parameter is the "number of the lookup table", in our case "3", and the 2nd parameter is the number in the 2nd column that you want to match. In our case, the Tool Number.

     times_used = finc(3, t$)

When used at the Tool Change (and in 'psof$', to count the first tool once), it will return the "instance number of the Tool Number". So if you've already had three operations that use "T24", and this is the 4th time you are using it, then calling the function would set 'times_used' to '4'.

 

I helped Steven get this setup, and it's now working to output the "Tool Sequence Number".

 

We set this up to output a three digit "NXXX" for T1-T9, four digit "NXXXX" for T10-T99, and five digit "NXXXXX" for T100-T999, on every Tool Instance that is "2" or greater.

 

For example, if you called T210 the "4th" time, you'd get "N21004". The 5th time you call "T21", you'd get "N2105", and so on. Technically, it would work for up to "99" calls of each tool, although if you call a tool more than 9 times, reading the N number gets a little bit tougher...

 

Just wanted to post this for anyone that might be looking to implement similar functionality in their post...

  • Like 3
Link to comment
Share on other sites

The easiest way to do this is to use a Lookup Table. The Lookup Table function allows you to defined two columns of numbers, the first (starting at "0") is the "number of times the tool has been used", and the 2nd column of numbers can be set to the actual "Tool Number". (some numbers omitted for ease of typing)

flktbl  3  30
        0  1
        0  2
        0  3
        .
        .
        .
        0  29
        0  30

Then, you can use the 'finc' function to return the "incremental" value of the tool number. In other words, "how many instances of this tool have been called at the tool change?"

 

The 'finc' function is also setup to "automagically" increment each value in the 1st column by "1" every time it is called.

 

You "call" the function using two parameters. The first parameter is the "number of the lookup table", in our case "3", and the 2nd parameter is the number in the 2nd column that you want to match. In our case, the Tool Number.

     times_used = finc(3, t$)

When used at the Tool Change (and in 'psof$', to count the first tool once), it will return the "instance number of the Tool Number". So if you've already had three operations that use "T24", and this is the 4th time you are using it, then calling the function would set 'times_used' to '4'.

 

I helped Steven get this setup, and it's now working to output the "Tool Sequence Number".

 

We set this up to output a three digit "NXXX" for T1-T9, four digit "NXXXX" for T10-T99, and five digit "NXXXXX" for T100-T999, on every Tool Instance that is "2" or greater.

 

For example, if you called T210 the "4th" time, you'd get "N21004". The 5th time you call "T21", you'd get "N2105", and so on. Technically, it would work for up to "99" calls of each tool, although if you call a tool more than 9 times, reading the N number gets a little bit tougher...

 

Just wanted to post this for anyone that might be looking to implement similar functionality in their post...

 

Thank you Colin, you made it worked.

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...