SHARE
TWEET

CNC Mach3 Z Probe Script DT02-3

sn4k3 Mar 6th, 2020 254 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. '
  2. ' CONFIGURATION
  3. '
  4. PlateThickness = 47.3 'GetUserDRO(1151) 'Z-plate thickness DRO
  5.  
  6. StartDelay = 2 ' Start delay seconds to start probing
  7.  
  8. DownStroke = -50 'Set the max down stroke to find probe
  9. DownFeedRate = 100 'Set the down FeedRate
  10.  
  11. RetractStroke = 10 'Set the retract Stroke
  12. RetractFeedRate = 300 'Set the retract FeedRate
  13. '
  14. ' END CONFIGURATION
  15. '
  16.  
  17. CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
  18. CurrentAbsInc = GetOemLED(48) 'Get the current G90/G91 state
  19. CurrentGmode = GetOemDRO(819) 'Get the current G0/G1 state
  20.    
  21.     Code "(Z Probe Start - Plate Thickness: " &PlateThickness &")"
  22.     If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
  23.         DoOEMButton (1010) 'zero the Z axis so the probe move will start from here
  24.         Code "G4 P" &StartDelay ' this delay gives me time to get from computer to hold probe in place
  25.         Code "G90 G31 Z" &DownStroke &" F" &DownFeedRate 'probing move
  26.        
  27.         While IsMoving() 'wait while it happens
  28.         Wend
  29.        
  30.         ZProbePos = GetVar(2002) 'get the axact point the probe was hit
  31.         If Abs(ZprobePos) <= Abs(DownStroke)-0.1 Then 'Check if the probe has been found
  32.             Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
  33.    
  34.             While IsMoving ()
  35.             Wend
  36.             Call SetDro (2, PlateThickness) 'set the Z axis DRO to whatever is set as plate thickness
  37.             Code "G4 P0.25" 'Pause for Dro to update.
  38.             Code "G1 Z" &PlateThickness + RetractStroke &" F" &RetractFeedRate 'retract
  39.             While IsMoving ()
  40.             Wend
  41.             Code "(Z axis is now zeroed)" 'puts this message in the status bar 
  42.         Else
  43.             Code "G0 Z0" 'retract to start pos
  44.             While IsMoving ()
  45.             Wend
  46.             Code "(Z-Plate not found, check connection or stroke and try again)" 'puts this message in the status bar
  47.         End If
  48.        
  49.     Else
  50.         Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
  51.     End If
  52.    
  53.     Code "F" &CurrentFeed 'Returns to prior feed rate
  54.  
  55.     If CurrentAbsInc = 0 Then 'if G91 was in effect before then return to it
  56.         Code "G91"
  57.     End If
  58.  
  59.     If CurrentGMode = 0 Then 'if G0 was in effect before then return to it
  60.         Code "G0"
  61.     End If
  62.  
  63. Exit Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top