------------------ Center OUTSIDE Touch Functions --------------------- function TouchCenterOutside0() -- Center Outside With Z (COM EIXO Z) --WWW.MACHSUPORTE.COM.BR --INIT VARS Zsafe = 60.0 -- ALTURA DE SEGURANCA P/ MOVIMENTO RAPIDO Zprobe = 0.0 -- ALTURA DE LEITURA DO PROBE DiamenterAprox = 180 DiamenterOffset = 10 GetMachPos('X') GetMachPos('Y') DiameterTravelPos = ( (DiamenterAprox / 2) + DiamenterOffset ) DiameterTravelNeg = ( (DiamenterAprox / 2) + DiamenterOffset ) * (-1) Code(string.format('G92 Z' .. Zprobe)) --Set Zprobe as current Code(string.format('G90 G0 Z' .. Zsafe)) --Move to Z-Safe Code(string.format('G90 G0 X0 Y0')) --X Moves --XNeg Code(string.format('G90 G0 Z' .. Zsafe)) --Move to Z-Safe --Code(string.format('G90 G0 X0')) Code(string.format('G90 G0 X' .. DiameterTravelNeg)) Code(string.format('G90 G0 Z' .. Zprobe)) TouchOff('X', 1) -- Do a touch move in the X positive direction local Pos11 = mc.mcAxisGetProbePos(inst, mc.X_AXIS, 1) --Get the probe position in machine coordinates --XPos Code(string.format('G90 G0 Z' .. Zsafe)) --Move to Z-Safe --Code(string.format('G90 G0 X0')) --Move back to start position Code(string.format('G90 G0 X' .. DiameterTravelPos)) Code(string.format('G90 G0 Z' .. Zprobe)) TouchOff('X', -1) -- Do a touch move in the X negative direction local Pos12 = mc.mcAxisGetProbePos(inst, mc.X_AXIS, 1) --Get the probe position in machine coordinates Code(string.format('G90 G0 Z' .. Zsafe)) --Move to Z-Safe --Calculate CenterX local XCenterOut = (Pos11 + Pos12) / 2 Code(string.format('G90 G53 X' .. XCenterOut)) --Move to CenterX position --Y Moves --YNeg Code(string.format('G90 G0 Z' .. Zsafe)) --Move to Z-Safe --Code(string.format('G90 G0 Y0')) Code(string.format('G90 G0 Y' .. DiameterTravelNeg)) Code(string.format('G90 G0 Z' .. Zprobe)) TouchOff('Y', 1) -- Do a touch move in the Y positive direction local Pos21 = mc.mcAxisGetProbePos(inst, mc.Y_AXIS, 1) --Get the probe position in machine coordinates --YPos Code(string.format('G90 G0 Z' .. Zsafe)) --Move to Z-Safe --Code(string.format('G90 G0 Y0')) Code(string.format('G90 G0 Y' .. DiameterTravelPos)) Code(string.format('G90 G0 Z' .. Zprobe)) TouchOff('Y', -1) -- Do a touch move in the Y negative direction local Pos22 = mc.mcAxisGetProbePos(inst, mc.Y_AXIS, 1) --Get the probe position in machine coordinates Code(string.format('G90 G0 Z' .. Zsafe)) --Move to Z-Safe --Calculate CenterY local YCenterOut = (Pos21 + Pos22) / 2 Code(string.format('G90 G53 Y' .. YCenterOut)) --Move to CenterY position mc.mcCntlSetLastError(inst, 'Moving to Center.') -- Tell the operator we are moving to the center. --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