CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Adaptative filter?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

Adaptative filter?
PostPosted: Sun Sep 04, 2005 3:36 pm     Reply with quote

Hi,

A project of mine uses a simple RC filter to avoid hi frequency noise, but this also kills the response time when the DC level changes.

I was thinking about this kind of filter.. when the input is varying a lot, the filter gain is reduced to stabilize the output and when the DC level changes above a threshold, the gain is increased again.

I thought about an adaptation from the moving average code, but I didn't write anything yet.

Any tips about where to start?

Thank you.
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Wed Sep 07, 2005 11:24 am     Reply with quote

I use an RC filter matched to the required DC level changes and then use software filtering for high frequency noise. There have been a number of software filtering methods posted.
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

Re: Adaptative filter?
PostPosted: Wed Sep 07, 2005 11:42 am     Reply with quote

future wrote:
Hi,

A project of mine uses a simple RC filter to avoid hi frequency noise, but this also kills the response time when the DC level changes.

I was thinking about this kind of filter.. when the input is varying a lot, the filter gain is reduced to stabilize the output and when the DC level changes above a threshold, the gain is increased again.

I thought about an adaptation from the moving average code, but I didn't write anything yet.

Any tips about where to start?

Thank you.



Any high-pass filter, digital or analog, will result in an exponential (or som e sum of exponential) rise or fall to a sudden change in DC value. If it's not doing that, its not filtering.

I'd be careful about using a nonlinear filter like you're talking about. You alot of noise would end up reducing the size of the slow drifts that you're trying to measure. For you particular example, how would you tell the difference between noise and a DC shift?

I'd recommend simulating any filter like this before you burn it onto a chip, just to make sure your output is predictable.

More to the point, are you sure your RC value is optimally chosen?? Perhaps you've made a filter that's too slow for what you're trying to do. How fast are you sampling, what are your RC values, and what is the frequency content of the signal you're trying to measure? What is the frequency content of the "high-frequency" noise?

A simple option would be to use a filter that drops like a rock at high frequency, so you can set your cutoff higher than what you would do with an RC. There are 4 and 8 pole filters that will do just this on one chip. If you're willing to use a clocked filter, there are almost no passive elements to add.

Scott
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Wed Sep 07, 2005 1:14 pm     Reply with quote

Just like sseidman asks, can you tell us what frequency you want to filter out? And also, just as important, what is the worst-case frequency of your changing DC signal? (i guess it would look like a square wave).

There are hardware methods out there that are more robust in filtering out high frequency noise, such as LC filters, pi filters, ferrites, etc. Basically, at high frequencies, the capacitor will shunt the signal to ground, while the inductor (or ferrite?) will become a high resistance.
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Wed Sep 07, 2005 8:13 pm     Reply with quote

Well,

The sensor is a pressure sensor that measures vacuum in an engine.

With wild cams and low rpm there is a big vacuum oscillation.

The problem lives mostly below 2000rpm ( 66 events/second ).

At the moment I am using a RC filter that slows down the response to make the low rpm end good, but it slows down the high end too.

So, I think that a variable gain filter would solve the problem, either by analysing the stream and setting the gain or setting it by the rpm.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

$0.02 on hardware and $0.02 on firmware
PostPosted: Thu Sep 08, 2005 12:27 am     Reply with quote

If you know the instantaneous RPM:

Hardware approach. There is a clock-tunable filter LTC1068, which can be configured as a high-pass or band-pass filter. The frequency of the square wave sets its cutoff frequency (in case of a LPF), or the position of the pass-band (in case of the BPF). You can generate this square wave with a PIC. For example, you could have a table of optimal frequencies for different ranges of RPM. By the way, LTC1068 itself requires an RC anti-aliasing LPF.

Firmware approach. If you can sample your signal and crunch the numbers fast enough, you could make an FIR filter. Then you could change the filter coefficients depending on the RPM, and thus adjust the cutoff frequency. There is a host of digital filter design software out there.
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Thu Sep 08, 2005 7:31 am     Reply with quote

future wrote:
Well,

The sensor is a pressure sensor that measures vacuum in an engine.

With wild cams and low rpm there is a big vacuum oscillation.

The problem lives mostly below 2000rpm ( 66 events/second ).

At the moment I am using a RC filter that slows down the response to make the low rpm end good, but it slows down the high end too.

So, I think that a variable gain filter would solve the problem, either by analysing the stream and setting the gain or setting it by the rpm.


We're getting there now. We almost know the frequency content of interest.

