Machsupport Forum
Mach Discussion => General Mach Discussion => Topic started by: faby on July 29, 2006, 11:39:42 AM
-
Hi there,
I'm new in mach3 world, I need a toolchanger macro, but i don't know how to write it.
I made a video that shows how my actual software do that, there's anyone who can make a thinks like that?
You can see the video at this address:
www.fxmodel.it/tool.mp4
or
www.fxmodel.it/tool.mov
In the video you can see the machine stop in the "tool change position", when i ask to change the tool, it goes over the probe and go down slowly, when it press the microswith stops and go back until it release.
Now it come back to the "tool change position" and wait until i change the tool, then it measure the new tool.
I'll be grateful to anyone can help me.
Ehm... sorry for my english, I'm italian :P
Bye Fabiano
-
This is no problem..
This is how I would do it:
Xpos = GetDRO(0) 'Get the X and Y position
Ypos = GetDRO(1)
Code "G53 G00 Z-.1" 'Move the tool all the way up
Code "G53 G00 X3.5 Y6.00" 'Move to the probe position
While IsMoving()
Wend
Zpos = GetDRO(2)'Get the Zpos
Code "G31 Z" & Zpos - 5 & " F30" 'Probe down 5 Units
While IsMoving()
Wend
Zpos = GetVar(2002) 'Get the Position that the Porbe hit at
Code "G00 Z" & Zpos' Move to the point where the probe hit
While Ismoving()
Wend
Call SetDRO(2,0.000) 'Set the Z to 0.00
Code"G53 G00 Z-.1" 'Pick the tool up to the home switch
Code"G00 X" & Xpos & "Y" & Ypos 'Move to the point where the tool change started
-
Well, I try it but... is not exactly what I'm looking for.
I write thins one... ::)
ChX = GetUserDRO( 1200 )
ChY = GetUserDRO( 1201 )
ChZ = GetUserDRO( 1202 )
Code "G53 G00 Z-0.1" 'Move the tool all the way up
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position
While IsMoving()
Wend
Code "G31 Z-230 F450" 'Z move down until hit
While IsMoving()
Wend
ZposOld = GetVar(2002) 'Get the Position that the Probe hit at
Code "G53 G00 Z-0.1"'Z move all way up
Code "G53 G00 X65 Y-200" 'Move to change tool position
While IsMoving()
Wend
MsgBox ("Insert the new tool")
Code "G53 G00 Z-0.1" 'Move the tool all the way up
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position
While IsMoving()
Wend
Code "G31 Z-230 F450" 'Z move down until hit
While IsMoving()
Wend
ZposNew = GetVar(2002) 'Get the Position that the Probe hit at
Offs = ZposOld - ZopsNew 'Make the difference with the old and new tool
Code "G53 G00 Z0.1"
Now i have the length difference between the old tool and new tool.
Is it possible to set the Z zero position as "machine coords"?
So i can get the old z pos as machine coords and correct it with the new one, without go on zpos with the machine...
:-\ I don't know if you understand... :P
There's a DRO or system var (getvar(2002) ex) list?
Fabiano
-
I set the axis to zero with this
Call SetDRO(2,0.00) ' This will set the Z axis to zero
Do you need it to do more then that?
-
sorry i don't understand,
maybe because i'm a beginner.
Zpos = GetVar(2002) 'Get the Position that the Porbe hit at
it's ok, but after this it stay there on the probe
Code "G00 Z" & Zpos' Move to the point where the probe hit
if Zops=-5 (for exaple) it result that g00 z-5 then the machine stay there...
Call SetDRO(2,0.000) 'Set the Z to 0.00
so I set the zero point on the probe and not where it was before tool change...
there's a way to indicate the z zero position as machine cood? if it's possible I solved the problem
-
nope, I got the point where the probe hit THEN moved back to that point THEN call that Zero:
Zpos = GetVar(2002) 'Get the Position that the Porbe hit at
Code "G00 Z" & Zpos' Move to the point where the probe hit
While Ismoving()
Wend
Call SetDRO(2,0.000) 'Set the Z to 0.00
Hope this helps :)
-
I tryed it.... uhm sorry but it do exactly what I said.
the purpose of this macro is to change the tool and measure it for keep the zero point in the same plase as bofore the change...
I haven't a mobile probe to put on material
Pleeeeease, be patient with me, I don't do intentionally ;D
I tryed this one, is the same as the old one except for the last 4 lines
ChX = GetUserDRO( 1200 )
ChY = GetUserDRO( 1201 )
ChZ = GetUserDRO( 1202 )
Code "G53 G00 Z-0.1" 'Move the tool all the way up
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position
While IsMoving()
Wend
Code "G31 Z-230 F450" 'Z move down untill hit
While IsMoving()
Wend
ZposOld = GetVar(2002) 'Get the Position that the Porbe hit at
Code "G53 G00 Z-0.1"'Z move all way up
Code "G53 G00 X65 Y-200" 'Move to change tool position
While IsMoving()
Wend
MsgBox ("Insert the new tool")
Code "G53 G00 Z-0.1" 'Move the tool all the way up
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position
While IsMoving()
Wend
Code "G31 Z-230 F450" 'Z move down untill hit
While IsMoving()
Wend
ZposNew = GetVar(2002) 'Get the Position that the Porbe hit at
Offs = ZposOld - ZposNew
ZNew = 0
ZNew = ZNew - Offs
Code "G53 G00 Z0.1"
Code "G00 x0 y0"
Code "g00 z" & ZNew
Call setdro (2,0.000)
This one work fine, but...
I don't like the fact that It has to go physically to the new zero to set it.
what do you think of my macro?
There a list of all DRO and system variables?
-
Hi. I have not done any scripting in Mach, but it looks much like VB code, which I am familiar with.
Brian- can you set a DRO to a value that is in a variable?
Instead of this:
Offs = ZposOld - ZposNew
ZNew = 0
ZNew = ZNew - Offs
Code "G53 G00 Z0.1"
Code "G00 x0 y0"
Code "g00 z" & ZNew
Call setdro (2,0.000)
Can you do this?
Offs = ZposOld - ZposNew
Call setdro (2,&Offs) 'Set the value of the DRO to the value that is in "Offs"
Code "G53 G00 Z0.1" 'or hoever high you want to go to get up safely off the probe
Code "G00 x0 y0"
This would get around having to goto the zero to set it, correct?
-
That will work GREAT! and is just what I was going to tell him ;D
the macro looks nice and if it works for you it is GREAT!!
Looking good
Brian
-
Yeeeesss it works!!! ;D
It's exactly what I want... I'll post it asap.
There's a list of all DRO? where I can find it?
Thanks Fabiano
-
Here you are:
http://www.machsupport.com/MachCustomizeWiki/index.php?title=OEM_DROs
This is the Wiki and I would love to see you put your probe macro into the Wiki :)
-
Hello Fabiano,
I sent you a PM but I don't know if you saw it. Could you please post a copy of your tool change macro ? It would definitely help me a lot as I have absolutely no experience in VB script.
Thanks
Jean-Louis
-
Could you please post more about what you would like?
Thank you
Brian
-
Hi Brian,
Sorry I may have used wrong terms. What I actually would like to get is a tool probe macro as described by Fabiano (tool change position --> tool measurement --> tool change position --> new tool measurement).
I'm trying to understand the macro's listed above nevertheless, as I'm a real dummy in scripting, I wanted to get the final macro that Fabiano successfully used as a valid basis to make test on my machine.
Thanks
Jean-Louis
-
I hope he will be nice and post the Code :)
-
Yes, I hope too ;)
-
Here I am...
I was on holiday, I read the new posts only now.
I'll send the code as soon as possible, I keep it on another Pc.
Faby
-
Here it is, my macro:
ChX = GetUserDRO( 1200 )
ChY = GetUserDRO( 1201 )
ChZ = GetUserDRO( 1202 )
Code "G53 G00 Z-1" 'Move the tool all the way up
While IsMoving()
Wend
ZOld = Getdro(2)
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position
While IsMoving()
Wend
Code "G31 Z-230 F450" 'Z move down untill hit
While IsMoving()
Wend
HitOld = GetVar(2002) 'Get the Position that the Porbe hit at
Code "G53 G00 Z-1"'Z move all way up
Code "G53 G00 X65 Y-200" 'Move to change tool position
While IsMoving()
Wend
MsgBox ("Insert the new tool")
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position
While IsMoving()
Wend
Code "G31 Z-230 F450" 'Z move down untill hit
While IsMoving()
Wend
HitNew = GetVar(2002) 'Get the Position that the Porbe hit at
Diff = HitOld - HitNew
DiffABS =Abs(Diff)
If DiffABS=0 Then End
ZNew=0
If HitOld < HitNew Then ZNew = ZOld - DiffABS :A=1
If HitOld > HitNew Then ZNew = ZOld + DiffABS :A=2
Code "G53 G00 Z-1"
While IsMoving()
Wend
Call setdro(2,ZNew)
'FxModel Creation
End
You have to set in mach3 the position of the tool switch
It's not perfect yet, when I change the tool it remain out of 0.5/1mm but i think it's a switch problem.
I'll try to get 3-4 measure value, for the same tool and then keep the average value.
I'll be in vacation for another week so if I won't answer you know why ;D
Bye Faby
FxModel Team
-
Thank you for posting it :D
-
Thanks Faby and enjoy your holidays ;D
-
Hi everybody,
First I just wanted to let you know that the macro Faby wrote works perfectly for my machine. Thanks ;)
However I have a strange behaviour of the motors. All the axis have a lot of interruptions when moving during the macro execution while their movements are very fluid when I simply run a GCode.
Does a macro execution require more ressources from the computer (the one I use is not very powerful : only 300 MHz however it has always been sufficient until now) or did I miss something (the macro has been saved as "M6Start.m1s" in the "Mach3/macros/mach3mill" directory) ?
Thanks for your help.
Jean-Louis
-
I write this new version, but I have still a problem.
There's an error measuring the tool, from 0.15 to 0.5mm out, this is not due to the switch because when the tool hit it the measured value is always the same.
there's something that i don't know?
well, this is the new version.
ChX = GetUserDRO( 1200 )
ChY = GetUserDRO( 1201 )
ChZ = GetUserDRO( 1202 )
Code "G53 G00 Z-1" 'Move the tool all the way up
While IsMoving()
Wend
ZOld = Getdro(2)
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position
While IsMoving()
Wend
Code "G31 Z-230 F600" 'Z move down untill hit
While IsMoving()
Wend
Code "G91 G00 Z5"
Code "G31 Z-10 F60"
While IsMoving()
Wend
HitOldA = GetVar(2002) 'Get the Position that the Porbe hit at
Code "G91 G00 Z5"
Code "G31 Z-10 F60"
While IsMoving()
Wend
HitOldB = GetVar(2002)
Code "G91 G00 Z5"
Code "G31 Z-10 F60"
While IsMoving()
Wend
HitOldC = GetVar(2002)
HitOld = (HitOldA + HitOldB + HitOldC)/3
Code "G90"
Code "G53 G00 Z-1"'Z move all way up
Code "G53 G00 X65 Y-200" 'Move to change tool position
While IsMoving()
Wend
MsgBox ("Insert the new tool")
Code "G53 G00 X" & ChX & "Y" & ChY 'Move to the probe position
While IsMoving()
Wend
Code "G31 Z-230 F600" 'Z move down untill hit
While IsMoving()
Wend
Code "G91 G00 Z5"
Code "G31 Z-10 F60"
While IsMoving()
Wend
HitNewA = GetVar(2002) 'Get the Position that the Porbe hit at
Code "G91 G00 Z5"
Code "G31 Z-10 F60"
While IsMoving()
Wend
HitNewB = GetVar(2002)
Code "G91 G00 Z5"
Code "G31 Z-10 F60"
While IsMoving()
Wend
HitNewC = GetVar(2002)
HitNew = (HitNewA + HitNewB + HitNewC)/3
Diff = HitOld - HitNew
DiffABS =Abs(Diff)
If DiffABS=0 Then End
ZNew=0
If HitOld < HitNew Then ZNew = ZOld - DiffABS
If HitOld > HitNew Then ZNew = ZOld + DiffABS
Code "G90"
Code "G53 G00 Z-1"
While IsMoving()
Wend
Call setdro(2,ZNew)
'FxModel Creation
End
Bye
-
I tried whit my usual software, and the tool measure works perfect...the machine is the same...
Brian have you some suggestions?
It is always out of 0.1 to 0.8/1 mm... and it's too much, but I can't understand why...
-
HitOldA = GetVar(2002) 'Get the Position that the Porbe hit at
Code"G4 P.1" ',<------ add dwell here to be sure that Get VAr has time to work and add is moving
While IsMoving()
Wend
Code "G91 G00 Z5"
Code "G31 Z-10 F60"
While IsMoving()
Wend
Is that any help?
-
I'll try, I thought about it but I didn't know how to add a delay... :P
Thanks
-
No way... it doesn't work... I'm unlucky :'(
-
I don't know if this could be the problem... but try to code this with ABS programing. I never use Inc programing in a macro... Other then that I am at a loss and will have to set it up on my mill to test it..
Thanks
Brian
-
You mean when I use "G91 G00 Z5"?
I don't think that it's a problem because in previous version I didn't use it and the problem was the same.
Asked to Popeye if on his machine it works correctly, I'm waiting for an aswer.
Maybe my pc??
-
Hello Fabiano,
At the moment, the mechanical installation of the switch on the mill is not finalized therefore I didn't do any accuracy test.
I can't make further investigation during the week (I'm not where the mill is) but this week end I will try to make a preliminary installation of the switch and then make some tests. I'll post the results on the forum.
I hope that the movement interruption problem that I have described in my previous post will not affect the results (any clue about it Brian ?).
Jean-Louis
-
when I execute the macro step by step it works fine... than Brian says right, I have to put a "G04" code but... I have to find where... ;D
I'm working on it :P
-
The is moving() is a very hard one to get to work right.. there are somany things that need to be updated in mach3 ass it is running that .1 sec just gives the program soen time to finish... I need to set up a probe and test...
-
Hi,
Ive measured the "reaction - time" of Mach3 with a Logicanalyser.
Here is the picture with the G31 movement. You see a delay of about 20ms between
switch trigger and movement stop of Mach3 (1,13GHz, 45kHz pulse, 500 debounce).
This time is nearly contant at homing, limit switch trigger and must be calculated for precision
measurement or probing. Only the emergency stop is a bit faster (10ms).
500mm/min/ 60 * 0,02s = 0,16mm error movement after trigger....
So, if you decrease your speed, your precision will be better.
Im making a macro with two speeds, first move very fast on the probe, then move back (1-2mm) and then a second, very slow move on the probe.
That will increase the precision into um range.. ;D
regards,
Wolfram
www.cnc-steuerung.com
-
Im making a macro with two speeds, first move very fast on the probe, then move back (1-2mm) and then a second, very slow move on the probe.
My macro do this yet...
Code "G31 Z-230 F600"
While IsMoving()
Wend
Code "G91 G00 Z2"
Code "G31 Z-10 F60"
While IsMoving()
Wend
HitOld = GetVar(2002)
It works fine, but only when I run step by step...
I'm working on it
-
If the error or deviance is always the same, cant you just add or substract that value to the offset?
Regards
Fernando
-
ehehe unfortunately is not olways the same... :-\
It need only a dewl in the right place, but now I have no time to try... ;D
-
Hi,
I tried to make some accuracy tests, but it was unfortunately impossible due to this jerked operation when executing the tool change macro.
I'll open a new topic about it not to pollute this one with my macro execution problem.
Jean-Louis
-
Well I think I have found the problem that may be making the macro not pause... There is a new version that will be coming out D1.90.081 please try your macro with that after it is out :)
-
Sorry this version doesn't work at all on my pc...
Well I hope it's a pc problem.
It loose a lot of steps during the execution of a G01 path but not in the circle (G02).
Sorry I can't try
-
Do you have another PC that you can try?
-
I'm searching... ;D
-
Hi to all,
I like to ask if I have a custom screen that was built by the company that made My machine ,how can I set up a dro to take one of the macro to run the tool change switch? Thank You for Your help,Marco.
-
Hi Faby,
Code "G31 Z-230 F600"
While IsMoving()
Wend
Code "G91 G00 Z2"
Code "G31 Z-10 F60"
While IsMoving()
Wend
HitOld = GetVar(2002)
It works fine, but only when I run step by step...
Ok, I think you must wait after movement G91 G00 Z2:
Code " G91 G00 Z2"
While IsMoving()
Wend
Code " G31 Z-10 F60"
While IsMoving()
Wend.
Thats the reason because it does work step by step.
But be careful!!
Th G91 command sets the mode to G91 ... (really logic, ;) )
If your mode at the beginning of your measure macro was G90,
your macro returns with G91! Your crash will be shure..
So read the G9x-Status (from LED) first in your macro and restore it
after measurement...
@ REM300WM:
You cannot connect a macro with DROs only with buttons.
So you must place a button with VB-Script function on your screen and
have to place your code there...
Greetings from Germany,
Wolfram
-
Thank You for Your help, Wolfram ,
Marco.
-
Thank You Fernando for Your help With My screen problem,it is solved now,Marco.
-
Hello to all,
I loaded the tool change macro and when I run the macro alone it works good but when I put it in Mach3 and try to have a tool change nothing happens the file just runs but it doesn't stop for the tool change.Any ideas why this happens? Who exactly puts the command to do the tool change?
Thank You for the help,Marco.
-
Check in the general configs and see that you Don't have "Ignore ToolChange" checked
-
Hello Brian,
Yes, the auto Tool Change is checked.
Thank You for the help,Marco.
-
Did that Fix it?
-
Hello Brian,
No, try to run 2 more files and Mach did not stop for the tool changes.
Thank You,Marco.
-
Please post your XML and I will see what I can find
Thanks
Brian
-
Hello Brian,
I will like to ask if You got a chance to look at the XML that I send?
Thank You Marco.
-
Hello Marco
Could you please resend the XML and tell me what the problem is?
Thanks
Brian
-
Hello to Brian,
I send the XML a while ago and was wandering if You had a chance to look it up?
Also I try to run a tool measure macro and got the one from Faby (hope is not mad) and put it in the macros,Mach3 profile, but when I try to run it with a cut file Mach just stops for a couple of seconds and goes to cut the next process.it does not do the tool change. I check the set up in Mach and looks good,the auto tool button is check. Any ideas?
Thank You,Marco.
-
I didn't get it :( Could you please post it here on the forum?
Thanks
Brian
-
Hello Brian,
Here is the XML,
Thank You,Marco.
-
I tested your XML and it is working good here... Could you please post the toochange macro that you are trying to run? Also please update to the latest Rev of mach3 :)
Thanks
Brian
-
Hello Brian,
Well i just got to update to the last version of Mach and the tool macro is posted in the first page of the topic Tool Measure Macro started by Faby.it's the last version of that macro.Thank You Marco.
-
Fabiano,
Did you succeed to make macro working OK? I mean accuracy? If yes, could you, please, pot it here. I would like to try it.
Thank you,
Zoltan
-
I have to try some changes and then I let you know if it works...
I have no time at all... so I never work on it.
Fabiano
-
On the measured value error, if you come at the switch at the same feedrate each time, wouldn't it be consistent enough that if you included a 'Switch Error' DRO or hard code that error in the macro so that it could then be subtracted from the new position.
I use a Z zero touch off plate that measures 0.3125" but I have to fool Mach with a value of 0.3040" and it's always on the mark.
Do these switches have a +/- tolerance that may cause the problem?
Just a thought, I've never dealt with one before.
-
Sorry I have not had time to get into the VB stuff.. I did a tool changer the other day and have not looked back ;) If you run into problems with the VB mail me off list with the code in the Mail and a note telling me what you need looked at. I can't take editing code in the forum (Makes me go nuts)