# Momentary button

**URL:** <https://forum.inductiveautomation.com/t/momentary-button/12456>\
**Category:** Ignition\
**Created:** [December 12, 2016, 1:48pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456 "2016-12-12T13:48:52Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![msynco1](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@msynco1](https://forum.inductiveautomation.com/u/msynco1)\
**Post date:** [December 12, 2016, 1:48pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/1 "2016-12-12T13:48:52Z")

</div>

Ive had a couple occasions where using a momentary button tag where the tag would turn on the bit but wouldnt set it back upon release.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [December 12, 2016, 2:40pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/2 "2016-12-12T14:40:08Z")

</div>

If you search the archives you’ll find this topic popping up many times. There’s no pure-Ignition solution, as there’s no way to guarantee that the release event in a client occurs, nor that the OPC write on release succeeds.  
The correct answer varies by situation, but always requires some heartbeat or validation or fallback on the PLC side.

---

<div class="post-metadata">

**Author:** ![Curlyandshemp](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Curlyandshemp](https://forum.inductiveautomation.com/u/Curlyandshemp)\
**Post date:** [December 12, 2016, 7:16pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/3 "2016-12-12T19:16:23Z")

</div>

> [@msynco@gmail.com](#):
>
> Ive had a couple occasions where using a momentary button tag where the tag would turn on the bit but wouldnt set it back upon release.

if is an absolute critical function, such as momentary button to start a process, always best to have the PLC unlatch the bit once the start function has been activated.

---

<div class="post-metadata">

**Author:** ![gilles.levesque](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@gilles.levesque](https://forum.inductiveautomation.com/u/gilles.levesque)\
**Post date:** [August 26, 2022, 2:05pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/4 "2022-08-26T14:05:16Z")

</div>

We had the same problem that started few weeks ago. And i find out that was related to the tag group Rate (Scan class).  
I’ve create a Tag group for momentary button and set the rate to half the minimum hold time of the push button and it seem to have resolve our problems. Momentary Buttons are set with a min Hold time of 1000 ms, so the rate of the tag group should be 500ms.  
With the rate a 1000ms i could make the plc contact latch almost every time by pressing the button again just before the min hold time was ending.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [August 27, 2022, 2:45am UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/5 "2022-08-27T02:45:56Z")

</div>

For a momentary button, you could probably use the tag activated bit to activate an OTE within the PLC logic that acts as the actual command bit in the PLC program. Then, put a corresponding OTU for the tag activated bit one rung above the OTE, so that each PLC scan unlatches the command bit. Placing an ONS in line with the OTE would probably be helpful as well.

Edit: Added Example Picture:  
 ![PLC_Example](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/3/f3c2168557f148cf12b61bc7d2f576ae602c3d63.png)

Example with ONS for added safety:  
 ![PLC_Example with ONS](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/7/2706ea25b6bf2e775d2f35798c13ae08b6014aa0.png)

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [August 27, 2022, 3:09am UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/6 "2022-08-27T03:09:01Z")

</div>

Momentary buttons can be dangerous, and should never be relied upon. No matter how robust you've made the timing on the Scada side, there is always a chance due to some external reason that a release event doesn't arrive at the controller. The rate of your Tag Group may have made your issue more prevalent, but I seriously doubt that it was the root cause.

See this thread for the reasons why.

> [@Very Concerning Read/Write Issues. Important information for all users](https://forum.inductiveautomation.com/t/very-concerning-read-write-issues-important-information-for-all-users/18583):
>
> Hello Ignition Members, Disclaimer - All of our senior designers/programmers are qualified for their jobs where I work. These problems are described as I see them, they may not be exactly what happened. Therefor they are to be used for troubleshooting the issue only. Thank you. We are in contact with some ignition developers and are desperately trying to fix this problem. This is a GLOBAL problem therefore it won’t be affecting just us. It may be affecting anyone who is using ignition well. Ti…

> [@pturmel](#):
>
> The correct answer varies by situation, but always requires some heartbeat or validation or fallback on the PLC side.

This is still the correct answer if a momentary button _must_ be used.

Personally, I avoid them.

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [August 27, 2022, 4:52am UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/7 "2022-08-27T04:52:51Z")

</div>

After some consideration, I realize that the PLC command should probably be written this way with the unlatch bit below the command bit:  
 ![PLC_Example](https://us1.discourse-cdn.com/inductiveautomation/original/3X/2/9/29b13c22e5080c4833f0be62ea150fdd3c342854.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 27, 2022, 1:06pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/8 "2022-08-27T13:06:49Z")

</div>

Unlatching in the PLC means that bit is being written by both Ignition and the PLC. Writing anything from two directions has inherent race conditions with OPC subscriptions. Use separate bits, or better, use an incrementing short integer.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [August 27, 2022, 1:32pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/9 "2022-08-27T13:32:57Z")

</div>

FWIW, I have never had any issues with unlatching commands in the PLC. I have been doing this practice for years and not just with Ignition… Wonderware, FactoryTrash, etc.

Can you give an example of a race condition on this? If the HMI writes, once the PLC sees it, it clears. What race condition can exist here?

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 27, 2022, 1:57pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/10 "2022-08-27T13:57:28Z")

</div>

Sigh. As noted elsewhere, I've been harping on this for years. Because, while rare in most cases, small disruptions can make it extreme:

[https://forum.inductiveautomation.com/search?q=tag%20write%20race%20user%3Apturmel%20order%3Alatest](https://forum.inductiveautomation.com/search?q=tag%20write%20race%20user%3Apturmel%20order%3Alatest)

The most likely race is when the PLC resets the bit _immediately_ (same scan) instead of waiting for a timeout.

The race is not applicable to many HMI's that have naïve write algorithms with direct PLC connections. OPC server's subscriptions (and similar technologies) with report-on-change make the race possible.

Also, your example:

> [@jlandwerlen](#):
>
> If the HMI writes, once the PLC sees it, it clears.

is not a momentary button behavior. That's a simple button sending a single write. The momentary button behavior where the signal is to be maintained while pressed is the vulnerable one. (There are other handshakes that are vulnerable, too, which is why my advice is more generic.)

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [August 27, 2022, 2:12pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/11 "2022-08-27T14:12:06Z")

</div>

Wasn’t my example, reread the posts. You responded to example PLC code and stated there could be a race condition. I asked how. Sigh.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 27, 2022, 2:21pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/12 "2022-08-27T14:21:02Z")

</div>

The sample PLC code in this topic both breaks the _maintained_ behavior of a momentary button and uses a pattern that is vulnerable to races. Sigh.

---

<div class="post-metadata">

**Author:** ![jlandwerlen](https://avatars.discourse-cdn.com/v4/letter/j/bc8723/32.png) [@jlandwerlen](https://forum.inductiveautomation.com/u/jlandwerlen)\
**Post date:** [August 27, 2022, 2:30pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/13 "2022-08-27T14:30:57Z")

</div>

Meh 🙂

---

<div class="post-metadata">

**Author:** ![justinedwards.jle](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/justinedwards.jle/32/37854_2.png) [@justinedwards.jle](https://forum.inductiveautomation.com/u/justinedwards.jle)\
**Post date:** [August 27, 2022, 9:37pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/14 "2022-08-27T21:37:29Z")

</div>

When I read this, I envisioned something like a simple start, stop, or reset function. I was not envisioning something like a jog function.

My apologies

---

<div class="post-metadata">

**Author:** ![nminchin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/nminchin/32/6911_2.png) [@nminchin](https://forum.inductiveautomation.com/u/nminchin)\
**Post date:** [August 28, 2022, 8:23pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/15 "2022-08-28T20:23:38Z")

</div>

> [@jlandwerlen](#):
>
> Sigh

> [@pturmel](#):
>
> Sigh

You guys 😂

---

<div class="post-metadata">

**Author:** ![gilles.levesque](https://avatars.discourse-cdn.com/v4/letter/g/919ad9/32.png) [@gilles.levesque](https://forum.inductiveautomation.com/u/gilles.levesque)\
**Post date:** [August 29, 2022, 12:33pm UTC](https://forum.inductiveautomation.com/t/momentary-button/12456/16 "2022-08-29T12:33:53Z")

</div>

You are right, it’s probably not the main reason we had this problem. But the Ignition HMI is working on this production line for more than 2 years, and it’s the first time we are having issues with the momentary push button… Any way I have made an AOI in the PLC to reset the Button after a preset time. That should be the long terme solution.
