Hello Guest it is April 28, 2024, 07:39:18 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

221
Mach4 General Discussion / Re: Strange tangential knife movement
« on: March 19, 2021, 03:39:40 PM »
Tweekie,

Thanks.
I will try it.

222
Mach4 General Discussion / Strange tangential knife movement
« on: March 18, 2021, 01:51:49 PM »
I have 2 files that did not work correctly.
E Knife does a 360 degree turn while it is still moving and in the material at the point indicated in the picture.
I removed a point in that area for E Knife 2 and the tangential knife does not turn at all.
Mach4 version 4517
ESS version 260

223
Mach4 General Discussion / Re: auto soft limits again
« on: February 23, 2021, 05:28:24 PM »
cd_edwards,

I did something similar depending on if they  Referenced the machine.
If they did Reference the machine soft limits are active if they did not the soft limits are inactive.
Good job on the code.

Bill

224
Mach4 General Discussion / Re: auto soft limits again
« on: February 23, 2021, 05:22:11 PM »
Brian and Totally,

I understand what you are saying but I personally want to know how to do this stuff in Lua.
I am sure some things can not be done in PMC.

Bill

225
Mach4 General Discussion / Re: Read DRO from Lua
« on: February 22, 2021, 08:57:07 AM »
Kent,

This might help.
Use the version from 6_22_2020 towards the bottom.

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

Bill

226
Mach4 General Discussion / Re: edit screen
« on: February 19, 2021, 04:41:04 PM »
Steve,

I thought so but just wanted verification.
Thanks,

Bill

227
Mach4 General Discussion / edit screen
« on: February 19, 2021, 03:04:16 PM »
If I edit the screen (some of the code in the Screen Load script) are the changes all in the screen?
So if I replace any other machines screen will they have the new script?
 

228
Mach4 General Discussion / Re: service timer
« on: February 05, 2021, 09:14:07 AM »
Here is what I use.
You need to make a couple of registers also.

In PLC
-------------------------------------------------------
--  Cycle time label update
-------------------------------------------------------
--Requires a static text box named "CycleTime" on the screen
if (machEnabled == 1) then
   local running = mc.mcCntlIsInCycle(inst)
   if (running == 1) then
      local cycletime = mc.mcCntlGetRunTime(inst, time)
      scr.SetProperty("CycleTime", "Label", SecondsToTime(cycletime))
   
      --run time
      local hRun = mc.mcRegGetHandle(inst, 'iRegs0/RunningTime')
      RunTime = cycletime
      mc.mcRegSetValue(hRun, RunTime)
   
   end
end


In PLC First Run section
---------------------------------------------------------   
   --Pop up message for maintenance
   --Keep at bottom
   ---------------------------------------------------------      
   local MaintReg = mc.mcRegGetHandle(inst, 'iRegs0/MaintTime')
   local MaintRegVal = mc.mcRegGetValue(MaintReg)
   if (MaintRegVal >= 144000) then
      mc.mcRegSetValue(MaintReg, 0.0)
      wx.wxMessageBox("Please perform maintenance")
   end



In the Cycle Start function in Screen Load Script
         --Set time on Maintenance timer
         local hMaint = mc.mcRegGetHandle(inst, 'iRegs0/MaintTime')
         local MaintTime = mc.mcRegGetValue(hMaint)
         local hRunning = mc.mcRegGetHandle(inst, 'iRegs0/RunningTime')
         local RunningTime = mc.mcRegGetValue(hRunning)
         MaintTime = (MaintTime + RunningTime)
         mc.mcRegSetValue(hMaint, MaintTime)
         mc.mcRegSetValue(hRunning, 0.0)
         

229
Mach4 General Discussion / Re: Scripting Custom Control Panel
« on: February 02, 2021, 10:52:40 AM »
I made a pendant not a control panel but same thing for button.
Here is how I make my buttons work.
You can do a lot with these and how Lua/Mach4 function.

[mc.ISIG_INPUT0] = function (state)
    if (state == 1) then
      CycleStart()
   end
end,

[mc.ISIG_INPUT1] = function (state)
    if (state == 1) then
      mc.mcCntlRewindFile(inst)
   end
end,

[mc.ISIG_INPUT2] = function (state)
    if (state == 1) then
      CycleStop()
   end
end,

[mc.ISIG_INPUT3] = function (state)
   if (state == 1) then
      if (Pause == 1) then
         mc.mcCntlCycleStart(inst)
         Pause = 0
      elseif (Pause == 0) then
         mc.mcCntlFeedHold(inst)
         Pause = 1
      end
   end
end,

