Machsupport Forum

Mach Discussion => General Mach Discussion => Topic started by: Toad on October 29, 2009, 03:55:46 PM

Title: Auto Zero
Post by: Toad on October 29, 2009, 03:55:46 PM
I need your assistance, How can I get the Z- auto zero to work?  I have Mach-3 configured for the probe set up on a board output #14, The board is grounded to the router. What else do I need to do to get the auto zero to work?
Title: Re: Auto Zero
Post by: ger21 on October 29, 2009, 06:12:21 PM
Do you have the VB code? Lots of info here.

http://cnczone.com/forums/showthread.php?t=36099
Title: Re: Auto Zero
Post by: Greolt on October 29, 2009, 06:49:43 PM
Yes there is a lot of info about.  That thread and others.

One of the first things you will need to do is use an input not an ouput.

Greg
Title: Re: Auto Zero
Post by: Chaoticone on October 29, 2009, 07:16:45 PM
This may help. There is better code floating around I'm sure. The post Gerry pointed you to probably has a good macro in it. Mine works but could have more checks in it.

http://www.machsupport.com/forum/index.php/topic,10088.0.html
Title: Re: Auto Zero
Post by: Toad on October 31, 2009, 11:28:04 AM
Good day Chaoticone:

I pasted the script, and I get an Script compile error.  Any Idea what I did wrong?

I went to the operator tab, edit button script. The button began to blink and I pasted the code in.

Toad
Title: Re: Auto Zero
Post by: Chaoticone on October 31, 2009, 12:46:59 PM
I'm not sure unless you had my signuture at the end. If it is a later version of Mach it could have issues as well. Here is an updated one for later versions of Mach.

'Auto Tool Zero Script

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

Code "G90 F" &ProbeFeed

If GetOemLed (825)=0 Then
Code "G4 P5000" 'Time to get to the z-plate
Code "G31Z-5 F" &ProbeFeed
Code "G4 P0.25"
While IsMoving()
Sleep(100)
Wend
ZProbePos = GetVar(2002)
Code "G0 Z" &ZProbePos
While IsMoving ()
Sleep(100)
Wend
Call SetDro (2, PlateThickness)
Sleep(100)
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: Auto Zero
Post by: Toad on October 31, 2009, 06:39:02 PM
Thanks,

I'll try this one and let you know. I do appreciate your assistance and patience.

Toad
Title: Re: Auto Zero
Post by: Toad on October 31, 2009, 08:41:24 PM
OK , One more time, I still get a script compile error.  Must be me, but I am pasting everything from auto zero script down to end if.

Don't know enough to know what I an doing wrong.

Toad
Title: Re: Auto Zero
Post by: Greolt on November 01, 2009, 01:39:06 AM
I tried the above posted script and do not get any compile errors.

However there are a couple of problems in its operation.

The first is that if you have G04 dwell time set to seconds in General Config, (the default setting) then 5000 seconds is too long to wait.  My coffee would go cold while I waited.

And if you have it set to MS, then the other G04 delays are so short as to be irrelevant.  Something like Sleep 100 would be more appropriate.

The other issue is, if a user started this script with Z axis DRO at say -6, then the first move will be in an unexpected direction.

I really hate it when a CNC machine I am operating does something I do not expect.  :)

Either zero the Z axis DRO prior to the G31, or do  G91 G31 Z-5  probe move.

Greg
Title: Re: Auto Zero
Post by: Chaoticone on November 01, 2009, 08:38:02 AM
Greg, your right. That is my personal touch off routine set up up for my machine and it works well with it but it could cause others problems. We need to come up with a standard auto zero script taking into account all possibilities. Metric/Imperial, abs./inc., ms/s etc.   :)  There are a lot of auto zero scripts floating around but I haven't seen one that everyone was happy with yet.  :(  It would have to be well commented too. Maybe we need to start a topic specifically for this? This is one of the things I have wanted to do for a long time but right now time is the problem.

Brett

 
Title: Re: Auto Zero
Post by: Chaoticone on November 01, 2009, 08:45:11 AM
This looks like a good place to start. It is the latest update I saw to yours in the thread at the zone.

Quote
1) Returns the probe to the original starting postion once contact is made. This was somewhat problematic if the "Machine Coordinates" button was activated. Finally go it solved.

