Hello Guest it is April 18, 2024, 04:52:23 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

411
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

412
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

413
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.

414
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

415
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.

416
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


417
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

418
Mach4 General Discussion / Update error
« on: November 02, 2017, 06:50:07 PM »
Today I decided to update Mach4 to the latest build on the PMDX site, Build3481

After downloading and installing the new build I imported the lathe profile package I created just prior to installation.  After answering yes to about 25 windows asking me if I wanted to overwrite files the screen load script ran and then I got the following error window.

I don't know what caused it or how to fix it.

Any help greatly appreciated 

419
Mach4 General Discussion / sms to phone
« on: October 31, 2017, 11:56:17 AM »
I would like to be notified when a script is complete by sending a SMS text message to my cell phone.
Has anyone successfully been able to do this with Mach4?  I found this snippet from the web but I get an error message:
Got a socket error trying to read. Address '192.168.1.5'. Port 52181


-- load the smtp support
local sckt = require("socket.smtp")

-- Connects to server "localhost" and sends a message to users
from = "<luasocket@example.com>"

rcpt = {
  "<myPhoneNumberHere@vtext.com>"
}

mesgt = {
  headers = {
    to = "Ralph Tuttle <myPhoneNumberHere@vtext.com>",
    subject = "CNC Lathe Task Complete"
  },
  body = "CNC Lathe Task Complete, body"
}

r, e = sckt.send{
  from = from,
  rcpt = rcpt,
  source = smtp.message(mesgt)
}


TIA

RT