As you all know Mach3 software has G31 function for probing. Using this function we can do precise tool length measurement or determine a location of an edge of our workpiece on a work table. Since plugin version 2.200 (2014-02-13) you can perform probing using M31 macro.
Probing with M31 macro is done mainly by CSMIO/IP motion controller as an internal function. M31 macro can be freely extended and modified as you wish, what gives an user great opportunities. To make it easier to do please look at the description of M31 construction and operation rules.
M31 macro mechanism of operation
Principle of operation of the macro is very easy – it’s to transfer the „P”, „Q” and „R” parameters to the plugin and wait for probing finish.
M31 macro construction
The construction of the macro is decribed in paragraphs for better understanding and so you can use it further in your own projects.
1) Declaration of local variables
2) „P”, „Q” and „R” parameters read out transfered by „Param” function to the macro.
The „Param” function task is to get from „MDI” line or from g-code the „P”, „Q” and „R” parameters and to pass them to the macro, specifically to „Parg, Qarg, Rarg” variables.
A detailed description of the “Param” function you can find in this document:
http://www.machsupport.com/wp-content/uploads/2013/02/Mach3_V3.x_Macro_Prog_Ref.pdf
pages 58-59.
3) „M31 START” information display in a „STATUS” line of Mach3 software.
4) „Parg, Qarg, Rarg” variables value transmission to the plugin through the UserDRO 1511, 1512 i 1513. (Remember to not use the UserDRO mentioned above for other purposes, as it may cause unexpected probing function behavior.)
5) Issue a command for probing start to the plugin.
6) UserDRO 1510 reset and waiting for probing end in a „While” loop.
UserDro 1510 was used to inform the macro through the plugin about current stage of probing.
When UserDro 1510 is 0, it means that the probing still lasts and the macro waits for probing end in a „While” loop.
7) When UserDro 1510 value is 1, it means that probing was succefully completed and waiting in a „While” loop was stopped. As a result the „STATUS” line of Mach3 software displays „M31 Probe hit.” information, which will be displayed for 1 second.
8) When UserDro 1510 value is 2, it means that probing failed and waiting in a „While” loop was stopped. As a result the „STATUS” line of Mach3 software displays „M31 Probe end. (no hit)” information and the macro ends.
9) Probing results data reading from Var system variables and their transmission to local variables X_SENS, Y_SENS and Z_SENS (CSMIO/IP uses the same Var system variables to store probing results as G31 function).
10) Probing results information display in the „STATU” line of Mach3 software.
VB macro operation parameters setting
The M31 macro has four parameters with which we can define probing operation way.
M31 P… Q… R… F…
P – the distance (incremental), that X axis can overcome during probing
Q – the distance (incremental), that Y axis can overcome during probing
R – the distance (incremental), that Z axis can overcome during probing
F – probing feedrate
I used the “incremental” word because M31 macro as opposed to the G31 runs probing on specified distance.
For example, if we want to run probing in Z axis on 50 mm distance in the axis negative direction then we have to set the macro parameters as follows: M31 P0 Q0 R-50 F100.
Note that the P and Q parameters have 0 value, what for incremental motion means that these axes do not move. The R parameter has -50 value, it means that only the Z axis will run probing on 50mm distance in the axis negative direction.
For more vistit Download: Macro section