I wrote: > One approach would be to "dither" the rounding by simply adding 1 or adding > 0 on alternate iterations. "Peter L. Peres" wrote: > I also think that the fiddling with conditional > clauses will introduce points of discontinuity into the mapping function > and if this is a part of a servo or some control loop it may react > strangely to those points. Olin Lathrop wrote: > I agree. That kind of fiddling will only lead to trouble. Then you guys simply do not understand the concept of "dither", which has a long tradition of application in both control systems and audio applications for *linearizing* the response when dealing with quantization effects. A simple "square wave" dither of 1/2 LSB seems perfect for this application, in terms of low computational cost. Random dither would be more difficult to compute, and would probably have no net benefit for the overall application. Anyway, another approach would be to simply avoid the internal quantization altogether by maintaining the filter state as a 16-bit variable to begin with. Just take the high byte as the 8-bit output value when you need it. Something like this: filter is a 16-bit variable used to maintain the state of the filter factor is an 8-bit constant whose value is 256 * FFrac filter = filter + (new - filter>>8) * factor; Where "filter>>8" is just C-style notation for "the high byte of filter". This is an 8-bit subtract, an 8*8->16 multiply (which can be optimized to a 16-bit shift if factor is a power of 2), and a 16-bit addition. The only cost is one more byte of data storage. -- Dave Tweed -- http://www.piclist.com hint: To leave the PICList mailto:piclist-unsubscribe-request@mitvma.mit.edu