Hello Guest it is March 28, 2024, 04:01:31 PM

Author Topic: Automatically Activate Soft Limits (The same way the button does)  (Read 1934 times)

0 Members and 1 Guest are viewing this topic.

Hello All,

I have been trying to find an elegant way of activating the soft limits after the ref all button has been pressed.

I have read through: http://www.machsupport.com/forum/index.php?PHPSESSID=upo39p5fi37e018ldiefmlbds1&topic=30192.0;wap2

That's a nice solution, but it's getting a bit too custom for my liking. I don't want to re-write the function that already works.

What I would like to do, is leave the SoftLimit button Up Action and Down Action alone. Then just call the "Soft Limit On" action from the end of the RefAllHome() function.

Failing that, is there a way to "click" a toggle button from a script?


Regards,

Owen.

Offline thosj

*
  •  532 532
    • View Profile
--
Tom

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Automatically Activate Soft Limits (The same way the button does)
« Reply #2 on: February 20, 2018, 08:55:17 AM »
Underneath the coroutine.yield line you can add something like this

Code: [Select]
if mc.mcSignalGetState (mc.mcSignalGetHandle mInst, mc.OSIG_MACHINE_ENABLED)) == 1 then
    mc.mcSoftLimitSetState(mInst, mc.X_AXIS, mc.MC_ON)
    mc.mcSoftLimitSetState(mInst, mc.Y_AXIS, mc.MC_ON)
    mc.mcSoftLimitSetState(mInst, mc.Z_AXIS, mc.MC_ON)
    wx.wxMessageBox("Machine is Homed and SoftLimits Enabled", "Homing Sequence",4)
else
    wx.wxMessageBox("Homing Aborted", "Homing Sequence",4)
end

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Automatically Activate Soft Limits (The same way the button does)
« Reply #3 on: February 20, 2018, 04:44:22 PM »
You might also like to try the following: API call

    number scr.ButtonDown(string ctrlName) -- Simulate a button down event.

Substitute the actual soft limits button name for ctrlName in the above. I haven't tried this, so there could be side effects.

Allan
Re: Automatically Activate Soft Limits (The same way the button does)
« Reply #4 on: February 20, 2018, 08:25:18 PM »
Thank you all for the replies!

I ended up using the code DazTheGaz posted, I just had to add a parenthesis on the first line and change the instance name. I added it to the end of the RefAllHome() and it works a treat in the simulation. I'll give it a try on my machine soon! Tick another job off the list!

Code: [Select]
if mc.mcSignalGetState (mc.mcSignalGetHandle(inst, mc.OSIG_MACHINE_ENABLED)) == 1 then
    mc.mcSoftLimitSetState(inst, mc.X_AXIS, mc.MC_ON)
    mc.mcSoftLimitSetState(inst, mc.Y_AXIS, mc.MC_ON)
    mc.mcSoftLimitSetState(inst, mc.Z_AXIS, mc.MC_ON)
    wx.wxMessageBox("Machine is Homed and SoftLimits Enabled", "Homing Sequence",4)
else
    wx.wxMessageBox("Homing Aborted", "Homing Sequence",4)
end

Allan, I couldn't get that API Call to work unfortunately :(

Cheers,

Owen.
Re: Automatically Activate Soft Limits (The same way the button does)
« Reply #5 on: February 21, 2018, 02:01:46 PM »
Why doesnt Mach 4 automatically enable soft limits after homing? Its really annoying. Do you know if there is a way to make that happen?
Re: Automatically Activate Soft Limits (The same way the button does)
« Reply #6 on: February 21, 2018, 02:23:06 PM »
Peter, thosj's post answered this question.
Bryanna posted this on the linked thread. 
https://www.machsupport.com/forum/index.php/topic,36545.msg250346.html#msg250346
Chad Byrd
Re: Automatically Activate Soft Limits (The same way the button does)
« Reply #7 on: February 21, 2018, 02:59:37 PM »
Thank you :-)

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Automatically Activate Soft Limits (The same way the button does)
« Reply #8 on: February 21, 2018, 03:03:14 PM »
This has been looked at many times before and posted here, but IMHO the most efficient is to use a function like what Bryanna posted and then on first run of PLC run the function so softlimits are on from the start, When homing an axis softlimits are ignored so it doesnt hurt to switch them on before homing. ( I have tested this on my own machine with ESS )

You will notice with the current RefAllHome that if you canx the homing for any reason then it still says your homed, when your not. So if the operator is not careful then he/she could be crashing the machine.
I have many fallbacks to make sure softlimits are on like my cycle start button checks for this and warns me. I you noticed the code I posted it adds a simple check to see if the controller is enabled at the end of the coroutine, if not then it must of been aborted or something went wrong so a different dialog is displayed so I wont crash my machine (AGAIN!) ;-)

DazTheGas
New For 2022 - Instagram: dazthegas