Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: Bluephish on February 20, 2018, 06:37:59 AM
-
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.
-
https://www.machsupport.com/forum/index.php/topic,36545.msg250346.html#msg250346
This is pretty elegant. What I do!
-
Underneath the coroutine.yield line you can add something like this
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
-
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
-
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!
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.
-
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?
-
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
-
Thank you :-)
-
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