Hello Guest it is May 24, 2019, 11:40:35 AM

Author Topic: help with VB script for z-height probe  (Read 2346 times)

0 Members and 1 Guest are viewing this topic.

help with VB script for z-height probe
« on: May 21, 2014, 06:55:04 PM »
I found this online and got it to work a little bit but it isn't exactly what I'm after.  Maybe one of you sharp VB folks can help me adjust it a touch?

Basically it doesn't seem to create an error when it goes down and tries to find the plate and can't and hits the Zmove distance.

I would like it to move (not jog/rapid) the Z axis down the ZMove distance.  If it doesn't touch the plate then it will immediately go back up to where it started from and send a message "Touch Plate Not Found".  If it does contact the touch plate then it will go back up to Zsal and the DRO will read correctly.  


'VB Code Start
CurrentFeed = GetOemDRO(818)

ZMove = 0.5 'Total length of Probe to move before Stop or no Contact Made.
ZOffset = .125 'Plate Hight
ZSal = ZOffset + 0.5 '+ Free Height, Will position the probe 0.5 over the material.

StopZmove = 0
If GetOemLed (825)=0 Then
DoOEMButton (1010)
Code "G4 P2.5"
Code "G31 Z-"& ZMove & "F25"
While IsMoving()
Probepos = GetVar(2002)
If Probepos = - ZMove Then
responce = MsgBox ("**ERROR** " , 4 , "Probe **ERROR**" )
Code "G0 Z10"
StopZmove = 1
Code "F" &CurrentFeed
End If
If StopZmove = 0 Then
Code "G0 Z" & Probepos
While IsMoving ()
Sleep (200)
Call SetDro (2, ZOffset)
Code "G4 P1"
Code "G0 Z" & ZSal
Code "(Z zeroed)"
Code "F" &CurrentFeed
End If
Code "(Check Ground Probe)"
End If
Exit Sub
'VB Code Stop

Offline dude1

  •  1,253 1,253
    • View Profile
Re: help with VB script for z-height probe
« Reply #1 on: May 21, 2014, 07:10:37 PM »
Code: [Select]
Rem Auto Tool Zero Z- Metric Version
DownStroke = -25 'Set the down stroke to find probe
DownFeedRate = 100 'Set the down FeedRate
RetractStroke = 10 'Set the retract Stroke
RetractFeedRate = 300 'Set the retract FeedRate

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) '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" ' this delay gives me time to get from computer to hold probe in place
Code "G90 G31 Z" &DownStroke &" F" &DownFeedRate 'probing move
While IsMoving() 'wait while it happens
ZProbePos = GetVar(2002) 'get the axact point the probe was hit
If Abs(ZprobePos) <= Abs(DownStroke)-0.1 Then 'Check if the probe has been found
Code "G0 Z" &ZProbePos 'go back to that point, always a very small amount of overrun
While IsMoving ()
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 "G1 Z" &PlateThickness + RetractStroke &" F" &RetractFeedRate 'retract
While IsMoving ()
Code "(Z axis is now zeroed)" 'puts this message in the status bar
Code "G0 Z0" 'retract to start pos
While IsMoving ()
Code "(Z-Plate not found, check connection or stroke and try again)" 'puts this message in the status bar
End If
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
End If
Code "F" &CurrentFeed 'Returns to prior feed rate
If CurrentAbsInc = 0 Then 'if G91 was in effect before then return to it
Code "G91"
End If
If CurrentGMode = 0 Then 'if G0 was in effect before then return to it
Code "G0"
End If
Exit Sub

try this one it has work for 2 years with out any problems
Re: help with VB script for z-height probe
« Reply #2 on: May 22, 2014, 12:30:43 AM »
This works great, thank you very much!