Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: cnc-kursk on February 08, 2018, 07:01:00 AM
-
Hi.
I use this script:
mc.mcSoftLimitSetState(inst, mc.Z_AXIS, MC_ON);
mc.mcSoftLimitSetState(inst, mc.Y_AXIS, MC_ON);
mc.mcSoftLimitSetState(inst, mc.X_AXIS, MC_ON);
1. SoftLimit not worked.
2. No Output signal:
[mc.OSIG_SOFTLIMITS_ON] = function (state)
mc.mcCntlSetLastError(inst,"OSIG_SOFTLIMITS_ON " .. tostring(state));
if( state == 1) then
scr.SetProperty('tbtnSoftLimits', 'Button state', '0');
else
scr.SetProperty('tbtnSoftLimits', 'Button state', '1');
end
end,
If I switch by button action, softlimits are worked and OSIG_SOFTLIMITS_ON triggered.
Possible need switch softlimits globally?
Can I switch softlimits by code?
M4 ver.4.2.0.3658
-
I will be watching this thread. I tried to turn on the soft limits with an Initialize Code on startup. It never worked properly. It would turn the button Yellow, like I had pressed it, but it wouldn't actually turn the soft limits on. Frustrating.
That would be a nice feature. Have an option to have soft limits turn on as a default from the general config.
-
Anything to do with the axis needing to be referenced first ?
Don't see it mentioned in above examples.
(might have overlooked it though)
-
I'm going to be including this in a homing/soft limits video in the near future, but it may help with what you're trying to do. Replacing the Ref All Home chunk in the screen load script with the following will turn the soft limits on immediately after homing.
---------------------------------------------------------------
-- Ref All Home() function.
---------------------------------------------------------------
function RefAllHome()
mc.mcAxisDerefAll(inst) --Just to turn off all ref leds
mc.mcAxisHomeAll(inst)
coroutine.yield() --yield coroutine so we can do the following after motion stops
----See ref all home button and plc script for coroutine.create and coroutine.resume
wx.wxMessageBox('Referencing is complete.\nSoft Limits Set.')
SetSoftlimits()
end
-------------------------------------------------------
-- Set Soft Limits
-------------------------------------------------------
function SetSoftlimits()
for v = 0, 5, 1 do --start, end, increment
mc.mcSoftLimitSetState(inst, v, mc.MC_ON)
end
scr.SetProperty("tbtnSoftLimits", "Button State", tostring(SLState))
scr.SetProperty("tbSoftLimits", "Button State", tostring(SLState))
end
-
Thanks Bryanna.
-
Whoa Bryanna, been sitting thinking on how to do exactly that just lately. Thanks a LOT :D
IMHO, Mach4 should just DO that, but there are likely reasons to NOT do it by default, like people not having soft limits configured!!!
Anyway, I'll be implementing this TODAY. I might have to do something differently because I've modified my Ref All Home script in the screen load script a bit already, so hopefully I can figure it out.
Thanks again, I'm actually starting to finally LIKE Mach4!
Tom
-
Heres a topic from the past that might help.
http://www.machsupport.com/forum/index.php/topic,33813.0.html
DazTheGas
-
Hi Tom,
Thanks again, I'm actually starting to finally LIKE Mach4!
it took a wee while but once I started to make progress with Mach/Lua I felt exactly the same way.
Craig
-
Hi, Bryanna.
I'm going to be including this in a homing/soft limits video in the near future, but it may help with what you're trying to do.
My script very similar (on top page).
Please check, IRL softlimits after mcSoftLimitSetState are ON?
Why OSIG_SOFTLIMITS_ON doesn't triggered?
-
Had a quick look today and spotted the small mistake MC_ON should be mc.MC_ON
mc.mcSoftLimitSetState(inst, mc.Z_AXIS, mc.MC_ON);
mc.mcSoftLimitSetState(inst, mc.Y_AXIS, mc.MC_ON);
mc.mcSoftLimitSetState(inst, mc.X_AXIS, mc.MC_ON);
DazTheGas
-
::)
Thanks.
-
ThanX Bryanna...... that works great....
All it took was a quick copy n paste n all was good!
Sometimes I was forgettin to turn on soft limits n would go the WRONG DIRECTION by mistake n work through the recover / limits over ride stuff after the HOMING sequence!
Your a life saver.... probably a RED one. LOL
MegaMoog :)