Hello Guest it is March 29, 2024, 11:07:17 AM

Author Topic: Home Signal  (Read 3750 times)

0 Members and 1 Guest are viewing this topic.

Home Signal
« on: December 29, 2017, 11:28:46 AM »
When you set up a motor you define a home signal pin and whether that motor homes.  Is there an api that will allow you to turn on/off, mapping enabled or input name?

On my lathe I have my spindle configured to be either run by a motor for the spindle function or alternately driven by a stepper (belt change, motor 3, drive C) to act as a rotary/indexer.  I use input 12 as the spindle index pulse and as the homing signal for the C drive.  When used as a spindle the C drive homing signal is sent on each revolution.  It doesn't affect performance but the log has a message sent for each revolution.  I know I could just use two profiles but that creates other issues (re-referencing all axes).

TIA

RT

Offline Chaoticone

*
  • *
  •  5,624 5,624
  • Precision Chaos
    • View Profile
Re: Home Signal
« Reply #1 on: December 29, 2017, 11:38:19 AM »
Look in the API doc, API Reference by Category, Mach Signals and I think you will find what you're looking for.
;D If you could see the things I have in my head, you would be laughing too. ;D

My guard dog is not what you need to worry about!
Re: Home Signal
« Reply #2 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
Re: Home Signal
« Reply #3 on: February 19, 2018, 06:25:45 AM »
Hi RT,
not sure this will help with the input signals firing all the time but it may give you some insights into how Mach assigns axes and motors, when and how it updates the profile
etc.

http://www.machsupport.com/forum/index.php/topic,33866.0.html

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: Home Signal
« Reply #4 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

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Home Signal
« Reply #5 on: February 19, 2018, 01:16:44 PM »
When ever anything config wise is being done then mach4 needs to be in a config state, this will send a MSG_CONFIG_START to plugins, on exiting the config state MSG_CONFIG_END is sent to plugins. It is here where plugins do there housework etc, so without these msg's a plugin doesnt know anything has changed. There are commands ie mc.mcCntlConfigStart etc but wether they work or not??

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Home Signal
« Reply #6 on: February 19, 2018, 01:20:57 PM »
If I understand what you are saying..... you are trying to change to a mode where the
spindle is just rotating, not under trajectory control, and then remove the signal that
is used as Home for the C axis. If you do this and then ask for a Home All to execute,
then the PMDX SmartBob response is correct, you cannot do that because you have an
invalid configuration for the C axis.

It may be possible to use the API to set the C axis for Home In Place, but I could not
find out how to do that in a script.

The more likely alternative is to create a new custom Home All button that is aware of
which axes actually have a home signal at the time homing is requested, and only ask
 for Mach4 to home that set of axes.

Steve Stallings, PMDX
Steve Stallings
www.PMDX.com
Re: Home Signal
« Reply #7 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

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Home Signal
« Reply #8 on: February 19, 2018, 05:32:55 PM »
So ive been back and reread the 1st post and if I have got it right, you want to use the same profile but have 2 different kinds of homing so you can leave an Axis out. If so it can be done like Steve says.
You can add another button and say which Axis to ref, ive just tested this and it is fine apart from both Axis will home at same time.

Code: [Select]
local mInst = mc.mcGetInstance()
mc.mcAxisHome(mInst, mc.Z_AXIS)
mc.mcAxisHome(mInst, mc.X_AXIS)

To ref individually and have dro`s moving then you would need to wrap this in a coroutine.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Home Signal
« Reply #9 on: February 20, 2018, 10:58:04 AM »
Daz, as Strother Martin says in 'Cool Hand Luke',  "What we've got here is failure to communicate!"  ;D

Not trying to have two homing operations.  Trying to stop the PMDX411 from throwing an 'C axis homing tripped' error message every revolution when using the spindle as a spindle.  It seems to me that that message should only be thrown when that axis is being homed, but that's just me.  If on a mill you have a your x axis home switch not at the end of travel but somewhere in the middle you really don't want an error message thrown every time you travel over it during an operation.

Here's a real world example.  Let's say on my lathe I want to make a knob with 10 equally spaced markings.  First I turn the knob to my desired shape.  Now I need to change belts on the spindle and control it as a rotary with a stepper(motor 3/C axis).  I need to home the C axis, then use a diamond drag to etch the markings every 36 degrees.  Now when I go back to turn another one, change belts, I will get the tripped error every revolution. 

What I want is to enable the 'Motor 3 home' mapping before homing and disable it after homing.  I don't think that is doable.  I think I am just going to have to manually change it when I manually change the belts. :-\

RT