Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: dracen knights on April 03, 2016, 08:49:15 PM

Title: Auto tool length with manual tool change
Post by: dracen knights on April 03, 2016, 08:49:15 PM
ok so first off thanks for all the help so far even if I just joined I have been reading and looking through here for a while.

anyway to the point.
I have a Taig cnc mill and I got it with an Auto tool setter or so Deepgroove1 calls it. pretty much from what I have learned it's a 5 way switch. My machine doesn't currently have home switches (next project after I get this figured out. What I'm trying to do is get the machine to auto set the tool length after I do a manual tool change. But the script I came up with seams to give me a compiling error every time. Originally I started with a script I found online to use the auto tool zero button on the mach3 program run tab it worked but it resets Z zero for the work offset rather than setting the tools length in the register. which is not what I wanted and with that macro I had to place the tool setter on the work piece I want to mount it to my table and give it a location Say (g59p200) any way heres where I got the first macro  https://drive.google.com/file/d/0B2hPzRSbcroXSU9veTVwUjhfbjQ/edit (https://drive.google.com/file/d/0B2hPzRSbcroXSU9veTVwUjhfbjQ/edit) so over time I came up with a complete from scratch macro and can't get it to work either. I was giving it it's own Mcode 901 and then I just add it to my normal gcode.

So here's what I'm wanting the macro to do.
     be assigned it's own M code (currently 901)
     Not affect the work offset
     Set the tool length in the register for the requested tool#
     Pause to give time to change the tool (ideal would be a message box where the ok button would allow the macro to move forward)
     Once tool is measured continue with the program without any more input from me.

I'm attaching my own macro in txt document file form. I wrote it on notepad as I read that word and all cause problems.
any help would greatly be appreciated. In the end I want this to work but I would also like to know where I went wrong so I could change it later if I change my setup. I really I really want to add home switches and I have everything Just wanted to use the auto tool setter with everything I make on this mill.



     
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 05, 2016, 09:49:06 AM
If there is already a thread or thread on this please feel free to post links as I have been looking I just might have missed them.
Title: Re: Auto tool length with manual tool change
Post by: ger21 on April 05, 2016, 12:39:44 PM
Use the M6 Start and M6End macros.
M6 start runs when you get to an M6 in the g-code, and at the end of M6 Start, it will stop and wait for you to change tools. After changing tools,, clicking Cycle Start will run M6End. After M6 End finishes, g-code execution will resume.

You need to configure toolchanges in General Config to Stop Spindle, Wait for Cycle Start.
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 05, 2016, 01:22:22 PM
Thank you for the reply.

I already have it set to stop on tool Change. I honestly hadn't thought about edifying the m06 to be the auto tool length measure and set. I guess I think of it for the atc... Lol I guess I could easily switch that and it would save the extra steps but then I still have the error in my Marco somewhere and I just can figure out where or what I'm doing wrong but this is my first macro ever. I just tried looking one up and when I didn't find one that fit my exact needs I tried to edit them and still not right so I started reading and learning all I could and then I wrote the one I uploaded. I'll try a new edit of it tonight when I get home using m06 start and end and see how that goes.
Title: Re: Auto tool length with manual tool change
Post by: ger21 on April 05, 2016, 01:29:59 PM
Your first While IsMoving is missing the Wend.

This line

Code "G00 G31 z" &zmove"F4"

should be

Code "G00 G31 z" & zmove & "F4"

Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 05, 2016, 01:47:54 PM
Once again thanks for the quick reply.

Go figure I looked at that line 100 times and missed that does the rest like it will work to set the tool length?  I'm thinking I not getting something in it correct.  I originally had it so a zero for the g59p200 was at the point where the tool length setter was .001" above the activation point but when I started reading along through other codes I was not sure if the macro would know to start moving where I started it at which was g59p200 x0y0z4... In my case the mill has 6" of travel and later when I get the home switch mounts made I'm hoping to have it go from a home but I don't know how to do the line of code so mach3 would know how to figure tool length.

Maybe I'm wrong but if I had it at z zero or a home and told,it to set tool length to where it touched the tool setter wouldn't that make it think the tool was the length of the z travel down to that point? 

I'm also thinking that would rather have it double touch the tool setter once at a higher feed rate the slower to be more accurate. The first time would be to save the time it takes to go down the say 4 inches before the tool comes close to the setter and at 4ipm that's a full minute extra for no real reason.  Which is why currently I have it at 4 inches above because the first item I'm hoping to really use it on needs to use my drill chuck as the drill bit doesn't fit any of my collets.
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 05, 2016, 02:01:51 PM
I also see where the code posted above I must have edited it once already as I had g58p200x0y0z0 the same as g59p199x0y0z4.

The p199 is where the z0 is at the point where the collet is one step above turning on the digitize led.

I thought that by doing this the z fro reading would then be the correct tool length but I was not sure if the macro would work without the dooembutton(1010) line.

And if I do the m06start and end edit you suggested I could do this in two full macros making it honestly simpler no need for the machmsg. Just position the spindle above the setter and wait until I hit the green button again. I honestly had the machmsg in there so I could turn off the stop on m06 option but I like the idea of doing it with the factory stop on m06 option, because later on I do want to try building a full atc.
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 05, 2016, 08:35:01 PM
ok I'm working on testing now and it looks like I'm missing a setting somewhere because any time I either go in to edit button script or anything if Mach3 moves the machine at all I no longer can do anything without hitting reset. it's like I have it set to lockout all axis controls or something.
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 05, 2016, 08:48:27 PM
now mach is saying the dostopspin() is an error I don't understand why.
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 05, 2016, 09:29:04 PM
ok well it looks like I'm more over my head than I though or something. Nothing seams to be working correctly.I'm going to step away for the rest of the night start again fresh in the morning.
Title: Re: Auto tool length with manual tool change
Post by: ger21 on April 05, 2016, 09:39:05 PM
DoSpinStop()
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 05, 2016, 09:44:15 PM
That's what I had and it said script error and that line# it worked before but not tonight exact line... I just wrote it on here without the capitals sorry got frustrated with it tonight... Been a long day... Had to drive 2.5 hours one way to see a doctor for 15 minutes be told everything's good to drive home...  I'm currently recovering for surgery on both feet... That's why I now have the taig mill and sherline lathe both setup inside the main part of the house I'm calling my office... Lol wife is pushing me to stay off my feet as much as I can.
Title: Re: Auto tool length with manual tool change
Post by: ger21 on April 05, 2016, 10:35:12 PM
No, you had DoStopSpin.
It's DoSpinStop
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 05, 2016, 10:38:31 PM
wow now I feel stupid... like I said it's been a long day... but I toke that line out and still had problems.
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 06, 2016, 11:08:28 PM
ok spending a little time on this tonight and Go figure if you use the DoSpinStop() that code line works great... Thanks again. I think I just spent to much time on it and everything was looking correct even when it was stupid mistakes like that. Thanks again Ger21 for your help on this.

Ok so for today I did make it into 2 different macros one for m6start and one for m6end. Now I started my using the edit macro button and placing the m6start macro in the auto tool zero location making it easy to test. and all I did for it was have it go to the G59p200 x0yoz0  location that worked great...

my m06start macro looks like

Quote
DoSpinStop()
Code "G59P200 X0 Y0 Z0" ' This sets the spindle so you can change the tool
While IsMoving() 'Pauses the code read while machine moves
Wend

Just to get the spindle to a good place to change the tool which is also above the tool setter.

Then I started on the m6end and it looks like the fallowing.
Quote
' This area does not need adjusting
Currentfeed = GetOemDRO(818) ' Gets the current feed rate for return after tool change
CurrentAbsInc = GetOemLed(48) ' Gets current G90/G91 to return it later
CurrentGMode = GetOemDRO(819) ' Gets current G00/G01 to return it later
CurrentTool = GetOeMDRO(824) ' Gets current tool number

' Adjust below to the machine.
' use G59P199 X0 Y0 Z0 at the point where the spindle is just about to trigger the tool setter
' use G59P200 X0 Y0 Z0 at the point you want the Z to travel down from

ZMove = 4.0 'Max allowable Z travel before spindle contacts tool length setter

DoSpinStop()
Code "G59P200 X0 Y0 Z0" ' This sets the spindle so you can change the tool
While IsMoving() 'Pauses the code read while machine moves
Wend

If GetOemLed(825) = 0 Then 'This checks the tool probe before moving forward
Code "G59P200 X0 Y0 Z0"
DoOemButton(1010)
Code "G90 G31 z-" & zmove &"F4" 'Feed rate here for how fast you want z to go down
While IsMoving()
Wend
ZprobePos = GetVar(2002)
Code "G00 Z" &ZprobePos 'place tool at the exact where the tool touched the tool setter
While IsMoving()
Wend
Code "G59P199"
Call SetOemDro(109)'sets the current tool Offset
Sleep 200  'allows time for update
Code "G59P200 X0 Y0 Z0"
While IsMoving()
Wend
Code "This tool's Length is now set"
Code "F" &CurrentFeed
Else
Code "Tool SEtter Error"
End If
If CurrentAbsInc = 0 Then
Code "G91"   
End If
If CurrentGMode = 0 Then
Code "G00"
End If

Still testing because I noticed I had a G00 where I ment G90 seams I missed a lot of little things like that.

Now I have always seen that VB code have capital letters and all do they truly matter for example is dospinstop() the same as DoSpinStop()?
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 06, 2016, 11:35:45 PM
OK well so far so good it's acting right only issue seam to be I don't have something right because it's not setting the tool length.... But"m getting closer... I found a few more places in the above code that I had to change  but I'll edit it to show the current changes.

NM already to long sense I posted it... Here is the current macro

Quote
' This area does not need adjusting
Currentfeed = GetOemDRO(818) ' Gets the current feed rate for return after tool change
CurrentAbsInc = GetOemLed(48) ' Gets current G90/G91 to return it later
CurrentGMode = GetOemDRO(819) ' Gets current G00/G01 to return it later
CurrentTool = GetOeMDRO(824) ' Gets current tool number
GetZDRO = GetOemDRO(180) 'used to set tool length from this DRO reading

' Adjust below to the machine.
' use G59P199 X0 Y0 Z0 at the point where the spindle is just about to trigger the tool setter
' use G59P200 X0 Y0 Z0 at the point you want the Z to travel down from

ZMove = 4.0 'Max allowable Z travel before spindle contacts tool length setter

DoSpinStop()
Code "G59P200 X0 Y0 Z0" ' This sets the spindle so you can change the tool
While IsMoving() 'Pauses the code read while machine moves
Wend

If GetOemLed(825) = 0 Then 'This checks the tool probe before moving forward
Code "G59P200 X0 Y0 Z0"
DoOemButton(1010)
Code "G90 G31 z-" & zmove &"F4" 'Feed rate here for how fast you want z to go down
While IsMoving()
Wend
ZprobePos = GetVar(2002)
Code "G00 Z" &ZprobePos 'place tool at the exact where the tool touched the tool setter
While IsMoving()
Wend
Code "G59P199"
SetOemDro(109,GetZDRO)'sets the current tool Offset
Sleep 200  'allows time for update
Code "G59P200 X0 Y0 Z0"
While IsMoving()
Wend
Code "(This tool's Length is now set)"
Code "F" &CurrentFeed
Else
Code "(Tool Setter Error)"
End If
If CurrentAbsInc = 0 Then
Code "G91"   
End If
If CurrentGMode = 0 Then
Code "G00"
End If    


I believe the issue that I have now is with this line. I'm not sure I'm using the right places as current tool length seams to have oemdro 42 109 and 836

GetZDRO = GetOemDRO(180) 'used to set tool length from this DRO reading
SetOemDro(109,GetZDRO)'sets the current tool Offset

Am I using the correct OemDRO for the tool length anyway?

Title: Re: Auto tool length with manual tool change
Post by: ger21 on April 07, 2016, 08:02:24 AM
Usually, you just change the Z axis DRO to set the tool length, unless you are using G43.
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 07, 2016, 08:54:55 AM
I use g43. I don't want the work offset to change with each tool as that's not to correct way to do it.

For example you start with a. 1" cube and the top is z zero then you go around the a 3/4" circle center drill and drilling hole then the program calls for a tool to take the full exposed area down to a wave shape and the top most piece now .0873.. Well if you finish the part and then flip the part it's supported to match on top only to find out out the holes at .058 to shallow its much easier to simply add that amount into the wear and run the drill portion over again and that doesn't waste the material of having to make another part from stock.  It seams like most people don't use tool legth offset for some reason.  
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 07, 2016, 10:43:36 PM
OK I got the correct OemDRO figured out for to use for the tool legth offset Just not sure where to pull the number from yet...LOL I think what I'm looking for should be in the active work offset Z DRo reading but not sure... any ideas? I think GetOemDRO(802) should get me the number I'm looking for but not sure.
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on April 08, 2016, 05:27:55 PM
wow Just found this thread and I think it might have the last of the info I need in the macro they posted
https://www.machsupport.com/forum/index.php/topic,23124.10.html (https://www.machsupport.com/forum/index.php/topic,23124.10.html)... I'll post and update to mine later tonight when/if I get time to work on it...
Title: Re: Auto tool length with manual tool change
Post by: FelixPQ on May 24, 2016, 06:49:51 AM
Your first While IsMoving is missing the Wend.

This line

Code "G00 G31 z" &zmove"F4"

should be

Code "G00 G31 z" & zmove & "F4"



I'm just curious, above both of you use G00 with this probe move, any particular reason?

Gerry, I know you don't probe exactly the same way, you do the following in most case I've seen from you.

Code "F" & FRate1
Sleep(125)
Code "G31 X" & ProbeLength

Thanks,
Yves
Title: Re: Auto tool length with manual tool change
Post by: FelixPQ on May 24, 2016, 06:59:35 AM
I just saw that the G00 I was wondering about should have been a G90 instead.

Thanks,
Yves
Title: Re: Auto tool length with manual tool change
Post by: FelixPQ on May 24, 2016, 07:50:41 AM
I'm sure I'm not the only one, almost every time I look at others VB code the same problem comes up, those dam DRO numbers, DoButton, DoOEMButton and all other internal variables and or parameters should have been written in plain English in a VB include file as CONST or whatever even if the current version of the scripting language doesn't allow for it (include files). It's like all this is on the dark side of the force, it's a shame and a complete waste of time to search way to often for these numbers and there meaning.  

I want to do my own homing and especially squaring routine because I use Hall sensor and the distance to move off the sensor is to large. I've found C code from Dynomotion that does exactly what I want. One of the first thing it does is to disable the slave mechanism to the master axis. I found after a minimum of 4 hours of search, a post that said to use DoOEMButton(357) and  DoOEMButton(358) and a few hours more to find the meaning of these numbers. The 357 is for Slave ABC off and the 358 is for Slave A on. Your a lucky man if you slaved with the A axis but unfortunate if you used the B or C axis. I found no trace of neither Slave B on or Slave C on numbers and every one knows the functionality is there on the set slave dialog, so where are the numbers for these???

Incredible!
Yves

 
Title: Re: Auto tool length with manual tool change
Post by: Tweakie.CNC on May 24, 2016, 08:28:33 AM
Quote
I found no trace of neither Slave B on or Slave C on numbers and every one knows the functionality is there on the set slave dialog, so where are the numbers for these???

http://www.machsupport.com/forum/index.php/topic,11061.msg69361.html#msg69361

Tweakie.
Title: Re: Auto tool length with manual tool change
Post by: FelixPQ on May 24, 2016, 09:45:15 AM
Tweakie,

sorry, maybe I don't understand something but the only reference to slave axis is this here.
 
Quote
CoupleSlave(bool)  //sets the slave axis to home exactly with the master axis 1 for on, 0 for off

It's not a big deal, I can use the 357 and 358 calls because at this time I use a 4th axis but if ever I do then I'll need to De-slave my B axis and put it back on after I'm done. It would be nice to do this now while I'm working on this.

Thanks,
Yves



Title: Re: Auto tool length with manual tool change
Post by: dracen knights on May 24, 2016, 10:29:29 AM
Wow lots of talking in one day... Honestly I have not touched my cnc in almost a month... I had both my feet worked in surgically just over 6 weeks ago and 6 days ago they redid my elbow for the second (and final) time in 2 years... Simply have not been able to get any time back in the office/ shop area. I did manage to make my home switch mounts and all but my issue now is that some times the machine wants to over run the home switches during a program like mach is not seeing it as a limit switch as well... Mach sure is acting odd. And honestly it's going to take me a few hours to even remember where all I was at in writing the code.
Title: Re: Auto tool length with manual tool change
Post by: RICH on May 24, 2016, 10:36:11 AM
 
Quote
same problem comes up, those dam DRO numbers, DoButton, DoOEMButton and all other internal variables and or parameters should have been written in plain English
There is a listing of most of them, I think you'll find it in Members Doc's. Also use machscreen as you can find where the Dro, Button, etc is. Of course sometimes the script is
used for items created by the user so one needs the same screen to find. Waite until you get duplicated stuff in a screen set and different scripts.

Must admit that sometimes it is not fun, even irritable, but then, this guy is just a novice at it all!

RICH
Title: Re: Auto tool length with manual tool change
Post by: dracen knights on May 24, 2016, 10:39:34 AM
I can't wait to try making screen sets myself. But I felt this auto tool length zero was the most important item on my to do list.
Title: Re: Auto tool length with manual tool change
Post by: FelixPQ on May 24, 2016, 12:09:19 PM
I can't wait to try making screen sets myself. But I felt this auto tool length zero was the most important item on my to do list.
Quote
same problem comes up, those dam DRO numbers, DoButton, DoOEMButton and all other internal variables and or parameters should have been written in plain English
There is a listing of most of them, I think you'll find it in Members Doc's. Also use machscreen as you can find where the Dro, Button, etc is. Of course sometimes the script is
used for items created by the user so one needs the same screen to find. Waite until you get duplicated stuff in a screen set and different scripts.

Must admit that sometimes it is not fun, even irritable, but then, this guy is just a novice at it all!

RICH

Rich,

I appreciate a lot the effort members have made to figure out all these numbers for DRO's Buttons and the works that I've found so far. Without the users efforts, well I'm not sure this forum would still exist... The way I see this, it's plain documentation work that should have been done at the company's level not by the users.

My two cents,
Yves