![]() |
|
#1
|
|||
|
|||
An alternative to block processingHello!
I'm trying to implement, in C++, an averaging filter, which is represented by the following equation: y[n] = (1 - a)*x[n] + y[n-1] Where y[n] = current output, y[n-1] = previous output and x[n] = current input. My implementation of this is as follows: CPP / C++ / C Code:
This works fine when the data is known and is read from a static array or from a file, but my application will require the data to be read from an Analog-to-Digital Converter. How do I rewrite this program so that it doesn't do block-processing but reads data sample by sample. The program will have to keep the previous sample's output in memory, to calculate the average. Thanks! |
|
#2
|
|||
|
|||
|
Quote:
Well, in general the algorithm can be described like this: Algorithm: Repeat for each new value of x: 1. CurrentValueOfY = (something * CurrentValueOfX) + (somthingelse * OldValueOfY); 2. OldValueOfY = CurrentValueOfY; 3. /* do whatever you need with the current value of y */ Generic code could look something like this: CPP / C++ / C Code:
Unless you need the history of input and/or output sigals for other purposes, that's the filter! Does that help? |
Recent GIDBlog
Stupid Management Policies by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to do basic image processing using MFC | yuhui | MS Visual C++ / MFC Forum | 5 | 08-Aug-2006 06:43 |
| Having a problem | Chuckles | Computer Hardware Forum | 19 | 13-Sep-2004 13:17 |
| [CONTEST?]Data Structure Test | dsmith | C Programming Language | 2 | 06-Jun-2004 16:13 |
| Microsoft to block Trillian from MSN messenger on October 15th | jrobbio | Computer Software Forum - Windows | 1 | 12-Sep-2003 19:35 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The