Timer reset to zero

Hi,
I am trying to get the timer to reset to zero at a specific time, I am using a gateway script schedule to change a tag called reset to value 1 which is resetting a counter but I cant figure out how to get this to zero the timer value?

Thanks,
Alex

What timer ? You need to be a bit more accurate, we don't know your system and we can't just guess what you're talking about.

That said, it seems like you want a tag change to trigger something. There are 2 different kind of tag change scripts: On the tag itself, or in the gateway events. You can use one of those (probably the gateway event in your case) to script whatever you want.

Sorry, I am using the timer in vision and I want it to reset the value on the timer property to 0 when the reset tag = 1, I am using the gateway event to set the reset tag value to 1 but don't know how to link this across to a property to set the timer value to 0.
Hope that makes more sense

Thanks

Create a custom property on the timer component and bind that reset tag to it. Then use a propertyChange event to monitor the custom property and perform the reset.

Hi Phil, I didn't think you could create a custom property on a timer in vision? could I creating a custom property elsewhere and do the same thing?

Yeah, if any given component doesn't have the ability to use custom props, I just use its container.

once I have the property made on the root container called reset and assigned to the reset tag to it, how do I go about scripting on the timer for the set value to 0 sorry?

So, you would create a property change event on the root container that looked something like this:

if event.propertyName == 'reset':
	if event.newValue:
		timer = event.source.getComponent("Timer")
		timer.value = 0

Sorry @pturmel I am new to the scripting side of ignition, I have followed the steps but cant get it to work have I made an error somewhere?
Screenshot 2024-02-06 152505
Screenshot 2024-02-06 152522

Your custom property has a capital R. Match that in line #1 of the script. Pretty much everything in scripting is case sensitive.

1 Like

Thank you very much for your help that has worked now!