News:

  • April 18, 2024, 02:08:42 PM

Login with username, password and session length

Author Topic: Scan time savings  (Read 1259 times)

PLCwannabe

  • Hero Member
  • *****
  • Posts: 173
Scan time savings
« on: September 15, 2019, 01:17:49 AM »
 Good evening all

 As my program is growing larger I notice the scan time increasing. I've seen it up to 20 mS. I'm using quite a few FOR loops now, seems like they are a little slow. Also wondering about rungs with multiple parallel branches, as opposed to math functions, which method increases the scan time more. Attached are a couple examples of the same control logic in different ways. I prefer the math function as takes up less space, but I don't want it to slow down the whole scan.

BobO

  • Host Moderator
  • Hero Member
  • *****
  • Posts: 5984
  • Yes Pinky, Do-more will control the world!
Re: Scan time savings
« Reply #1 on: September 15, 2019, 09:17:04 AM »
Loops are slow, but when put into tasks/programs with a yielding time slice, can break the work up across multiple scans.

Math is fast, particularly integer math.
"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

ATU

  • Internal Dev
  • Hero Member
  • ****
  • Posts: 2121
  • YKPAIHA
    • ATU, Inc.
Re: Scan time savings
« Reply #2 on: September 16, 2019, 12:23:16 PM »
Using stages to execute looping may actually yield a faster overall scan time, but the overall time of indexing the loop will be longer.  Which you choose, depends on your application.