Hello Guest it is October 09, 2024, 12:06:20 PM

Author Topic: DROs refuse to reset in probing  (Read 3612 times)

0 Members and 1 Guest are viewing this topic.

DROs refuse to reset in probing
« on: January 12, 2010, 06:42:35 PM »
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
« Last Edit: January 12, 2010, 06:44:26 PM by Mike_F »
Re: DROs refuse to reset in probing
« Reply #1 on: January 13, 2010, 09:01:09 AM »
Hi,

Problem solved - I did a little more searching and found that I needed to add another 'While' 'Wend' with a 'Sleep(1000)' after the machine moves to zero, zero and before the re-setting of the DROs. As I inderstand it, this is to allow time for the axes to move before the code moves on to the next command.

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
 
   While IsMoving()                                         
   Sleep (1000)                                     'Pause code while machine moves
   Wend


'   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

The added code is in red.  The routine now works brilliantly - now all I have to do is to work out how to add a button to the screen set and attach the code to it.

Mike