
with a boolean flag called do_normal_work_flag. a limit switch closing we wish to pause for three
#How to build a rentive on delay timer siemens step 7 code
task with a section of code that simply increments that can be interrupted by a pause when some In this example we are executing normal tasks In the following example we want a pause in normal operations when some condition occurs: The reset flag will be turned back off at the beginning of the next scan. In order for our flag to take effect we must call the TONR instruction one more time. To do this we set the Reset flag to true. The last thing that we want to do at the end of the true side of the IF statement is to reset the timer so it will count down again. The line that increments the tag my_work simply represents some task that we want to happen every second. On the first scan after the timer has expired and the done flag is set we enter into the true side of the IF statement. Nothing else will happen in this routine until the timer expires and the done flag is set. We must make sure we call the TONR instruction before reading any tag values to ensure the state of the tag is current. Notice that we check this done flag after we called the TONR instruction. Since we keep the TimerEnabled flag on, the timer is always running. Here we are checking the done flag (DN) of the my_TONR tag. Since we have changed values in the my_TONR tag including the Reset flag, we must call the TONR instruction in order for them to take effect. Later when we use this flag to reset the timer by setting it to true, we will need to set it back to false ourselves because it will not be reset by the timer. Also, at the beginning of each scan, we will set the Reset flag to false. Even though we set these values on each scan, it doesn’t hurt to do so because the values are constant and don’t ever change. We will set the TimerEnable to be true and leave the timer enabled throughout this example, while the timer is controlled with the reset flag. In this case we will set it to 1000 milliseconds and it will trigger every second. The PRE tag contains the number of milliseconds that the timer will count down. In this example the first two lines set up some initial values. call TONR() in each scan after you set the Reset value

this represents work being done once per second call TONR() in each scan after you set the Reset value and before you read the DN value you MUST clear the reset flag yourself, it doesn’t happen automatically this can be placed in an initialize step but it doesn’t hurt to set these each time Here is a simple example where the timer executes a line of code once every second: If you don’t the values won’t be correct.Ĥ. You must call TONR before you read values from your tag such as the DN bit. If you don’t the changes won’t take effect.ģ. You must call TONR after you change values in your tag in the same scan. This got me for a while, I was afraid I would overwrite something, but it is safe to do so.Ģ. You can call TONR multiple times during a single scan.

Siemens offers 7PV0 electronic timers which meet the various control timing requirements of the industry.Four Simple Rules for Using TONR in Structured Text By Douglas TaylorĪfter struggling with using the TONR instruction within structured text in Logix 5000, I have empirically devised four rules that takes the mystery out of it.
