Machsupport Forum

Mach Discussion => VB and the development of wizards => Topic started by: AVRnj on May 18, 2015, 10:49:53 AM

Title: Z probe macro with offset
Post by: AVRnj on May 18, 2015, 10:49:53 AM
Hey everyone, I posted this in a different area but I think this area is more appropriate.

I am trying to get my Probe working in Mach3, so I entered 2 tools into my tool table, tool 99 (my probe) at 6.5 height, and tool 30 at 4 height.

I went into the offset tab in Mach3, I changed the tool from 0 to 99 which is my probe, and I am using the following macro for Z:
Code: [Select]
CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO

If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P2" ' two second delay
Code "G31 Z-1.0 F5" 'Z goes down a max of 1.0 at 5IPM
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
Code "G0 Z1.0" 'retract Z to 1.0 inch
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
Exit Sub
End If

When I enter tool 99, the offset light goes green, as I would expect. If I run that macro, it touches, and starts retracting, and then it actually goes up the full 6.5 from the offset, than an extra 1" for the Z1.0, and then it sets my DRO at 1, which is actually way off.

If I manually turn the offset off, and run the macro, it behaves as I would expect, it touches down, retracts 1, and sets the DRO at 1. The problem is, if I do that with the offset off, when I change tools, it does not change the DRO, which is exactly what I would expect.

So, it seems as though I need to use the offsets, but my macro is not working correctly. Can anyone help me out here with this? I have tried a few different macros for this that I found either in things I bought from Hoss, or in various forum posts, and they all behave the same way.

Do I need to reed the tool offset before retracting, and then somehow change my retraction accordingly?

Any help would be appreciated
Title: Re: Z probe macro with offset
Post by: BR549 on May 18, 2015, 11:32:56 AM
You do not normally set he tool height with an offset already in play.  Also the Macro you are running it not really setting the tool height it is simply Zeroing Z at the tip of the tool.

IF you run the Zero macro you don't need/want the tool length offset in play(active) that is what the macro does it accounts for the tool length to set Z zero. So you would run one OR the other but not both at the same time.

Just a thought, (;-) TP
Title: Re: Z probe macro with offset
Post by: AVRnj on May 18, 2015, 12:18:05 PM
TP, thanks for the reply.

I am not trying to set tool height, so if that is what this macro is doing, its definitely wrong.

All I am really trying to do is tell Mach3 where my Z zero is, by using the probing, and the tool table. So, for example, my probe has a height of 4, and my end mill has a height of 2, and both of those are in my tool table, I want to use the probe to touch the part, call that Z zero for the probe's height of 4, and when I switch to my end mill tool, it will use the offsets to adjust the z height accordingly.

My tool table works fine. If I manually touch my work piece with an end mill in my tool table, set my DRO to zero, and then change the tool, the DRO adjust automatically to the new tool using the new height.

I am just trying to automate the zeroing out with my probe.

Is that not what this macro is doing?
Title: Re: Z probe macro with offset
Post by: BR549 on May 18, 2015, 01:33:19 PM
The function you turned on is a special internal function and it links all the dros in that section to the tool table. That is NOT what you need to do .  With it active it is doing exactly what it was designed for , Setting tool height via the tool table. 

When you turn OFF the routine the Macro responds as it should . But since you have not invoked the tool offsets you get what you see.

I think IF you run it all from a Gcode program it will work fine.

(;-) TP



Title: Re: Z probe macro with offset
Post by: AVRnj on May 18, 2015, 02:04:11 PM
Thanks for your reply again TP.

So I am not sure how to run it from a Gcode program to be honest, I thought it had to be done from a macro, so that you can change the DRO.

The button I am clicking is the Tool Offset On/Off toggle button. When I click it off, not green, the macro works perfectly. But the problem is if I turn offset back on, so that my other tools can use offset, it does not work at all.

Can you help me out with the macro or the process I should be using?
Title: Re: Z probe macro with offset
Post by: BR549 on May 18, 2015, 03:45:35 PM
The best approach is to MAKE the probe the MASTER tool that everything is reference from. Its offset is always ZERO.   ALL other tools are set as compared to the master tool.

When it is time to setup the Part put the master tool into the Spindle. THEN run the Macro to find the TOM (top of material) it will then auto set the Z to ZERO. Now when you call any other tool the offsets will be correct.

The macro can simply be

Code"G91"
Code"G31 -5.000 F20" 'probe down 5 inches looking for surface
While Ismoving()
Wend
Code"G90"
Code"G00 Z#2002"     'Retract back to contact point
While Ismoving()
Wend
Code"G92 Z0.000"       'Set Z to ZERO
Code"G00 Z1.000"       ' Retract Z back to 1.000


From Gcode

