Hello Guest it is May 15, 2025, 01:45:52 PM

Author Topic: Tool Release Script Help  (Read 433 times)

0 Members and 1 Guest are viewing this topic.

Tool Release Script Help
« on: April 20, 2025, 06:07:53 PM »
I'm trying to add a script to my screen load script for a physical button to activate the knock out to release the tool. I could probably just trigger it but I want to have logic to make sure the spindle is stopped. I've tried a lot of combinations but it refuses to activate the output. Here's the latest code I've tried:

[mc.ISIG_INPUT3] = function (state)
   local output6 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT6)
--   local spin0 = mc.mcSignalGetHandle(inst, mc.ISIG_INPUT0);
--   local spin0state = mc.mcSignalGetState(spin0)
   mc.ISIG_INPUT0 = function (state1)
      if(state == 1) and
         (state1 == 1) then
            mc.mcSignalSetState(output6, 1)
         end
      end
end,


I've tried what's commented out.  Tried using SpindleAtZero, this the I made input 0 the same as SpindleAtZero.  Any suggestions?


Thanks,

Mike
Re: Tool Release Script Help
« Reply #1 on: April 20, 2025, 09:02:06 PM »
I just figured it out!   Only issue now is the last section doesn't shut off output6 if I wiggle the spindle.  I tried it with an or instead of 2 if statements, but it didn't work either.  it won't activate if the spindle is running though, which is the main thing I wanted.

[mc.ISIG_INPUT3] = function (state)
   local output6 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT6)
   local spin0 = mc.mcSignalGetHandle(inst, mc.ISIG_SPINDLE_AT_ZERO);
   local spin0state = mc.mcSignalGetState(spin0)
      if(state == 1) and
         (spin0state == 1) then
            mc.mcSignalSetState(output6, 1)
      end
      if(state == 0) then
            mc.mcSignalSetState(output6, 0)
      end
      if(spin0state == 0) then
         mc.mcSignalSetState(output6, 0)
      end
end,

Offline Graham Waterworth

*
  • *
  •  2,782 2,782
  • Yorkshire Dales, England
Re: Tool Release Script Help
« Reply #2 on: April 21, 2025, 07:20:52 PM »
I think this should do what you want.

[mc.ISIG_INPUT3] = function (state)
   local output6 = mc.mcSignalGetHandle(inst, mc.OSIG_OUTPUT6)
   local spin0 = mc.mcSignalGetHandle(inst, mc.ISIG_SPINDLE_AT_ZERO);
   local spin0state = mc.mcSignalGetState(spin0)
      if(state == 1) and (spin0state == 1) then
          mc.mcSignalSetState(output6, 1)
      else
          mc.mcSignalSetState(output6, 0)
      end
end,
Without engineers the world stops
Re: Tool Release Script Help
« Reply #3 on: April 22, 2025, 08:01:04 AM »
Thanks Graham!