Host Engineering Forum
General Category => Do-more CPUs and Do-more Designer Software => Topic started by: RBPLC on October 19, 2020, 11:36:10 AM
-
Is there a direct way to get a running average for a value? Say I had a value at R100 and I wanted to "Start" averaging this value and store the average in R101 and then "Stop" at some other time (manual start/stop, sampling could be every scan or at some predetermined interval). I could probably come up with a solution but didn't know if there was a direct way to do this.
-
Is there a direct way to get a running average for a value? Say I had a value at R100 and I wanted to "Start" averaging this value and store the average in R101 and then "Stop" at some other time (manual start/stop, sampling could be every scan or at some predetermined interval). I could probably come up with a solution but didn't know if there was a direct way to do this.
I would just use FILTER. Virtually the same results, without the effort.
-
At my last job we used a running average over 24 hours to set the rate that we processed waste water so the process ran very consistently. I have the BRX code around here if that would help you.
-
Yes I would appreciate it.
-
Hope this helps. Two examples shown here in the Math blocks, clocked by a minute pulse, and there are 1440 minutes in a day.
-
Use FIFO. Then use math to average the fifo table. Works great to get a rolling interval average, if that is what you need.
-
Yeah, FIFO's PROBABLY the best. Ring accumulator works OK for storing the last n values too.