Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: M250cnc on August 13, 2008, 08:57:15 AM

Title: Scripting Help Tool Zero
Post by: M250cnc on August 13, 2008, 08:57:15 AM
Hi all,

I am using an Auto Tool Zero and it works very well but i want to add to it and i'm not sure what i need to do to achieve my goal.

I want to add or subtract a figure so my tool height reads correctly i guess it is an offset im looking for.

So what i am doing at the moment is touching top of workpiece "Z reads Zero"

I move away use MDI G0 Z0 then change the Z dro  to what i actually want, 12mm in this case

I have my dro on the screen but it does not do anything i want to add 12 in that dro and when i touch off my Z reads 12

Easy peasy when you know how, but unfortunately i do not. :-[

Thanks
Phil_H
Title: Re: Scripting Help Tool Zero
Post by: Chaoticone on August 13, 2008, 09:25:56 AM
Phil, this is the auto tool zero I use and it does what you want.

'Auto Tool Touchoff CurrentFeed = GetOemDRO(818) 'Get the current feedrate.
PlateThickness =0.059
ProbeFeed = 5


Code "G90 F" &ProbeFeed

If GetOemLed (825)=0 Then
Code "G4 P2" 'Time to get to the z-plate
Code "G31Z-5 F" &ProbeFeed
While IsMoving()
Wend
Code "G4 P0.25"
ZProbePos = GetVar(2002)
Code "G0 Z" &ZProbePos
While IsMoving ()
Wend
Call SetDro (2, PlateThickness)
Code "G4 P0.5" 'Pause for Dro to update.
Code "G0 Z0.25" 'Change the Z retract height here
Code "(Z axis is now zeroed)"
Code "F" &CurrentFeed
Else
Code "(Z-Plate is grounded, check connection and try again)"
Exit Sub
End If   

Brett
     
Title: Re: Scripting Help Tool Zero
Post by: M250cnc on August 13, 2008, 01:16:44 PM
Thanks for the reply Brett,

That is the Script i am using but it doesn't work for me.

Quote
Call SetDro (2, PlateThickness)

Is this the bit i have to attach to the dro ?

If so how ?

Phil_H
Title: Re: Scripting Help Tool Zero
Post by: Chaoticone on August 13, 2008, 01:32:11 PM
'Auto Tool Touchoff CurrentFeed = GetOemDRO(818) 'Get the current feedrate.




PlateThickness =0.059   'This is where you enter your plate thickness.






ProbeFeed = 5


Code "G90 F" &ProbeFeed

If GetOemLed (825)=0 Then
Code "G4 P2" 'Time to get to the z-plate
Code "G31Z-5 F" &ProbeFeed
While IsMoving()
Wend
Code "G4 P0.25"
ZProbePos = GetVar(2002)
Code "G0 Z" &ZProbePos
While IsMoving ()
Wend





Call SetDro (2, PlateThickness)   'This is where it sets your z axis dro to compensate for plate thickness.







Code "G4 P0.5" 'Pause for Dro to update.
Code "G0 Z0.25" 'Change the Z retract height here
Code "(Z axis is now zeroed)"
Code "F" &CurrentFeed
Else
Code "(Z-Plate is grounded, check connection and try again)"
Exit Sub
End If
Title: Re: Scripting Help Tool Zero
Post by: M250cnc on August 13, 2008, 04:16:33 PM
Thanks Brett,

But please tell me how do name the dro so it is called. ::)

I'm an engineer not a script kiddie. ;D

Phil_H
Title: Re: Scripting Help Tool Zero
Post by: Chaoticone on August 13, 2008, 06:23:44 PM
Phil, I'm sorry, I don't know what your asking. At teh top it says

PlateThickness =0.059   'This is where you enter your plate thickness.

Then further down it says

Call SetDro (2, PlateThickness)   'This is where it sets your z axis dro to compensate for plate thickness.

Thie line above sets dro 2 to the value you have in the line at the top "PlateThickness =0.059 "
You can change the number of the DRO it is setting in this line from 2 to what ever your using. 2 is the z axis dro to 0.059 "Plate thickness"  after it touches the plate. In the Plate Thickness line you can change 0.059 to 12 if you want to.

Brett

Brett
Title: Re: Scripting Help Tool Zero
Post by: M250cnc on August 14, 2008, 04:13:54 AM
Hi Brett i appreciate your patience.

