Hello Guest it is March 28, 2024, 06:43:57 AM

Author Topic: Can soft limits be automatically on at start up?  (Read 6048 times)

0 Members and 1 Guest are viewing this topic.

Can soft limits be automatically on at start up?
« on: December 11, 2016, 09:53:59 AM »
My machine is working great with limit override and soft limits!  ;D It is wonderful to be able to go at rapids to the limits and it always stops now with no limit switches being hit.  The only issue is that I have is that I have to activate soft limits by going to another screen to hit the button to turn on soft limits.  It would be better to have soft limits on when the Mach4 boots then turn off soft limits if not needed.  I see no reason to ever run the machine with soft limits off?  Is there a way to set soft limits on at boot. 

Thanks
Keith

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Can soft limits be automatically on at start up?
« Reply #1 on: December 11, 2016, 10:10:46 AM »
Check out the mcSoftLimitSetState command in the API Docs.

DazTheGas
New For 2022 - Instagram: dazthegas
Re: Can soft limits be automatically on at start up?
« Reply #2 on: December 11, 2016, 02:32:49 PM »
Thanks!
Re: Can soft limits be automatically on at start up?
« Reply #3 on: December 12, 2016, 06:47:08 PM »
This is my first attempt to program in Lua in the PLC script.  Trying to turn on softlimits   Here is the code that says syntax error.
I have no idea what I am doing...  I put the code under the PLC First Run section which should be correct?  Got to start somewhere...

Thanks!
-------------------------------------------------------
--  PLC First Run
-------------------------------------------------------
if (testcount == 1) then --Set Keyboard input startup state
    local iReg = mc.mcIoGetHandle (inst, "Keyboard/Enable")
    mc.mcIoSetState(iReg, 1) --Set register to 1 to ensure KeyboardInputsToggle function will do a disable.
    KeyboardInputsToggle()

----------- turn on soft limits by kfc 12/2016

    int TurnOn=MC_ON;

    int axis=Z_AXIS;
    mcSoftLimitSetState(inst, axis, TurnOn);

    int axis = Y_AXIS;
    mcSoftLimitSetState(inst, axis, TurnOn);

    int axis = X_AXIS;
    mcSoftLimitSetState(inst, axis, TurnOn);
-- ----------------------------------------------
Re: Can soft limits be automatically on at start up?
« Reply #4 on: December 12, 2016, 06:55:03 PM »
-- turn on soft limits by kfc 12/2016
    local TurnOn=MC_ON;

    local axis=Z_AXIS;
    mcSoftLimitSetState(inst, axis, TurnOn);

    local axis = Y_AXIS;
    mcSoftLimitSetState(inst, axis, TurnOn);

    local axis = X_AXIS;
    mcSoftLimitSetState(inst, axis, TurnOn);
-- ----------------------------------------------


?seemed to work???
Re: Can soft limits be automatically on at start up?
« Reply #5 on: December 12, 2016, 06:56:29 PM »
compiled last version but bad call   almost working

Offline DazTheGas

*
  •  778 778
  • DazTheGas
    • View Profile
Re: Can soft limits be automatically on at start up?
« Reply #6 on: December 13, 2016, 03:07:02 AM »
Try something like this, not near my computer so cant the moment

    mc.mcSoftLimitSetState(inst, mc.Z_AXIS, mc.MC_ON)

DazTheGas
New For 2022 - Instagram: dazthegas

Offline Stuart

*
  •  311 311
    • View Profile
Re: Can soft limits be automatically on at start up?
« Reply #7 on: December 13, 2016, 03:45:18 AM »
DTG

I tried o do this very same thing a while ago and failed/gave up on it

How about a 2min. Vidieo to educate us that struggle with this lua plc stuff



where should the code be inserted ?

Does it have to be done for each axis ?

But as you say a picture is worth a 1000 words


Stuart
Re: Can soft limits be automatically on at start up?
« Reply #8 on: December 13, 2016, 09:18:26 AM »
Stuart

I am sure it goes in the plc program and has to be done for each axis. It needs to be in the section of the plc script where a counter is active so it only gets run one time when the counter equals 1
Re: Can soft limits be automatically on at start up?
« Reply #9 on: December 13, 2016, 01:16:40 PM »
It works   Here is the code   GO to screen edit on operator menu to open editor.  Click on top wx of upper left screen   Then click on lightening bolt option on lower left box to see plc line the click on ... button to open up plc script.  insert where indicated in code below.  Compile   Save    then exit screen editor by clicking on screen edit of operator menu which will ask again to save screen.  Now when you come into Mach4 the softlimits will be on and the softlimits button will be green!

-here is section of plc to insert the code into
-------------------------------------------------------
--  PLC First Run
-------------------------------------------------------
if (testcount == 1) then --Set Keyboard input startup state
    local iReg = mc.mcIoGetHandle (inst, "Keyboard/Enable")
    mc.mcIoSetState(iReg, 1) --Set register to 1 to ensure KeyboardInputsToggle function will do a disable.
    KeyboardInputsToggle()

--INSERT HERE THE FOLLOWING CODE
-- turn on soft limits
      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);
-- ----------------------------------------------