2) If no contact is made while plunging the probe to the maximum distance, probe is NOT retracted and the Z-DRO shows the current position. This allows for sequential movements until the probe reaches the contact plate.

3) Put the parameters that you may want to fiddle with at the top and added comments to remind me what I did and why.


Here is the modified script:

' Program to automatically zero the Z-axis using a contact plate of known thickness positioned
' on top of the X-Y plane at the Z zero position. Cutting tool acts as a probe.

' Program moves the Z-axis downward at plunge speed defined by parameter "ProbeFeed" until
' the tool touches the contact plate. At this point, the Z-DRO is set to zero, adjusted for
' the thickness of the contact plate. Z-axis then retracts to the starting position.

' Last updated: 10/13/09

' Define fixed parameters

ProbeDist = "-1.0" 'Set the maximum distance to move the Z-axis before probe touches contact plate.
ProbeFeed = "10" 'Set the plunge speed for the probe
DelayTime = "1" 'Set the delay time in seconds from button push to start of Z-motion

' Obtain current state values so that they can be restored upon completion.

CurrentFeed = GetOemDRO(818) ' Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) ' Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) ' Get the current G0/G1 state

PlateThickness = GetUserDRO(1151) ' Read contact plate thickness DRO
StartingPoint = GetOemDRO(85) - GetOemDRO(832) ' Get starting Z position in work coordinates

If GetOemLed (825)=0 Then ' Check to see if the probe is already grounded or faulty
Code "G4 P" &DelayTime ' This delay gives me time to get from computer to hold probe in place
Code "F" &ProbeFeed ' Set the probe plunge speed
Code "G91 G31Z" &ProbeDist ' Probing move using incremental move mode.
While IsMoving() ' Wait while it happens
Wend

ZProbePos = GetVar(2002) ' Get the axact point the probe was hit
If (ProbeDist+StartingPoint = ZProbePos) Then GoTo NoContact ' No contact was made during plunge
Code "G90 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
Sleep 500 ' For some reason unknown to me,need this pause or retract goes to wrong place
Retract=Val(PlateThickness)+Val(StartingPoint)-Val(ZProbePos) ' Calculate retract position
Code "G0 Z" &Retract ' Retract to original position
While IsMoving ()
Wend
Code "(Z axis is now zeroed)" ' Puts this message in the status bar
GoTo Finish
NoContact:
Code "(No contact made within probing distance, try again!)" 'Puts this messge in the status bar
Finish:
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
End If

' Reset the machine state

If CurrentAbsInc = 0 Then Code "G91" ' If G91 was in effect before then return to it
If CurrentGMode = 0 Then Code "G0" ' If G0 was in effect before then return to it

Exit Sub

Title: Re: Auto Zero Quit working after .029 install!
Post by: m1911bldr on November 08, 2009, 05:03:32 AM
I was using the Auto Tool Zero and very happy with it unti I installed build .029.  Now it is so unpredicatble I can't use it anymore.  Sometimes it retracts over an inch, or feeds down an inch after touching the probe plate. Other times it doesn't advance more that .o1 or so the stops and reprots "Z is now zeroed." Anyone know what's different between the old version and the new version that caused this? Anyone got a new VB script that works reliably with the newer versions?
Title: Re: Auto Zero
Post by: ruzter on November 11, 2009, 01:13:50 AM
I had the same issue.  I took the above code and modified it to the following and now it works great, thanks for the help!

' Program to automatically zero the Z-axis using a contact plate of known thickness positioned
' on top of the X-Y plane at the Z zero position. Cutting tool acts as a probe.

' Program moves the Z-axis downward at plunge speed defined by parameter "ProbeFeed" until
' the tool touches the contact plate. At this point, the Z-DRO is set to zero, adjusted for
' the thickness of the contact plate. Z-axis then retracts to the starting position.

' Last updated: 10/13/09

' Define fixed parameters

ProbeDist = "-1.0" 'Set the maximum distance to move the Z-axis before probe touches contact plate.
ProbeFeed = "10" 'Set the plunge speed for the probe
PlateThickness = 0.040

' Obtain current state values so that they can be restored upon completion.

CurrentFeed = GetOemDRO(818) ' Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48) ' Get the current G90/G91 state
CurrentGmode = GetOemDRO(819) ' Get the current G0/G1 state

