Momentary button with InTouch

defcon.klaxon

Lifetime Supporting Member
Join Date
Feb 2015
Location
Far NorCal
Posts
616
Hi guys,

I'm trying to write a simple little script that will take a button in InTouch that's animated for "Direct" (i.e., momentary) and make it stay true for, say, five seconds.

I've read generally that one can write a script that'll look at $Second and use that to wait 5 (or 10 or whatever) seconds, but I'm not sure the right way to go about that script-wise (I'm pretty new to the script aspect of InTouch). Would I use a FOR loop, inside an IF? I'm sure this is simple, but I'm not sure how to attack this.

So far, I've come up with a conditional script whose condition is the button's Direct tag being true, with the following script:

Code:
button_tag == 1 (this is the condition that starts the script)

script:
x = $second;
FOR i = 1 TO 100000
     button_tag = 1;
     IF x <> $second THEN
     EXIT FOR;
     ENDIF;
NEXT;
I found this as an example on the forum, but I'm not sure if this'll be suitable for what I'm doing. As for the number in the FOR loop, I assume that'll depend on how fast my code is executed on the PC, so it'll have to be tuned; or I could make a tag for that upper limit and have it as a temporary user adjustable setpoint. Does this sound right to you guys? Thanks!
 
Last edited:
It would be easy if you do it in the plc

