How to configure a 10 Second timer

The following Scheduler configuration will set Output1 to the on state when you set TagA to 1 momentarily with the push button. Output 1 will remain on for 10 seconds, while Timer counts from 1 to 10. When Timer reaches 10, Output 1 is reset to 0. The rectangle’s caption will show ON or OFF, based on the state of Output1.

 

 

 

Another method is to use the following script, such that when you set the value of Timer2 to 1, Output2 gets written to a 1 until Timer 2 reaches the value 10 and is reset:

 

Parents
  • Thanks for this post it was exactly what I was looking to do.

    I was able to get the first Timer example to work as expected and modified it for my use. But the Timer2 Script example is not working as I would expect it to.

    I made a copy of the TagA button from the scheduler example and changed the On Down script to $Timer2=1 and removed the code from the On Up. When I press the new button Timer2 does count up to 10 and the output turns on and off as expected. The issue is that it counts to 10 in about 2 seconds, not the 10 seconds I would expect. I am guessing it has something to do with the Second tag used for execution of the script.

    I just did some testing and using the Second tag is the reason why the script is not working as I expected. Because the Second tag is considered to be true for 59 seconds out of every minute. So the script will run as fast as it can until the second tag gets back to zero, be false for 1 second and the be true for another 59 seconds.

    How can the script be written to work as I would expect it to?

Reply
  • Thanks for this post it was exactly what I was looking to do.

    I was able to get the first Timer example to work as expected and modified it for my use. But the Timer2 Script example is not working as I would expect it to.

    I made a copy of the TagA button from the scheduler example and changed the On Down script to $Timer2=1 and removed the code from the On Up. When I press the new button Timer2 does count up to 10 and the output turns on and off as expected. The issue is that it counts to 10 in about 2 seconds, not the 10 seconds I would expect. I am guessing it has something to do with the Second tag used for execution of the script.

    I just did some testing and using the Second tag is the reason why the script is not working as I expected. Because the Second tag is considered to be true for 59 seconds out of every minute. So the script will run as fast as it can until the second tag gets back to zero, be false for 1 second and the be true for another 59 seconds.

    How can the script be written to work as I would expect it to?

Children
No Data