If MsgBox("Ready to auto-detect z zero" & Chr(13) & Chr(13) & "Auto-height pad in place?",1) =1 Then
   If GetOemLed (825)=1 Then ' Check to see if the probe is already grounded or faulty
      MsgBox("Touch-Plate is grounded, check connection and try again")
      Code "Z-Plate is grounded, check connection and try again" 'this goes in the status bar if aplicable
   Else   
      StartingPoint = GetOemDRO(85) - GetOemDRO(832) ' Get starting Z position in work coordinates
      Code "F" &ProbeFeed ' Set the probe plunge speed
      Code "G91 G31Z" &ProbeDist ' Probing move using incremental move mode.
      While IsMoving() ' Wait while it happens
      Wend
      
      ZProbePos = GetVar(2002) ' Get the axact point the probe was hit
      If Val(ProbeDist)+Val(StartingPoint) >= Val(ZProbePos) Then ' No contact was made during plunge
         Code "G90 G0 Z" & StartingPoint ' Go back to that point. Always a very small amount of overrun.
         While IsMoving ()
         Wend
      Else
         Call SetDro (2, PlateThickness) ' Set the Z axis DRO to whatever is set as plate thickness
         Sleep 500 ' For some reason unknown to me,need this pause or retract goes to wrong place
         Code "G90 G0 Z0.25" '&Retract .25 inches up ' Retract to original position
         While IsMoving ()
         Wend
         Code "(Z axis zeroed)" ' Puts this message in the status bar
      End If   
   End If
End If   

' Reset the machine state
Code "F" &CurrentFeed ' Returns to prior feed rate
If CurrentAbsInc = 0 Then Code "G91" ' If G91 was in effect before then return to it
If CurrentGMode = 0 Then Code "G0" ' If G0 was in effect before then return to it

Exit Sub
Title: Re: Auto Zero
Post by: bowber on November 11, 2009, 06:26:16 AM
Does this code work for sensible units (mm  ;)) and just change the -1.0 to -25 and the plate thickness in mm.

Steve
Title: Re: Auto Zero
Post by: ruzter on November 11, 2009, 12:51:09 PM
One way to find out! (I think it should)  ;D
Title: Re: Auto Zero
Post by: bowber on November 12, 2009, 04:44:37 AM
One way to find out! (I think it should)  ;D

I could mount the touch plate on a spring then it would just give when the tool caries on.
I could call it Zebedy ;-)

Steve
Title: Re: Auto Zero
Post by: ruzter on November 12, 2009, 10:02:08 AM
I wouldn't worry about damaging bit due to the over run, here is a youtube video showing that it won't damage even a tiny bit

http://www.youtube.com/watch?v=DOBxt9MIbFo&feature=channel (http://www.youtube.com/watch?v=DOBxt9MIbFo&feature=channel)
Title: Re: Auto Zero
Post by: bowber on November 12, 2009, 10:48:07 AM
Yes I'd seen that.
I was just joking about changing it to metric "should" be ok. ;)

Steve
Title: Re: Auto Zero
Post by: ruzter on November 12, 2009, 11:13:06 AM
 ;D Yes, I think mm is the sensible type of units too. Being in Canada, I work in both inches and mm.
Title: Re: Auto Zero
Post by: Toad on November 14, 2009, 02:01:14 PM
OK, I re-loaded mach 3 and now it works.   How do I change the Dwell time? It is taking 6 minutes before it begins to move.

 

When to goes down and touches the plate,( which I have the thickness set @ .375) it backs off .25 above the plate and resets Z DRO to .25 . How do I get it to allow for the plate thickness so when I go to 0.000 it is touching the piece I am working on?

Toad

 

Title: Re: Auto Zero
Post by: Toad on November 14, 2009, 02:49:46 PM
Good day;

I loded this code to auto zero Z and it does work, But I have a question, When it touches the plate, it backs off .25 and sets the DRO to .25 as it should by what I best understand. How can I get it to allow for the thickness of the touch plate so when I set Z to zero it touches the material. My touch plate I am using now is .375. 

Also, when I go to auto Zero Z it dwells for 6 minutes before moving, how do I change that?




'Auto Tool Zero Script

CurrentFeed = GetOemDRO(818) 'Get the current feedrate.
PlateThickness =0.375
ProbeFeed = 5

Code "G90 F" &ProbeFeed

