Hello Guest it is March 29, 2024, 03:15:23 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 - rhtuttle

301
Mach4 General Discussion / Re: Home Signal
« on: February 19, 2018, 02:18:42 PM »
Daz, thanks for the suggestion , but no joy. 

Adding the mcCntlConfigStart and stop lock the GUI.  Wrapping it in the disable and enable umlocks the GUI but none of the subsequent code gets executed.  As it stands now.

local function myHomeC()
  local inst=mc.mcGetInstance()
  local rc,sState
  local pos=-1
mc.mcCntlEnable(inst,0)
mc.mcCntlConfigStart(inst)
  local hSigH=mc.mcSignalGetHandle(inst,mc.ISIG_MOTOR3_HOME)
  rc=mc.mcSignalEnable(hSigH,1)
  mc.mcProfileWriteInt(inst,'Signal68','Enabled',1)
  mc.mcProfileSave(inst)
  mc.mcProfileFlush(inst)
mc.mcCntlConfigStop(inst)
mc.mcCntlEnable(inst,1)

-- now none of this code is executed, makes sense since a disable cancels all running code

  local hSig,rc=mc.mcSignalGetHandle(inst,mc.ISIG_INDEX)
  if rc==mc.MERROR_SIGNAL_NOT_FOUND  then
    wx.wxMessageBox('wrong Signal')
  end
  sState=mc.mcSignalGetState(hSig)
  if sState==1 then  -- sitting on the slot so move off it
    mc.mcCntlGcodeExecuteWait(inst,'g0 f20000 h15\n')--g1 h366 f5000')
  end
  mc.mcAxisHome(inst,mc.C_AXIS)
 
-- None of the folowing code ever got executed

 mc.mcCntlSetLastError('Homing')
 
  repeat
    wx.wxMilliSleep(1000)
    rc= mc.mcAxisIsHoming(inst,mc.C_AXIS)
    mc.mcCntlSetLastError('Homing: '..tostring(rc))
  until rc==0 
  rc=mc.mcSignalEnable(hSigH,0)
  mc.mcProfileFlush(inst)
end

myHomeC() 

RT

302
Mach4 General Discussion / M1 optional stop
« on: February 19, 2018, 01:07:08 PM »
It appears that m1 'optional stop' only works when running a gcode file.  It has no affect in the MDI, mcCntlGcodeExecute, mcCntlMDIExecute or mcCntlGcodeExecuteWait.

I assumed (silly me) that execution of gcode would be the same across all execute requests.  How would you recommend accomplishing the same effect in a macro or button script?

Executewait,messagebox,executewait,messagebox,execute?

TIA

RT

303
Mach4 General Discussion / Re: Home Signal
« on: February 19, 2018, 12:42:44 PM »
Craig,  thanks for that but unfortunately even after writing to the profile, saving and flushing the PMDX still complains of an invalid configuration. I have confirmed that the correct profile string is written to with the correct settings before calling homing.

  local hSigH=mc.mcSignalGetHandle(inst,mc.ISIG_MOTOR3_HOME)
  rc=mc.mcSignalEnable(hSigH,1)
  mc.mcProfileWriteInt(inst,'Signal68','Enabled',1)
  mc.mcProfileSave(inst)
  mc.mcProfileFlush(inst)

Evidently PMDX does not read the current profie setting before doing homing.

I think I need to have Steve Stallings address whether this is a 'feature' or bug  ;)

RT

304
edit:

this line needs to be removed from the PLC script:

--  if flag==0 then return end      --no request



305
Mach4 General Discussion / Re: Home Signal
« on: February 18, 2018, 02:26:46 PM »
Everything as stated above but have added the signal enable/disable code.  Below is the code in my Ref C button left up script.  I have un-ticked the motor3 mapping home input signal through Mach4 config.  When the button is clicked I get

 PMDX: C-axis homing error, missing or invalid home switch configuration

Mach4 is disabled.  Not what I was hoping for. :-\  When I check the mach4 config the motor3 home mapping is ticked so the code is executing correctly but it appears PMDX is not checking the status of the mapping signal before homing.  Is it supposed to or am I misunderstanding what is happening?

