Master Disaster

How to get manufacturer code (parameter 20002) of the next tool ?

Recommended Posts

Hi guys,

I have a small problem that is giving me a headache. Maybe someone here can help me 🙂

On a new machine with automatic tool changer, I need to pre-stage the next tool. Normally the next tool is called with the variable next_tool$. However, in my case, the tool number is stored under the tool manufacturer's code due to our internal rules.

In a first step, I changed my post to get the output with the "normal next tool number":

 

stagetool             : 1     #0 = Do not pre-stage tools, 1 = Stage tools
one                       : 1     #Define constant
s_last_used_tool : ""    #last used tool 
s_next_tool          : ""    #tool to be pre-staged in ATC
s_tdef                   : "TOOL DEF"

 

p_goto_strt_tl       #Make the tool start up at toolchange
      pfd_shft_inc
      psign_ang_out
      
      ##### Custom changes allowed below #####
         s_next_tool = no2asc(34) + no2str(next_tool$) + no2asc(34)
         if stagetool = one,   
           [
             if s_last_used_tool <> s_next_tool,
               [
                 pbld, n$, s_tdef, s_next_tool, e$
                 s_last_used_tool = s_next_tool
               ]
           ]

If I just want the next tool number, that would work fine.

But now: How can I get the tool manufactures code of the next tool ?

image.png.69f621ef45bd77c808affb032b87be1f.png

I tried to use something like this:

s_next_tool = opinfo(20002,1)

However, this doesn´t work at all - because the returned value points to the next toolpath ( passed parmeter 1) and not to the next tool (change). If the next toolpath uses the same tool, the return value is "-99999".If the next toolpath uses a different tool, the return value is correct.

I thought it could be solved with a while loop, but that get´s me to the problem, that I have to know how to determine the end of all posted toolpaths to prevent a endless recursion.

Does anyone can give me a hint how I can solve this ? 

I've searched this forum up and down and found some posts, but everything I've tried doesn't end up with the desired output.

It would be great if someone could give me some advice to get me back on track.

Thanks,

Erich

 

 

Share this post


Link to post
Share on other sites
13 minutes ago, JParis said:

mUXC6lk.png

Thanks JParis - But idk what does this picture want to tell me 🤔 I want to change my post. This seems to be a report.

Share this post


Link to post
Share on other sites
4 minutes ago, Master Disaster said:

Thanks JParis - But idk what does this picture want to tell me 🤔 I want to change my post. This seems to be a report.

There are details about getting the manufacturer info on the official mastercam.com forum, Iirc its a new option for 2022

  • Like 1

Share this post


Link to post
Share on other sites
7 minutes ago, Master Disaster said:

Thanks JParis - But idk what does this picture want to tell me 🤔 I want to change my post. This seems to be a report.

Ahh, I missed that...

You can check here but you'll find you're going to have to migrate to the newer tool info to get at that piece..

 

Share this post


Link to post
Share on other sites
7 minutes ago, [email protected] said:

There are details about getting the manufacturer info on the official mastercam.com forum, Iirc its a new option for 2022

 

Oh, I forgot to mention: the post must also run in version 2017

 

Share this post


Link to post
Share on other sites
5 minutes ago, Master Disaster said:

 

Oh, I forgot to mention: the post must also run in version 2017

 

Some mfg information is only available in mc2022, In older versions, you need to use a nethook or chook integrated into your post to access certain manufacturer information.

 

  • Like 1

Share this post


Link to post
Share on other sites

The 20002 data is only written to the NCI when there is a physical tool change.  Post this on the official forum so someone from CNC’s post team can have a look.

Share this post


Link to post
Share on other sites
On 11/17/2021 at 2:18 AM, Zaffin_D said:

The 20002 data is only written to the NCI when there is a physical tool change.  Post this on the official forum so someone from CNC’s post team can have a look.

@Zaffin_D I searched in the depths of this forum and found a post by you 

 

 

I used your code snippet and changed it a bit and it worked really well 🙂 I don't know if this is bug free or causes performance issues, but I will implement it first and see how it works.

 

op_identity              : 0

tool_number              : 0
tool_manufacturer        : 0
op_ident                 : 0

stack_tool_number        : 0
stack_tool_manufacturer  : 0
stack_op_ident           : 0


stack_size               : 0
stack_result             : 0

fstack 1 3

is_tool_in_stack         : no$


stream_idx   : 1
stream_op_id : 0

s_quotation_mark : ""

output_tool_number         : 0
output_tool_manufacturer   : 0
output_op_ident            : 0

fs2 4   1 0 1 0 
fmt ""  4 output_tool_manufacturer


p_goto_strt_tl       #Make the tool start up at toolchange
      pfd_shft_inc
      psign_ang_out
      
      ##### Custom changes allowed below #####
         s_next_tool = no2asc(34) + "T"+ no2str(next_tool$) + no2asc(34)
         next_tool_number = scan("T",s_next_tool)
         
         if stagetool = one,
           [
             if s_last_used_tool <> s_next_tool,
               [
                 pwrite_tdef_info
                 s_last_used_tool = s_next_tool
               ]
           ]


