Recommended Posts

Hi guys,

We are using a 4 digit tool number in our tool library that works great for the Makino mills we have.  We are trying to standardize this process over to some Hurcos.  The Makinos use H1 D1 for offsets because we use the tool management.  The limitation on the Hurcos is that they only have 199 registers for diameter offsets, and apparently the restisters cannot be re-numbered.  So regardless of the tool number, the diameter offset needs to use 1-199.   I have a buffer that extracts tool numbers from the pwrtt$ postblock.

This is what the tool table looks like at the beginning of the program:

( T3293 ( GARR VRX - 27763 0.5 Bull-Nosed Endmill ))
( T3299 ( GARR VRX - 61374 0.5 Flat Endmill ))
( T5200 ( HARVEY - 68062-C3 0.0625 Roundover Tool ))
( T5415 ( INTERNAL TOOL - 64-2880-C 0.375 Chamfer Mill ))
( T5806 ( HARVEY - 43362-C3 0.375 Slotting Tool or Saw ))

Here is a sample array:

0. 3293. 1.
0. 3299. 2.
0. 5200. 3.
0. 5415. 4.
0. 5806. 5.

The second column represents the tool number, the third represents the initial order in which the tools run.  The problem is that sometimes tools repeat after others have already run.  How can I look up the second column and match it to the third so that any time T5200 comes up in the program, it will always use offset 3?

Thanks in advance

Share this post


Link to post
Share on other sites

Are you trying to uniquify the buffer?

Side note, I'd consider using a stack for this.  Buffers are limited, and only really make sense if you need to read or write to disk.

Share this post


Link to post
Share on other sites

Actually, I'm trying to mimic the "INDEX / MATCH" that I would use if this was an Excel file.  Essentially, I want to use the position of the tool number in the tooltable as the diameter offset, so that if the tool number is say T3407 and it is on the 13th row in the tooltable then T3407 would use D13.  The data exists in my array, I just can't seem to access it.  I have never used a "stack" in MP.  This may seem like a crazy way to do it, but the mills are limited to 1-199 for offset registers.

Share this post


Link to post
Share on other sites

There may be a way to do this by combining a Buffer File and a Lookup Table. I'd use the Buffer to keep track of the "order" that each tool is called in.

To make it easier to control, I'd suggest setting 'buf_no_index$ = yes$' (Or 'buf_no_index$ = 1'). Turning off the "Automatic incrementing" of the loop counter variable (index), allows you full control over the value.

Each time you write to the Buffer, you would set the 'Index variable = tool number'. Every time you "write" to the buffer (the record = tool number), you're simply recording a single value in that row/record. That value would be the "index number of the tool".

Depending on your coding skills, it may just complicate the matter, but I would suggest creating a 'Lookup Table' in your Post. We use Lookup Tables to do many things (Gear Ranges, Coolant Codes, Etc.), but in this case we are just checking to see if "a tool has been used, or not used".

The Lookup Table Command to use with Tool Lists, is 'finc'. The 'finc' command will increment the 2nd column, based on the value in the 1st column.

In your case, the Lookup Table is just a long list, with 10,000 entries. It is a pain to build columns of sequential values, so I do this in Excel, and just copy/paste the values into the Post.

In a nutshell:

  • Build a Lookup Table, with 9,999 entries (1-9999)
  • Create a 'Tool Change Index Variable', to keep track of the Number of "Actual" Tool Changes.
  • we'd use the Lookup Table to determine "has my tool been used previously, or is this the 1st time the tool is being used"?
  • If this is a "new tool", we would increment our "Tool Counter Variable" and use this Counter as the Index to the Buffer.
  • The 'Index' value is the sequential order of H/D Offset Registers. Each 'Index' value is equal to the row/record that we are writing too.
  • If this is a "used tool", then we use a separate 'loop counter variable' to loop through the buffer, starting at Record/Row 1. We read the buffer at each Row, and compare the 'stored tool number' to the 'current tool number'. If the values match, then we know which H/D Index (row) is used for an existing (previously used) tool.
  • The 'lookup table' is not absolutely necessary. We could certainly build logic to "loop through" the entire buffer, to check for a previously used tool. I just like 'Lookup Tables and the 'finc' function.
  • You must be careful when "looping" through a buffer, to be sure that your 'condition' eventually evaluates to 'false', so we can exit the loop. If the condition never equates to 'false', you can get trapped in a endless loop.

Share this post


Link to post
Share on other sites

So I could be way off in the weeds here, but it sounds like you want to use the index position of the tool in the buffer as the diameter offset.  Assuming that your buffer / tool list is non-repeating the below should work.

First, I set up pwrtt$ so that a tool will only be added to the stack once no matter how many times it appears in the program.  I much prefer then enhanced tool table for this, but since you mentioned pwrtt$...  

pwrtt$
	if (t$ > 0) & (gcode$ <> 1003),
		[
		p_add_to_tool_stack
		]

Next, I defined the stack and associated variables.

stack_101_size        : 0
stack_101_index       : 0
stack_101_result      : 0

stack_101_tool_number : 0

fstack 101 1

Then I created a utility postblock to add the tool to the stack 

p_add_to_tool_stack
	t$ = push(101, stack_101_result, 1)

The below postblock will iterate through the stack looking for a matching tool number to the one passed in.  If a match is found, it's index is set to diameter_offset and passed back by reference.  If no match is found -99999 is passed back  

tool_number : 0
diameter_offset : 0

p_get_diameter_offset(tool_number, !diameter_offset)	
	stack_101_index = 1

	stack_101_size = pop(101, stack_101_result, 0)
	while stack_101_index <= stack_101_size,
		[
		stack_101_tool_number = pop(101, stack_101_index, 5)
		if tool_number = stack_101_tool_number,
			[
			diameter_offset = stack_101_index
			stack_101_size = -99999
			]
		else, diameter_offset = -99999

		stack_101_index = stack_101_index + 1
		]

To use this, at tool change (be it start-of-file, real, or null) do something like this

psof$
ptlchg$
ptlchg0$
      p_get_diameter_offset(t$, !result)

That's it.  If t$ exists in the list, it's index will be returned to result in this case.

I hope that helps, but if not I'm sure someone more knowledgeable than I will step in.

  

  • Like 1

Share this post


Link to post
Share on other sites

@Zaffin_D Excellent work. I am interested to see how you would do it with the enhanced tool table if you don't mind sharing it. 

Share this post


Link to post
Share on other sites
3 hours ago, crazy^millman said:

@Zaffin_D Excellent work. I am interested to see how you would do it with the enhanced tool table if you don't mind sharing it. 

Not much would change in this example; this...

pwrtt$
    if (t$ > 0) & (gcode$ <> 1003),
        [
        p_add_to_tool_stack
        ]

...would change to this...

ptooltable$ 
    if tt_count$ = 1,
        [
        p_add_to_tool_stack
        ]

 

  • Like 1

Share this post


Link to post
Share on other sites
17 minutes ago, Zaffin_D said:

Not much would change in this example; this...

pwrtt$
    if (t$ > 0) & (gcode$ <> 1003),
        [
        p_add_to_tool_stack
        ]

...would change to this...

ptooltable$ 
    if tt_count$ = 1,
        [
        p_add_to_tool_stack
        ]

 

Thank you. 

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