Hello Guest it is March 28, 2024, 12:11:44 PM

Author Topic: Auto Z Probing retract height  (Read 1840 times)

0 Members and 1 Guest are viewing this topic.

Auto Z Probing retract height
« on: September 03, 2020, 06:01:56 PM »
Hello,
I am trying to get the auto Z to work. I am unsure if this is a 2010 screenset problem or a general Mach issue so I am posting here. My mill travels down in the Z till it hits my plate then retracts all the way to the limit switch. It is supposed to back off a touch and then lower slowly again for a more precise measurement. Do you know what might be causing this, safe z maybe?

Joe

Offline ZASto

*
  •  423 423
    • View Profile
Re: Auto Z Probing retract height
« Reply #1 on: September 04, 2020, 05:28:46 AM »
Show your script.
Make no mistake between my personality and my attitude.
My personality is who I am.
My attitude depends on who you are.
Re: Auto Z Probing retract height
« Reply #2 on: September 04, 2020, 03:46:51 PM »
Thanks for the quick reply!

Code: [Select]
Sub Main()
' Simple Auto Zero
' Based on the macros created be Big Tex -  May 25 2010
' and modified by Poppa Bear 11dec10


Dim ZNew, Zplate, ZMaxRetract, Zplatetomaterial
Dim XWork, YWork, XMachine, YMachine, ZMachine
Dim XScale, YScale, ZScale
Dim xtoprobe, ytoprobe
Dim PlateOffset, MatOffset, TotalOffset
Dim MatOffsetYN
Dim ZClear, ClearAllow
Dim CurrentFeed
Dim CurrentAbsInc
Dim Response

XWork = GetOEMDRO(800)  ' Get Current X Work Coordinate
YWork = GetOEMDRO(801)  ' Get Current Y Work Coordinate
XMachine = GetOemDRO(83)  ' Get Current X Machine Coordinate
YMachine = GetOemDRO(84)  ' Get Current Y Machine Coordinate
ZMachine = GetOemDRO(85)   ' Get Current Z Machine Coordinate
PlateOffset = GetUserDRO(1851)  ' Get Plate Thickness DRO
MatOffset = GetUserDRO(1815)  ' Get Material Offset DRO

If GetOEMLED(1863) Then  ' Set Flag if Material Offset is used
MatOffsetYN=1
Else
MatOffsetYN=0
End If

'Get Axis Scale factors
ZScale = GetOEMDRO(61)

'Set All Axis' Scale to 1

Call SetOEMDRO(61,1)
Sleep(250)


CurrentFeed = GetOemDRO(818)  ' Get the current feedrate to return to later
CurrentAbsInc = GetOemLED(48)   ' Get the current G90/G91 state
Zclear=GetOEMDRO(1814) ' Get Z Clearance Plane from DRO

'//////// the block below will set all your reusable vars depending on Inch or mm.
'//////// this sets the vars so you only need ONE large block of probing code.

If GetOEMLED(801) Then  ' On = English Measure INCH

FirstProbeDist = 6.0 ' Probe down 6 inches
FirstRetractDist = 0.05 ' Then retract .05 inch
SecProbeDist = 0.25 ' Then probe down .25 inches
FirstProbeFeed = 10.0 ' First probe feed @ 10 ipm
SecondProbeFeed = 1.0 ' Second probe feed @ 1 ipm
ClearAllow = 0.125 ' Max Allowable Clearance = Z Machine Zero - .125in

Else ' Off = Metric Measure MM

FirstProbeDist = 150.0 ' Probe down 150mm
FirstRetractDist = 1.0 ' Then retract 1mm
SecProbeDist = 6.0 ' Then probe down 6mm
FirstProbeFeed = 250.0 ' First probe feed @ 250 mm/min
SecondProbeFeed = 25.0 ' Second probe feed @ 25 mm/min
ClearAllow = 2.0 ' Max Allowable Clearance = Z Machine Zero - 2mm

End If

'//////// Error Condition checking code

If GetOemLED(16)<>0 Then ' Check for Machine Coordinates
Code "(Please change to working coordinates)"
Exit Sub ' Exit if in Machine Coordinates
End If

If GetOemLED(825)<>0 Then
Code "(Z-Plate Grounded Check connection and try again)"
Exit Sub ' Exit if probe is tripped
End If

If PlateOffset < 0 Then
Code "(Plate Thickness < 0 - Please Correct and try again)"
Exit Sub ' Exit If Plate Thickness is less than 0
End If

If MatOffsetYN=1 Then
If MatOffset < 0 Then
Code "(Warning - Material Offset < 0)"
Sleep(3000)
End If
End If

If ZClear <= 0 Then
Code "(Clearance Plane Must > 0 - Please Reset)"
Exit Sub ' Exit If Clearance Plane is less than  or equal to 0
End If


If MatOffsetYN=1 Then  ' If Use Material Offset = Yes
TotalOffset = PlateOffset - MatOffset
Else
TotalOffset = PlateOffset
End If


'//////// Start Probing Code, Probe In -Z direction.
'//////// The vars will be Inch or Metric from above if/else statment

