The formula in the box says it all. New = Old + (Raw - Old)/FDC
At each moment when you have a new analog reading you determine the difference between it and the previous filtered value. The you preserve only a part of that to add to the previous filtered value to get the newest filtered value.
Prepare these memory areas (float would be best):
Old - which will be your filtered reading
Raw - which receives the newest reading from the analog module
Raw_Minus_Old - which will contain the difference between the newest reading and the old filtered reading
Divisor - this is the fraction of the difference you want to use
Raw_Minus_Old_Div - which will contain the fraction of the new difference you want to retain.
1. Process newest analog reading into the float value 'Raw'
2. Subtract this newest value from the previous filtered value. Store in 'Raw_Minus_Old'
3. Multiply 'Raw_Minus_Old' by your fraction you wish to keep (Divisor). Store this in 'Raw_Minus_Old_Div' (Note 1.00 is no filtering. As the fraction gets smaller you have more and more filtering. You won't use a number greater than 1.00)
4. Finally add 'Raw_Minus_Old_Div' to 'Old'
'Old' is your filtered reading. In the formula 'New' is the value of 'Old' on THIS scan (or iteration of the filter). 'Old' is the value on the previous time. They can actually be the same location.