Hello Guest it is March 28, 2024, 04:50:19 PM

Author Topic: No way to switch soft limits from lua script?  (Read 3483 times)

0 Members and 1 Guest are viewing this topic.

No way to switch soft limits from lua script?
« on: February 08, 2018, 07:01:00 AM »
Hi.

I use this script:
Code: [Select]
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:
Code: [Select]
[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

Don’t do good – won’t endure the evil
Re: No way to switch soft limits from lua script?
« Reply #1 on: February 08, 2018, 09:03:38 AM »
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.
Chad Byrd
Re: No way to switch soft limits from lua script?
« Reply #2 on: February 08, 2018, 09:13:40 AM »
Anything to do with the axis needing to be referenced first ?
Don't see it mentioned in above examples.
(might have overlooked it though)
Re: No way to switch soft limits from lua script?
« Reply #3 on: February 08, 2018, 09:14:31 AM »
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.

Code: [Select]
---------------------------------------------------------------
-- 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
Newfangled Solutions Helpdesk: http://support.machsupport.com
YouTube Support Channel: https://www.youtube.com/c/MachSupportOfficial
Re: No way to switch soft limits from lua script?
« Reply #4 on: February 08, 2018, 09:21:41 AM »
Thanks Bryanna.
Chad Byrd

Offline thosj

*
  •  532 532
    • View Profile
Re: No way to switch soft limits from lua script?
« Reply #5 on: February 08, 2018, 09:34:26 AM »
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
« Last Edit: February 08, 2018, 09:37:28 AM by thosj »
--
Tom

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: No way to switch soft limits from lua script?
« Reply #6 on: February 08, 2018, 11:35:43 AM »
Heres a topic from the past that might help.

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

DazTheGas
New For 2022 - Instagram: dazthegas
Re: No way to switch soft limits from lua script?
« Reply #7 on: February 08, 2018, 06:42:27 PM »
Hi Tom,

Quote
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
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: No way to switch soft limits from lua script?
« Reply #8 on: February 09, 2018, 03:45:31 AM »
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?
Don’t do good – won’t endure the evil

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: No way to switch soft limits from lua script?
« Reply #9 on: February 09, 2018, 04:48:56 AM »
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
New For 2022 - Instagram: dazthegas