RayL's Edge/Mid-Point/Center Finding and Tool Length Setting Macros

OVERVIEW:

I have created these for my own use, and make no representations whatsoever as
to their correctness.  Use them at your own risk.  These are really not well
suited to novice users!!  If you have problems, you can contact me at
Jagboy@pacbell.net, but my time is very limited, so I may be able to provide
only very limited assistance.

That said, for me, they have worked very well, and been a huge time-saver.

REQUIRED CUSTOMIZATION - READ THIS!!!!:

These macros are based on a set of about a half-dozen Subroutines, which are
embedded in the macros that use as required.  ALL of the Subs of a given name
in ALL of the macros are identical, so if you find it necessary to make any
changes, you can edit a single macro, the copy/paste the modified code into
all other macros that use it.  

By default, these macros use a number of new DROs, which are defined in the
macros themselves.  Each macro that requires any these values contains a Sub named
GetProbeParameters which fetches them from the DROs.  You can modify this one
Sub to get the parameters from another location, or to hard-wire them to fixed
values.  You MUST either add these DROs to your screenset, OR modify the macros
before they will work correctly!!

Most of these macros also make use of an LED, the "ZeroDROOnProbeLED" #1201,
which determines whether the DROs are zeroed to the location of the probed
edge(s).  If this LED is OFF, the DROs are not zeroed.  If this LED is ON, then
the appropriate DROs are zeroed on a successful probe operation.  This allow,
for example, the circle center finding macro, M965, to be used to either set
the current fixture origin to the center of the circle, or simply to position
the spindle to the center of the circle, without modifying the DROs.  You MUST
either add the LED to your screenset, OR modify the macros before they will
work correctly!!  The M970 macro is provided as a means of toggling this LED via
script or an on-screen button if desired.

INSTALLATION:

Copy all the attached macro files to the Mach3\macros\Mach3Mill directory.

Note that your directory *may* not be named Mach3Mill if you are using a profile
with a different name.

The macros are as follows:

The following macros probe various features, and zero DROs as appropriate:

M950 - X axis edge finder, moving in the + direction
M951 - X axis edge finder, moving in the - direction
M952 - Y axis edge finder, moving in the + direction
M953 - Y axis edge finder, moving in the - direction
M954 - Z axis tool length setting, moving in the - direction
M955 - X/Y Left Front corner finder
M956 - X/Y Right Front corner finder
M957 - X/Y Left Rear corner finder
M958 - X/Y Right Rear corner finder
M959 - Vise alignment macro, Vise fixed jaw to the rear, parallel to X axis
M960 - Vise alignment macro, Vise fixed jaw to the front, parallel to X axis
M961 - Vise alignment macro, Vise fixed jaw to the left, parallel to Y axis
M962 - Vise alignment macro, Vise fixed jaw to the right, parallel to Y axis
M963 - Finds mid-point between two edges, moving in X
M964 - Finds mid-point between two edges, moving in Y
M965 - Finds center of circle or pocket

The following macros probe various features, and report measurements, without
zeroing any DROs:

M970 - Utility macro to toggle ZeroDROOnProbeLED (see REQUIRED CUSTOMIZATION)
M971 - Measures X distance from start position to edge in + direction
M972 - Measures X distance from start position to edge in - direction
M973 - Measures Y distance from start position to edge in + direction
M974 - Measures Y distance from start position to edge in - direction
M975 - Measures X distance between two edges
M976 - Measures Y distance between two edges
M977 - Measures diameter of circle or pocket

The edge finding macros will move in the specified direction until the edge is
detected, then zero the axis DRO to the location of the edge, correcting for
the diameter of the probe tip.  Each probe operation is performed in two steps:
First, a high-speed pass, to find the edge quickly, then a low-speed pass to
locate the edge more precisely.  In my tests, these will consistently repeat
to about 0.0001".

The corner finding macros do the same, but in two axes, so the spindle ends
up aligned exactly to the corner.  It will first move the specified "probe
distance" in one axis, to ensure it is alongside the part, before probing.  So,
you must always position within "probe distance" of the corner in both axes, but
to the outside of both axes, before invoking the macro.

The Mid-point finding macros find a edge first in the + direction, then in the
- direction, then move to the exact center between the two, and zero the axis
DRO.  The center finding macro basically does a mid-point find in X, followed
by a mid-point find in Y, so the X and Y axes end up zeroed to the exact center
of the circle or pocket.

The vise alignment macros always reference to the left end of the fixed jaw, and
first do a corner-find, so setup is the same as for a corner find macro.  After
locating, and zeroing both axis DROs, to the corner, it then moves to 1/8" from
the opposite end of the fixed jaw, and again probes.  The amount by which the
opposite end is misaligned is displayed on the status line.  If the vise is
positioned with the jaw parallel to the X axis, and the fixed jaw towards the
back of the machine, position the probe slightly to the left, and slightly
forward, of the left front corner of the fixed jaw before executing the macro.
When the macro completes, if it indicates a misalignment of +0.010", then the
right end of the vise needs to move towards the front of the machine by 0.010".

Any of the above macros can be called by buttons or other scripts, by using the
Mach3 "Code" function.  For example, to configure an on-screen button to do
tool length setting, either configure the button in Screen4 to execute G-code
function "M954", or to use a button script containing the single line:

Code "M954"