If GetOemLed (825)=0 Then
Code "G4 P5000" 'Time to get to the z-plate
Code "G31Z-5 F" &ProbeFeed
Code "G4 P0.25"
While IsMoving()
Sleep(100)
Wend
ZProbePos = GetVar(2002)
Code "G0 Z" &ZProbePos
While IsMoving ()
Sleep(100)
Wend
Call SetDro (2, PlateThickness)
Sleep(100)
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: Auto Zero
Post by: Toad on November 14, 2009, 03:13:43 PM
OK, I re-loaded mach 3 and now it works.   How do I change the Dwell time? It is taking 6 minutes before it begins to move.

 

When to goes down and touches the plate,( which I have the thickness set @ .375) it backs off .25 above the plate and resets Z  DRO to .25 . How do I get it to allow for the plate thickness so when I go to 0.000 it is touching the piece I am working on?

Toad
Title: Re: Auto Zero
Post by: Greolt on November 14, 2009, 05:00:53 PM
Here is the same code with a couple of small edits.

This will dwell for 3 seconds.

'Auto Tool Zero Script modified for Toad

CurrentFeed = GetOemDRO(818) 'Get the current feedrate.
PlateThickness =0.375

If GetOemLed (825)=0 Then
DoOEMButton (1010)
Code "G4 P3" 'Time to get to the z-plate, 3 seconds
Code "G90 G31 Z-2 F4" ' probing move, can set the feed rate here as well as how far to move
While IsMoving()
Wend
ZProbePos = GetVar(2002)
Code "G1 Z" &ZProbePos
While IsMoving ()
Wend
Call SetDro (2, PlateThickness)
Sleep(120)
Code "G0 Z1" 'Change the Z retract height here to what you want, must be higher than touch plate
Code "(Z axis is now zeroed)"
Code "F" &CurrentFeed 'returns to prior feedrate
Else
Code "(Z-Plate is grounded, check connection and try again)"
End If
Exit Sub
%
Title: Re: Auto Zero
Post by: Toad on November 14, 2009, 05:09:04 PM
Thanks, I'll give it a try
Title: Re: Auto Zero
Post by: Toad on November 14, 2009, 05:38:15 PM
Greolt

Thanks, that worked.  If I get a thinner plate, do I just need to go into edit script and change the plate thickness, or is there something else I have to change?

You are a big help.

Toad
Title: Re: Auto Zero
Post by: Greolt on November 14, 2009, 05:44:56 PM
Yes edit the plate thickness.

This is something that will need fine tuning to get the Z zero really accurate.

Greg
Title: Re: Auto Zero
Post by: 15mgtar on July 25, 2010, 04:25:02 PM
I'm sorry but how do I get the VB code in mach3 mill? what do I have to click n paste? I have the text copy of the script somewhere from a guy here.
can anyone teach me step by step?
Title: Re: Auto Zero
Post by: Hood on July 25, 2010, 05:59:12 PM
I'm sorry but how do I get the VB code in mach3 mill? what do I have to click n paste? I have the text copy of the script somewhere from a guy here.
can anyone teach me step by step?

I have not read through the rest of the post so may not be understanding what you want fully. If it is just making a button with the Auto Zero code then go to Operator menu then Edit Button Scripts. You will then see the AutoZero button flash, click it and the editor window will open, paste your code in there and save.
Hood
Title: Re: Auto Zero
Post by: 15mgtar on July 26, 2010, 05:06:39 AM
I apologize for posting someone else's work here and without his permission. I can not find his thread anymore because there are so many of them. Again I apologize for posting his work without his permission:
 the codes for auto tool zero

Rem   VBScript To probe In the z axis

