Machsupport Forum

Mach Discussion => Mach4 General Discussion => Topic started by: da40flyer on May 20, 2016, 03:53:15 PM

Title: Setting Soft Limits On as the Default
Post by: da40flyer on May 20, 2016, 03:53:15 PM
Is there a way to set the soft limits to ON as the default?
Title: Re: Setting Soft Limits On as the Default
Post by: DazTheGas on May 22, 2016, 06:22:24 AM
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
Title: Re: Setting Soft Limits On as the Default
Post by: da40flyer on May 22, 2016, 09:14:26 PM
Thanks Daz,  I will try it out.....

BTW, great Youtube videos.  They were very helpful in setup.
Title: Re: Setting Soft Limits On as the Default
Post by: mgamber on May 23, 2016, 09:34:47 AM
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
?
Title: Re: Setting Soft Limits On as the Default
Post by: DazTheGas on May 23, 2016, 10:28:44 AM
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
Title: Re: Setting Soft Limits On as the Default
Post by: da40flyer on May 23, 2016, 02:08:51 PM
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.

Title: Re: Setting Soft Limits On as the Default
Post by: DazTheGas on May 23, 2016, 02:46:43 PM
Perhaps this could help  ;)

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

DazTheGas
Title: Re: Setting Soft Limits On as the Default
Post by: da40flyer on May 23, 2016, 03:22:19 PM
Don't know how I missed that one...   ::)  

Works as needed!
Thanks again Daz...
Title: Re: Setting Soft Limits On as the Default
Post by: Stuart on June 29, 2016, 11:30:11 AM
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
Title: Re: Setting Soft Limits On as the Default
Post by: DazTheGas on June 29, 2016, 01:19:27 PM
If you mean the toggle button then yes this can be set in the button properties tab to either up or down.

DazTheGas
Title: Re: Setting Soft Limits On as the Default
Post by: Stuart on June 29, 2016, 01:52:21 PM
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
Title: Re: Setting Soft Limits On as the Default
Post by: DazTheGas on June 30, 2016, 03:24:27 AM
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
Title: Re: Setting Soft Limits On as the Default
Post by: Stuart on June 30, 2016, 03:54:04 AM
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
Title: Re: Setting Soft Limits On as the Default
Post by: ped8015 on July 06, 2018, 10:07:22 AM
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.
Title: Re: Setting Soft Limits On as the Default
Post by: cd_edwards on July 13, 2018, 04:41:44 AM
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)