News:

  • October 13, 2025, 01:37:43 PM

Login with username, password and session length

Author Topic: Count (0) out of range in AVGR  (Read 1527 times)

jcb

  • Full Member
  • ***
  • Posts: 41
Count (0) out of range in AVGR
« on: December 03, 2019, 03:56:39 PM »
Why would I get this error? The way I understand it there should be no way for the AVGR to be interpreted if the Count Variable is 0?

I am triggering this on a falling edge diferential inside a stage. This is on the same output rung that jmps the next stage.

V2151 = CountIfNE(0, R151, 98)

R148 = IF(V2151 != 0, AVGR(R151, V2151), 0)

MOVE 0 into V2151

Everything works fine but I hate seeing the warning on the status bar.

Thanks in advance,
John.


franji1

  • Bit Weenie
  • Host Moderator
  • Hero Member
  • *****
  • Posts: 3761
    • Host Engineering
Re: Count (0) out of range in AVGR
« Reply #1 on: December 03, 2019, 04:04:18 PM »
The MATH instruction performs all branches, so IF(A, B, C) will always evaluate A, B, and C.

However, if you move the IF functionality to Ladder Logic (I like using the NOT contact for IF/THEN/ELSE in Ladder), it will do what you expect (see attachment)

jcb

  • Full Member
  • ***
  • Posts: 41
Re: Count (0) out of range in AVGR
« Reply #2 on: December 03, 2019, 04:43:50 PM »
Fixed.

Thank you.