I am using that Zero tool as is, i have made a touch plate that is nearly 13mm thick as i also use the probe by a guy over in the USA i am sorry i have forgotten who. :-[ "So my plate touches when it breaks contact".

All the coding is inside the script, i just touch down then i am at Zero.

But i want a dro on the screen so that if it says 0.0000 then when i use my touch tool then i am at zero on the top of my workpiece.

But i want this dro to add an offset so that if i enter 12 then when i zero i am actually 12 mm "PART THICKNESS NOT PLATE THICKNESS"

As i say in my original post i want to add to the script so that i can set an offset either in the plus or minus direction.

This is how i do it at the moment

What i am doing  is touching top of workpiece "Z reads Zero"

I move away use MDI G0 Z0 my tool is at zero according to the touch plate then change the Z dro  to what i actually want, 12mm in this case but it could be 3mm 15mm 1.mm or Zero if dro is empty

So this is maybe how it works i have a dro on my desktop it has 12 in it i run the standard script and at the end after going to the retract height it then says does "Z=Z+dro" or something to that effect to reach my goal of adding a figure in my dro the the z figure.

Does that make sense.
Phil_H


Title: Re: Scripting Help Tool Zero
Post by: Chaoticone on August 14, 2008, 06:47:25 AM
Phil, I have to run to work right now but the script I posted jogs the z down till it hits the plate, sets the z axis dro to vale determined in this line. "Plate Thickness=0.059. It then retracts the z to a sfe distance of 2.5. If you jog down 2.5 inches wou will be at tht top of the part (if your using my plate). But, any of those values can be edited in that script to do as you wish. Another dro can be added, will try to work on it this evening when i get in.

Brett
Title: Re: Scripting Help Tool Zero
Post by: M250cnc on August 16, 2008, 02:29:22 AM
Brett i appreciate your help.

I just didn't think this would be so difficult.

Phil_H
Title: Re: Scripting Help Tool Zero
Post by: Greolt on August 16, 2008, 09:19:35 PM
Phil

The following is the code that I use.

The red line is the one I have changed to suit your need.    It is possible the VB syntax is not correct.

I am no VB guru  :)  and I have not tested it with this alteration, but the idea should be sound.

You will need to add the DRO 1151 to your screen.  This will be "Material Thickness"  DRO

If the syntax is faulty then one of the VB experts here on the forum should be able to help.  :)

Apart from the red bit I have used this script for ages on a number of machines and it is good.



CurrentFeed = GetOemDRO(818) 'Get the current feedrate.
PlateThickness = 3.0 + GetUserDRO(1151) 'Set touch plate thickness here and it will add the material thickness from the onscreen DRO

If GetOemLed (825)=0 Then
DoOEMButton (1010)
Code "G4 P01"
Code "G31 Z-20 F100" 'Set probe move distance and speed here
While IsMoving()
Sleep 20
Wend
ZProbePos = GetVar(2002)
Code "G0 Z" &ZProbePos
While IsMoving ()
Wend
Call SetDro (2, PlateThickness)
Code "G4 P0.25"
Code "G0 Z30" 'Change the Z retract height here
Code "(Z axis is now zeroed)"
Code "F" &CurrentFeed
Else
Code "(Z-Plate is grounded, check connection and try again)"
Exit Sub
End If     

PS;  There are some numbers you will want to change if you use imperial measuments.       
Title: Re: Scripting Help Tool Zero
Post by: Chaoticone on August 16, 2008, 09:33:22 PM
Phil, I think i understand what you want. I have sent you a Personal message.

Brett
Title: Re: Scripting Help Tool Zero
Post by: Greolt on August 17, 2008, 02:42:29 AM
Phill

I have now tested the script I suggested.

It works perfect on LPT and SmoothStepper.

So the line that I was not sure about syntax, is good.

PlateThickness = 3.0 + GetUserDRO(1151) 'Set touch plate thickness here and it will add the material thickness from the onscreen DRO

Greg

Title: Re: Scripting Help Tool Zero
Post by: M250cnc on August 17, 2008, 05:43:59 AM
Hi Greolt,

I have just tested the script it does exactly what i want.  ;D

It seems explaining what you want is harder than the actual coding.  ::)

Thanks also to Brett "Chaoticone" for your kind offer via PM and help thus far but Greolt just beat you to it.

This came about as i am engineering rather than routing and i cannot always get my touch plate in a position to get a Touch

So i touch off on another face and either add or subtract to get me back to where my datum is.

I did not want the zero tool thickness coming into the equation "Outside Of The Script" as a mistake can have disastrous consequences IE i wanted that thickness left hard coded where it would always be correct.

I think i may change the title to reflect what i consider a usefull addition to the Auto Tool Zero Script.

Phil_H
Title: Re: Scripting Help Tool Zero
Post by: Chaoticone on August 17, 2008, 07:25:57 AM
Glad Greg got you sorted Phil. Thats what it is all about. Good job Greg.

Brett