Host Engineering Forum
General Category => General Discussion => Topic started by: Controls Guy on September 05, 2014, 02:56:22 PM
-
It just struck me the math in a FILTERB must be integer. I'm using one to smooth a [usually] noisy analog input. Yesterday the input happened pretty stable, and I noticed that the filtered value asymptotically approached the unfiltered value, but stopped at (Filter Count / 2) counts away from the unfiltered value, the /2 due obviously to rounding.
This could be almost totally avoided by doing the math in floating point, but then you'd have to convert to real and then convert the result back to integer, which would make the instruction much slower, and is also unnecessary because in those cases where we need that, we can either decide to use those values as reals, or do the convert and convert-back explicitly in ladder. It was just something interesting that I noticed and thought worthy of note for people applying FILTERB. I never stopped to think about it.
-
It just struck me the math in a FILTERB must be integer. I'm using one to smooth a [usually] noisy analog input. Yesterday the input happened pretty stable, and I noticed that the filtered value asymptotically approached the unfiltered value, but stopped at (Filter Count / 2) counts away from the unfiltered value, the /2 due obviously to rounding.
This could be almost totally avoided by doing the math in floating point, but then you'd have to convert to real and then convert the result back to integer, which would make the instruction much slower, and is also unnecessary because in those cases where we need that, we can either decide to use those values as reals, or do the convert and convert-back explicitly in ladder. It was just something interesting that I noticed and thought worthy of note for people applying FILTERB. I never stopped to think about it.
Your observation, analysis, and conclusions are just as we designed! Other tidbits:
- 05 does NOT support REAL, but does support FILTERB IBox, yet another reason for doing it all in integer math
- The algorithm for FILTER IBox (BCD version) is similar.