Hello Guest it is April 28, 2024, 02:15:56 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

131
here is where you can find all the mc calls
C:\Mach4Hobby\Docs\Mach4CoreAPI.chm

132
It will take a little coding but this is basically what you need to do.

get current units
mcCntlGetUnitsCurrent

if G20 for inch
do tool change

if G21 for mm
set units to G20
do tool change
set units back to G21


133
I do not use that pendant.
Under Configure / Plugins is there a plugin for it?
It might be in there you can tell it not to use "A"

134
It looks to me like you need to fix the code.
Go to Operator then Edit Screen.
On the left select the top object in the Screen Tree Manager
Under Properties select the middle icon.
Click on Screen Load Script then click the button with the three"..."
Find function GoToWorkZero()
It should have several options.
Some will be commented out.
Make sure the one you want is not commented out and all the others are commented out.

This might help also.
https://www.machsupport.com/forum/index.php?topic=45397.0


Bill

135
Mach4 General Discussion / Re: Z home before cycle start
« on: March 04, 2022, 08:56:12 AM »
Quote
this function that you use:
mc.mcAxisSetPos(inst, 0, PosSetX1)
not make any change on x value

PosSetX1 is a variable.
If you did not set PosSetX1 to a number first it will not work.

136
Mach4 General Discussion / Re: Persistent Spindle Range DRO
« on: February 25, 2022, 04:02:48 PM »
Probably need to do some other code to make the register set the spindle range.

137
Mach4 General Discussion / Re: Persistent Spindle Range DRO
« on: February 24, 2022, 09:14:00 AM »
I usually will do something like set a register then make the register permanent.
Then have the dro read the register.

138
Mach4 General Discussion / Re: Z home before cycle start
« on: February 23, 2022, 12:28:02 PM »
I am far from a Lua expert but here is my custom cycle start.
You might be able to find what you need it it.

---------------------------------------------------------------
-- Cycle Start() function.
---------------------------------------------------------------
function CycleStart()
    local rc;
    local tab, rc = scr.GetProperty("MainTabs", "Current Tab")
    local tabG_Mdione, rc = scr.GetProperty("nbGCodeMDI1", "Current Tab")
    local tabG_Mditwo, rc = scr.GetProperty("nbGCodeMDI2", "Current Tab")
    ------------------------------------------------------------------------------------
   --if machine home not done exit run with message
   MachHmdRegH = mc.mcRegGetHandle(inst, 'iRegs0/MachHmd')
   MachHmd = mc.mcRegGetValue(MachHmdRegH)
   ATCOnRegH = mc.mcRegGetHandle(inst, 'iRegs0/ATCOnOff')
   ATCOn = mc.mcRegGetValue(ATCOnRegH)
   if (MachHmd == 0) and (ATCOn == 1)then
      wx.wxMessageBox('Please Set Machine Home Before Clicking Run')
   else
   ------------------------------------------------------------------------------------
      --See if we have to do an MDI command and if so, which one
      if ((tonumber(tab) == 0 and tonumber(tabG_Mdione) == 1) or (tonumber(tab) == 2 and tonumber(tabG_Mditwo) == 1 )) then
         local state = mc.mcCntlGetState(inst);
         if (state == mc.MC_STATE_MRUN_MACROH) then
            mc.mcCntlCycleStart(inst);
            --mc.mcCntlSetLastError(inst, "Do Cycle Start");
         else
            if (tonumber(tab) == 0) then 
               scr.ExecMdi('mdi1');
               --mc.mcCntlSetLastError(inst, "Do MDI 1");
            else
               scr.ExecMdi('mdi2');
               --mc.mcCntlSetLastError(inst, "Do MDI 2");
            end
         end
      elseif tonumber(tab) > 2 then --No G Code or MDI panel is displayed so Do Nothing
         --mc.mcCntlSetLastError(inst, "Nothing to Start");
      else --Do CycleStart
         --mc.mcCntlSetLastError(inst, "Do Cycle Start");
         
         --if project home or surface not set exit run with message
         hregHm1 = mc.mcRegGetHandle(inst, 'iRegs0/ProjHm1Set')
         ProjHmd1 = mc.mcRegGetValue(hregHm1)
         hregHm2 = mc.mcRegGetHandle(inst, 'iRegs0/ProjHm2Set')
         ProjHmd2 = mc.mcRegGetValue(hregHm2)
         hreg2 = mc.mcRegGetHandle(inst, 'iRegs0/SurfSet')
         SurfHmd = mc.mcRegGetValue(hreg2)
         
         --Set time on Maintinance 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)
         
         --get offset number
         local hregPHN = mc.mcRegGetHandle(inst, 'iRegs0/ProjHmPos')
         local ProjHmNum = mc.mcRegGetValue(hregPHN)
         
         --get if in tk mode and if homed
         local TKOnOff = mc.mcCntlGetParameter(502)
         local TKHmdH = mc.mcSignalGetHandle(inst, mc.OSIG_HOMED_A)
         local TKHmdV = mc.mcSignalGetState(TKHmdH)
               
            if (ProjHmNum == 1) then
               if (ProjHmd1 == 0) then
                  wx.wxMessageBox('Please Set Project 1 Home Before Clicking Run')
               elseif (SurfHmd == 0) then
                  wx.wxMessageBox('Please Set Surface Before Clicking Run')
               elseif (TKOnOff == 1) and (TKHmdV == 0) then
                  wx.wxMessageBox('Please Home TK Before Clicking Run')
               else               
                  --get and set home 1 offsets
                  hregX1 = mc.mcRegGetHandle(inst, 'iRegs0/ProjHm1X')
                  ValX1 = mc.mcRegGetValue(hregX1)
                  hregY1 = mc.mcRegGetHandle(inst, 'iRegs0/ProjHm1Y')
                  ValY1 = mc.mcRegGetValue(hregY1)
                  MachX = mc.mcAxisGetMachinePos(inst, 0)
                  MachY = mc.mcAxisGetMachinePos(inst, 1)
                  PosSetX1 = (MachX - ValX1)
                  PosSetY1 = (MachY - ValY1)
               
                  mc.mcAxisSetPos(inst, 0, PosSetX1)
                  mc.mcAxisSetPos(inst, 1, PosSetY1)
                  
                  --regenerate toolpath
