Welcome!
Welcome PIC fans! (to Pascal language fans too!) Technical
General documentation
How to support PMP Manuals
Tips
Other stuff
Documentation How to support PMP
Off Topic Today's favourites
Search
Downloads
The last 5 downloads
The last 5 most downloaded
|
Tips - Implementing a low pass filter for ADC or any value
To minimize noise or to limit the response to a disturbing phenomenon, the ADC values may be processed by a LPF (Low Pass Filter) that may be easily implemented with a very common exponential single pole filter:
To workaround this, we may use a scaled accumulator, say: a 32-bit accumulator for filtering 16-bit values. Example: We may use values scaled by P32 = 65536; this is optimal because 65536 = (1 shl 16). The formula becomes: AccValue32 := (AccValue32 * (N - 1) + NewValue32 * P32) div N; Value16 := AccValue32 div P32; With N = 16, and P32 = 65536 and 16-bit New16 input value, it comes: AccValue32 := (AccValue32 * 15 + (longword(New16) shl 16) shr 4; Value16 := hiword(AccValue32); // The filtered 16-bit output value is simply the high word of the accumulator. At initialization (or at first input value), we do: AccValue32 := longword(New16) shl 16; Value16 := New16; This is easy for the compiler's optimizer to generate fast code and there is no floor or ceiling phenomenon. Creation date : 2010.08.13 3:44 PM Reactions to this article
| Connection...
Members : 75
[ Password lost ? ] [ Join us ] Member online :
Anonymous online : 32
Total visits: 1704521
Most ever online
Total : 200
The 20/10/2024 @ 06:06 Webmaster - Infos
Ip: 13.58.161.115 Search
Friends News
Where are you from?
|