Sign in

Not a member? | Forgot your Password?

Search compdsp

Search tips

Free PDF Downloads

A Quadrature Signals Tutorial: Complex, But Not Complicated

Understanding the 'Phasing Method' of Single Sideband Demodulation

Complex Digital Signal Processing in Telecommunications

Introduction to Sound Processing

C++ Tutorial

Introduction of C Programming for DSP Applications

Fixed-Point Arithmetic: An Introduction

Cascaded Integrator-Comb (CIC) Filter Introduction

Discussion Groups

FFT Spectral Analysis Software

Free Online Books

See Also

Embedded SystemsFPGA

Discussion Groups | Comp.DSP | C code for implementation of low pass filter to time series signal

There are 4 messages in this thread.

You are currently looking at messages 1 to .


Is this discussion worth a thumbs up?

0

C code for implementation of low pass filter to time series signal - helen - 2006-09-07 09:55:00

I am doing C programming for low pass filtering time series signal and then
downsampling the signal.

Is there any available C source code for dummies? 
For instance, given filter coefficients, h[n], and signal
x[numberofSamples], how shall I get the filtered signal ??

Thanks


Re: C code for implementation of low pass filter to time series signal - Tim Wescott - 2006-09-07 10:45:00

helen wrote:
> I am doing C programming for low pass filtering time series signal and then
> downsampling the signal.
> 
> Is there any available C source code for dummies? 
> For instance, given filter coefficients, h[n], and signal
> x[numberofSamples], how shall I get the filtered signal ??
> 
> Thanks 
> 
Is this a finite impulse response filter (FIR), or an infinite impulse 
response filter (IIR)?

If it's a FIR then you just take the last N samples and multiply them 
sample-for-sample by the filter coefficients, so for sample n you'd use:

out[n] = sum from {k = max(0, n - N)} to n {x[n - k] * h[k]}

This article _may_ clear things up.  Although it's written more for 
control system design it does go into the implementation of IIR filters: 
  http://www.wescottdesign.com/articles/zTransform/z-transforms.html.

-- 

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Posting from Google?  See http://cfaj.freeshell.org/google/

"Applied Control Theory for Embedded Systems" came out in April.
See details at http://www.wescottdesign.com/actfes/actfes.html


Re: C code for implementation of low pass filter to time series signal - Jim Thomas - 2006-09-08 09:58:00

helen wrote:
> I am doing C programming for low pass filtering time series signal and then
> downsampling the signal.
> 
> Is there any available C source code for dummies? 
> For instance, given filter coefficients, h[n], and signal
> x[numberofSamples], how shall I get the filtered signal ??
> 

You might find this useful:
http://www.dspguru.com/info/faqs/firfaq.htm

Good luck.

-- 
Jim Thomas            Principal Applications Engineer  Bittware, Inc
j...@bittware.com  http://www.bittware.com    (603) 226-0404 x536
There's a fine line between clever and stupid


Re: C code for implementation of low pass filter to time series signal - dilpreet06 - 2006-09-08 19:35:00

I have the C++ code for convolution : 

iCoefficients can be the FIR / IIR Coefficients, iIndex is the Index
number of the vector that is being filtered.
vec is the typedef for std::vector<double> 

For an IIR filter your code would look like:

filteredData[i] Convolution(i,input,BCoefficients)-Convolution(i,filteredData,ACoefficients);


double Convolution(int iIndex, vec& iData, vec& iCoefficients) 
/**< answer = conv(signal, filtercoefficients)*/
{
     double answer = 0;
     for(int l=0; l<iCoefficients.size();l++) 
     {
         if((iIndex-l-1)>=0)
         {     
             answer+= iData(iIndex-l-1)*iCoefficients(l); 
         }
         else
         {
             answer+=0.0;             
         }
     }
     return answer;
}






 As for calculating the coefficients of a low pass filter, try using the
billinear transform of if you need fast results, calculate the
coefficients in MATLAB and save them in your code.