Well that's the problem, actually. The button's tag is a boolean in a remote PLC, that gets its data from a data concentrator that polls multiple sites over a span of multiple seconds. So if the operator happens to press the button just as the polling cycle is at the remote site, then great. But if the operator pushes the button any other time, the bit won't stay on long enough to send to the remote site. I suppose I could do the "stay on" in the data concentrator rather than the remote site, but with an InTouch script I can create a few variables right in the Tagname Dictionary and not worry about timers and hold on bits and etc (unless there's a really easy way to do this in ladder logic [RSLogix 5000 ver 24 is what I'm using) and I'm not aware of it. I'm definitely open to PLC based solutions.
 
I remember this problem in the oil fields.
Everything was over radio, so momentary buttons from Wonderware were a bad call.
Wrote everything so that Wonderware set the bit, and the plc saw it and reset it.
Trying to remember what I did for momentary.
 
I remember this problem in the oil fields.
Everything was over radio, so momentary buttons from Wonderware were a bad call.
Wrote everything so that Wonderware set the bit, and the plc saw it and reset it.
Trying to remember what I did for momentary.

I'd love to hear what you did if you remember, thanks for the post.
 
I'd love to hear what you did if you remember, thanks for the post.

I'm pretty sure I always set the bit in Wonderware, and had the plc one shot another bit in the plc and immediately reset the hmi bit.

Sometimes used a status bit from the plc for a button depressed indicator on the hmi.

Don't think I needed momentary accept for a jog button.

In which case, you could use a tmr in the plc to keep the oneshot'd coil on for 5 seconds.
 
While I advocate handshaking in the PLC, if you just want to do it in the HMI because it should work then see below

From the Intouch HMI Scripting and Logic Guide, available on google somewhere:
Periodic Script Execution
Scripts that execute periodically do not execute immediately
after triggering, but after the specified period for the first
time.
For example, if you configure a key script to execute every
5000 ms while a specific key is pressed, it executes 5 seconds
after the key is pressed and held down and then every 5
seconds afterwards.
Which means you can change the pushbutton from direct to set

Code:
Condition Script
Condition: MyBit
Condition Type: While True
Period: 5000 ms

Script:
MyBit = 0;
 
While I advocate handshaking in the PLC

What exactly do you mean by that? The idea that the "master" PLC (the one interfacing with the HMI) would hold the bit true until it was sent to the remote PLC, and use feedback from the remote PLC to reset the bit in the "master" PLC? I'd love to hear how you would tackle this.
 
Use a "Touch Pushbutton" action script on the PB and enter "PB = 1" to use "On Left Click/Key Down"..
Then in a Condition script for PB, Use "While True" and set 5000 msec and "If PB==1 Then PB=0".
 
Last edited:
The button's tag is a boolean in a remote PLC, that gets its data from a data concentrator that polls multiple sites over a span of multiple seconds.

How many seconds is the polling rate?
It sounds like you would need to hold the button tag high for at least 2x that value; to avoid timing issues.
ex. if the polling rate is 2 seconds, you need to hold the tag high for 4 seconds.

Nyquist rate



But I would rather go with the set tag idea; set the tag in the HMI and let the PLC clear the tag after it gets the value.
That helps avoid timing issues altogether.
 
How many seconds is the polling rate?
It sounds like you would need to hold the button tag high for at least 2x that value; to avoid timing issues.
ex. if the polling rate is 2 seconds, you need to hold the tag high for 4 seconds.

Nyquist rate



But I would rather go with the set tag idea; set the tag in the HMI and let the PLC clear the tag after it gets the value.
That helps avoid timing issues altogether.

You cannot use a "Set" PB and reset from PLC. It is "Set" in Intouch, the PLC cannot turn off "Set". A "Set" is like a latch. I rarely use a "Set/Reset" PB in Intouch because of this.

Use a "Touch Pushbutton>Action" script on the PB and enter "PB = 1" to use "On Left Click/Key Down" (I am referring to "PB" as the tagname for your push button)..
Then the PLC can send a "0" to the PB bit after time delay.
 
Last edited:
I am pretty sure I've used set on Intouch and then I just reset the same bit in the PLC that was set in the HMI. You can probably think about it that it gets latched but then the PLC unlatches it and the value of the bit goes to 0 until you press the button again to set it to 1.
 
You cannot use a "Set" PB and reset from PLC. It is "Set" in Intouch, the PLC cannot turn off "Set". A "Set" is like a latch. I rarely use a "Set/Reset" PB in Intouch because of this.

Use a "Touch Pushbutton>Action" script on the PB and enter "PB = 1" to use "On Left Click/Key Down" (I am referring to "PB" as the tagname for your push button)..
Then the PLC can send a "0" to the PB bit after time delay.

Wrong. You out of touch w/ the intouch
 
You cannot use a "Set" PB and reset from PLC. It is "Set" in Intouch, the PLC cannot turn off "Set". A "Set" is like a latch. I rarely use a "Set/Reset" PB in Intouch because of this.

Use a "Touch Pushbutton>Action" script on the PB and enter "PB = 1" to use "On Left Click/Key Down" (I am referring to "PB" as the tagname for your push button)..
Then the PLC can send a "0" to the PB bit after time delay.


I'm sorry to say, Nathan, that you are wrong about this. "Set", in InTouch, is not like a latch. It is a simple bit set, and either a PLC or another script within InTouch can most certainly Reset said bit.

As to the original question, it is not necessary to use a FOR loop. You could just as easily create a counter that adds one count with each execution of the script, and yes, knowing the time base is critical for accurately converting counts into time. That said, the general concept of resetting a bit set by a PB with a conditional script will definitely work, but you should allow the PB to set the bit, rather than using a "momentary" PB. A momentary PB will reset the bit as soon as the PB is released.
 
Last edited:
I'm sorry to say, Nathan, that you are wrong about this. "Set", in InTouch, is not like a latch. It is a simple bit set, and either a PLC or another script within InTouch can most certainly Reset said bit.

As to the original question, it is not necessary to use a FOR loop. You could just as easily create a counter that adds one count with each execution of the script, and yes, knowing the time base is critical for accurately converting counts into time. That said, the general concept of resetting a bit set by a PB with a conditional script will definitely work, but you should allow the PB to set the bit, rather than using a "momentary" PB. A momentary PB will reset the bit as soon as the PB is released.

You may be right on the set... It just seems odd to use the Set function in Intouch, when there is no Reset from Intouch.
It seems easier to use a PB script for PB=1, instead of a set.
But.....I never said use a "momentary" PB......see my post again. PB = 1 is not momentary.
 
Last edited:

Similar Topics

I have a Window with few Pushbuttons set as Direct. There's no problem using mouse clicking. But on touch screen monitor, the button behavior is...
Replies
7
Views
2,920
Hello everyone, Does anybody know if there is a way of simulating the behaviour of a FTV momentary push button on iFix? I am trying to create a...
Replies
5
Views
1,784
Hi All Could anyone advise me on how to protect the push button on the screen from occasional touch? I've faced up the problem that I can't...
Replies
22
Views
6,578
For reasons, I find myself having to disable buttons using SE controls rather than in the PLC (massive project, no time to edit PLC properly). I...
Replies
0
Views
1,024
We have a compact logix L32E running RsLogix 5000 v.20, connected to two panelview plus 6 1000 over ethernet. 1) One, possibly both panelviews...
Replies
10
Views
2,923
Back
Top Bottom