Skip to content

MACH3 scripts for probing with guard features

DISCLAIMER: The scripts described at this page are dedicated to the concrete machine and must be reconfigured and tested if used for any purpose. Author does not take any responsibility for any damage, injury or lost caused by using of this sources.

DISCLAIMER: The scripts are published and shared for free and are not a part of any sold item by any selling channel. User is allowed to download, modify and share the scripts. Author does not guarantee, that scripts will work to your system. Any ordered item can not be claimed based on fact, that these scripts do not work in the customer’s system.


MACH3 has a rich scripting system, which allows you to realize a lot of additional functions to your machine. Scripts are written in language based on VBA (Visual Basic for Application) and implements a lot of the functions. Even if the MACH3 script editor has sometimes little bit strange behavior, it is the powerful tool for programming the extra features for your machine.

This article does not explain how to program or modify the scripts. If you are interested of that, let me know, and I can touch this topic in some of the next articles. In this article is described way, how to use the prepared scripts, dedicated to probing in MACH3.

These scripts can be connected also with the Simple MACH3 screen set for a router or 3axis milling machine.


Specification:

  • MACH3 scripts prepared for probing with these devices:
  • debugged in MACH3 Version R3.043.062. In case of older version can happen, that some features may not work.

Download:

If you are interested in MACH3 programming manual, you can download it here:

https://www.machsupport.com/wp-content/uploads/2013/02/Mach3_V3.x_Macro_Prog_Ref.pdf

You can be also interested in the list of all OEM codes of Buttons, LEDs and DROs, which can be used in the scripts and screen set modificaion:


How to install the macros:

  1. backup your MACH3 folder with all subfolders to be able to return back, if something happens 🙂
  2. download and unpack the file from the download section (above)
  3. copy all files from the “macros” folder to your current profile script folder “…Mach3/macros/profilename/

List of the macros

FilenameDescription
common_defs.m1sCommon definitions for all other macros. This file is linked to the other macros and is a source for configuration.
common_subs.m1sCommon subroutines for all other macros. Contains subroutines, which realize the basic functions. This file is linked to the other macros.
M500.m1smacro for “GoTo home in Z axis” (go to machine Z=0)
M501.m1smacro for “GoTo home in all axis” (go to machine X=0, Y=0, Z=0)
M542.m1smacro for the measurement of a surface reference to a fixed TLS
M543.m1smacro for the measurement of a tool length by a fixed TLS
M555.m1smacro for the measurement of a tool length by a hand operated TLS
M556.m1smacro for all probing functions by a probe

Common definitions (common_defs.m1s)

This macro file contains the common configuration. It must be configured according your system.

'definition of the named constants, do not change these lines.
Const relative=1
Const absolute=2
Const machine=3

'if you use SMART.MER/2 or SMART.GUARD, you need to define the outputs for guard blocking functions
'if guard blocking functions are not used, define some not used/configured output
Const ProbeLockOutput=OUTPUT5             'output is activated when measured by a probe
Const ManTLSLockOutput=OUTPUT5            'output is activated when measured by a hand operated TLS
Const FixTLSLockOutput=OUTPUT6            'output is activated when measured by a fixTLS

'notice, that outputs for a probe and hand operated TLS are the same. It is because I use both with magnetic connector, which share the same channel at SMART.MER/2 

'this option enables/disables using the feature, which block multi-start of the macro, when the same macro is already running.
Const UseMacroMultiStartBlocking=false

'these options enable/disable start probing or measurement by TLS by a hardware button. It is useful, when you start a functions by the button in the software and than you need a time to move to machine. So you can use hardware button connected to dedicated input. If you use this function, button input must be defined.
Const UseButtonForManTLS=true	  'macro M555
Const UseButtonForAutoTLS=false   'macro M542, M543
Const UseButtonForProbing=false   'macro M556 
Const ButtonInput=INPUT1

'Absolute position (machine coordinates) of fixed TLS (if used)
Const FixTLSX=346
Const FixTLSY=222

'Switching points of Fixed and Hand operated TLS (measured from the bottom surface to the switching point)
'Const FixTLSheight=25.1   'not used in the macros
Const HandTLSheight=23.53

'constants of measurement types for M556 macro. Do not change these lines
Const TypeLeftBottom=1
Const TypeLeftTop=2        'not implemented 
Const TypeRightBottom=3    'not implemented
Const TypeRightTop=4       'not implemented
Const TypeZ=5              'not implemented
Const TypeLeft=6           'not implemented
Const TypeRight=7          'not implemented
Const TypeBottom=8         'not implemented
Const TypeTop=9            'not implemented
Const TypeCenter=10
Const TypeInnerLeftBottom=11

common_subs.m3s

This macro file contains the common subroutines linked to the other macro files.

FunctionDescription
Function IsProbeInputActive() As BooleanReturns true, when probe input is active, false when is inactive. This function is used for checking, if probe is ready.
Sub WhileIsMoving()Realizes waiting, till a machine finishes all movements. When the routine is called, macro is blocked, till the movement is finished. This function is very important for macro synchronization.
Sub ProbeGuardBlock(state As Boolean)Enables/disables MC output for blocking of guard function for a probe.
Sub FixTLSGuardBlock(state As Boolean)Enables/disables MC output for blocking of guard function for a fixed TLS.
Sub ManTLSGuardBlock(state As Boolean)Enables/disables MC output for blocking of guard function for a fixed TLS.
Sub SlowMoveNoWait(cmd As String, feed As Integer, coordmode As Integer)This function generates G-code for movement by defined feedrate, but does not wait till the movement is finished.
coordmode can be selected in between machine, workpiece-relative or workpiece-absolute coordinates.
Sub SlowMove(cmd As String, feed As Integer, coordmode As Integer)The same like the previous one, but this function block the script execution till the movement is finished.
Sub RapidMoveNoWait(cmd As String, coordmode As Integer)This function generates G-code for rapid movement, but does not wait till the movement is finished.
coordmode can be selected in between machine, workpiece-relative or workpiece-absolute coordinates.
Sub RapidMove(cmd As String, coordmode As Integer)The same like the previous one, but this function block the script execution till the movement is finished.
Function Probe(cmd As String, feed As Integer, coordmode As Integer) As BooleanThis function manages all probing processes (by a probe and TLS also). Returns true, when probing process is finished correctly.

Programming examples

Using the subroutines for movement

'move in the speed of 1000mm/min, +10mm in Zaxis, relative from the current position and wait till the movement is finished
SlowMove "Z+10", 1000, relative

'move to absolute workpiece position X=10, Y=-5, and wait till the movement is finished
SlowMove "X+10 Y-5", 500, absolute

'move relative from the current position Z+3, than X-10, than Z-5. Macro generates the G-codes, but does not wait till the movements are finished
RapidMoveNoWait "Z+3", relative
RapidMoveNoWait "X-10", relative
RapidMoveNoWait "Z-5", relative

'now you can wait till all these movements are finished
WhileIsMoving 

'probe in X axis, maximum 30mm, by 100mm/minute, relative from the current point
Probe "X+30",100, relative 
'Probe function everytime waits, till the probing is finished. Machine stops, when a probe/TLS is touched.