Hello Guest it is November 22, 2019, 07:09:54 AM

Author Topic: center probe script problems  (Read 1405 times)

0 Members and 1 Guest are viewing this topic.

center probe script problems
« on: October 19, 2017, 01:57:57 PM »
I have been using the script below with triple edge finder (http://www.themakersguide.com/home/products/triple-edge-finder-2). The script is supposed to move -X until it touches, return to center, +X, then -Y, then +Y. Problem is sometimes the script starts +X first and when it touches right edge of edge finder it then immediately rapids to furthest +X and hits the limit switch and stops. Scares the hell out of me. I usually have to power down CNC (uses etherstepper if that matters any) before it will work correctly. I now know if it starts left (-X) first it will work and if it starts right it will mess up so I immediately stop the machine before it goes haywire.

Any help would be great. Thanks.

Rem   VBScript To center probe inside a pipe

If GetOemLed (825) <> 0 Then       'Check to see if the probe is already grounded or faulty
   Code "(Probe plate is grounded, check connection and try again)"
   FeedCurrent = GetOemDRO(818)    'Get the current settings
   XCurrent = GetDro(0)
   YCurrent = GetDro(1)

   Code "G4 P1"         'Pause 1 second to give time to position probe plate
   Code "F4"         'slow feed rate to 4 ipm

Rem   Probe Left
   XNew = Xcurrent - 1      'probe 3 inches to left
   Code "G31 X" &XNew
   While IsMoving()      'wait for the move to finish
   XPos1 = GetVar(2000)      'get the probe touch location

   Code "G0 X" &XCurrent      'rapid move back to start point

Rem   Probe Right
   XNew = XCurrent + 1      'probe 3 inches to right
   Code "G31 X" &XNew
   While IsMoving()
   XPos2 = GetVar(2000)

   XCenter = (XPos1 + XPos2) / 2   'center is midway between XPos1 and XPos2
   Code "G0 X" &XCenter      'rapid move to the x center location

Rem   Probe up

   YNew = YCurrent + 1
   Code "G31 Y" &YNew
   While IsMoving()
   YPos1 = GetVar(2001)

   Code "G0 Y" &YCurrent

Rem   Probe down
   YNew = YCurrent - 1
   Code "G31 Y" &YNew
   While IsMoving()
   YPos2 = GetVar(2001)

   YCenter = (YPos1 + YPos2) / 2

Rem   move To the center
   Code "G0 Y" &YCenter
   While IsMoving ()

   Code "F" &FeedCurrent        'restore starting feed rate
End If