Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: TTalma on January 28, 2019, 11:34:02 AM

Title: My LUA Tool changer script Needs to run twice to change tool number, How to fix?
Post by: TTalma on January 28, 2019, 11:34:02 AM
I worked on a LUA tool change script this weekend. It is working great except that the script needs to run twice for the Current tool number to be updated.

What happens is on power up. Tool 1 is loaded by default, and I command T4 M6, (or M6 T4), The machine changes to tool 4. Then if I command T2 M6. The message pops up that tool 4 is already loaded. But if command T2 M6 again, the machine changes to tool 2. And this continues for each tool change command.

It is mostly a copy from the LUA programming script tool change function. I've attached my code. I can't see where this is going wrong. Does anybody have any idea? (Had to add TT to the file name to get it to upload)
Title: Re: My LUA Tool changer script Needs to run twice to change tool number, How to fix?
Post by: joeaverage on January 28, 2019, 12:39:10 PM
Hi,
sounds like your Mach setup has the wrong toolchange mode selected.

There are two modes.

The first, and most logical to you and I, is where M6 T4 say would cause the tool to be changed to T4 then resume machining.

The second mode, which is common on production machines, is where M6 T4 and tool 4 is prepared in the toolchanger
for the NEXT toolchange. Having the tool carousel pre positioned is faster.

The setting for the toolchange mode is on Configure/Control/Tools page.

Craig
Title: Re: My LUA Tool changer script Needs to run twice to change tool number, How to fix?
Post by: Cbyrdtopper on January 28, 2019, 12:40:40 PM
HAHA Craig,
I was posting this exact reply, then it wouldn't post because a new post had been made.  Nice!
Great Explanation of the differences as well!!
Title: Re: My LUA Tool changer script Needs to run twice to change tool number, How to fix?
Post by: TTalma on January 28, 2019, 06:16:07 PM
Thanks! This was it exactly!. I never would have found that. :D