Best way to turn boolean tag value high every 5 seconds?

Handshake issues asside, i'm not sure this is the most efficient way but in your place i would do the following:

  • Create a Timer Gateway Event, configure it with a delay of 5000(ms) with fixed delay and shared threading.

  • Use the following script:

#Read the tag value.
#readBlocking requires you to use a list of tags to read and
#returns a qualified value.
#A list containing only the tag we want to read is passed
#to the function and then
#we look into the .value part of the qualified value from the 
#first and only returned item
myTag = system.tag.readBlocking(['TagAddressHere'])[0].value

if myTag == False:
	#Write only if the Tag is False.
	#If your tag is True for too long, the alarm should detect it.
	#Similar to readBlocking, writeBlocking needs you to provide
	#a list of tag paths to write to along with a list of values to
	#write to each address
	system.tag.writeBlocking(['TagAddressHere'],[True])

The Equal mode with a setpoint of 1 will monitor when your tag is True to turn on the alarm but with the Active delay set to 15, it should wait 15 seconds before actually activating the alarm.

I hope this helps!

1 Like