Machsupport Forum
Mach Discussion => Mach4 General Discussion => Topic started by: da40flyer on May 20, 2016, 03:53:15 PM
-
Is there a way to set the soft limits to ON as the default?
-
You will need to add the mcSoftLimitSetState command in the screen load script. (This is accessed from the screen editor)
this command is an as per axis command, so for example if you only needed soft limits for axis 0 (X) then you would use mc.mcSoftLimitSetState(inst, 0, 1)
inst = our controller instance
0 = our axis number
1 = on and 0 = off
mc.mcSoftLimitSetState(inst, 0, 1)
mc.mcSoftLimitSetState(inst, 1, 1)
mc.mcSoftLimitSetState(inst, 2, 1)
this would turn on XYZ on my machine.
mc.mcSoftLimitSetState(inst, 0, 0)
mc.mcSoftLimitSetState(inst, 1, 0)
mc.mcSoftLimitSetState(inst, 2, 0)
and this would turn them back off
DazTheGas
-
Thanks Daz, I will try it out.....
BTW, great Youtube videos. They were very helpful in setup.
-
0 = our axis number
Is this truly axis number or is it motor number?
i.e. 0=X ... 5=C
or
0=Motor 0 ... 5=Motor 5
?
-
It is the AXIS number as per API Docs, you assign motors to an axis,
IE - I have motors 1 and 3 assigned to axis 1, by doing this mach knows to do whatever on both motors.
DazTheGas
-
You will need to add the mcSoftLimitSetState command in the screen load script. (This is accessed from the screen editor)
Daz, Can you be more specific on what file to edit? I went into the menus: Operator > Edit Screen
But I do not see where I can add edit the screen load script from within there.
-
Perhaps this could help ;)
http://www.machsupport.com/forum/index.php/topic,32604.0.html
DazTheGas
-
Don't know how I missed that one... ::)
Works as needed!
Thanks again Daz...
-
Daz
I may be talking rubbish here as I am not up to speed with LUA but could the default state of the button be changed from its off state to on ( maybe a true/false thing or a 0 1 )
Just me thinking out loud
Stuart
-
If you mean the toggle button then yes this can be set in the button properties tab to either up or down.
DazTheGas
-
Thanks Daz
Thought it may be so
Pity they do not save its state in the profile , but again there may be reasons I do not know about
Btw long time Mach3 user but due to the Chinese motion controller playing silly whats its I have converted the mill to mach4 and ESS with a C25
Stuart
-
With a little coding you can save the state of a button, look at the ButtonEnable() function in the Screen Load Script which is using scr.SetProperty on loadup, this combined with a scr.GetProperty and mcProfileWriteInt or String before the screen is destroyed on exit will do this for you.
DazTheGas
-
Thanks
That will take some thinking about for my 70 year old brain cell :)
Nice topic for one of your great quick tips vidieo's ;D please
Thanks for taking the time to reply
Stuart
-
I am not getting this button default state to work. I select button down and it seems that it just changes it for the moment and and does set the default. My goal is to have keyboard and softlimits enabled by default.
i change to button down, restart and the button is not active.
thank you for any info.
-
something else you can use is mc.X_AXIS, mc.Y_AXIS etc to specify which axis you want. it makes your code more legible.
function autoSoftLimitsToggle (togglevalue)
local rc = 0
for i=0, 11 do
if mc.mcAxisIsEnabled (inst,i) == 1 then mc.mcSoftLimitSetState (inst,i,togglevalue) end
end
end
autoSoftLimitsToggle(1)