sleep(1000) ' Pause for 1 second to give time to position probe plate

Code "F" & FirstProbeFeed ' Set feedrate to 10 ipm or 300mm/min

Code "(Probing for Z Zero.....)" ' Puts this message in the status bar

ZNew = (GetOEMDro(802) - FirstProbeDist ) ' Probe move to current Z - 6 inches
Code "G90 G31 Z" & Znew

While IsMoving() ' Wait for probe move to finish
Wend

ZNew = GetVar(2002) ' Read the touch point
Code "G0 Z" & ( ZNew + FirstRetractDist ) ' Move up .05 inch or 1mm in case of overshoot

While IsMoving()
Wend

Code "F" & SecondProbeFeed ' Set feedrate to 1 ipm or 25mm/min

ZNew = (GetOEMDro(802) - SecProbeDist ) ' Probe move to current Z - .25 inches
Code "G90 G31 Z" & Znew

While IsMoving()
Wend

ZNew = GetVar(2002) ' Read the touch point
Code "G0 Z" & ZNew ' Move back to hit point in case of overshoot

While IsMoving()
Wend

Call SetOEMDRO (802, TotalOffset) ' Set the Z axis DRO to plate thickness
sleep(500) ' Pause for DRO to update.

'Make Sure Z Clearance Plane is below Home Switch. If not, Notify User and Proceed.
ZMaxRetract = Abs(GetOemDRO(85)) - ClearAllow ' Distance to Home Switch - Clearance Allowance


If ZClear - TotalOffset > ZMaxRetract Then

Response = MsgBox ("Warning !!!" & (Chr(13)) & "Z Clearance Plane is Above Z Axis Home Switch." & (Chr(13)) & "Press OK To Retract Safely Below Switch" & (Chr(13)) & "Or Press Cancel to Exit Operation",49,"Insufficient Z Clearance!!")

If Response = 1 Then ' If OK
ZClear = TotalOffset + ZMaxRetract ' Retract to Z Machine zero - .125in or 2mm
ElseIf Response = 2 Then ' If Cancel
Exit Sub
End If
End If

Code "G0 Z" & ZClear ' Retract to Z Clearance Plane

While IsMoving()
Wend

Call SetOEMDRO(61,ZScale)
Sleep(250)

Code "(Z axis is now zeroed.)"


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



End Sub   
             
     
 
 
Re: Auto Z Probing retract height
« Reply #3 on: September 06, 2020, 04:37:33 PM »
Hey All,
I added some debug info the script. After the initial touch, my machine wants to retract to 9.878.... But 0 it the top of my Z and all the numbers on the Z should be negative. Also, even if 9 was negative, it is pretty far from the machine coordinate of -13 or the work coordinate of -3.2. Based on the DROs it seems the retract should be -13.02... or -3.19...

Is there a way to update the values?

The message in the display is showing the values before the move:
Code: [Select]
Code "G0 Z" & ( ZNew + FirstRetractDist )
Please see attached.

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: Auto Z Probing retract height
« Reply #4 on: September 06, 2020, 04:57:53 PM »
Do you have a height offset active, you may need a G49 to cancel it.

Check 'include TLO in G31' in general config.

Or

Are you reading the correct var number, 2002 for Z axis.

Without engineers the world stops
Re: Auto Z Probing retract height
« Reply #5 on: September 06, 2020, 05:16:42 PM »
@Graham Waterworth,
Thanks for the suggestions. In general config, "include TLO in G31" was unchecked, it is checked now. I added a G49 to the beginning of the script. Yes, the script was looking for var number 2002. With those changes, the new retract is still headed to +9.

Can I use GetOemDRO(85) or GetOemDRO(802) instead of GetOemDRO(2002)? They seem to have proper values, though I don't know if these moves should be in machine or work coordinates.
Re: Auto Z Probing retract height
« Reply #6 on: September 06, 2020, 07:18:51 PM »
I meant GetVar(2002) vs GetOemDRO(85) or GetOemDRO(802)
Re: Auto Z Probing retract height
« Reply #7 on: September 07, 2020, 12:16:09 AM »
I got it working woo woo!

Anywhere there was a call to GetVar:
Code: [Select]
ZNew = GetVar(2002)
I swapped it out for a sleep and GetOEMDro
Code: [Select]
Sleep(250)
ZNew = GetOEMDro(802)
Re: Auto Z Probing retract height
« Reply #8 on: September 24, 2020, 09:30:19 AM »
hi mike c here hookup z touch probe (i watch a video from guru brew) but when i touch the ground lead to the spindle the limit switch trips
and the digitized button is on when i touch the probe ground to the plate it goes off
can you help thanks mikec

Offline ZASto

*
  •  423 423
    • View Profile
Re: Auto Z Probing retract height
« Reply #9 on: September 24, 2020, 09:46:13 AM »
Settings/Ports & Pins/Input Signals...
Change the state of Probe pin (if Unchecked Active Low check it, and vice versa).
Make no mistake between my personality and my attitude.
My personality is who I am.
My attitude depends on who you are.