Author Topic: Computing an average: need help finding a bug.  (Read 6807 times)

ET

  • Guest
Computing an average: need help finding a bug.
« on: October 26, 2012, 06:56:41 PM »
I'm building an averaging function, and most of the components are working fine; I am successfully filling an array with your numbers to average X1, X2...Xn.
However, the last step, computing the average from an array of numbers, is not working.
My loop appears to only loop one cycle, and end prematurely.
So, instead of computing (X1 + X2 ... + Xn) / n, I'm getting X1 / n.
Attached is the pertinent page, if anyone would like to help.

P.S.
I'm building this, because the average filter function block, in the basic library from SDF only computes averages with 3 to 7 numbers, and numbers from 2 to 7.
TWO to SEVEN.
This is not even remotely useful for averaging numbers in a normal program, which will be many times larger.
« Last Edit: October 26, 2012, 10:07:13 PM by ET »

ET

  • Guest
Re: Computing an average: need help finding a bug.
« Reply #1 on: October 26, 2012, 11:09:06 PM »
Built an even simpler loop for testing, and it turns out that the 'loop counter level' is never incrementing.
It's wired the same as in the example, so I have no idea what is going on.

Offline Jakob

  • PLUS+1 Expert
  • ****
  • Posts: 98
  • Karma: +2/-0
Re: Computing an average: need help finding a bug.
« Reply #2 on: October 29, 2012, 08:37:10 AM »
It looks like your loop counter is reset, at every puls.
That could explain the problem.

ET

  • Guest
Re: Computing an average: need help finding a bug.
« Reply #3 on: October 29, 2012, 09:31:23 PM »
I've given up using the repeat-until loops in GUIDE for this, and just built my own clock signal to walk through the array of samples.
Averaging filters attached to this post:
http://www.sauer-danfoss-plus1.com/index.php?topic=404.0