Hi,
I have just been writing a simple script to probe the edge of a workpiece. When I step through the script, it works fine but when I run it, the X and Y DROs refuse to zero and I am always left with X at -6 and Y at +4. I have tried using the SetDro() and DoOEMButton() calls but to no avail. I am sure there is a simple explanation but it is alluding me. I also tried a search on the forum and something similar was thrown up but without conclusion.
Strange thing is that I constantly use a Z zeroing script, from which I modified the code for this one, and it works perfectly. I hope someone can help.
Mike
CurrentFeed = GetOemDRO(818) 'Get the current feedrate to return to later
ProbeDiameter = 8 'Set Probe diameter
If GetOemLed (825)=0 Then 'Check to see if the probe is already grounded or faulty
Xpos = GetDro(0)
Ypos = GetDro(1)
Zpos = GetDro(2)
' ------ Probe in X positive direction ------
Code "G31 X" & Xpos + 20 & " F50" 'probing move, can set the feed rate here as well as how far to move
While IsMoving() 'wait while it happens
Wend
XProbePos = GetVar(2000) 'get the axact point the probe was hit
'------ Re-position probe ready for Y direction probing ------
Code "G0 X" & XProbePos - 1 'Probe backs off 1mm
Code "G0 Y" & Ypos-20 'Preparation move for Y probing
Code "G0 X" & XProbePos + 10 'Preparation move for Y probing
'------ Probe in Y positive Direction ------
Code "G31 Y" & Ypos 'Probing move in Y
While IsMoving() 'wait while it happens
Wend
YProbePos = GetVar(2001) 'get the axact point the probe was hit
'------ Move probe to safe Z height and then to X0, Y0 ------
Code "G0 Y" & YProbePos - 1 'Probe backs off 1mm
Code "G0 Z" & Zpos + 30 'Retract Z
Code "G0 X" & (XProbePos + (ProbeDiameter/2))
Code "G0 Y" & (YProbePos + (ProbeDiameter/2)) 'Move to zero, zero
' DoOEMButton (1008)
Call SetDro(0,0) 'Zero X axis DRO
Code "G4 P0.5"
' DoOEMButton (1009) 'Zero Y axis DRO
Call SetDro(1,0)
Code "G4 P0.5"
Code "(X & Y axes now zeroed)"
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 applicable
Exit Sub
End If