Hello Guest it is December 22, 2024, 06:01:05 AM

Author Topic: Z Zero Probe problem with script  (Read 6759 times)

0 Members and 1 Guest are viewing this topic.

Z Zero Probe problem with script
« on: February 21, 2018, 08:53:26 AM »
Hello You Z Zero Probe Script Wizards

I have been running Mach3 for some time now and have recently made a Z Zero spring loaded probe which is placed on top of the stock. The script I made is partly from what I could find on the forums, but I have modified it to make it more safe and take different dimensions into account.

My problem is that the script runs very nicely and sets Z zero correctly the first 2 or 4 times.

After these successful zeroing of the router bit the script/Mach3 fails. What happens is that the router bit stops when making electrical contact to the probe, then waits a little bit and then continues down and I have to quickly press the Emergency stop. (I'm happy that I made a spring loaded zero probe!)

The error now sticks and no mater what I do, load new G-Code file etc., every time I click "Auto Tool Zero" the router bit stops when making contact and then continues down into the spring loaded probe.

It gets even worse. Once the error occurs, it will stick and Mach3 seems to overwrite variables including X and Y position on the CNC table. Mach3 goes down and takes Windows down too. A reboot of Windows is necessary. Once rebooted, Mach3 works again including the "Auto Tool Zero" function until it has been used 2 to 4 times.

I know that it is not a probe contact issue. I just build a electronic circuit which will remove any contact bounces. It is a retriggerable monostable pulse generator. 

I run Mach3 version: 3 0043 066

As my work requires several changes of router bits this problem is quite annoying, so I would appreciate any help.

Please see my script included in this post:


'Z Zero Probe Script 20180215 KOU
'Place the Z Probe on top of the stock
'Z = 0 will be set on top of the stock after the routine finishes successfully

Option Explicit

Dim ZProbeThickness As Double
Dim ZProbePos As Double
Dim MaxMove As Double
Dim ZRetract As Double

ZProbeThickness = 18.1                   'Init Z Probe thickness in mm
MaxMove = -20.0                     'Init the maximum distance the Z Axis will move during G31
ZRetract = 30.0                     'Init Z Retract Height in mm. OBS: must be lager than Probe Thickness

If GetOemLed(825)=0 And ZRetract > ZProbeThickness + 5.0 Then   'If the Z Probe is grounded then skip the Z Zero routine
   DoOEMButton(1010)                'Zero Z Axis. The Z axis will start to move from this position
   Code "G4 P0.5"                   'Wait 0.5 sec before routine continues
   Code "F100"
   Code "G31 Z" &MaxMove               'Straight Probe Move, Z Axis will start to move MaxMove down or
                        'until it touches Z Zero Probe at Speed F********* 
   
   While IsMoving() = 1                'Wait until Z Axis touches the Z Zero Probe
      Sleep(50)               'Sleep in 50ms to let the Z Axis advance
   Wend
   
   ZProbePos = GetVar(2002)            'Set ZProbePos = the exact Z position where the Z Probe was hit
   
   'Message "ZProbePos = " &ZProbePos         'Check and display ZProbePos
   'Code "G4 P5"                  'Wait so I can read the value     

   If ZProbePos > MaxMove + 0.5 Then         'Safety margin of 0.5mm so that Zero Probe is within proper reach
      Code "G01 Z" &ZProbePos            'Step back to this point as there might be a slight overrun
   
      While IsMoving() = 1            'Wait until Z Axis is at the exact Zero point
         Sleep(50)            'Sleep in 50ms to let the Z Axis advance
      Wend
   
      SetOEMDRO(802, ZProbeThickness)         'Set the Z Axis DRO to the exact Z Probe Thickness
      
      
      'Message "ZProbeThickness = " &GetOEMDRO(802)      'Check and display ZProbePos
      'Code "G4 P5"                  'Wait so I can read the value 
      
      
      Code "G4 P0.25"             'Wait for DRO to update
      Code "F1000"
      Code "G01 Z" &ZRetract             'Move the Z Axis up to ZRetract mm above the Stock at Speed F*********
      Message "Z Axis is zeroed at Stock Top"      'Write message in the status bar
   Else
      Speak "Error"
      Code "G4 P1"      
      Code "F1000"
      Code "G01 Z" &ZRetract            'Move the Z Axis up to ZRetract mm above the Stock at Speed F*********
      Message "Error: Router Bit started too high above the Z Probe!"
   End If

Else
   Speak "Error"
   Message "Error: Z Probe is activated, Z Zero routine aborted!" 'Display error message in Status Bar
End If

Offline Tweakie.CNC

*
  • *
  •  9,279 9,279
  • Super Kitty
Re: Z Zero Probe problem with script
« Reply #1 on: February 21, 2018, 10:36:29 AM »
There are known issues with version .066 and this could be causing the problem.

Try version .062 (which can be installed over the top of your existing version). ftp://anonymous:guest@ftp.machsupport.com/Mach3/Mach3Version3.043.062.exe

Tweakie.
PEACE
Re: Z Zero Probe problem with script
« Reply #2 on: February 22, 2018, 06:22:24 AM »
Hello Tweakie
Thanks for the help!

In version 3.043.066 I tried to modify my script so that it no longer used the G31 command, but as I see it the "Auto Tool Zero" execution is somewhat unpredictable and in some cases over writes variables like X and Y positions.

I then installed version 3.043.062 as you suggested and with the amount of testing done so far it works a lot better. Should I see the "old" problem again, I will return and post the results.

Again thanks for your help!

LSGuy 

Offline Tweakie.CNC

*
  • *
  •  9,279 9,279
  • Super Kitty
Re: Z Zero Probe problem with script
« Reply #3 on: February 22, 2018, 06:36:43 AM »
Hi LSGuy,

I have never had any problems using the G31 command ( my Auto Tool Zero is probably used >100 times a day ) but over the years many have reported difficulties of one sort or another. I don't think the exact reason for these problems will ever be discovered but I would be interested to hear from you if your problems return.

Tweakie.
PEACE