Adding an Auto Z Zero probe macro for Mach3
I wanted to implement the Auto Z Zero probe upgrade for the Kronos KRMx02, but didn’t want to use the XBox360 controller (which is how Michael implemented it). This post explains how I modified the KRMx02 MACH3 screen to run the macro using the (not implemented) “Auto Tool Zero” button on the main MACH3 screen (in the KRMx02 profile).
Note that the probe construction and wiring are not covered here: For this, you could buy the KRMx02 Upgrades book. Or you can figure it out yourself; it’s not rocket science. Just note that when input terminal 3 on the G540 gets a ground signal, it means the tool bit has touched the probe plate. Also, make sure you have a backup copy of your “KRMx02.set” file somewhere, just in case.
I also modified the macro a little, using modern versions of some commands, adding more extensive comments, and modifying some of the specific parameters like probe speed and depth. You’ll at least want to set the Plate Thickness value! The macro is included below: Copy the text, paste it into a file named “M910.m1s” and put it into the “C:\Mach3\macros\KRMx02\” subdirectory (assumes default locations).
Second step is to edit the existing screen set. Use “MachScreen” from Klaus Dietz (Google it), load the program onto your computer, run it and load the KRMx02.set file. Move the “MachScreen properties” window off to the side.
Single-click on the “Auto Tool Zero” button (in the “Tool Information” area of the Program Run screen) and, in the dialog window that opens (“MachSreen” <sic>) single-click on the “button” line. In the MachScreen properties window, set the Button parameters as follows:
Global: No
Function: Execute Basic-Script (Find this near the bottom of the list in the “Std” section when you double-click the value. Double-click again to ‘save’ it)
Standard Code: 34 (This should come up automatically when the above is selected)
Hotkey: (I left this blank, but you can pick a key value, such as 119 which is the “F8” key)
Execute Code: Code “m910” (Use “File > Open file” to select the macro file on your computer. Once you see the text of the macro you can close that window. Answer “Yes” to “Include data to screen set”)
Text on ctrl: Auto Tool Zero (Leave it as it is, trust me)
Locked for mouse: No
SAVE the screen set file and close MachScreen.
Now when you open your KRMx02 profile for Mach3, the “Auto Tool Zero” button will start the probe down auto-zero process.
Here is the macro “M910.m1s”
Code:
Rem Auto Z Zero with Probe 'Orig. Written by Michael Simpson, re-written by Don N2 IRZ 30DEC2014
If GetOemLed (825) <> 0 Then 'check probe first see if it is grounded
Code "(Probe Grounded, check connection and try again)" 'Status Bar display
Else
Code "(Probe Down)" 'Status Bar display
Code "G4 P1" 'Pause for a second
PlateThk = .375 'Thickness of probe plate in inches
SaveFeed = GetOemDRO(818) 'Store the current feed rate
'------------------------------------------------------------------------------
'Fast Probe Down
Code "F8" 'Set the Fast feed rate to 8 IPM
ZNew = GetOEMDRO(802) - 7 'Get Z axis value, subtract 7 to set ZNew target for maximum probe depth
'7 is the maximum Z axis movement and then some, you may decide to use a smaller value
Code "G31Z" &ZNew 'Perform a G31 probe down to ZNew
While IsMoving()
Wend
Code "(Touch Down.. Backup)" 'Status bar display
ZNew = GetVar(2002) +.1 'read the touch G31 Response (probe value for z aka 2002) Z and add 0.1, set ZNew to this value
Code "(Z=" &ZNew &")" 'Status bar display?
Code "G0 Z" &ZNew 'move back to ZNew
While IsMoving ()
Wend
Code "(Brief Pause)" 'Status bar display
Code "G4 P5" 'Wait 5 seconds in case of problems
'------------------------------------------------------------------------------
'Slow Probe Down
Code "F2" 'Set the feed rate to 2 IPM
ZNew = GetOEMDRO(802) - .25 'Set the ZNew target to 0.25 inches below current reading
Code "G31Z" &ZNew 'Perform G31 probe down to ZNew
While IsMoving()
Wend
Code "(Slow Touch)"
ZNew = GetVar(2002) 'Read the touch G31 response
Code "G0 Z" &ZNew 'Move to ZNew with G0
While IsMoving ()
Wend
'----------------------------------------------------------------------------
'Set Dro
Call SetOEMDRO(802, PlateThk) 'Sets the Z DRO reading to plate thickness
Code "G4 P0.5" 'Pause 1/2 second for DRO to update
ZNew = PlateThk + 0.8 'Set ZNew to current plus 0.8 inches (retract distance)
Code "G0 Z" &ZNew 'Retract to ZNew (the retract amount)
While IsMoving ()
Wend
Code "(Z axis is now zeroed)" 'Status bar message
Code "F" &SaveFeed 'Resets the feed rate to what it was
End If
Have fun and post here with your results!
Re: Adding an Auto Z Zero probe macro for Mach3
Old post, but new to this part of the forum. Looking at building a Kronos machine. Excellent info. Thanks.
Re: Adding an Auto Z Zero probe macro for Mach3
Got it going but when it touches off It sets a large neg number (-11.5098) and runs Z up to the limit switch and I get a limit error.
I use Big Tex Blue Screen Set with the Probe built in and the touch off works flawless using a hotkey for it on my controller.
My Machine is grounded with my touch plate is on pin 15 Input.
Re: Adding an Auto Z Zero probe macro for Mach3
Got a Macro working, here is what worked for me:
I believe if you are using Big Tex Blue Screen Set you must use the same script (M920.m1s).
M910.m1s Probably works with other screen sets.
M920.m1s
Code:
Rem VBScript To probe In the z axis
If GetOemLED(801) Then 'check if English Units
If GetOemLED(16)<>0 Then 'Checks for machine coordinates
code "(Please change to working coordinates)"
Else
If GetOemLed (825) <> 0 Then 'check to see if the probe is already grounded or faulty
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
Else
Code "G4 P1" 'pause 1 seconds to give time to position probe plate
PlateOffset = GetUserDRO(1151) 'get plate offset DRO
CurrentFeed = GetOemDRO(818) 'get the current feedrate to return to later
Code "F10" 'slow down feedrate to 10 ipm
Rem Probe In the z direction
ZNew = GetDro(2) - 6 'probe move to current z - 6 inches
Code "G31Z" &ZNew
While IsMoving() 'wait for probe move to finish
Wend
ZNew = GetVar(2002) 'read the touch point
Code "G0 Z" &ZNew +.1 'move back +.1 to hit point incase there was overshoot +.1
While IsMoving ()
Wend
Rem End add lines
Code "F2" 'slow down feedrate to 2 ipm
ZNew = GetDro(2) - .25 'probe move to current z - .25 inches
Code "G31Z" &ZNew
While IsMoving() 'wait for probe move to finish
Wend
ZNew = GetVar(2002) 'read the touch point
Code "G0 Z" &ZNew 'move back to hit point incase there was overshoot
While IsMoving ()
Wend
If PlateOffset <> 0 Then
Call SetDro (2, PlateOffset) 'set the Z axis DRO to plate thickness
Code "G4 P0.25" 'pause for Dro to update.
'ZNew = PlateOffset + 3.6315 'calc retract
'Code "G0 Z" &ZNew 'put the Z retract height you want here
Code("G53G0Z-0.5") 'Z retract
While IsMoving ()
Wend
Code "(Z axis is now zeroed in English Units)" 'puts this message in the status bar
End If
Code "F" &CurrentFeed 'returns to prior feed rate
End If
End If
Else 'This portion of script is for Metric Native Units
If GetOemLed (825) <> 0 Then 'check to see if the probe is already grounded or faulty
Code "(Z-Plate is grounded, check connection and try again)" 'this goes in the status bar if aplicable
Else
Code "G4 P1" 'pause 1 seconds to give time to position probe plate
PlateOffset = GetUserDRO(1151) 'get plate offset DRO
CurrentFeed = GetOemDRO(818) 'get the current feedrate to return to later
Code "F300" 'slow down feedrate to 300 mmpm
Rem Probe In the z direction
ZNew = GetDro(2) - 150 'probe move to current z - 150 mm
Code "G31Z" &ZNew
While IsMoving() 'wait for probe move to finish
Wend
ZNew = GetVar(2002) 'read the touch point
Code "G0 Z" &ZNew + 3 'move back + 3 mm to hit point incase there was overshoot + 3 mm
While IsMoving ()
Wend
Rem End add lines
Code "F50" 'slow down feedrate to 50 mmpm
ZNew = GetDro(2) - 6 'probe move to current z - 6 mm
Code "G31Z" &ZNew
While IsMoving() 'wait for probe move to finish
Wend
ZNew = GetVar(2002) 'read the touch point
Code "G0 Z" &ZNew 'move back to hit point incase there was overshoot
While IsMoving ()
Wend
If PlateOffset <> 0 Then
Call SetDro (2, PlateOffset) 'set the Z axis DRO to plate thickness
Code "G4 P0.25" 'pause for Dro to update.
'ZNew = PlateOffset + 50 'calc retract
Code("G53G0Z-12")
'Code "G0 Z" &ZNew 'put the Z retract height you want here
While IsMoving ()
Wend
Code "(Z axis is now zeroed in Metric units)" 'puts this message in the status bar
End If
Code "F" &CurrentFeed 'returns to prior feed rate
Code "F200"
Sleep 100
End If
End If
Re: Adding an Auto Z Zero probe macro for Mach3
Due to issues with Windows 10 and UC100 and UC300ETH issues, I have started moving away from the Xbox controllers as jog interfaces. There are other options that work better. When I implement a probe now, I assign it to one of the programmable Mach 3 buttons.
Step 1
Under the operator menu, select VB Button Editor.
Step 2
I select the Auto Tool Zero button.
Step 3
Paste VB script Code and save.
I also use one of the wireless shuttle jog controllers. It has a Probe Z button and I assign the same macro to that button as well.
Note that the KRmx02 screen set has an indicator for testing the probe. If you use another screen set, it may not have probe indicator LED. In addition you may have to modify the script.