Hi Scott, From: "Scott Dattalo" > > I think this may be what you're looking for: > > http://www.dattalo.com/technical/software/pic/medfilt.asm > Thanks for this it looks interesting. However I don't think the code you gave a pointer to does what you just described (it seems to do a lot more!). The code you have given a pointer to seems to maintain a secondary set of pointers to 16 bit data (not 12 bit) that are used to maintain a sorted version of the circular buffer. Then when you want to obtain the actual output of the filter you can drop an arbitary number of entries from the low and high end of the sorted data (as defined by high index and low index) the remaining middle data points are then summed and used to provide an average of these points. I may have got this wrong but I think this is what the code does (and it seems to do it very well). This would appear to be a superset of your described algorithm did you by any chance refine one into the other? Anyway thanks a lot for the input. Refering to your originnally described algorithm I have been thinking along similar lines. In psudoe code I was thinking of doing the following add_data_point(val) /* maintain simple circular buffer of ARRAY_SIZE data items */ data[index] = val index = index + 1 if (index >= ARRAY_SIZE) index = 0 get_filter_value() /* get hold of the average of the data points dropping the highest and lowest sort of comined median and average filter */ low = MAX_VALUE high = MIN_VALUE sum = 0; for(i=0; i<=ARRAY_SIZE;i++) sum = data[i] + sum if (data[i] > high) high = data[i]; if (data[i] < low) low = data[i]; sum = sum - high - low; return sum/(ARRAY_SIZE - 2) I think that the above is equivalent to the mechanism you have described except that it does more work when the data is needed rather than when it is inserted. Is this correct? Or have I got things totally wrong? Thanks again Andy -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics