Welcome!
![]() (to Pascal language fans too!) Technical
Other stuff
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 ![]()
| Connection...
![]() [ Password lost ? ] [ Join us ] ![]() ![]() ![]() Most ever online
![]() The 01/12/2024 @ 13:20 Webmaster - Infos
Ip: 18.216.69.124 Search
Friends News
Where are you from?
|