Announcement

Collapse
No announcement yet.

Timer inside a Loop

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • kewakl
    replied
    @OP, you are not the only one to observe issues when placing timers in loops - link

    Leave a comment:


  • ControlsGuy
    replied
    It's a side effect of the way they accumulate time in a timer. Every time the timer instruction is executed, they add the last scan time to the accumulator, so for a loop, the scan time gets added four times every scan.

    Either multiply your timer setpoint by [loop count] or better yet, do your own clock-based timer. To do a clock-based timer, on the first scan where enabled, take the current clock time and add the timer setpoint. Then you have a scheduled time for timer expiration. Whenever your code is executed check the current clock time and determine if the timer has expired. If the Click doesn't have a real time clock, make your own or use a free-running timer or timer-counter hybrid as your time reference. Make sure that one is not inside a loop.

    Leave a comment:


  • Skolbuc
    started a topic Timer inside a Loop

    Timer inside a Loop

    I have ran into a problem and am wondering if anyone knows how to fix it or has also experienced it. I am using CLICK Programming Software Version 2.60. I am trying to put a timer in a For loop, but when I increase the amount of times I want it to loop, it also increases the speed of the timer. For example in the picture below I have the loop set to 4, and this is causing my timer to go 4x as fast. Then if I change that loop to 1, the timer will go regular speed. I want my timer to go regular speed but loop 4 times.
    Attached Files
Working...
X