--                  mc.mcToolPathGenerate(inst)
                  
                  --if machine homed check if file larger than soft limits
                  hregMHmd = mc.mcRegGetHandle(inst, 'iRegs0/MachHmd')
                  valMHmd = mc.mcRegGetValue(hregMHmd)
                  if (valMHmd == 1) then
                     MaxX = mc.mcAxisGetSoftlimitMax(inst, 0)
                     MaxY = mc.mcAxisGetSoftlimitMax(inst, 1)
                     hregPathXMax = mc.mcRegGetHandle(inst, 'core/inst/PathXmax')
                     PathXmax = mc.mcRegGetValue(hregPathXMax)
                     hregPathYMax = mc.mcRegGetHandle(inst, 'core/inst/PathYmax')
                     PathYmax = mc.mcRegGetValue(hregPathYMax)
                     
                     MinX = mc.mcAxisGetSoftlimitMin(inst, 0)
                     MinY = mc.mcAxisGetSoftlimitMin(inst, 1)
                     hregPathXMin = mc.mcRegGetHandle(inst, 'core/inst/PathXmin')
                     PathXmin = mc.mcRegGetValue(hregPathXMin)
                     hregPathYMin = mc.mcRegGetHandle(inst, 'core/inst/PathYmin')
                     PathYmin = mc.mcRegGetValue(hregPathYMin)
                     
                     if (PathXmax >= MaxX) or (PathYmax >= MaxY) or (PathXmin <= MinX) or (PathYmin <= MinY) then
                        wx.wxMessageBox("Cut file is outside cut area.\nContinuing may damage machine.")
                     end
                  end
                  
               mc.mcCntlCycleStart(inst);

               end
            end
            if (ProjHmNum == 2) then
               if (ProjHmd2 == 0) then
                  wx.wxMessageBox('Please Set Project 2 Home Before Clicking Run')
               elseif (SurfHmd == 0) then
                  wx.wxMessageBox('Please Set Surface Before Clicking Run')
               elseif (TKOnOff == 1) and (TKHmdV == 0) then
                  wx.wxMessageBox('Please Home TK Before Clicking Run')
               else               
                  --get and set home 2 offsets
                  hregX2 = mc.mcRegGetHandle(inst, 'iRegs0/ProjHm2X')
                  ValX2 = mc.mcRegGetValue(hregX2)
                  hregY2 = mc.mcRegGetHandle(inst, 'iRegs0/ProjHm2Y')
                  ValY2 = mc.mcRegGetValue(hregY2)
                  MachX = mc.mcAxisGetMachinePos(inst, 0)
                  MachY = mc.mcAxisGetMachinePos(inst, 1)
                  PosSetX2 = (MachX - ValX2)
                  PosSetY2 = (MachY - ValY2)
               
                  mc.mcAxisSetPos(inst, 0, PosSetX2)
                  mc.mcAxisSetPos(inst, 1, PosSetY2)
                  
                  --regenerate toolpath
--                  mc.mcToolPathGenerate(0)
                  
                  --if machine homed check if file larger than soft limits
                  hregMHmd = mc.mcRegGetHandle(inst, 'iRegs0/MachHmd')
                  valMHmd = mc.mcRegGetValue(hregMHmd)
                  if (valMHmd == 1) then
                     MaxX = mc.mcAxisGetSoftlimitMax(inst, 0)
                     MaxY = mc.mcAxisGetSoftlimitMax(inst, 1)
                     hregPathXMax = mc.mcRegGetHandle(inst, 'core/inst/PathXmax')
                     PathXmax = mc.mcRegGetValue(hregPathXMax)
                     hregPathYMax = mc.mcRegGetHandle(inst, 'core/inst/PathYmax')
                     PathYmax = mc.mcRegGetValue(hregPathYMax)
                     
                     MinX = mc.mcAxisGetSoftlimitMin(inst, 0)
                     MinY = mc.mcAxisGetSoftlimitMin(inst, 1)
                     hregPathXMin = mc.mcRegGetHandle(inst, 'core/inst/PathXmin')
                     PathXmin = mc.mcRegGetValue(hregPathXMin)
                     hregPathYMin = mc.mcRegGetHandle(inst, 'core/inst/PathYmin')
                     PathYmin = mc.mcRegGetValue(hregPathYMin)
                     
                     if (PathXmax >= MaxX) or (PathYmax >= MaxY) or (PathXmin <= MinX) or (PathYmin <= MinY) then
                        wx.wxMessageBox("Cut file is outside cut area.\nContinuing may damage machine.")
                     end
                  end
                  
               mc.mcCntlCycleStart(inst);
               end
            end
      end
   end
end

139
Havoc and Chriscam,

This might help some.
When I was trying to learn Lua I made this for people like me to get started.

https://www.machsupport.com/forum/index.php?topic=45397.0


140
Mach4 General Discussion / Re: Homing scripts
« on: January 17, 2022, 08:31:41 AM »
Brad,

Here is a starter for you to start learning how to modify your Mach4.
Hope it helps.
https://www.machsupport.com/forum/index.php?topic=45397.0

Bill