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

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

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?

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.

2 Likes

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

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?

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.

1 Like

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!