------------------ Center INSIDE Touch Functions --------------------- function TouchCenterInside0() -- Center Inside No Z (SEM EIXO Z) --WWW.MACHSUPORTE.COM.BR --INIT VARS GetMachPos('X') GetMachPos('Y') Code(string.format('G90 G0 X0 Y0')) TouchOff('X', -1) -- Do a touch move in the X negative direction local Pos1 = mc.mcAxisGetProbePos(inst, mc.X_AXIS, 1) --Get the probe position in machine coordinates Code(string.format('G90 G0 X0 ' .. 'F ' .. ToffPrepRate)) --Move back to start position TouchOff('X', 1) -- Do a touch move in the X positive direction local Pos2 = mc.mcAxisGetProbePos(inst, mc.X_AXIS, 1) --Get the probe position in machine coordinates --Calculate CenterX local XCenterIn = (Pos1 + Pos2) / 2 Code(string.format('G90 G53 X ' .. XCenterIn .. 'F ' .. ToffPrepRate)) --Move to CenterX position TouchOff('Y', -1) -- Do a touch move in the Y negative direction local Pos3 = mc.mcAxisGetProbePos(inst, mc.Y_AXIS, 1) --Get the probe position in machine coordinates Code(string.format('G90 G0 Y0 ' .. 'F ' .. ToffPrepRate)) --Move back to start position TouchOff('Y', 1) -- Do a touch move in the Y positive direction local Pos4 = mc.mcAxisGetProbePos(inst, mc.Y_AXIS, 1) --Get the probe position in machine coordinates --Code(string.format('G90 G53 Y ' .. YMach .. 'F ' .. ToffPrepRate)) --Move back to start position --Calculate CenterY local YCenterIn = (Pos3 + Pos4) / 2 Code(string.format('G90 G53 Y ' .. YCenterIn .. 'F ' .. ToffPrepRate)) --Move to CenterY position --Move to CenterXY mc.mcCntlSetLastError(inst, 'Moving to Center.') -- Tell the operator we are moving to the center. Code(string.format('G90 G53 G' .. ToffProbeCode .. 'X' .. XCenterIn .. 'Y' .. YCenterIn .. 'F' .. ToffPrepRate)) -- Do a probe move to XCenter YCenter (machine coordinates) at the prep rate --Now that we are at the center lets zero out our work coordinates rc = mc.mcAxisSetPos(inst, mc.X_AXIS, 0.0000) rc = mc.mcAxisSetPos(inst, mc.Y_AXIS, 0.0000) GetFixOffsetValues() mc.mcCntlSetLastError(inst, 'Touch combination is finished. X axis set to ' .. XSet .. ' Y axis set to ' .. YSet) --Tell the operator what the work offset values are. mc.mcCntlGcodeExecute(inst, string.format('G ' .. m_CurAbsMode .. '\nF ' .. m_CurFeed)) --Set mode and feed back end