Help with filter design in C

Status
Not open for further replies.

sudil99

Junior Member level 3
Joined
Mar 20, 2012
Messages
29
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,283
Visit site
Activity points
1,503
I have a real time signal, a new sample is coming continuously and needs to be filtered before further processing. I want to design the filter in C. But I don't have much experience in C.
Could someone give an simple example of C-code so that I can go further. e.g., I need to filter the real time signal with a low pass filter of 15 Hz. The sampling rate is 450 Hz.
 

// Return RC low-pass filter output samples, given input samples,
// time interval dt, and time constant RC
function lowpass(real[0..n] x, real dt, real RC)
var real[0..n] y
var real α := dt / (RC + dt)
y[0] := x[0]
for i from 1 to n
y := α * x + (1-α) * y[i-1]
return y

Dt value can be extracted from sampling frequency & RC from cut off frequency.
Source: https://en.wikipedia.org/wiki/Low-pass_filter
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…