View Full Version : Discussion hardware vs software filtering?
rbeall
Feb 17, 2009, 12:53 AM
I am in a predicament. My filtering on my pitot-statics just isn't quite good enough. Noise isolation when making circuit boards is all new to me and I know nothing so needless to say my board is somewhat noisy. It's not bad but for example my calculated altitude when sitting still is +-29 feet. Obviously not good enough. However if I low pass it in software I get about +-1.2 feet. I know the best solution is always to hardware filter but is there any reason why I shouldn't use the software filtering in this case? Aliasing? etc.
Krogoth
Feb 17, 2009, 02:02 AM
Aliasing occurs when the signal you are trying to measure is equal to or above the Nyquist frequency (equal to half your sampling frequency). For example's sake, let's say you wanted to detect changes in your altitude at up to 10Hz - this means you would have to sample at more than 20Hz to correctly reconstruct the signal digitally.
Filtering does not generate aliasing, but it does generate a phase delay in your signal (try putting a pure sinewave through your filter and check the phase plot). If you're trying to do control, this phase delay can become quite important, otherwise it's not that much of an issue.
The best solution isn't always hardware - a software filter costs nothing to implement, and can do many things (especially at lower frequencies) that an analog filter can't (unless you plan on putting giant capacitors or inductors on your plane). If you can cope with sampling above double the Nyquist frequency, the phase delay (which will be there either way) and the extra processing caused by the digital filter, then I can't see any problems with it.
Out of interest, how did you design your digital LPF?
Will.
rblilja
Feb 17, 2009, 10:22 AM
About the Nyquist-Shannon theorem (don’t forget Shannon’s work) it is true that one is to sample with at least the double frequency (f_sample > 2*f). Still this sampled signal needs to be filtered for proper reconstruction of the actual (continuous-time) signal measured. However…
There is a good practice/rule to have an analog (read hw.) LP filter present as an anti-aliasing filter; the white noise (or any other frequency components breaking the sampling theorem) in the signal can otherwise distort your sampled signal obtained from the ADC.
Please correct me if I'm wrong...
// Lilja
rich smith
Feb 17, 2009, 02:01 PM
That is with MPXV5010DP?
I am in a predicament. My filtering on my pitot-statics just isn't quite good enough. Noise isolation when making circuit boards is all new to me and I know nothing so needless to say my board is somewhat noisy. It's not bad but for example my calculated altitude when sitting still is +-29 feet. Obviously not good enough. However if I low pass it in software I get about +-1.2 feet. I know the best solution is always to hardware filter but is there any reason why I shouldn't use the software filtering in this case? Aliasing? etc.
rbeall
Feb 17, 2009, 06:44 PM
I'm using the MPX2010
I switched the opamp out for a better quality TI equivalent that I had laying around. Standard deviation was cut in half. I then started to notice something quite obvious. Plot speaks for itself.
If I take out those few random spikes the standard deviation drops an order of magnitude which is about the performance I was expecting to be adequate.
I cross referenced the gryos (on the same 5v switching reg) and they don't have any corresponding spikes at the same time interval. But they also may do a lot better job of blocking out source noise and power fluctuations.
Should I put like a 1uF cap maybe or ? Couldn't believe how much noise dropped just by chaning opamps, but there still is something there. I plan on hooking up the oscope this weekend but I'm away for work so kinda just sitting on pins right now.
For my low pass I just use a simple running low pass. ex: reading = a*new_reading + (1-a)*old reading;
eddymoore
Feb 18, 2009, 12:48 PM
About the Nyquist-Shannon theorem (don’t forget Shannon’s work)
I don't think Shannon gets a rough deal... he's probably one of the most cited human beings ever :) I'm taking David Mackay's Info theory lecture course currently, and we just proved his Channel Capacity Limit. All I can say is, that guy was a smart cookie.
rich smith
Feb 18, 2009, 02:07 PM
Thank you, this is better than I expected. MPX2010 in mine too. I use 10mf and 256x oversampling w/8bit but needless to say can't detect fast drops. It will be very interesting to see how yours works out. Update please.
I'm using the MPX2010
I switched the opamp out for a better quality TI equivalent that I had laying around. Standard deviation was cut in half. I then started to notice something quite obvious. Plot speaks for itself.
If I take out those few random spikes the standard deviation drops an order of magnitude which is about the performance I was expecting to be adequate.
I cross referenced the gryos (on the same 5v switching reg) and they don't have any corresponding spikes at the same time interval. But they also may do a lot better job of blocking out source noise and power fluctuations.
Should I put like a 1uF cap maybe or ? Couldn't believe how much noise dropped just by chaning opamps, but there still is something there. I plan on hooking up the oscope this weekend but I'm away for work so kinda just sitting on pins right now.
For my low pass I just use a simple running low pass. ex: reading = a*new_reading + (1-a)*old reading;
rbeall
Feb 18, 2009, 02:37 PM
wow, I am using a 16bit a2d. I can't imagine getting anything out of your altitude data unless you significantly reduce your max range by boosting your gain. I was barely capable of 3000ft max range with a 12bit a2d and 3 ft res
Hopefully I can isolate the problem, but honestly the pressure sensors are the least noisy of my sensor package. I think my Kalman will keep up with the imu noise but the altitude and airspeed is just not tight enough. Hopefully I will get an overall increased performance by focusing on the pressures.
Does the physical size of the cap (ex 0805 vs 0603) affect its noise tolerance in anyway. In some of the circuits I have been studying I noticed that they switched physical size on a couple of caps for some unknown reason?
rich smith
Feb 18, 2009, 04:01 PM
Oversampling w/8bit can give you higher resolution than 16bit assuming there is noise w/gaussian distribution present. See? Noise is sometimes your friend.
Cap size relates to voltage and power handling and is not a factor in signal filtering. ESCs need big ones due to HUGE ripple. For LP smallest is best. Chemistry can be a big factor in noise but not size AFAIK.
wow, I am using a 16bit a2d. I can't imagine getting anything out of your altitude data unless you significantly reduce your max range by boosting your gain. I was barely capable of 3000ft max range with a 12bit a2d and 3 ft res
Hopefully I can isolate the problem, but honestly the pressure sensors are the least noisy of my sensor package. I think my Kalman will keep up with the imu noise but the altitude and airspeed is just not tight enough. Hopefully I will get an overall increased performance by focusing on the pressures.
Does the physical size of the cap (ex 0805 vs 0603) affect its noise tolerance in anyway. In some of the circuits I have been studying I noticed that they switched physical size on a couple of caps for some unknown reason?
rbeall
Feb 18, 2009, 05:04 PM
Interesting, I just wish it was my friend! I guess I will just have to settle with low passing the data in software. I would like to get on an oscope but I don't know what it will buy me because I don't really know what to test? My board is all surface mount stuff so it not like I can just pipe new signals anywhere I want. I guess it could be coming from anywhere so the best thing to do is just start isolating each part on an o-scope.
rich smith
Feb 18, 2009, 05:57 PM
Do you have schematic? This is very interesting to me because I assumed it was el cheapo resistors causing trouble in my case. You using metal film and not carbon?
Also what impedance you driving that cap with. Unless it's at least few hundred ohms or even kohms no filtering will occur. Can't put caps directly on output of opamp.
Interesting, I just wish it was my friend! I guess I will just have to settle with low passing the data in software. I would like to get on an oscope but I don't know what it will buy me because I don't really know what to test? My board is all surface mount stuff so it not like I can just pipe new signals anywhere I want. I guess it could be coming from anywhere so the best thing to do is just start isolating each part on an o-scope.
rbeall
Feb 18, 2009, 08:01 PM
Rich I feel like we might be getting somewhere and maybe there is hope after all.
I am using metal film I believe. I cannot account for all of them but the few that I check that's what they looked like. What's should I use, whats better.
I am not driving a capacitive load with the opamp (a2d obviously but...). Just a straight connection. As far as the schematic. Its just the typical gain configured opamp for statics specifically. The only difference is I have added .1uF caps over the gain resistors as well as 1nF's on the sensor ouputs to ground.
The other thing I noticed about my board is that the a2d has a decoupling .1uF cap but its not between the +and- pins its just touching the + pin and grounded through the ground plane (4 layer board). I guess I thought that the a2d may be noisy as well beings all of my other channels have about 2 times the standard deviation than they should. The Pitot statics only popped out because they have to be a lot cleaner to be sufficient.
My power supply is adequately filtered in my opinion but then again I havn't hooked it up to an oscope or know anything about what I'm doing so...can you say round one is always the funnest!
rich smith
Feb 19, 2009, 11:59 AM
Metal film is lowest noise w/o getting involved with exotic types. Adding caps to the wrong point on gain resistors will increase noise so be careful. If noise comes from amp good idea to put RC LP on output. AD should have bypass from both supplies to GND. Scope is your friend, even if it's one of those PC soundcard type.
Airspeed is much trickier than alt so I'm skipping that for now. Got 10' accuracy ATM which is certainly better than anything the GPS provides however my response time could use improvement. BTW I also tried MPX12D w/external compensation but too many parts. Good luck.
Rich I feel like we might be getting somewhere and maybe there is hope after all.
I am using metal film I believe. I cannot account for all of them but the few that I check that's what they looked like. What's should I use, whats better.
I am not driving a capacitive load with the opamp (a2d obviously but...). Just a straight connection. As far as the schematic. Its just the typical gain configured opamp for statics specifically. The only difference is I have added .1uF caps over the gain resistors as well as 1nF's on the sensor ouputs to ground.
The other thing I noticed about my board is that the a2d has a decoupling .1uF cap but its not between the +and- pins its just touching the + pin and grounded through the ground plane (4 layer board). I guess I thought that the a2d may be noisy as well beings all of my other channels have about 2 times the standard deviation than they should. The Pitot statics only popped out because they have to be a lot cleaner to be sufficient.
My power supply is adequately filtered in my opinion but then again I havn't hooked it up to an oscope or know anything about what I'm doing so...can you say round one is always the funnest!
rbeall
Feb 19, 2009, 12:53 PM
The more I am thinking about it, the more I suspect the power supply. I should be on a scope by tonight so hopefully that will reveal some surprises.
I don't have a decoupling cap on both inputs to the a2d just tied them together with a trace same for ground. The cap that I have hooked up to them isn't touching the ground pins either its just grounded through a ground plane via. All of these are problems? I'll see what I see tonight and back fill any thing I figure out.
-ryan
rbeall
Feb 19, 2009, 11:10 PM
Some solutions more problems?
Well I noticed that my decoupling cap on the a2d was actually a 10k resistor so I replaced that and still no change...Seriously no change? Wow. I do need to add a 10uF or so cap to the .1uF that's already there.
My next attempt was with the oscope. I noticed imediately that as soon as the processor starts it induces a lot of noise in the circuit. It specifically surges when the a2d clocks. I don't think this is the primary issue but its still interesting.
Either way its back to the drawing board. Software is looking more and more likable!
The top is the a2d clock and the bottom is the dynamic voltage. Notice how thick the reading is? Yeah should be a lot thinner.
rich smith
Feb 20, 2009, 11:36 AM
What processor? My AVR has specific power management features to reduce AD noise but found I didn't need them after switching to internal osc.
Some solutions more problems?
Well I noticed that my decoupling cap on the a2d was actually a 10k resistor so I replaced that and still no change...Seriously no change? Wow. I do need to add a 10uF or so cap to the .1uF that's already there.
My next attempt was with the oscope. I noticed imediately that as soon as the processor starts it induces a lot of noise in the circuit. It specifically surges when the a2d clocks. I don't think this is the primary issue but its still interesting.
Either way its back to the drawing board. Software is looking more and more likable!
The top is the a2d clock and the bottom is the dynamic voltage. Notice how thick the reading is? Yeah should be a lot thinner.
rbeall
Feb 20, 2009, 12:45 PM
Its a rabbit 3400 core module. I think then only avenue left is splitting the power and ground planes. Analog plane and a digital plane. I got a feeling that will help significantly
vBulletin® Copyright ©2000-2009, Jelsoft Enterprises Ltd.