[mc.ISIG_INPUT4] = function (state)
      if (state == 0) then
         mc.mcCntlEnable(inst, true)
      else
         mc.mcCntlEnable(inst, false)
      end
end,

[mc.ISIG_INPUT20] = function (state)
    local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   if (state == 1) then
      mc.mcRegSetValue(AltRegH, 1)      
   else
      mc.mcRegSetValue(AltRegH, 0)   
   end
end,

[mc.ISIG_INPUT5] = function (state)
    local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
   if (state == 1) then
      if (AltVal == 0) then
      GoToWorkZero()
      elseif (AltVal == 1) then
      SetWorkZero()
      end
   end
end,

[mc.ISIG_INPUT6] = function (state)
    local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
   if (state == 1) then
      if (AltVal == 0) then
      ReturnToPosition()
      elseif (AltVal == 1) then
      RememberPosition()
      end
   end
end,

[mc.ISIG_INPUT7] = function (state)
    local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
   if (state == 1) then
      if (AltVal == 1) then
         wait = coroutine.create (RefAllHome)
      end
   end
end,




[mc.ISIG_INPUT8] = function (state)
   local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
      if (state == 1) then
      if (AltVal == 0) then
      Surface()
      elseif (AltVal == 1) then
      MaxDepth()
      end      
   end
end,

[mc.ISIG_INPUT11] = function (state)
      local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
   if (state == 1) then
      if (AltVal == 0) then
      CutSpeedMinus()
      elseif (AltVal == 1) then
      CutSpeedPlus()
      end            
   end
end,

[mc.ISIG_INPUT12] = function (state)
   local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)   
      if (state == 1) then
      if (AltVal == 1) then
      ExtraDepth()
      end      
   end
end,

[mc.ISIG_INPUT15] = function (state)
      if (state == 1) then
      SpeedsReset()
   end
end,

[mc.ISIG_INPUT16] = function (state)
      local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)   
      if (state == 1) then
      if (AltVal == 0) then
      MistOnOff()
      elseif (AltVal == 1) then
      SpindleOnOff()
      end                  
   end
end,

[mc.ISIG_INPUT19] = function (state)
      local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
   if (state == 1) then
      if (AltVal == 0) then
      JogSpeedMinus()
      elseif (AltVal == 1) then
      JogSpeedPlus()
      end            
   end
end,

[mc.ISIG_INPUT21] = function (state)
    local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
   if (state == 1) then
      if (AltVal == 0) then
         local MachHmdreg = mc.mcRegGetHandle(inst, 'iRegs0/MachHmd')
         local MachHmd = mc.mcRegGetValue(MachHmdreg)
         if (MachHmd == 0) then
            wx.wxMessageBox("Must set Machine Home")
         elseif (MachHmd == 1) then
--            mc.mcCntlGcodeExecute(inst, "m6")
            mc.mcCntlMdiExecute(inst, 'm6')
         end
      elseif (AltVal == 1) then
         local hsig = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT6)
         local sigOut6 = mc.mcSignalGetState(hsig)
         if (sigOut6 == 0) then
            mc.mcSignalSetState(hsig, 1)
         else
            mc.mcSignalSetState(hsig, 0)
         end
      end
   end
end,

[mc.ISIG_INPUT22] = function (state)
      local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
   if (state == 1) then
      if (AltVal == 0) then
      
      elseif (AltVal == 1) then
      
      end            
   end
end,

[mc.ISIG_INPUT25] = function (state)
    if (state == 1) then
      local Tool = mc.mcToolGetSelected(inst)
      --get max tools
      local ATCMaxTlsReg = mc.mcRegGetHandle(inst, 'iRegs0/ATCMaxTools')
      local ATCMaxTlsVal = mc.mcRegGetValue(ATCMaxTlsReg)   
      --if tool is 100(cam), 101(tks) or 102(tko) set tool to 0
      if (Tool == 100) or (Tool == 101) or (Tool == 102) then
         Tool = 0
      end
      --if tool is in range add one to tool #
      if (Tool <= (ATCMaxTlsVal - 1)) then
         Tool = (Tool + 1)
         mc.mcCntlSetPoundVar(inst, mc.SV_CUR_SELECTED_TOOL, Tool)
      end
   end
end,