M6 T99   ( change to Tool 99)
G91
G31 Z-5 F20  ( Probe for surface)
G90
G0 Z#2002  ( move back to contact point)
G92 Z0.000  ( set Z to ZERO )
G0 Z1.000   ( retract to Z1.000)

Change tool to 1st tool and start.

(;-) TP


Title: Re: Z probe macro with offset
Post by: TPS on May 18, 2015, 04:22:49 PM
Hi AVRnj,

not realy sure what you are trying to do.
in Your macro you are setting the z-axis zero to something (plate height, i asume).

tool hieght is set by g43 H??,

so i am not sure what you want to to,
set the z-axis height,
or set set the tool height ??

Thomas





Title: Re: Z probe macro with offset
Post by: AVRnj on May 18, 2015, 04:23:54 PM
I see what you are saying, but I must be missing something.

If my probe is tool zero with no offset, and say for argument sake my probe has a height of 5". When I put in my first tool, which say has a height of 4", how is it going to know that the new tool is 1" shorter than my tool zero?

I thought that was the whole reason to use offsets to begin with?
Title: Re: Z probe macro with offset
Post by: AVRnj on May 18, 2015, 04:27:33 PM
Hi AVRnj,

not realy sure what you are trying to do.
in Your macro you are setting the z-axis zero to something (plate height, i asume).

tool hieght is set by g43 H??,

so i am not sure what you want to to,
set the z-axis height,
or set set the tool height ??

Thomas







Thomas, sorry for the confusion with my post.

Here is exactly what I am trying to do:


Say my tool table looks something like this:

Tool 1  Digital Probe Height 4"
Tool 2  End Mill Height 3"
Tool 3 End Mill Height 2"

I want to be able to run a macro with Tool 1, my digital probe in the spindle, to touch zero on my work material, and have the DRO set to that zero for tool 1, and its 4" height.

Then, when I switch to tool 2, wherever my Z is, Mach3 should then adjust the Z DRO to be 1" less than it was when probed, which is correct.

Does that make sense?
Title: Re: Z probe macro with offset
Post by: TPS on May 18, 2015, 04:47:01 PM
OK,

again try to "play" a little bit with
G43 H??

G43H0 is your master, an then you will understand this
tool hight thing.

Thomas
Title: Re: Z probe macro with offset
Post by: BR549 on May 18, 2015, 04:53:28 PM
With tool setting all values HAVE to be referenced to Something, normally a master tool OR the spindle face.  THEN the top of part MUST be touched off with the master tool and Work Z has to be set to ZERO.  The master tool is the reference tool. When you change tools the offset is the difference between the master tool and the current tool.