If GetOemLED(801) Then            'NOTE: This script is for Inches as Native Units

   If GetOemLed (825) <> 0 Then       'check to see if the probe is already grounded or faulty
      Message "Z-Plate is grounded, check connection and try again" 'this goes in the status bar if aplicable
   Else
      Code "G4 P1"         'pause 1 seconds to give time to position probe plate
      PlateOffset = GetUserDRO(1151)   'get plate offset DRO
      CurrentFeed = GetOemDRO(818)    'get the current feedrate to return to later
      Code "F12"         'slow down feedrate to 12 ipm

   Rem   Probe In the z direction
   ZNew = GetOEMDro(802) - 6      'probe move to current z - 6 inches
      Code "G31Z" &ZNew
      While IsMoving()         'wait For probe move to finish
      Sleep(10)
      Wend

      ZNew = GetVar(2002)       'read the touch point
      Code "G0 Z" &ZNew +.05      'move back  +.1 to hit point incase there was overshoot +.1
      While IsMoving ()
      Sleep(10)
      Wend
   
   Rem End add lines   
   
      Code "F1"         'slow down feedrate to 2 ipm
      ZNew = GetOEMDro(802) - .1   'probe move to current z - .25 inches
      Code "G31Z" &ZNew
      While IsMoving()         'wait For probe move to finish
      Sleep(10)
      Wend

      ZNew = GetVar(2002)       'read the touch point
      Code "G0 Z" &ZNew       'move back to hit point incase there was overshoot
      While IsMoving ()
      Sleep(10)
      Wend

      If PlateOffset <> 0 Then
         Call SetOEMDro (802, PlateOffset)   'set the Z axis DRO to  plate thickness
         Code "G4 P0.25"       'pause for Dro to update.
         ZNew = PlateOffset + .937   'calc retract
         Code "G0 Z" &ZNew    'put the Z retract height you want here
         While IsMoving ()
         Sleep(10)
         Wend
         Message "Z axis is now zeroed in Imperial units"    'puts this message in the status bar
      
      End If

      Code "F" &CurrentFeed       'returns to prior feed rate
   End If         
Else                                             'NOTE: This portion of script is for Metric as Native Units

   If GetOemLed (825) <> 0 Then       'check to see if the probe is already grounded or faulty
      Message "Z-Plate is grounded, check connection and try again" 'this goes in the status bar if aplicable
   Else
      Code "G4 P1"         'pause 1 seconds to give time to position probe plate
      PlateOffset = GetUserDRO(1151)   'get plate offset DRO
      CurrentFeed = GetOemDRO(818)    'get the current feedrate to return to later
      Code "F300"         'slow down feedrate to 300 mmpm

   Rem   Probe In the z direction
      ZNew = GetOEMDro(802) - 150   'probe move to current z - 150 mm
      Code "G31Z" &ZNew
      While IsMoving()         'wait For probe move to finish
      Sleep(10)
      Wend
   
      ZNew = GetVar(2002)       'read the touch point
      Code "G0 Z" &ZNew + 3      'move back  + 3 mm to hit point incase there was overshoot + 3 mm
      While IsMoving ()
      Sleep(10)
      Wend
   
   Rem End add lines   

      Code "F50"         'slow down feedrate to 50 mmpm
      ZNew = GetOEMDro(802) - 6   'probe move to current z - 6 mm
      Code "G31Z" &ZNew
      While IsMoving()         'wait For probe move to finish
      Sleep(10)
      Wend

      ZNew = GetVar(2002)       'read the touch point
      Code "G0 Z" &ZNew       'move back to hit point incase there was overshoot
      While IsMoving ()
      Sleep(10)
      Wend

      If PlateOffset <> 0 Then
         Call SetOEMDro (802, PlateOffset)   'set the Z axis DRO to  plate thickness
         Code "G4 P0.25"       'pause for Dro to update.
         ZNew = PlateOffset + 20   'calc retract
         Code "G0 Z" &ZNew    'put the Z retract height you want here
         While IsMoving ()
         Sleep(10)
         Wend
         Message "Z axis is now zeroed in Metric units"    'puts this message in the status bar
      
   End If

      Code "F" &CurrentFeed       'returns to prior feed rate
End If   
End If     

please help me what to do with this? What do I need to click in mach3? I really wanted to try his codes seems like it is VERY GOOD!
Title: Re: Auto Zero
Post by: Hood on July 26, 2010, 06:34:57 AM
As said above, Open Mach and from Operator menu choose to edit Button scripts. The Auto tool zero button will be flashing, click on it and the editor will open. Replace any code in the editor with the code you have posted above and then save.
Thats it, should work now when you press that button.
Hood
Title: Re: Auto Zero
Post by: 15mgtar on July 26, 2010, 07:41:13 AM
THANK YOU SO MUCH Hood!!!
Title: Re: Auto Zero
Post by: 15mgtar on July 27, 2010, 12:28:12 PM
I tried the code but didn't work it got error. what did I do wrong?
Title: Re: Auto Zero
Post by: Hood on July 27, 2010, 03:14:20 PM
What error?

If you open the button script again and press the green single arrow do you get an error?
Hood