Hello Guest it is October 03, 2023, 05:08:22 PM

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 - rhtuttle

401
Mach4 General Discussion / DRO behavior
« on: November 09, 2017, 01:29:30 PM »

If a DRO who's DRO code is set to CurrentJogIncr. has a valid number (read, one of the 10 jog increments defined) entered through the keyboard the 'core/inst' register entries for JogIncX through JogIncC are updated with the new value and when incremental jogging is requested the axis moves the correct amount.  Same thing occurs when using the 'Incremental Jog Step' button. 

It appears that some event is triggered when the value changes.

If however you change the value programmaticaly, e.g. scr.SetProperty('droJogInc',"Value",tostring(SetInc)) , the event is not fired.  Shouldn't any change to the 'Value' call the update event/action?
Is there a way to force/call that event/action?

Additionally, it you write to the registers, new values:

        mc.mcJogSetInc(mInst, mc.X_AXIS, SetInc) -- set inc for axis
        mc.mcJogSetInc(mInst, mc.Y_AXIS, SetInc) -- set inc for axis
        mc.mcJogSetInc(mInst, mc.Z_AXIS, SetInc) -- set inc for axis
        mc.mcJogSetInc(mInst, mc.A_AXIS, SetInc) -- set inc for axis
        mc.mcJogSetInc(mInst, mc.B_AXIS, SetInc) -- set inc for axis
        mc.mcJogSetInc(mInst, mc.C_AXIS, SetInc) -- set inc for axis

they are ignored on further incremental jog requests.  Is it not correct to read the register for the jog increment each time an incremental move is made?

And why is there no mcJogCycleIncrement() api available?

TIA

RT

402
Mach4 Plugins / Re: mcX360 Plugin for Lua
« on: November 08, 2017, 12:13:45 PM »
I've been chasing my tail with trying to change the jog increment for a full day.  To test it without the xBox so as to limit the possible errors I have done the following:
on the jog panel added a DRO and set it to CurrentJogIncr.  When using the 'Incremental Jog Step' button it correctly updates.
I then added a button and in the left up script added the following code which is what I would be doing in the xBox controller:

Code: [Select]
       local mInst=0
        local CurInc = mc.mcProfileGetInt(mInst,"Preferences","JogIncSet",0) --make a new setting in profile to hold our current inc number
        local SetInc = mc.mcProfileGetDouble(mInst,"Preferences","JogInc"..CurInc,0.00) -- fetch our inc value from the profile JogInc + 2 say = [Preferences][JogInc2]

        CurInc = CurInc + 1 -- increment our CurInc by 1
        if CurInc > 10 then CurInc = 1 end -- if our CurInc is greater than 10 then go back to 1
        
        mc.mcJogSetInc(mInst, mc.X_AXIS, SetInc) -- set inc for axis
        mc.mcJogSetInc(mInst, mc.Y_AXIS, SetInc) -- set inc for axis
        mc.mcJogSetInc(mInst, mc.Z_AXIS, SetInc) -- set inc for axis

        mc.mcProfileWriteInt(mInst,"Preferences","JogIncSet",CurInc) --set our profile to new CurInc
        local s=tostring(CurInc)
        mc.mcCntlSetLastError(0,s)

When I use the button the txtJogInc control updates but the DRO does not.  You can see from the error messages that the CurInc is updating but when the 'Incremental Jog Step' button is used it is not synced to the last change.  There seems to be a flaw in the way the dro works or in the way mach checks to see what the current increment has been changed to...or...in my understanding!

Any help?

RT

403
Mach4 Plugins / Re: mcX360 Plugin for Lua
« on: November 07, 2017, 02:08:04 PM »
Amazing what a little lunch will do for you. 

I had declared local Xenabled=false and was using xEnabled instead

404
Mach4 Plugins / Re: mcX360 Plugin for Lua
« on: November 07, 2017, 01:36:43 PM »
Daz, sage advice as always.

One correction for anyone following this thread:
    if GetXin("Btn_A") == "1" then
should read:       
    if GetXin("Btn_A") == 1 then
   

After rethinking how I want to use the controller I want to toggle the controller on/off (xEnabled) using the start button.

The following code does what I want but the first press shows 'Pendant Disabled' rather than my expected 'Pendant Enabled'.  Where did I err in my code/logic?

Code: [Select]
-----------------Event Timers
X360_Timer:Start(100)
local StartVal=0
X360_Panel:Connect(wx.wxEVT_TIMER, function (event)
-- Toggle xEnabled when Start Button is depressed
  if GetXin("Btn_START") == 1 then
    if StartVal==1 then --more than one start signal received before release
      return
    end
    if xEnabled == false then
--      Btns_Timer:Start(50)
      mc.mcCntlSetLastError(mInst,"Pendant Enabeled")
      xEnabled=true
    else
--      Btns_Timer:Stop()
      mc.mcCntlSetLastError(mInst,"Pendant Disabeled")
      xEnabled=false
    end
    StartVal=1
  else
    StartVal=0
  end
end)

TIA

RT

405
Mach4 Plugins / Re: mcX360 Plugin for Lua
« on: November 06, 2017, 04:45:12 PM »
First thanks to all that have contributed to this effort on the xBox controller.

I saw that the plugin was already present in the plugins directory so,


What I did:

Watched the video twice.
Enabled the xBox360 plugin. Restarted Mach4.
From 'Diagnostics->RegFile I can see the Btn_B entry change from 0 to one when I press the xBox B
copied the code from Franco (I am using on a lathe as well):
  https://www.machsupport.com/forum/index.php/topic,33121.30.html
