2012-03-27 17:41:50 (CET)

Tool measurement macro

 Under user menu button 2 you'll see this: ;Tool length measurement example
Sub user_2

   goSub m_tool ;See sub m_tool

Endsub

 The user 2 button calls subroutine m_tool.

This subroutine needs a few values that are stored:

#4996  Z coordinate at tool change safe height
#4997  X coordinate for tool change
#4998  Y coordinate for tool change
#4999  Z coordinate at tool length equals zero or calibration tool height.
 Tool #16 is used as reference tool and should have filled in its tool length before you start. This tool length can be 0 if you use the tool-chuck itself instead of a calibration tool.
  The values #4996 .. #4999 are to be determined once. This can be done using the calibrate_tool_setter function below.  Make sure the machine is homed before you start this.
your action machine message

Open MDI and type :

gosub calibrate_tool_setter

 

Press enter to execute.

 

Close the MDI window using F6, Go to the tools tab and check the tool length of tool 16. For me it is 0 because I use the tool chuck without calibration tool.

 

Press save changes. and go back to the operate tab.

 

The program is still inside subroutine       calibrate_tool_setter.

Press RUN to continue.

 
 

Do what the message says:

Jog Z to safe height.

In my case this is completely up.

Press RUN to continue

 
 

Do what the messages says:

Insert the calibration tool if you have one, or just leave the tool chuck empty.

Jog using X, Y, Z just above the tool setter.

 

When done jogging, press RUN.

 

The machine will move down to touch the tool setter, The measured tool-chuck height is stored into #4999.

Then the Z is moved up to safe height.

 

  

 

Calibration DONE

 

We need to do this only once.

 

You need to do this again if you have changed something that influences the calibrated data.

 

 

 

Press USER BUTTON 2.

The machine moves to safe height. The dialog is shown:

 

Type correct values for tool number, tool length and diameter.

Press OK.

The machine moves to the correct X,Y The machine moves 10 mm above the tool setter.

 

So make sure the approx tool length above is OK.

 

The machine does the move towards the tool setter, Then calculates and stores the values.

 

Then machine moves Z to safe height.

  Tool Length measurement Complete.
  

Sub calibrate_tool_setter

   warnmsg "close MDI, check correct calibration tool nr 16 data in tool table"

   warnmsg "jog to toolchange safe height, when done press RUN"

   #4996=#5073 ;Store toolchange safe height machine coordinates

   warnmsg "insert calibrationtool 16 length=" #5416 ", jog just above tool setter, when done press RUN"

   ;store x y in non volatile parameters (4000 - 4999)

   #4997=#5071 ;machine pos X

   #4998=#5072 ;machine pos Y

   ;Determine minimum toochuck height and store into #4999

   g38.2 g91 z-20 f30

   #4999=[#5053 - #5416] ;probepos Z - calibration tool length = toolchuck height

   g90

   g0 g53 z#4996

   msg "calibration done safe height="#4996 " X="#4997 " Y="#4998 " Chuck height="#4999

endSub

 

sub m_tool

   ;Check if toolsetter is calibrated

   if [[#4996 == 0] and [#4997 == 0] and [#4998 == 0] and [#4999 == 0]]

       errmsg "calibrate toolsetter first open mdi, enter gosub calibrate_tool_setter"

    else

       g0 g53 z#4996 ; move to safe z

       dlgmsg "enter tool dimensions" "tool number" 5016 "approx tool length" 5017 "tool diameter" 5018

 

       if [#5398 == 1];user pressed OK

            if [[#5016 < 1] OR [#5016 > 15]]

              ErrMsg "Tool must be in range of 0 .. 15"

           endif

    

           ;move to toolsetter coordinates

           g00 g53 x#4997 y#4998

           ;move to 10mm above chuck height + approx tool length + 10

           g00 g53 z[#4999+10+#5017]

           ;measure tool length and pull 5mm back up

           g38.2 g91 z-20 f30

           g90

           ;back to safe height

           g0 g53 z#4996

           ;Store tool length, diameter in tool table

           #[5400 + #5016] = [#5053-#4999]

           #[5500 + #5016] = #5018

           #[5600 + #5016] = 0 ;Tool X offset is 0

           msg "tool length measured="#[5400 + #5016]" stored at tool "#5016

       endif

   endif

endsub