Hello Guest it is April 28, 2024, 09:30:43 AM

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Bill_O

211
Mach4 General Discussion / Re: Reference all axiss from M function
« on: May 04, 2021, 11:00:33 AM »
Katz,

I think it would be best to do it like compewter is saying.
Having said that for some of our machines I do a home in script.
It needs to be done as a GCode.
mc.mcCntlGcodeExecute(inst, "G28.1 X0.0")

Bill

212
Mach4 General Discussion / Re: Tool Length Offset Macro Program
« on: May 03, 2021, 02:24:19 PM »
Cbyrdtopper,

I know why you started it after seeing the several posts about tool probing.
I was basically just letting them know there are many ways to do what they wanted.
Yours is much, much easier to start with.
Yes Lua can be a bear for us non programmers but it is well worth the effort to get exactly what you want.

213
Mach4 General Discussion / Re: Tool Length Offset Macro Program
« on: May 03, 2021, 10:25:59 AM »
This is the code I use and it works fine.
This is in my Screen Load Script.
There is a lot of extra stuff in here but go to the section on ATC.

function Surface()
   ----remove max depth cut
   local MaxDepthRegH = mc.mcRegGetHandle(inst, 'iRegs0/MaxDepth')
   mc.mcRegSetValue(MaxDepthRegH, -22.0)
   mc.mcCntlSetParameter(1801, -22.0)
   --set extra cut depth to 0 and turn off leds
   local Extrareg = mc.mcRegGetHandle(inst, 'iRegs0/ExtraDepth')
   mc.mcRegSetValue(Extrareg, 0.000)
   mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Z, 0.000)
   scr.SetProperty('led010', 'Value', '0')
   scr.SetProperty('led030', 'Value', '0')
   scr.SetProperty('led050', 'Value', '0')
   --set surface register to 0
   hreg = mc.mcRegGetHandle(inst, 'iRegs0/SurfSet')
   mc.mcRegSetValue(hreg, 0)
   --turn surface set led off
   scr.SetProperty('ledSurfaceSet', 'Value', '0')
   --get sm on or off register
   local SMReg = mc.mcRegGetHandle(inst, 'iRegs0/SMOnOff')
   local SMRegVal = mc.mcRegGetValue(SMReg)
   --set to project coordinates
   mc.mcCntlGcodeExecuteWait(inst, "g54")

   --check if using tang knife
   local TKOnOff = mc.mcCntlGetParameter(502)
   if (TKOnOff == 1) then
      SMRegVal = mc.mcRegSetValue(SMReg, 0)
      --scr.SetProperty('ledSMOnOff', 'Value', '0')
   end

      --check for ATC
      local ATCReg = mc.mcRegGetHandle(inst, 'iRegs0/ATCOnOff')
      local ATCRegVal = mc.mcRegGetValue(ATCReg)
      --if ATC turned off
      if (ATCRegVal == 0) then
         mc.mcCntlGcodeExecuteWait(inst, "G49")
         mc.mcToolSetCurrent(inst, 0)
         --If SM turned OFF
         if (SMRegVal == 0) then
            --set to 0 and lift 0.5
            mc.mcAxisSetPos(inst, 2, 0.0)
            mc.mcCntlGcodeExecuteWait(inst, "g0 z0.5")
            SMHit = 1
         end
         --If SM turned ON
         if (SMRegVal == 1) then
            --set jog speed to 100%
            scr.SetProperty('sliJogRate', 'Value', tostring(100))
            --wx.wxMessageBox("SM Used")
            mc.mcCntlGcodeExecuteWait(inst, "g31 z-8.0 f20.0")
            --check to see if sm hit
            SMHit = 0
            SMHit, rc = mc.mcCntlProbeGetStrikeStatus(inst)
            if (SMHit == 1) then
               mc.mcAxisSetPos(inst, 2, 1.5)
               --wx.wxMilliSleep(100)
               mc.mcCntlGcodeExecuteWait(inst, "g0 z2.0")
            else
               wx.wxMessageBox("DID NOT HIT SURFACE MOUSE")
               wx.wxMessageBox("MUST CLICK RESET BEFORE NEXT ATTEMPT")
            end
         end
      end   
      --if ATC turned on
      if (ATCRegVal == 1) then
         rc = wx.wxMessageBox("Have any of the tools in the ATC been changed?", "ATC Tools Changed?",2)
         if (rc == 2) then
            local CurrentTool = mc.mcToolGetCurrent(inst)
            mc.mcCntlGcodeExecuteWait(inst, "G49")
         
            hregMHmd = mc.mcRegGetHandle(inst, 'iRegs0/MachHmd')
            valMHmd = mc.mcRegGetValue(hregMHmd)
            if (valMHmd == 1) then
               --If SM turned OFF
               if (SMRegVal == 0) then
                  local ZCurPos = mc.mcAxisGetPos(inst, 2)
                  mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, CurrentTool, ZCurPos)
                  local ZCurClear = (ZCurPos + 0.5)
                  mc.mcCntlGcodeExecuteWait(inst, "g0 Z" .. ZCurClear)
                  mc.mcCntlGcodeExecuteWait(inst, "G43")
                  SMHit = 1
               end
               --If SM turned ON
               if (SMRegVal == 1) then
                  --set jog speed to 100%
                  scr.SetProperty('sliJogRate', 'Value', tostring(100))
                  --wx.wxMessageBox("SM Used")
                  mc.mcCntlGcodeExecuteWait(inst, "g31 z-8.0 f20.0")
                  --check to see if sm hit
                  SMHit = 0
                  SMHit, rc = mc.mcCntlProbeGetStrikeStatus(inst)
                  if (SMHit == 1) then
                     --mc.mcAxisSetPos(inst, 2, 1.5)
                     --wx.wxMilliSleep(100)
                     --mc.mcCntlGcodeExecuteWait(inst, "g0 z2.0")
                     local ZCurPos = mc.mcAxisGetPos(inst, 2)
                     local ZActualPos = (ZCurPos - 1.5)
                     mc.mcToolSetData(inst, mc.MTOOL_MILL_HEIGHT, CurrentTool, ZActualPos)
                     local ZCurClear = (ZCurPos + 0.5)
                     mc.mcCntlGcodeExecuteWait(inst, "g0 Z" .. ZCurClear)
                     mc.mcCntlGcodeExecuteWait(inst, "G43")
                  else
                     wx.wxMessageBox("DID NOT HIT SURFACE MOUSE")
                     wx.wxMessageBox("MUST CLICK RESET BEFORE NEXT ATTEMPT")
                  end
               end
            else
               wx.wxMessageBox("Must set Machine Home.")
            end
         elseif (rc == 8) then
            local CurrentTool = mc.mcToolGetCurrent(inst)
            mc.mcCntlGcodeExecuteWait(inst, "G43")
            SMHit = 1
         end
      end      
      --set Surface register to 1 and LED On
      if (SMHit == 1) then
         hreg = mc.mcRegGetHandle(inst, 'iRegs0/SurfSet')
         mc.mcRegSetValue(hreg, 1)
         --turn surface set led on
         scr.SetProperty('ledSurfaceSet', 'Value', '1')
      end
end


214
Mach4 General Discussion / Re: mcSignalWait issue
« on: April 09, 2021, 11:14:15 AM »
I set a register after a home and then look at that register.
I am sure it is not the best way but it works well.

Bill

215
Mach4 General Discussion / Re: Mach4 hogging CPU time
« on: April 07, 2021, 12:43:30 PM »
Mine is between 6 and 10 percent

216
I use an ESS with a PMDX-126.
The HICON Integra is nice also.

217
Mach4 General Discussion / Re: Tool setter, M6, tool length offsets
« on: April 05, 2021, 10:55:30 AM »
You might need to do a G43 to turn on Tool Length Offset

218
Mach4 General Discussion / Re: Tool setter, M6, tool length offsets
« on: April 05, 2021, 08:18:14 AM »
This might help with Lua.
Use the last one from 6_22_2020

https://www.machsupport.com/forum/index.php?topic=43260.msg279695#msg279695

219
striplar,

You might look at the Vital Systems controllers.
They can use a secondary encoder input.

Bill

220
Mach4 General Discussion / Re: Trouble using scr Library
« on: March 19, 2021, 03:50:10 PM »
I think you will need to put something in the PLC Script.