' 'Reset The Machine and Move to Home Position ' Code "M05" 'Turn off Spindle Code "G17" 'XY Plane Select Code "G20" 'Inches Code "G40" 'Cancel Cutter Radius Compensation Code "G49" 'Cancel Tool Length Offset Code "G10 L2 P253 X0 Y0 Z0 A0 B0 C0" 'Zero P253 Fixture Offsets Code "G52 X0 Y0 Z0" 'Cancel Coordinate System Offset Code "G59 P253" 'Cancel Fixture Offsets - Assumes P253=0,0,0 in Mach3 Code "G64" 'Constant Velocity Mode Code "G90" 'Absolute Distance Mode Code "F90" 'Set Feedrate to 90 in/minute Code "G01 Z0" 'Move to Safe Z Position While IsMoving() Wend Code "G01 X0 Y0" 'Move X & Y to Home Position While IsMoving() Wend DoButton(24) 'Home the Z Axis While IsMoving() Wend ' 'The Machine should now be initialized and resting at the Home Position ' ColletHeight = 13.2805 'Set distance between collet and table - A Constant ProbeHeight = 3.25 'Set height of probe - A Constant MaxToolLength = 3 'Set Maximum tool length QuickMove = -ColletHeight + ProbeHeight + MaxToolLength ToolNum = GetOEMDRO(824) 'Get the Current Tool Number Code "F60" 'Set Feed Rate Code "G00 Z" & QuickMove 'Move Z down until it is near the Probe While IsMoving() Wend Code "G31 Z-11 F5" 'Move Z down until probe switch is triggered While IsMoving() Wend Code "G4 P0.1" 'Set Dwell - Pause for 0.1 Seconds Position = GetVar(2002) 'Retreive Z position where probe was triggered 'Calculate the Tool offset ToolOffset = ColletHeight - ProbeHeight + Position SetToolParam(ToolNum, 2, ToolOffset) 'Set the offset in the tool table Code "F60" Code "G01 Z0" 'Move to Safe Z Position While IsMoving() Wend Code "G01 X0 Y0" 'Move X & Y to Home Position While IsMoving() Wend End