News:

  • August 21, 2026, 12:27:07 AM

Login with username, password and session length

Author Topic: Timer Loop  (Read 8558 times)

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Timer Loop
« on: January 04, 2020, 10:32:18 PM »
Attached is a timer array running inside of a loop (in simulator). It appears to be working the way I would expect it to but I have the warning messages shown at the bottom of the screen. Is what I have programmed bad practice and if so what would be the correct way to program it? I must confess I get easily confused about best practices concerning multi-scan and yielding instructions.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6172
  • Yes Pinky, Do-more will control the world!
Re: Timer Loop
« Reply #1 on: January 05, 2020, 01:04:48 AM »
We warn because it can be a problem. If you understand it and know that it isn?t, ack the warning for that instance and move on.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

RBPLC

  • Hero Member
  • *****
  • Posts: 586
Re: Timer Loop
« Reply #2 on: January 05, 2020, 06:54:24 AM »
Is it bad practice to use a multi-scan instruction inside of a for loop? What potential issues would you see doing that that would prompt the warning message?

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 6172
  • Yes Pinky, Do-more will control the world!
Re: Timer Loop
« Reply #3 on: January 05, 2020, 11:00:04 AM »
It isn't an issue of best practices. It's an issue of working right or not. The way you are doing it works fine as long as you do it in a program or task that has a .TimeSlice value of 65535. You posted this originally on ADC's forum under Productivity. I'm not familiar with their implementation, so I don't know if it will work there or not.
"It has recently come to our attention that users spend 95% of their time using 5% of the available features. That might be relevant." -BobO

Controls Guy

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 3626
  • Darth Ladder
Re: Timer Loop
« Reply #4 on: January 05, 2020, 12:32:24 PM »
Attached is a timer array running inside of a loop (in simulator). It appears to be working the way I would expect it to but I have the warning messages shown at the bottom of the screen. Is what I have programmed bad practice and if so what would be the correct way to program it? I must confess I get easily confused about best practices concerning multi-scan and yielding instructions.

The timer works by accumulating scan time every time it's run, so each timer must be executed every scan.  If you do that it'll be OK.
I retract my earlier statement that half of all politicians are crooks.  Half of all politicians are NOT crooks.  There.