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