1damo1
Hi Team,

just starting out with OpenPLC and having a great time using it!, I've been looking all over the place to help resolve an issue I'm having. I'm wanting to create a 1 button ON/OFF with a long press (at least 1 second) to turn back off, to stop any accidental button presses.

openplc post.png 
Thank you.
Reply 0 0
Martin
Hey Damo,

i would use one button/input (in this case your 'ON_OFF_BUTTON'), a TON for your long press as reset, then a RS flipflop and after the flipflop your Output (in this case your relay).

Connect the Button to the RS - S and to the TON - IN, the TON - OUT should go to the RS - R. Set the timer to your desired time.

In this config its important to use an RS and not an SR, because both contacts will be active and it would not reset if its an SR. 

Another way would be to connect the input to the TON - IN and to an additional AND and the TON - OUT to the SR - R and also to the AND but inverted so it puts out TRUE when the TON is inactive. The AND - OUT goes to the SR - S.

In this config, its irrelevant if you use a SR or a RS flipflop because only one contact, the S or the R will be active, because as the TON puts out TRUE the AND will go to FALSE and SR - S will get no input any longer.

I hope this helps.
Reply 0 0
1damo1
Hey Martin,

thanks for the assist! the first option you suggested is working perfectly!

Thankyou
Reply 0 0
Martin
Happy i could help.

The second option is a more 'big programm friendly' way, because having one input both setting and resetting a flipflop tends to cause problems in larger programms where you often have more then one signal/variable going to the S or R contacts.
Reply 0 0
Reply