Before you even attempt a software adaptive filter, you need to filter out the high frequency content of your signal before you sample to avoid aliasing. What is the highest frequency of vacuum change that you need to track? This will dictate how fast you need to sample. What are the values of the RC filter you're using? All this info is central to any design you might come up with, adaptive or otherwise, and you'll save a ton of time and effort by writing down these specs. Once we see them, it will take about two seconds to determine if what you need to do will require anything nonstandard.

Scott
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

Re: $0.02 on hardware and $0.02 on firmware
PostPosted: Thu Sep 08, 2005 7:36 am     Reply with quote

kender wrote:
By the way, LTC1068 itself requires an RC anti-aliasing LPF.



To clarify, clocked filters often require an RC on the output, to clear out the clock noise, which is generally two orders of magnitude above the pass band (which is why you can use a simple RC). The filter works just fine without the RC, but to best sample the output you need to filter.
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

A different $.02
PostPosted: Thu Sep 08, 2005 8:04 am     Reply with quote

Do you by any chance have access to a timing signal from the engine? Could you sample the vacuum A/D at a certain crankshaft angle? That might let you avoid the pressure spikes without filtering them. Just choose a period of the engine cycle when the pressure is stable.
_________________
The search for better is endless. Instead simply find very good and get the job done.
MikeValencia



Joined: 04 Aug 2004
Posts: 238
Location: Chicago

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Thu Sep 08, 2005 8:23 am     Reply with quote

I have a lot of high current switching noise all over the place, and some guys at a UL testing house once recommended this circuit to quiet my encoders down. (Disregard the redundant set of .01uf capacitors; i just put them there in case i would need it).

.1uF capacitors actually slowed down my signal, but for my app, .01uf was just fine. With it, i know i can read 1200 pulses per second without any noise errors (i hope!)

kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

Re: $0.02 on hardware and $0.02 on firmware
PostPosted: Thu Sep 08, 2005 3:20 pm     Reply with quote

sseidman wrote:
kender wrote:
By the way, LTC1068 itself requires an RC anti-aliasing LPF.



To clarify, clocked filters often require an RC on the output, to clear out the clock noise, which is generally two orders of magnitude above the pass band (which is why you can use a simple RC). The filter works just fine without the RC, but to best sample the output you need to filter.


Yep. The clocked filter actually requires two (2) RCs. One on the output, as sseidman have described. One on the input as well. The clocked filter is sampling the input, and thus it's a subject for aliasing just like an ADC. So similarly, there has to be an anti-aliasing filter.
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

Re: $0.02 on hardware and $0.02 on firmware
PostPosted: Thu Sep 08, 2005 3:41 pm     Reply with quote

kender wrote:
[


Yep. The clocked filter actually requires two (2) RCs. One on the output, as sseidman have described. One on the input as well. The clocked filter is sampling the input, and thus it's a subject for aliasing just like an ADC. So similarly, there has to be an anti-aliasing filter.


I often leave the input filter off. Keep in mind that the filter is clocked a few orders of magnitude faster than the frequency of interest. I think a factor of 200 is what the filter mentioned is using. So, a 200 Hz filter is sampled at 40K, and noise above 20K in many apps is very small in just about all of my apps. It's nice to be reminded to check that assumption, though Shocked
future



Joined: 14 May 2004
Posts: 330

View user's profile Send private message

PostPosted: Sun Sep 11, 2005 11:47 pm     Reply with quote

Thank you all for the ideas..

I'll start trying a low pass software filter with a presetable response time.

Maybe something like the 'running average'.
kender



Joined: 09 Aug 2004
Posts: 768
Location: Silicon Valley

View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger

PostPosted: Mon Sep 12, 2005 12:50 am     Reply with quote

Future, I can help you design a filter. I have MATLAB, and it has a filter design tool (fdatool) in it. Let me know.
sseidman



Joined: 14 Mar 2005
Posts: 159

View user's profile Send private message

PostPosted: Mon Sep 12, 2005 6:46 am     Reply with quote

future wrote:
Thank you all for the ideas..

I'll start trying a low pass software filter with a presetable response time.

Maybe something like the 'running average'.


Future--

You're missing something here. A software filter does not preclude the necessity of an anti-aliasing filter prior to acquisition. From what you've described, this prefiltering seems fairly important to your application. If you don't get this right, high frequency changes will disguise themselves as low-frequency changes, and no digital processing can help you recover.

Again, how fast are you sampling, and what RC values are you using? Just because the RC you've chosen isn't doing the job, it doesn't mean that an analog filter isn't the right approach.

Scott
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group