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:

Trying to get tool table to show different diameter offset for same tool


Recommended Posts

As the title implies I want to get the tool table to list all the tools and include different diameter offsets.

 

Current output below.

(T1   -  1/8 SPOTDRILL       - H1   - D1   - D0.1250")(T2   -  1/2 FLAT ENDMILL    - H2   - D2   - D0.5000")
 
Desired output below.
(T1   -  1/8 SPOTDRILL       - H1   - D1   - D0.1250")(T2   -  1/2 FLAT ENDMILL    - H2   - D2   - D0.5000")(T2   -  1/2 FLAT ENDMILL    - H2   - D5   - D0.5000")

As you can see the above output shows that tool 2 is using diameter offset 2 and diameter offset 5. Eventually I want to have the post output the VTOFD command for Okumas so when running the progam on the machine it will automatically fill in the cutter comp value, which I think I can figure out as soon as I get the above resolved.

 

Below is what my tool table currently looks like. Any help is greatly appreciated!

 --------------------------------------------------------------------------# Tooltable Output# --------------------------------------------------------------------------pwrtt$      # Write tool table, scans entire file, null tools are negative           if rotaxis$ > 0 | rotary_type$ > 0 | mill5$ <> 0,             [             sav_rot_on_x = rot_on_x             output_z = no$             ]           if vmc = 0 & tlplnno$ <> 2, sav_rot_on_x = rot_on_x           if vmc = 1 & tlplnno$ > 1, sav_rot_on_x = rot_on_x           #sav_rot_on_x = rot_on_x    #Uncomment this line to output rotary axis value even when it's not used                      if tool_table = 1, ptooltable           if tool_table = 2, ppredtool           if tool_table = 3, pmetatool           if t$ >= zero, tcnt = tcnt + one           ptravel           pwritbuf5ptooltable # Write tool table, scans entire file, null tools are negative tester           tnote = t$           toffnote = tloffno$           tlngnote = tlngno$           spaces$=0           if t$ >= zero,             [             scomm_str, *t$, ptspace, " - ", plistcomm, " - ", *tlngno$, phspace, " - ", *tloffno$, pdspace, " - ", *tldia$, punit, pdiamspc, " - ", *tcr$,  punit, scomm_end, e$ #if tcr$>0,              scomm_str, *t$, ptspace, " - ", plistcomm, " - ", *tlngno$, phspace, " - ", *tloffno$, pdspace, " - ", *tldia$, punit, pdiamspc,  scomm_end, e$ #if tcr$=0,              ]
Link to comment
Share on other sites

Here is something I did in a lathe post a few years back. I could never get the number to come out correct it would always be one number off.

pwrtt$           #Buffer toolchange information, tooltable = 3 calls on 1003
      if gcode$ = 1001, psetup
      pcut_cctyp
      if opcode$=104 | opcode$=105 | opcode$=three | opcode$=16, cc_pos$ = zero
      if gcode$ <> 1001, plast_recd
      pcur_recd
      if gcode$ <> 1003, cc_pos$ = zero
      !opcode$, !tool_op$
      if gcode$ = 1003,
        [
        size1 = rbuf (one, zero)
        rc1 = one
        if rc1 < size1, preadcur_nxt
        if cc_1013$ = zero, cc_pos$ = zero
        ]
      #if you want repetitive tool output, keep the abs( ) in ptooltable and remove the >= t$ from the pwrtt call to this block        
      #if (tool_info = 2 | tool_info = 3) & gcode$ <> 1003 & op_id$ <> last_op_id & last_tloffno <> tloffno$ & t$ >= 0, ptooltable
      if (tool_info = 2 | tool_info = 3) & gcode$ <> 1003 & op_id$ <> last_op_id & last_tloffno <> tloffno$, ptooltable #This allows us to see the same tool with different offset
      last_tloffno = tloffno$ #This controls the different offset tracking not to duplicate it when they are used in the operations
      last_op_id = op_id$
      last_t = t$ #Trying to save the tool to keep subtraction from happening in the tool list when the same tool is called

ptooltable # Write tool table, scans entire file, null tools are negative
           #if you want repetitive tool output, keep the abs( ) in ptooltable and remove the >= t$ from the pwrtt call to this block
           toolno = t$ * 100 + tloffno$
           tnote = abs(toolno) #use to be this abs(t$), but we want it to look different so we changed
           tldianote = abs(tldia$) #Oct-20-08 AEH
           [if spindle_no$ = 0, ntooltrack = t$],[if spindle_no$ = 1, ntooltrack = t$ + 1000]
           ntooltrack = abs(ntooltrack) #See it used else where Figure why not
           if opcode$ = 3 | opcode$ = 16, toffnote = tlngno$
           else, toffnote = tloffno$
           stinsert2 = ucase(stinsert2)
           !spaces$
           spaces$ = zero
           if posttype$ = 2,    #lathe tools
             [
             scomm_str, *tnote, " - ", *ntooltrack, " - ", plistcomm, " - ", *toffnote, pdspace, " - ", *stinsert, *stinsert2, " - ", *stholder, *stholder2, scomm_end, e$
             #scomm_str, *tnote, ptspace, " - ", *toffnote, pdspace, " - ", *stinsert, *stinsert2, " - ", *stholder, *stholder2, scomm_end, e$
             ]
           else,                  #mill tools
             [
             if opcode$ = 3 | opcode$ = 16,
               [
               if tcr$ = 0, scomm_str, *tnote, " - ", *ntooltrack, " - ", plistcomm, " - ", *tldianote, punit, pdiamspc, scomm_end, e$
               ]
             else,
               [
               if tcr$ > 0, scomm_str, *tnote, " - ", *ntooltrack, " - ", plistcomm, " - ", *toffnote, pdspace, " - ", *tldianote, punit, pdiamspc, " - ", *tcr$,  punit, scomm_end, e$
               if tcr$ = 0, scomm_str, *tnote, " - ", *ntooltrack, " - ", plistcomm, " - ", *toffnote, pdspace, " - ", *tldianote, punit, pdiamspc,  scomm_end, e$
               ]
             ]
           spaces$ = prv_spaces$

Here is the fmt statement for the variable:

fmt  "N" 24  ntooltrack #Sequence Number Process for N Tracking back to Tool Number on Fanuc Lathe

Here is where I used it other places in the post.

ltlchg$          #Toolchange, lathe
      toolchng = one
      gcode$ = zero
      copy_x = vequ(x$)
      pcc_capture   #Capture LCC ends, stop output RLCC
      c_rcc_setup$   #Save original in sav_xa and shift copy_x for LCC comp.
      pcom_moveb    #Get machine position, set inc. from c1_xh
      c_mmlt$        #Position multi-tool sub, sets inc. current if G54...
      [if spindle_no$ = 0, ntooltrack = t$],[if spindle_no$ = 1, ntooltrack = t$ + 1000]
      *ntooltrack, ptoolcomment
      comment$
      if mr1$ > 0, pbld, n$, *mr1$, e$ #WAIT CODE CALLED FROM MISC REALS
      pbld, n$, "G0G18G40G80G97G99", e$
      pbld, n$, "G0G28U0", e$
      if lturret$ = 1, pbld, n$, *sg28ref, "V0", e$ #Had to add Upper Turret Support for Y axis Home Call
      #if tool_op$ <> 65, pbld, n$, "G0G18G40G80G97G99", e$
      #if tool_op$ <> 65, pbld, n$, "G0G28U0", e$
      #if lturret$ = 1 | tool_op$ <> 65, pbld, n$, *sg28ref, "V0", e$ #Had to add Upper Turret Support for Y axis Home Call
      if mr3$ < 0 ,
          [
          [if spindle_no$ = 0, pbld, n$, *sg53,*mr3$],[if spindle_no$ = 1, pbld, n$, *sg53,*mr3$], e$ #Clearance is different on main and sub spindle
          ]
      else,
          [
          [if spindle_no$ = 0, pbld, n$, *sg53,"Z-8.5"],[if spindle_no$ = 1, pbld, n$, *sg53,"Z-7."], e$ #Clearance is different on main and sub spindle
          ]
      toolno = t$ * 100 + tloffno$


mtlchg$          #Toolchange, mill
      toolchng = one
      gcode$ = zero
      copy_x = vequ(x$)
      pcom_moveb    #Get machine position, set inc. from c1_xh
      c_mmlt$        #Position multi-tool sub, sets inc. current if G54...
      [if spindle_no$ = 0, ntooltrack = t$],[if spindle_no$ = 1, ntooltrack = t$ + 1000]
      *ntooltrack, ptoolcomment
      comment$
      if mr1$ > 0, pbld, n$, *mr1$, e$ #WAIT CODE CALLED FROM MISC REALS
      pbld, n$, "G0G18G40G80G97G99", e$
      pbld, n$, "G0G28U0", e$
      if lturret$ = 1, pbld, n$, *sg28ref, "V0", e$ #Had to add Upper Turret Support for Y axis Home Call
      if mr3$ < 0,
          [
          [if spindle_no$ = 0, pbld, n$, *sg53,*mr3$],[if spindle_no$ = 1, pbld, n$, *sg53,*mr3$], e$ #Clearance is different on main and sub spindle
          ]
      else,
          [
          [if spindle_no$ = 0, pbld, n$, *sg53,"Z-8.5"],[if spindle_no$ = 1, pbld, n$, *sg53,"Z-7."], e$ #Clearance is different on main and sub spindle
          ]
      if opcode$ = 3 | opcode$ = 16, toolno = t$ * 100 + tlngno$
      else, toolno = t$ * 100 + tloffno$

HTH(Hope that Helps)

Link to comment
Share on other sites

I'm not an expert at post editing so its hard for me to look through your post and decipher it. I appreciate the help through.

 

Let me try to bounce an idea of you and maybe you can point me in the right direction. My idea was to first "find" the total number of op_id$ 's and make a variable called total_op_id. Then looking at the code below...

;

if toolcountn <= tooltotal, nexttool = rbuf(4,toolcountn)                #else, nexttool = first_tool$

;

Change it to

 

if op_id$ <= total_op_id

 

;

I'm not sure how to get around double posting of tools other than using an if statement that checks the tool number and and tool diameter. Which won't work if the tools are not programmed next to each other in mastercam.

 

My knowledge is really lacking on buffers and preparatory post blocks. Is there a way to get the total op numbers?

 

 

 

 

Link to comment
Share on other sites

I figured it out!

What I did was use three buffers. Buffers 1 and 2 contained the exact same information of the tool number and the diameter offset number. After running that information through a few "while" and "if" statements I wrote the tool numbers and diameters to a line in buffer 3. Only tools that have a different tool number or the same tool number with a different diameter offset are put into buffer 3. No duplicates!

 

Below is the code I put into the variables section

 

#Variables added for tool table, wdg edit, 2-14-2016

sizecntw : 1 #variable for checking if post has compared all rows of information between buffers 1 and 2

 

chkdubw1 : 0 #variables for dublicate checking

chkdubw2 : 0

 

b1_1 : 0 #buffer one

b1_2 : 0

rc1 : 1

wc1 : 1

size1 : 0

fbuf 1 0 2 0 0

 

b2_1 : 0 #buffer two

b2_2 : 0

rc2 : 1

wc2 : 1

size2 : 0

fbuf 2 0 2 0 0

 

b3_1 : 0 #buffer three

b3_2 : 0

rc3 : 1

wc3 : 1

size3 : 0

fbuf 3 0 2 0 0

</pre>

 

 

 

 

 

 

 

Below is the code I put into the psof$ section

 

#Section below for tool table, wdg edit, 2-14-2016 -------------------------------

 

b1_1 = rbuf(1,rc1) #this section puts first tool info into buffer 3

b3_1 = b1_1

b3_2 = b1_2

b3_1 = wbuf(3,wc3)

 

 

size2 = rbuf(2,0) #gets size of buffer 2

rc1=1

rc2=1

 

while rc2 <= size2, #while statement that starts the loop for checking for duplicates

[

b1_1 = rbuf(1,rc1) #section reads loads values from tables 1 and two

b2_1 = rbuf(2,rc2)

 

if b1_1 <> b2_1, #checks tool number from buffer one against buffer two

[

chkdubw1 = b2_1 #section loads values from table two into the dublicate checking variables

chkdubw2 = b2_2

 

rc3=1 #resests read counter to 3 before going into the next while statment

size3 = rbuf(3,0) #reads size of buffer 3

while rc3 <= size3, #gets size of buffer 3

[

b3_1=rbuf(3,rc3) #loads values from buffer three into variables

if chkdubw1=b3_1 & chkdubw2=b3_2, #Here it checks if the values of chkdubw1 and 2 are already in buffer 3

[

chkdubw1=0 # if the values have already been entered into table 3 then it sets chkdubw1 to zero.

]

]

if chkdubw1<>0, #If chkdubw1 is not equal to zero then it writes those values into table 3

[

chkdubw1 = wbuf(3,wc3)

]

]

 

if b1_1 = b2_1 & b1_2 <> b2_2, #here it checks tool number and the tool diameter offset number...More of the same as above.

[

chkdubw1 = b2_1

chkdubw2 = b2_2

 

rc3=1

size3 = rbuf(3,0)

while rc3 <= size3,

[

b3_1=rbuf(3,rc3)

if chkdubw1=b3_1 & chkdubw2=b3_2,

[

chkdubw1=0

]

]

if chkdubw1<>0,

[

chkdubw1 = wbuf(3,wc3)

]

 

]

 

if rc2 = size2 & sizecntw <> size2*size2, #This is how I make it loop so that each line from buffers 1 and 2 are evauluated against each other

[

sizecntw=sizecntw + 1 #adds +1 to the size count.

rc2=sizecntw #resets the read counter for buffer 2 to the same as the sizecntw...coul have made it equal to 1 but didn't need to since those values had already been evaulated.

]

else,

[

rc1=rc1-1 #keeps the read counter for buffer 1 and the same value until it has evualuated all rows of buffer 2

]

]

 

#section below outputs the tool table by reading the information in buffer 3

rc3=1

size3 = rbuf(3,0) #gets size of buffer 3

while rc3 <= size3,

[

b3_1=rbuf(3,rc3)

tnote = b3_1

toffnote = b3_2

scomm_str, *tnote, ptspace, " - ", plistcomm, " - ", *toffnote, phspace, " - ", scomm_end, e$

]

*size3, e$

 

#end of tool table section-------------------------------

 

 

 

 

 

 

 

 

 

 

 

 

Below is the code I put into the pwrtt$ section

 

#section below adds values to buffers 1 and 2, wdg edit 2-14-2016

b1_1 = abs(t$)

b1_2 = tloffno$

b1_1 = wbuf(1, wc1) #writes info into buffer 1

 

b2_1 = abs(t$)

b2_2 = tloffno$

b2_1 = wbuf(2, wc2) #writes info into buffer 2

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