The master tool can be ANY tool NUMBER but the offset is ZERO. IF you use a tool as the master it must be used for every setup UNLESS you reset all the tools to a different master tool. That would a  reason to use the spindle FACE as the master as it never changes. But it is not always the best option.  Here I have a master STUB tool holder( #2 morse taper) that is ALWAYS the master for this machine. It make it very easy to use compared to the spindle face.

IF you are quill travel limited you would use the longest tool as the master. To prevent sucking up the tool into the quill, not good on a KneeMill.

Now are there OTHER ways to do it sure, Just pick one and stick with it.

Just a thought, (;-) TP



Title: Re: Z probe macro with offset
Post by: TPS on May 18, 2015, 05:03:10 PM
That is what i try to say in may bad bavarian english,

---With tool setting all values HAVE to be referenced to Something


all the height's are not based to the matierial, they are based to
one paticulare heigt (master tool, ore what ever you want to call it).

so you do not only have to measaure the material, also you have
tho measure your tool hights based to this macic height.
Title: Re: Z probe macro with offset
Post by: AVRnj on May 18, 2015, 05:04:01 PM
OK, I THINK I am seeing what you both are saying. This is different than the way I used to do this.

What you guys are saying is make my probe as tool zero, and say for argument sake, it has a height of 4"

Now, if Tool 2 is an end mill, and it's height is 3", in my Tool Table, I would enter -1" for it's height, is this what you guys are saying?

In the past I would devote my zero'ing tool as its own tool number in the table, and track it's height, this is far easier for recording, but I suppose I see how what you are saying would work, I just have to subtract out my probe height from the actual tool height before I put it in the table.

Am I reading you guys correctly?

Thanks!
Title: Re: Z probe macro with offset
Post by: BR549 on May 18, 2015, 05:37:20 PM
Put you master tool ( Probe)  into the spindle. It can be any tool # does not matter.  In the tool table make SURE that that tool(probe) is set to 0.000 (length).

Probe down with the macro to find the TOM (top of material) . The macro should have set the Z to zero. Install the next Tool and jog DOWN and touch off on the material.  The value in Z is the amount of offset from the master. Put that value into the tool table for THAT tool#.  Do all your tools.

NOW when you start a job , load the MasterTool (probe) in the spindle and run the macro to find the TOM.

Now from the Gcode program side load your 1st tool (M6T1) and apply the G43 H1 X1.000  AND the comp move and it will be set to the material top.  From there on out each tool will be comped correctly.

(;-) TP 
Title: Re: Z probe macro with offset
Post by: AVRnj on May 18, 2015, 09:33:21 PM
Thanks guys, I get it. This is definitely different than what I was hoping to do, I use TTS and wanted to measure the tool height off the spindle, and just capture the height of each tool, but I get it. Thanks for your help and your patience!
Title: Re: Z probe macro with offset
Post by: AVRnj on May 19, 2015, 08:27:45 AM
After walking through the macro, and understanding it a bit more, I was able to get this to behave the way I wanted it to.

I was able to capture the current tool's offset by capturing GetOEMDRO(32) and setting it in a variable. Then when the probe is triggered, instead of going back to the point where the probe was triggered, which is getVar(2002), I go back to getVar(2002) - the tool offset I stored in a variable. I then retract one inch, and set the Z DRO to 1. All of this is done with my probe in the tool table. and using the offset.

I like to measure all of my tools before a job, so what this allows me to do is use a granite block with a hole bored through it, place each TTS tool holder with tool in it in the bore, and use a height gauge to measure all of my tools including my probe. I then enter the height for all of my tools into the tool table, including probe, and everything works perfectly.

For me this is much faster and more accurate than having to use the probe as my master or tool zero without an offset.

This is the way Tormach does it.

Thanks for your help guys. If anyone is interested, I can post the exact macro that I am using.
Title: Re: Z probe macro with offset
Post by: BR549 on May 19, 2015, 11:17:24 AM
So when you set up to do a job do you use the probe to set the TOM (top of material) to zero ??

It would nice for you to show the macro you use for future users who may want to do it that way.

Yes Tormach does it that way but MOST do not have a seperate tool height guage so they use the machine (;-)

(;-) TP
Title: Re: Z probe macro with offset
Post by: AVRnj on May 19, 2015, 02:20:05 PM
Yes, I use the probe as tool 99 to set the TOM according to the height of the probe. Since I use TTS tools, I splurged on a granite block and a height gauge. To me, it would be one thing to use the machine if you only needed to do it once, but I like to measure all of my tools that I am going to use for a job, each time I do a new job. That would be a bit cumbersome to use the machine to do that every time.

Here is the code I am using, there are only 2 lines of code that are different than the original code I was using:

Code: [Select]
CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
PlateThickness = GetUserDRO(1151) 'Z-plate thickness DRO
ProbeHeight = GetUserDRO(32)

If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
Code "G4 P2" ' two second delay
Code "G31 Z-1.0 F5" 'Z goes down a max of 1.0 at 5IPM
While IsMoving() 'wait while it happens
Wend
ZProbePos = GetVar(2002) - ProbeHeight 'get the axact point the probe was hit, making sure to account for the tool offset which is not accounted for in 2002
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
Wend
Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
Code "G4 P0.25" 'Pause for Dro to update.
Code "G0 Z1.0" 'retract Z to 1.0 inch
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "F" &CurrentFeed 'Returns to prior feed rate
Else
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
Exit Sub
End If
Title: Re: Z probe macro with offset
Post by: BR549 on May 19, 2015, 06:07:23 PM
If you have not noticed you are still using the Probe as the master tool (;-) You just fudged the length values to suite your way of doing it.  Not a problem. There are as many ways to do this as there are machinest doing it.

You can set tools in the machine just about as fast as you would the tool setter AND the values are automatically loaded into the tool table (;-) So IF you count the time to enter the values the machine would be faster.

THANKS for posting your code it may be a great help to others

Just a thought, (;-) TP
Title: Re: Z probe macro with offset
Post by: AVRnj on May 20, 2015, 08:34:46 AM
Oh yeah, I realize I am still using the probe as the master, I always wanted to do that, I just did not want to use it as tool zero.

I may give the other method a shot. I am a bit set in my ways and have always done it that way, but it can't hurt to give a new way a shot. For me its time consuming to touch down with a tool on Z, I need to jog down, then step down until I touch the rolling paper, and then account for the thickness, it just seems to take too long.

Thanks for all your help on this.
Title: Re: Z probe macro with offset
Post by: BR549 on May 20, 2015, 10:43:47 AM
That is Why you build a simple tool setter base probe. You simply probe down and touch off on the Probe base it sets to Zero then probe all the rest of the tools.

IF you look in the Mach tool box section there is a simple routine there that does just that. It uses stock Screen resources so you do NOT have to mod a screen . You just need to add in a button code to a button that is not used.

There is NOTHING wrong with the way you do it (;-) As long as it suites you.

(;-) TP