How To Use The Tool Touch Macro
How To Use The Tool Touch Macro
Automatic tool setting is a powerful routine that will really improve the speed and
accuracy of your CNC work.
Configure Mach 2 to accept a digitize input on your inputs page, and set the correct input
pin assignment for your digitizer. The digitizer can be NC or NO and can trigger the
input signal “high” or “low”.
Your digitizer can be as simple as a NC electric switch or inductive proximity sensor, but
for accurate and repeatable touch off (.001”) you will need a touch probe like the one
shown in the photo. The touch probe sends an open circuit signal to Mach 2 whenever
the contact is broken by your tool touching the switch.
This can also be accomplished by simply attaching a wire to your work and to the tool.
When the two come together they will close the electric circuit and send the signal to the
control. Be aware however that if you are doing this the tool must be electrically
insulated from the work and this is not normal on most machine tools. Most machines
will conduct electricity through the entire chassis of the machine. Also be aware that
there is no “give” when your tool touches the work and any error in set up on your part
will result in a broken tool or gouged work or both.
The VB code to execute your tool touch is shown below with a brief explanation of the
functions shown in BLUE. Do not include the BLUE text in your code; it is simply an
explanation of the function of the code.
This text can be written into a button using Mach 2 Screen Designer, or can be used to
create a custom Macro function that can be executed a number of ways. Please consult
Mach 2 documentation for more info on creating Macros or using Screen Designer.
code "G49 g31 z-2 f10" Cancel any tool length offsets and move the tool to Z = -2.0
units at a feed rate of 10 units/time until a digitize signal is detected. Feed-rate is entirely
up to you but make sure it’s not too fast or you will get inaccurate results from your
digitize “touch”. You may want to set G90 or G91 on this line as well. The command
will behave differently if you are in absolute or relative mode. G31 is a probing
command that tells the machine to move in the commanded direction until a “digitize”
input signal is detected.
While IsMoving()
Wend
Height = GetOEMDRO(85) Set the variable “height” equal to the value of the Z axis
position DRO.
Call SetoemDRO(42,Height) Set the Z offset DRO to the value of the variable “height”
This also sets the Z touch value in the Tool Table for the tool that you have selected. Be
careful not to have tool “0” (zero) selected as this can cause some weird problems and the
only way to clear tool zero back to zero offset is to move the machine to machine
coordinates Z=0 and “touch”
code "G49 G54 Z0" Cancel tool length offset and move the tool back to Z = 0.
Depending on what mode you started in and how your Z axis is referenced this may not
be where the tool started from.
While IsMoving()
Wend
end if
CAUTION - READ BELOW!!
1. All motion will be in the ABS or INC mode that you have selected (i.e. G90 or G91).
For instance if the tool is at Z=-3 and you select “auto tool touch” the tool will actually
move up which isn’t much good for tool setting. You may have to experiment with the G
Code in your macro to get the machine to respond correctly for your application.
2. Make sure if you modify the code that you test all code before placing your probe
under the tool. It is very easy to make a mistake here and actually have your tool crash
into the probe and ruin it!! Please test all code safely before putting expensive
components in the way of the tool. The combination of G91 and G90 plus the tool length
offsets can create some confusing situations if you are not 100% familiar and experienced
with how these codes affect your machine. Please read and understand the MACH2
documentation concerning tool length offsets, fixture offsets, and relative and absolute
coordinate systems.
3. Be aware that if your Z axis has not been referenced you may experience some strange
behavior when attempting your automatic tool touch off.