Code: [Select]
local function myHomeC()
  local inst=mc.mcGetInstance()
  local rc,sState
  local pos=-1
  local hSigH=mc.mcSignalGetHandle(inst,mc.ISIG_MOTOR3_HOME)
  rc=mc.mcSignalEnable(hSigH,1)
  local hSig,rc=mc.mcSignalGetHandle(inst,mc.ISIG_INDEX)
  if rc==mc.MERROR_SIGNAL_NOT_FOUND  then
    wx.wxMessageBox('wrong Signal')
  end
  sState=mc.mcSignalGetState(hSig)
  if sState==1 then  -- sitting on the slot so move off it
    mc.mcCntlGcodeExecuteWait(inst,'g0 f20000 h15\n')--g1 h366 f5000')
  end
  mc.mcAxisHome(inst,mc.C_AXIS)
  repeat
    wx.wxMilliSleep(1000)
    rc= mc.mcAxisIsHoming(inst,mc.C_AXIS)
    mc.mcCntlSetLastError('Homing: '..tostring(rc))
  until rc==0 
  rc=mc.mcSignalEnable(hSigH,0)
end

myHomeC() 

TIA

RT

306
Mach4 Toolbox / Radio and Checkbox examples
« on: February 15, 2018, 02:56:02 PM »
Attached is a group box that can be imported into your screen set.  I keep it hidden and when I need a checkbox or group of radio buttons I just copy what I need from it to wherever I need it.  The buttons show how you would access the state.

download the txt and remove the txt extension and then it can be imported into your screen set.

HTH

RT


307
Mach4 General Discussion / Re: PMDX411 Spindle & MaCH4 Speed control
« on: February 15, 2018, 10:25:40 AM »
What happens when you issue a m3 s1500?  Do you still get 2900 rpm or does it slow?

Do you have Mach spindle configured with a tic in the 'Wait on spindle to stabilize'?

308
Mach4 General Discussion / Re: Running a subroutine from inside a macro?
« on: February 14, 2018, 12:42:34 AM »
There are multiple definitions of a macro.  If your gcode had a m900, what would your m900.mcs code contain?  Please provide a simplified example and we may be able to better answer how your definition  of macro differs from Mach4's.

RT

309
Mach4 General Discussion / Re: Running a subroutine from inside a macro?
« on: February 13, 2018, 10:44:01 AM »
Your question is a little bit confusing.  O# are used in gcode files, macros use function calls.  Could you restate the question so we know whether your trying to execute gcode files from a macro or another macro or anther function in the same macro?

RT

310
Mach4 General Discussion / Re: Can mcScriptExecute be called from a macro?
« on: February 10, 2018, 05:42:19 PM »
Thanks DAZ ;D

Could you point me to, or expound on, the difference between mcScriptExecute and mcScriptExecutePrivate?

It does work but I'm not sure if it will work when I start doing things I shouldn't

Code: [Select]
---------------------------------
--Macro to execute a script from call to m9001 with script name commented:
--N0100 m9001 (TestScript.mcs)
---------------------------------
function m9001()
  local inst=mc.mcGetInstance()
  local profile = mc.mcProfileGetName(inst)
  local path = mc.mcCntlGetMachDir(inst)
  local pn=path.."\\Profiles\\"..profile..'\\macros\\'
  local ln=mc.mcCntlGetGcodeLineNbr(0)
  local s=tostring(mc.mcCntlGetGcodeLine(0,ln))
  local n=string.find(s,'(',1,true)
  s=string.sub(s,n+1)
  n=string.find(s,')',1,true)
  s=string.sub(s,1,n-1)
  local fn=wx.wxFileName.FileExists(pn..s)
  if fn==true then
    mc.mcScriptExecutePrivate(0,pn..s,false)
  end
  return
end

if mc.mcInEditor()==1 then
 m9001()
end

It would be nice if it did, I hate having to keep updating the list of what each m... does.  Just naming the script for what it does and calling it with the same macro with the name commented would suit my way of thinking, which is always a bit twisted  ::)

RT