# Auto-turn off a PLC Bit after a user-input timeout?

**URL:** <https://forum.inductiveautomation.com/t/auto-turn-off-a-plc-bit-after-a-user-input-timeout/31410>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [January 20, 2020, 1:51pm UTC](https://forum.inductiveautomation.com/t/auto-turn-off-a-plc-bit-after-a-user-input-timeout/31410 "2020-01-20T13:51:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [January 20, 2020, 1:51pm UTC](https://forum.inductiveautomation.com/t/auto-turn-off-a-plc-bit-after-a-user-input-timeout/31410/1 "2020-01-20T13:51:01Z")

</div>

I’ve been trying to see if there’s a way to do this without scripting or minimal scripting.

I have UDT data tag that has a few OPC connections, the relevant ones being

```auto
runBit - 0 for stop, 1 for run, read from and written to OPC
presentValue - present value of OPC
timeoutSP - memory tag, input from user, how long until timeout

```

The idea we want to implement is such - when a user clicks start, the `runBit` is set to a 1. The `runBit` then has a 0 written two it in only one of two ways - the user manually clicks stop, or the timeout limit is reached. For example, if we have a timeoutSP of 300 seconds, and someone clicked “Start” as 10:00 am, then if the user does not do anything else, at 10:05, the runBit will have a 0 written to it. If the user decides to turn it off before 10:05, thats fine as well.

I was thinking something of having a new property of the UDT that kept track of when the runBit is turned on with some date arithmetic to figure out the timeout time, to determine if it should be turned off. But from there, I’m not really sure how to proceed and it’s starting to feel convuluted. I feel like there was a way to do this from the Ignition University videos. Is there a built in way for this functionality?

---

<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:** [January 20, 2020, 2:46pm UTC](https://forum.inductiveautomation.com/t/auto-turn-off-a-plc-bit-after-a-user-input-timeout/31410/2 "2020-01-20T14:46:27Z")

</div>

Consider using a timeout date (not a number) memory tag and a boolean expression tag (runBit). The expression would simply compare now() versus the timeout date, with OPC writeback enabled to send it to your PLC.

Your start button’s actionPerformed would set the timeout memory tag to now() plus your desired interval (timeoutSP). The stop button’s actionPerformed would set the timeout to a constant date in the far past.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [January 20, 2020, 2:50pm UTC](https://forum.inductiveautomation.com/t/auto-turn-off-a-plc-bit-after-a-user-input-timeout/31410/3 "2020-01-20T14:50:45Z")

</div>

Ah ok the OPC Writeback was the part I was missing. Thanks!

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [January 20, 2020, 3:46pm UTC](https://forum.inductiveautomation.com/t/auto-turn-off-a-plc-bit-after-a-user-input-timeout/31410/4 "2020-01-20T15:46:56Z")

</div>

I understanad the logic, but I guess I am missing something trivial here. I have my boolean expression thats 0 or 1 according to time out calcualtions, where do I tell this to write back to the runBit tag? Write a tag Event Script on it or is there an actual property I can just set to it?

---

<div class="post-metadata">

**Author:** ![witman](https://avatars.discourse-cdn.com/v4/letter/w/d2c977/32.png) [@witman](https://forum.inductiveautomation.com/u/witman)\
**Post date:** [January 20, 2020, 4:54pm UTC](https://forum.inductiveautomation.com/t/auto-turn-off-a-plc-bit-after-a-user-input-timeout/31410/5 "2020-01-20T16:54:23Z")

</div>

> [@bkarabinchak.psi](#):
>
> Write a tag Event Script on it

There used to be a checkbox to enable OPC write back. I believe this was eliminated in favour of tag event scripts in Ignition 8.

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [January 20, 2020, 5:05pm UTC](https://forum.inductiveautomation.com/t/auto-turn-off-a-plc-bit-after-a-user-input-timeout/31410/6 "2020-01-20T17:05:51Z")

</div>

Ah ok I thought there used to be a property for it but yea now we’re starting to use Ignition 8.0 for all new projects and I didn’t see it. That explains it. Thanks!
