Page tree
Skip to end of metadata
Go to start of metadata

Ниже пример макроса для поиска центра отверстия. Запускать макрос необходимо, когда датчик находится внутри отверстия.

function m154()
   local ProbeFeed = 100
   
   PushCurrentDistanceMode()
   PushCurrentMotionMode()
   
   local CurrX = AxisGetPos(Axis.X)
   local CurrY = AxisGetPos(Axis.Y)
   local CurrZ = AxisGetPos(Axis.Z)
   
   if (IsProbingPinConfigured()) then
      if (PinGetState(Inputs.Probing)) then
         DisplayMessage("Probe input is already active")
         return
      end
      
      local ProbeLim = 1000
      local ProbingMaximum = CurrX - ProbeLim
      ExecuteMDI("G90 G38.2 X"..ProbingMaximum.."F"..ProbeFeed)
      local X1 = AxisGetPos(Axis.X)
      ExecuteMDI("G90 G0 X"..CurrX)
      
      local ProbingMaximum = CurrX + ProbeLim
      ExecuteMDI("G90 G38.2 X"..ProbingMaximum.."F"..ProbeFeed)
      local X2 = AxisGetPos(Axis.X)
      ExecuteMDI("G90 G0 X"..CurrX)
      
      local XC = (X1 + X2) / 2
      
      local ProbingMaximum = CurrY - ProbeLim
      ExecuteMDI("G90 G38.2 Y"..ProbingMaximum.."F"..ProbeFeed)
      local Y1 = AxisGetPos(Axis.Y)
      ExecuteMDI("G90 G0 Y"..CurrY)
      
      local ProbingMaximum = CurrY + ProbeLim
      ExecuteMDI("G90 G38.2 Y"..ProbingMaximum.."F"..ProbeFeed)
      local Y2 = AxisGetPos(Axis.Y)
      ExecuteMDI("G90 G0 Y"..CurrY)
      
      local YC = (Y1 + Y2) / 2
      
      ExecuteMDI("G90 G0 X"..XC.." Y"..YC)
   else
      DisplayMessage("Probe input is not configured")
      return
   end
end

M154.pm