pwrite_tdef_info
    stream_idx = 1
    stream_op_id = streaminfo(1, stream_idx)
    while stream_op_id <> -99999,
        [
        pget_tool_parameters(stream_op_id)
        padd_tool_to_stack
        stream_idx = stream_idx + 1
        stream_op_id = streaminfo(1, stream_idx)
        ]
    stack_size = pop(1, stack_result, 0)
    while stack_size > 0,
        [
        output_tool_number = pop(1, stack_size, 5)
        if output_tool_number = next_tool_number,
          [
            !spaces$, spaces$ = 0
            s_quotation_mark = no2asc(34)
            pbld, n$, " TOOL DEF ", s_quotation_mark, *output_tool_manufacturer, s_quotation_mark, e$
            spaces$ = prv_spaces$
          ]
        stack_size = stack_size - 1
        ]

padd_tool_to_stack
    is_tool_in_stack = no$
    stack_size = pop(1, stack_result, 0)
    while stack_size > 0,
        [
        stack_tool_number = pop(1, stack_size, 5)
        if stack_tool_number = tool_number,
            [
            is_tool_in_stack = yes$
            stack_size = -1
            ]
        stack_size = stack_size - 1
        ]
    if not(is_tool_in_stack),
        [
        if tool_number <> -99999, tool_number = push(1, stack_result, 0)
        ]

pget_tool_parameters(op_identity)
    tool_number = opinfo(47, op_identity, 1)
    sparameter$ = opinfo(20002, op_identity, 1)
    tool_manufacturer = rpar(sparameter$, 2)
 

  • Like 1

Share this post


Link to post
Share on other sites

That’s far too much for what you want to do.  Create a loop to look for the next tool, and keep track of how far forward you looked for it.  Then use that as your look ahead to grab the next tool’s 20002.

Share this post


Link to post
Share on other sites

Thanks @Zaffin_D I tried what you suggested but unfortunately I don't know how to get the next op_id$, what I need to query the 20002 parameter. The problem of op_id$ is that this is not an ordered number. Would be happy if you can give me more hints 😀

Share this post


Link to post
Share on other sites
19 hours ago, Master Disaster said:

Thanks @Zaffin_D I tried what you suggested but unfortunately I don't know how to get the next op_id$, what I need to query the 20002 parameter. The problem of op_id$ is that this is not an ordered number. Would be happy if you can give me more hints 😀

If you want the "ordered number", opcode$ 15240 will give you the 'Operation Number in sequential order', as it appears in your Toolpaths Manager. 

Share this post


Link to post
Share on other sites
On 11/25/2021 at 12:20 PM, Master Disaster said:

Thanks @Zaffin_D I tried what you suggested but unfortunately I don't know how to get the next op_id$, what I need to query the 20002 parameter. The problem of op_id$ is that this is not an ordered number. Would be happy if you can give me more hints 😀

You do not need the op_id$ in this case; your only concern is how many operations are between the current operation and the next physical tool change.

In the below example, I set up a postblock to populate the s_next_20002 variable;  p_get__s_next_20002.  This postblock takes one parameter by reference and loops through the upcoming operations looking for the next physical tool change.  Once the next physical tool change has been found, the lookahead_index variable contains the number of operations needed to look ahead for the next 20002.  The parameter p_get__s_next_20002 modifies is a bool telling the caller if a valid 20002 was found or not. 

This is  as much as I can help; your reseller and the official forums are great resources if you have follow up questions.  

Implementation example: 

lookahead_index         :  0
next_tool_change_gcode  :  0
invalid                 := -99999

s_next_20002            :  ""
s_invalid               := "-99999"

is_valid_arg            :  no$

p_get__s_next_20002(!is_valid_arg)
    lookahead_index = 1
    next_tool_change_gcode = opinfo(92, lookahead_index)

   while next_tool_change_gcode <> invalid,
        [
        if next_tool_change_gcode = 1002,
            [
            next_tool_change_gcode = invalid
            ]
        else,
            [
            lookahead_index = lookahead_index + 1
            next_tool_change_gcode = opinfo(92, lookahead_index)
            ]
        ]

    s_next_20002 = opinfo(20002, lookahead_index)
    is_valid_arg = (s_next_20002 <> s_invalid)

 

Calling example:

psof$            #Start of file for non-zero tool number
      p_get__s_next_20002(!result)
      if result, "Next 20002->", s_next_20002, e$
  
ptlchg$          #Tool change
      p_get__s_next_20002(!result)
      if result, "Next 20002->", s_next_20002, e$

 

Output Example:

( T1 | 0.5 FLAT ENDMILL | H1 )
( T239 |  1/2 FLAT ENDMILL | H239 )
Next 20002-> Tool code 2
N100 G20
N110 G0 G17 G40 G49 G80 G90
( FINISH OUTER WALLS )
N120 M8
N130 T1 M6

...

N280 G91 G28 Z0.
N290 A0.
Next 20002-> Tool code 1
N300 M01
( CONTOUR 2 )
N310 T239 M6
N320 G0 G90 G17 G56 X-2.8424 Y-.789 A0. S1069 M3
N330 G43 H239 Z.25

...

N570 G91 G28 Z0.
N580 A0.
N590 M01
( MANUAL ENTRY TEXT COMMENT )
( FINISH OUTER WALLS )
N600 M8
N610 T1 M6
N620 G0 G90 G17 G56 X-2.8424 Y-.789 A0. S15000 M3

 

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • 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