Hello Guest it is April 16, 2024, 08:32:32 AM

Author Topic: PLC Inputs  (Read 459 times)

0 Members and 1 Guest are viewing this topic.

PLC Inputs
« on: December 03, 2022, 11:30:52 PM »
Anyone else have issue with the plc inputs not working on activation of an input and only firing after release of the input?  It doesn't seem to make a difference either whether it is from the keyboard input add on, or if I use an input directly from the motion controller?
 
Like the code below.  The CycleStart function should launch when the button is pressed triggering input 1.  You can see the input is on in the diagnostics, and in the log.  It doesn't though it triggers when the button is released.  I've tried changing the low/high setting on the input page.  Then it just fires off as soon as you enable the machine.

[mc.ISIG_INPUT1] = function (on_off)
   if (on_off == 1) then   
      CycleStart()
   else
      
   end

end, -- end isig input 1
Re: PLC Inputs
« Reply #1 on: December 04, 2022, 12:34:33 PM »
Which type of button are you using to activate input 1?
Re: PLC Inputs
« Reply #2 on: December 04, 2022, 01:05:07 PM »
it doesn't matter.  It does the same thing with a keyboard input or a push button contact hooked up to an input on the motion controller. MACH4 handles both the same way.  The condition seems to only effect inputs that call functions that use the motion handler.  if you use a button press to change something on screen it does that just fine.  Anything involving the motion handler like mdiexicute, gcodeexicute, or gcodeexicutewait it will not activate till the button is released.

The button I am using in particular is a BACO contact block momentary push button.  https://www.mcmaster.com/7403K19/ hardwired directly to an input on the motion controller.  It behaves the same way when i  hook up a keyboard and swap the input to a keyboard  input.

Re: PLC Inputs
« Reply #3 on: December 04, 2022, 06:04:10 PM »
Hi,
the signal script fires ANYTIME the signal changes state, and so it will trigger on activation, but also on deactivation.

I would guess that your BoB/motion controller has active pull-ups, and therefore the signal script will trigger on the negative going transition
not the more normal positive going transition.

Craig

'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: PLC Inputs
« Reply #4 on: December 05, 2022, 09:39:20 AM »
The syntax you have reminds me of when I first started with Mach4.... Try this instead.
[mc.ISIG_INPUT1] = function (state)
if (state == 1) then   
        CycleStart()
end,

This the function as State instead of On_Off. 

I'm with Craig, I would think the signal would fire when it changes state, not just the trailing edge of the signal.  But... lets exhaust all options.
Chad Byrd