In SX Microcontrollers, SX/B Compiler and SX-Key Tool, Beau Schwabe wrote: There are several ways to do this. Below is basically a digital low pass filter... This method allows you to dynamically set the number of samples without using the variable space to hold each sample. [code] New = {Sensor reading} DataBuffer = DataBuffer - Avg + New Avg = DataBuffer / Samples [/code] If 'Avg' is a BYTE variable, and 'DataBuffer' defined as a WORD, you can effectively hold an Average consisting of a maximum of 255 samples. If 'Avg' is a NIB, then 4096 samples can be achieved. The variable called 'Samples' can be a constant therefore not impacting the available variable space. ---------- End of Message ---------- You can view the post on-line at: http://forums.parallax.com/forums/default.aspx?f=7&p=1&m=175860#m175910 Need assistance? Send an email to the Forum Administrator at forumadmin@parallax.com The Parallax Forums are powered by dotNetBB Forums, copyright 2002-2007 (http://www.dotNetBB.com)