Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: Greg F. on April 02, 2019, 02:14:01 PM

Title: Re: Auto tool zero...manual tool change
Post by: Greg F. on April 02, 2019, 02:14:01 PM
Like to know if someone can help me to make a script to do manual tool change I never programmed before..or show me a script I can use..
Title: Re: Auto tool zero...manual tool change
Post by: joeaverage on April 02, 2019, 02:21:01 PM
Hi,
there are various examples of toolchanger scripts in:

Mach4Hobby/LuaExamples/Toolchanger

Craig
Title: Re: Auto tool zero...manual tool change
Post by: bryannab on April 02, 2019, 04:50:36 PM
Greg,

Check out the support video below for a versatile auto tool zero script that gives you the option to jog into place or enter in coordinates if you have a fixed touch plate.

https://youtu.be/6-4JkDv9AgM

-Bryanna
Title: Re: Re: Auto tool zero...manual tool change
Post by: MN300 on April 02, 2019, 06:05:20 PM
DazTheGas has also published a tool change script.
Video         https://www.youtube.com/watch?v=m1eMEec0N-E (https://www.youtube.com/watch?v=m1eMEec0N-E)
Script text  http://www.machsupport.com/forum/index.php?topic=31032.0;wap2 (http://www.machsupport.com/forum/index.php?topic=31032.0;wap2)

A difference is that DazTheGas uses the tool length stored in mc.MTOOL_MILL_HEIGHT to pre-position the new tool to minimize probing time.
The Artsoft video stores the Z coordinate from probing in that variable. It's not referenced elsewhere in the script so it's not obvious why.

DazTheGas detects if a zero length is in the tool table with 'if toollen == 0'.
However this can fail because a tiny, but not quite zero, value floating point value is sometimes returned for a zero tool length.
Changing to 'if toollen < 0.01' fixes that problem.

The Tool Change LED flashes when M6 is called but the LED is not addressed in the script. I'm curious about what piece of code does that. Is it accessible and are there other hidden functions?
Title: Re: Auto tool zero...manual tool change
Post by: Overloaded on April 02, 2019, 06:42:19 PM
Greg,

Check out the support video below for a versatile auto tool zero script that gives you the option to jog into place or enter in coordinates if you have a fixed touch plate.

https://youtu.be/6-4JkDv9AgM

-Bryanna

Very nice production ! I liked it. Well done.
I copied the macro below the video and pasted it in the cleared M6 .mcs and it was all on 1 line.
I figured out where to break/return but should I have had to do that ?
Can it be pasted as it needs to be in its final form ?
Thanks
Title: Re: Re: Auto tool zero...manual tool change
Post by: Greg F. on April 02, 2019, 07:36:35 PM
Thanks everyone....
Title: Re: Auto tool zero...manual tool change
Post by: bryannab on April 03, 2019, 08:07:41 AM
I figured out where to break/return but should I have had to do that ?
Can it be pasted as it needs to be in its final form ?
Thanks

Overloaded,

I copied and pasted the script into a Notepad file (regular old Notepad) and it was a jumbled mess. I made no changes, opened up Mach4, went to Edit/Debug scripts, and pasted it into a copy of m6.mcs, and the formatting was exactly as it should be. I am use a development version (4134) but I have made no changes to any of the ZeroBrane settings. I'm not sure why you had to fix the formatting on your end. I'm working on collecting a few more sample scripts for Lua (and making videos on one or more of them) and getting the whole collection in a more accessible place. The FTP server is an option, but the copy/paste scenario is a potential nuisance there as well. Once I have something set up, I'll post about it here on the forum so everyone can start utilizing it.

-B
Title: Re: Re: Auto tool zero...manual tool change
Post by: Overloaded on April 03, 2019, 09:12:29 AM
Thanks -B, :)
First, pasted to word pad, then note pad, word wrap (jumbled mess), then to the editor ....and directly into the editor.. it ends up all on one line in the editor.
4.2.0.3804
I can work with it.
Thanks again,
Russ
Title: Re: Re: Auto tool zero...manual tool change
Post by: Greg F. on April 03, 2019, 08:14:33 PM
-Bryanna I install your auto tool zero script and is working like it should
I find when it goes to probe it goes down to slow how can I make it go down just a little faster...thank you
Title: Re: Re: Auto tool zero...manual tool change
Post by: MN300 on April 03, 2019, 09:34:35 PM
The DazTheGas script uses the tool length from the tool table to pre-position the tool for faster probing. You could borrow from that part of his code to speed things up. His method determines the difference between the next and current tool and adjusts the Z accordingly. The one from Bryanna assumes you started with the first tool zeroed to your touch plate and does the same with the next tools. It shouldn't be to hard to take the best of both.
Title: Re: Re: Auto tool zero...manual tool change
Post by: Greg F. on April 03, 2019, 09:39:04 PM
I'm new to this programming..little help how would i do that...
Title: Re: Re: Auto tool zero...manual tool change
Post by: MN300 on April 03, 2019, 09:45:32 PM
There are 4 parts to the DazTheGas videos. He show hows each function works as he builds up the script. It's also a good education on how to do Lua script. If it's more than you want to do right now I'll look into what to borrow.
Title: Re: Re: Auto tool zero...manual tool change
Post by: Greg F. on April 03, 2019, 09:58:49 PM
I will take a look at DTZ videos..hoping I can get it right...
Title: Re: Auto tool zero...manual tool change
Post by: MN300 on April 04, 2019, 05:48:45 AM
I have been thinking about safety. The script supplied by Bryanna is slow but safe. The auto script lines move the Z axis up clear the tallest workpiece. In most cases there will then be a lot of clearance to be traveled while probing.

The DazTheGas script is faster because it estimates the extra clearance and travels it at high speed, but it could crash the tool into the touch pad if the tool table length entry is too short.

A compromise would be to start the probing by assuming the longest tool length and making a rapid move to put the tip of that tool some small safety margin away from the pad. Then do the slow probing move to the pad. Shorter tools still will have some extra distance to travel.
The distance to travel at high speed could be calculated by mounting the longest tool and setting Z to 0. The existing script sets Z to 0 before showing the message  'Now in Tool Change Position. Hit Cycle Start!'
Measure the distance to the touch pad and then subtract the desired safety margin.

Add the new line between existing lines as shown below.
        mc.mcCntlSetLastError(inst, "Probing in Progress!")
        mc.mcCntlGcodeExecuteWait(inst, " G91 Z-xx.x") -- xx.x = distance from the pad to the longest tool minus a safety margin
        mc.mcCntlGcodeExecuteWait(inst, " G91 G31 Z-5. F5.")--probe the new tool
Title: Re: Re: Auto tool zero...manual tool change
Post by: Greg F. on April 04, 2019, 07:28:54 AM
Ok I'll try that..thanks
Title: Re: Re: Auto tool zero...manual tool change
Post by: Greg F. on April 04, 2019, 07:55:14 PM
The G91 Z-××.x") --xx.x=
Is the x spouse to mean something...
Title: Re: Re: Auto tool zero...manual tool change
Post by: MN300 on April 04, 2019, 08:19:43 PM
xx.x shows where you enter the distance you want to the tool to travel before the probe command.
If it's 80mm from the longest tool to the pad after you set Z to zero and you want a safety margin of 2.5mm you would replace the x.xx with 77.5

mc.mcCntlGcodeExecuteWait(inst, " G91 Z-77.5")
Title: Re: Re: Auto tool zero...manual tool change
Post by: Greg F. on April 04, 2019, 08:37:31 PM
Oh ok thanks ..I'll try it again..
Title: Re: Re: Auto tool zero...manual tool change
Post by: Azalin on April 06, 2022, 06:25:12 AM
Hi,
there are various examples of toolchanger scripts in:

Mach4Hobby/LuaExamples/Toolchanger

Craig

Looks like this file/folder is removed from recent versions.