reply 31

Created the Lua panel and inserted the code
Saved the changes.
Added the on unload script to check to see if the timer is still running.


From the history button I see:  'mcX360 found and active'.

Pressing the B button nothing happens but shows in the RegFile as being changed.

The GetXin function and the X360_Panel:Connect are being constantly called.(Put a wxMessageBox in the function, thanks for the command line \e tip)
Neither the EStop_panel:Connect nor the Btns-Panel:Connect are ever called.

What did I miss?


TIA

RT

406
Mach4 General Discussion / Re: Macro help mcCntlGcodeExecuteWait
« on: November 03, 2017, 07:54:26 PM »
Crap, senior moment again, I typed M80 instead of G80.

407
Mach4 General Discussion / Macro help mcCntlGcodeExecuteWait
« on: November 03, 2017, 06:16:52 PM »
Using latest build 3481 -pmdx411 - Lathe mode

When I use this code in the MDI it functions as expected
g83 x0 z.6 r0 q.30 p.1 f4
so I don't think this is pmdx related

I have tried running the macro from both the mdi: M6999 D1.5

and from a button that gets the current Zaxis position and calls(correctly) the macro

I have tried mcCntlGcodeExecute and mcCntlGcodeExecuteWait and both basically run as expected, peck to.6 on the Zaxis but then continues on for another cycle and then just keeps going past the .6 mark.

I have also tried mcCntlMdiExecute and it wont run at all.

What am I missing in the macro sCode string?
Which api call should  I be using?

Code: [Select]
function m6999(hVars) 
  local roughFeed=4
  local roughSpeed=600
  local zStart=0
  local zEnd=0
 
  local inst=mc.mcGetInstance()

-- make sure the spindle is set in low gear,   manual change 
  if mc.mcSpindleGetCurrentRange(inst)~=0 then
    wx.wxMessageBox('Set Spindle Gearing to Low Speed')
    mc.mcSpindleSetRange(inst,0)
  end
--make sure the macro is called with the current z position 
  if (hVars ~= nil) then
    local DFlag = mc.mcCntlGetLocalVarFlag(inst, hVars, mc.SV_D)
    if(DFlag == 1) then
      zStart = mc.mcCntlGetLocalVar(inst, hVars, mc.SV_D)
  zEnd=zStart*.4
      mc.mcCntlSetLastError(inst,"Peck Drill From "..zStart.." to "..zEnd)
    end
  else
    wx.wxMessageBox("hVars=nil")
    return 0
  end
--macro assumes that you want to drill 60% through the material 
  if zStart<=zEnd then
    wx.wxMessageBox("zStart  is <= to zEnd")
    return 0
  end
  ts=os.time()

--Peck Drill
sCode=""
  sCode=sCode.."M3 S"..tostring(roughSpeed).."\n"
  sCode=sCode.."g83 x0 z"..zEnd.." r0 q.30 p.1 f4\n"
  sCode=sCode.."M80".."\n"
  sCode=sCode.."M5".."\n"
-- move back an inch to allow for the swapping of reel seat end to finish through drill
  sCode=sCode.."g0 z"..tostring(zStart+1).."\n"
--  wx.wxMessageBox(sCode)
  mc.mcCntlGcodeExecuteWait(inst,sCode)
  tr=os.difftime(os.time(),ts)/60
  mc.mcCntlSetLastError(inst,"Pecking Time: "..string.format("%.1f min",tr))
  return 1
end
if mc.mcInEditor()==1 then
  m6999()
end

Any help Greatly appreciated.

RT

408
Mach4 General Discussion / Re: Update error
« on: November 03, 2017, 04:41:40 PM »
Found the offending dro.  On the lathe set dro_11 is Dro(11) on the tabPositionsExtens tab with a label of Xwear Offset (doh)

The onUpdate and onModify scripts are the same as in a clean wxLathe screenset that gives no error.

local m_inst, m_currentOffset, XWear

XWear = scr.GetProperty("droXWearOffset", "Value")
XWear = tonumber(XWear)

m_inst = mc.mcGetInstance()
m_currentOffset = mc.mcCntlGetPoundVar(m_inst, mc.SV_CUR_LENGTH_INDEX)
mc.mcToolSetData(m_inst, mc.MTOOL_LATHE_X_W, m_currentOffset, XWear) --set the wear offset

I added:

if XWear==nil then XWear=0 end

before the call to mcToolSetData

The screen loads without complaint but I don't know why XWear comes back nil in my screen and not in the original.  We'll see if other problems arise.  thanks for your help.

409
Mach4 General Discussion / Re: Update error
« on: November 03, 2017, 12:58:30 PM »
Thanks Craig and Steve,

Craig, the profile is My4Lathe and the screen set is wxLathe.

Steve,

I have added 3 Dros to the screen, only one has a onUpdate script.  I added the code as directed and no change.

From the lua script line 931 says: function dro_11__on_update_script  I have searched the entire screen tree for a dro_11 and there is none.

I have searched the startup and PLC scripts for dro_11 and mcToolSetData and there is none to found.

Also searched all lua modules for mcToolSetData and only in the mcAutoTool.mcs is there a call to that function.

Where else should I look for an onUpdate script?

TIA

RT


410
Mach4 General Discussion / Re: Update error
« on: November 02, 2017, 08:23:39 PM »
Craig,  thanks for taking time to respond.  The screen set that I use has been saved under another name, My4Lathe.

RT