Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
10/21/07 10:27
Modified:
  10/21/07 10:28

Read: times


 
#145970 - You usually don\'t _want_ a stable last digit.
Responding to: ???'s previous message
Someone remarked that I need to implement a low pass (CR circuit) filter in software but how the hell do do that?

There are many ways to implement a digital low-pass filter, and trying to imitate a RC lowpass might not even be the best idea.

The simplest way to "stabilize" the last digit would be to use a simple moving average filter, i.e. take the last X ADC outputs, add them together, divide by X, and that's your "stabilized" filter output. Of course, using a power of 2 as X has quite a few advantages, such as making the division by X a simple bit-shift instead of an actual division.

All other filters will quite quickly start diving into the realm of digital signal processing. If you've never heard the term "z-transform", you might want to get yourself a book about the basics of DSP. Beware, though - if you're allergic to math, you may want to stay away from that topic as far as possible.

I found this book to be very comprehensive, and the author really starts at the basics, but unavoidably starts getting deep into heavy-duty math after the first few chapters. Some of the chapters I found very hard to digest, but the ones about general digital signal processing are very detailed and understandable.

http://www.amazon.com/Digital-S...920&sr=8-1

If the frequency response of a moving average filter doesn't fit your requirements, the next best try would be using a different type of FIR (finite impulse response) filters. They have the advantage of being fairly easy to design and hanldle numerically.

If you want to imitate an actual analog filter (such as RC), you'll have to use an IIR digital filter (infinite impulse response). Unless you're aware of the can of worms that you're opening by using this type of filter (it's recursive, so it may be unstable, depending on the parameters, and it has some additional pitfalls as far as numerics go), you might want to stick with the very simplest of IIR filters, like

Y(n) = X(n) + a * Y(n-1)

or

Y(n) = 0.5 * (X(n) + X(n-1)) + a * Y(n-1).

(Y is the filter output, X is the filter input. a affects the time constant and the gain of the filter, and needs to satisfy -1 < a < 1 for the filter to be stable, and 0 <= a < 1 for the filter to be non-oscillating).

Oh ... and you usually don't want a stable last digit in the raw adc output, because this will prevent you from using decimation to increase the resolution of the ADC.

List of 64 messages in thread
TopicAuthorDate
ADC last digit stability            01/01/70 00:00      
   DVM            01/01/70 00:00      
      DVM's only 10 bits?            01/01/70 00:00      
         Frequency response            01/01/70 00:00      
            Typically twice or more the sampling frequency            01/01/70 00:00      
               Missing the point            01/01/70 00:00      
   You usually don\'t _want_ a stable last digit.            01/01/70 00:00      
      Result            01/01/70 00:00      
         Hm.            01/01/70 00:00      
      Averaging/DSP/FIR filters            01/01/70 00:00      
         Math lecture ?            01/01/70 00:00      
            Can't use average-too slow            01/01/70 00:00      
               Analysis            01/01/70 00:00      
               already stated            01/01/70 00:00      
               Derivation            01/01/70 00:00      
                  The nitty gritty stuff            01/01/70 00:00      
                     Simulate using a spreadsheet            01/01/70 00:00      
                        Hi Russ and thanks for that            01/01/70 00:00      
                           My spreadsheet vs. your spreadsheet            01/01/70 00:00      
                              Unit test !            01/01/70 00:00      
                     As I said...            01/01/70 00:00      
                        Calibration?            01/01/70 00:00      
                           Horsefeathers            01/01/70 00:00      
                              Longs?            01/01/70 00:00      
                                 A long is more "accurate" than a float.            01/01/70 00:00      
                                    Yes it is, but....            01/01/70 00:00      
                                       _Known_ transfer functions.            01/01/70 00:00      
                                          FP pitfalls            01/01/70 00:00      
                                             The compiler isn't going to take care of that.            01/01/70 00:00      
                                                Mantissa fields            01/01/70 00:00      
                                                   Misunderstandings ?            01/01/70 00:00      
                                                      Adding FP's accurately            01/01/70 00:00      
                                 can you not read ?            01/01/70 00:00      
                           Nonsense ...            01/01/70 00:00      
                              Calculator?            01/01/70 00:00      
                     If you're really curious ...            01/01/70 00:00      
                        Climax time            01/01/70 00:00      
                           OOPS!!....            01/01/70 00:00      
                           Equations            01/01/70 00:00      
                              Quantisation            01/01/70 00:00      
                                 Works in unsigned integer, too:            01/01/70 00:00      
                                    Abstract?            01/01/70 00:00      
                                       Useful abstractions.            01/01/70 00:00      
                                          Nice talking with you, Christoph.            01/01/70 00:00      
                           What are the actual requirements ?            01/01/70 00:00      
                              re filters            01/01/70 00:00      
                              And moving forward            01/01/70 00:00      
               You can not due to Dither            01/01/70 00:00      
         Clueless ?            01/01/70 00:00      
            Just dump the LSB            01/01/70 00:00      
               Don't forget proper rounding.            01/01/70 00:00      
            Speaking of DSP            01/01/70 00:00      
         Fluke stability            01/01/70 00:00      
   Oh yes they do!            01/01/70 00:00      
   my take on this            01/01/70 00:00      
      Walk, don't run            01/01/70 00:00      
         :)            01/01/70 00:00      
      Hello Erik            01/01/70 00:00      
         have fun, Jason            01/01/70 00:00      
            I am having fun            01/01/70 00:00      
               Ok, you are aware of this            01/01/70 00:00      
                  He's learning            01/01/70 00:00      
                  Assumptions            01/01/70 00:00      
                     and I ...            01/01/70 00:00      

Back to Subject List