This works really well for a signal that is being measured on a regular basis. This results in a signal thats filtered much like an RC circuit. In an RC circuit one time constant gets you to reach ~66% of the full scale value and ~5 time constants gives you the final value. Using this formula each sample is like a time constant that gives you 1/x of the stable value where x is the number of shifts in the subtraction operation. The number of samaples required to reach a stable value is dependant on the number of shifts.
Code:
{ Analog_Input_1_RAW-=(Analog_Input_1_RAW>>2); // Decrement by 1/4
Analog_Input_1_RAW+=read_adc(ADC_READ_ONLY); // Add current value to filtered reading
}
This example results in a 12 bit result derived from the 10 bit ADC. If the RAW readings are going to be scaled these extra 2 bits dont matter and do nothing to reduce precision of a scaled result.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum