Programming Reference / Timers / Retentive Timer Example
A Retentive timer is one that when the elapsed time is less than the Preset value, a leading edge Stop command stops the timer and hold the accumulated elapsed time value. In this state, a leading edge Continue command causes the timer to restart and continue accumulating elapsed time without any reset to 0. This Stop and Continue sequence can continue as long as the elapsed time is less than the Preset time.
When the timer is Done, a maintained Continue command will cause the Accumulator to elapse time beyond the Preset value. Removal of the Continue command will cause the timer to stop accumulating elapsed time but will not reset the accumulator to 0. The only way to reset the Accumulator to 0 and reset the Done value to FALSE is to give a leading edge Start command.
Retentive Timer when Accumulator < Preset
Item | Description |
---|---|
① | When the leading edge of the Run signal is made, the timer begins timing and the Accumulator holds the value of elapsed msec. The Status value becomes 0 indicating that the timer is running. |
② | The Accumulator value becomes equal to the Preset value. The Done value becomes TRUE, the Status value = 2 indicating the timer is stopped and Done elapsing. The Accumulator maintains its elapsed value. |
③ | Because the selected timer has not received a Stop command, any leading edge signal inputs for the Run command are ignored |
④ | When the leading edge of the Stop signal is made and the timer is Done, the timer sets an internal flag that tells it that upon the next leading edge of the Run signal to reset the Accumulator to 0 and begin timing |
⑤ | When the leading edge of the Run signal is made, the timer begins timing and the Accumulator value increases with the elapsed msec. The Status value becomes 0 indicating that the timer is running and the Done value is set to FALSE. |
⑥ | When the Run signal is being maintained, a leading edge of the Stop signal will cause the timer to stop and Accumulator freezes at its last value. Also while the Stop signal is maintained, the timer remains stopped which is indicated by the Status value = 1. Because the Run signal is on when the Stop signal is removed, the Accumulator resets to 0 and the timer begins to run. The Status value then = 0 indicating the timer is running |
⑦ | The Accumulator value becomes equal to the Preset value. The Done value becomes TRUE and the Status value = 2 indicating the timer is stopped and no longer elapsing. The Accumulator maintains its elapsed value. |
Retentive Timer when Accumulator > Preset
The difference is that the Continue command becomes momentary/maintained in the program scan and not leading edge. The Accumulator only increases elapsed time while the Continue command is active.
Item | Description |
---|---|
① | Once the timer is Done, when the Continue command is TRUE and is held TRUE, the timer runs and Accumulator value increases beyond the Preset value. The Done Boolean remains TRUE and the Status value = 0 indicating the timer is running. |
② | When the Continue command becomes FALSE, the Accumulator value remains at its last value and the Status value = 2 indicating the timer is not running and the Done Boolean is TRUE. Note that the Done Boolean remains TRUE regardless of the state of the Continue command. |
③ | Same as ① |
④ | Same as ② |
⑤ | Upon the leading edge of the Start command, the Accumulator value resets to 0 and will continually stay at 0 as long as the Start command is TRUE. Once the Start command goes FALSE, the timer runs and the Accumulator value increases. Note that the Done Boolean immediatley switches to FALSE upon the leading edge of the Start command |
⑥ | When the Accumulator = Preset, the timer stops running, the Done Boolean goes to TRUE, and the Status value = 2 indicating the timer is stopped and the Done Boolean is TRUE. |