[mc.ISIG_INPUT26] = function (state)
   local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)   
      if (state == 1) then
      if (AltVal == 1) then
         local TKSReg = mc.mcRegGetHandle(inst, 'iRegs0/TKStdOnOff')
         local TKSRegVal = mc.mcRegGetValue(TKSReg)
         local TKOReg = mc.mcRegGetHandle(inst, 'iRegs0/TKOscOnOff')
         local TKORegVal = mc.mcRegGetValue(TKOReg)
         local TKSSigH = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT7)
         local TKOSigH = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT8)
         local TKOscSigH = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT9)

         local ATCOnOffReg = mc.mcRegGetHandle(inst, 'iRegs0/ATCOnOff')
         local ATCOnOffVal = mc.mcRegGetValue(ATCOnOffReg)
         local ATCToolHReg = mc.mcRegGetHandle(inst, 'iRegs0/ATCToolHolder')

         local SMReg = mc.mcRegGetHandle(inst, 'iRegs0/SMOnOff')
         local SMRegVal = mc.mcRegGetValue(SMReg)   
         
         mc.mcRegSetValue(TKSReg, 0)
         mc.mcSignalSetState(TKSSigH, 0)
         mc.mcRegSetValue(TKOReg, 0)
         mc.mcSignalSetState(TKOSigH, 0)
         mc.mcSignalSetState(TKOscSigH, 0)
         
         --if atc on change current tool to tool holder tool
         if (ATCOnOffVal == 1) then
            local CurTool = mc.mcToolGetCurrent(inst)
            local ATCToolHVal = mc.mcRegGetValue(ATCToolHReg)
            if (CurTool == 100) or (CurTool == 101) or (CurTool == 102) then
               mc.mcToolSetCurrent(inst, ATCToolHVal)
               mc.mcCntlGcodeExecuteWait(inst, string.format("G43 H" .. tostring(ATCToolHVal)))
               mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_X, 0.000)
               mc.mcCntlSetPoundVar(inst, mc.SV_HEAD_SHIFT_Y, 0.000)
            end
         end
         
         --turn off tang knife mode
         mc.mcCntlSetParameter(502, 0)
         mc.mcCntlSetLastError(inst, 'TK OFF')
         if (SMTempOn == 1) then
            mc.mcRegSetValue(SMReg, 1)
            SMTempOn = 0
         end
         
         --mc.mcRegSetValue(TKSReg, TKSRegVal)
         KeyTKSTemp = 0
         --mc.mcRegSetValue(TKOReg, TKORegVal)
         KeyTKOTemp = 0
      end      
   end
end,

[mc.ISIG_INPUT27] = function (state)
    local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
   if (state == 1) then
      if (AltVal == 1) then
         KeyTKSTemp = 1
         TKSOnOff()
      end
   end
end,

[mc.ISIG_INPUT28] = function (state)
    local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
   if (state == 1) then
      if (AltVal == 1) then
         KeyTKOTemp = 1
         TKOOnOff()
      end
   end
end,

[mc.ISIG_INPUT29] = function (state)
    if (state == 1) then
      local Tool = mc.mcToolGetSelected(inst)
      --get max tools
      local ATCMaxTlsReg = mc.mcRegGetHandle(inst, 'iRegs0/ATCMaxTools')
      local ATCMaxTlsVal = mc.mcRegGetValue(ATCMaxTlsReg)   
      --if tool is 100(cam), 101(tks) or 102(tko) set tool to MaxTool
      if (Tool == 100) or (Tool == 101) or (Tool == 102) then
         Tool = (ATCMaxTlsVal + 1)
      end
      --if tool is in range subtract one from tool #
      if (Tool >= 2) then
         Tool = (Tool - 1)
         mc.mcCntlSetPoundVar(inst, mc.SV_CUR_SELECTED_TOOL, Tool)
      end
   end
end,

[mc.ISIG_INPUT30] = function (state)
      local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
   if (state == 1) then
      if (AltVal == 0) then
      
      elseif (AltVal == 1) then
         local hsig = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT5)
         local sigOut5 = mc.mcSignalGetState(hsig)
         if (sigOut5 == 0) then
            mc.mcSignalSetState(hsig, 1)
         else
            mc.mcSignalSetState(hsig, 0)
         end
      end            
   end
end,

[mc.ISIG_INPUT31] = function (state)
      if (state == 1) then
      wait = coroutine.create (RefTKHome)
   end
end,

[mc.ISIG_INPUT32] = function (state)
    local AltRegH = mc.mcRegGetHandle(inst, 'iRegs0/Alt')
   local AltVal = mc.mcRegGetValue(AltRegH)
   local Sig9H = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT9)
   local Sig9Val = mc.mcSignalGetState(Sig9H)
   if (state == 1) then
      if (AltVal == 1) then
         if (Sig9Val == 0) then
            mc.mcSignalSetState(Sig9H, 1)
            --wx.wxMilliSleep(1000)
         else
            mc.mcSignalSetState(Sig9H, 0)
            --wx.wxMilliSleep(1000)
         end
      end
   end
end,


230
Brian,

The head shifts work great.

Bill