LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to filter a noisy sine in real-time?

Hi everyone!

I have a noisy sine and cosine signal from which I want to derive an angle between 0 and 360°. The angle will be requested in irregular intervals between 1 and 10 seconds.
With no noise present I simply used atan2 to calculate the angle (already corrected for quadrants), thus giving me a result between 0 and 360°.
With noise this is no longer accurately possible. I'm thinking about filtering the signal, but then there will be a group delay, and the phase is important.
Are there filter types in LabView that don't have a group delay? (BTW: LV 7.1 Full Dev.) Is there another way to calculate the angle from a sine and cosine than atan2 or similar functions?

Thanks in advance Smiley Happy

PS: Wanted to post a few screenshots of my signals and VIs so far, but I've got no webspace to upload them. Hope the problem is clear enough this way...
0 Kudos
Message 1 of 5
(3,384 Views)
I think all filters have delay. If you use identical filters, the delays should be the same. Once you measure the delay you should be able to compensate.

When you say real-time, can you put some numbers on this? What is the frequency of your signal? The sampling rate? How many samples do you acquire at a time? How much delay can you tolerate between data acquisition and phase calculation? What precision is required on the phase result?

Another approach is to use curve fitting to fit a "clean" sine/cosine to your data. This can work well if your frequency is well known, but has lots of challenges if the frequency is unknown.

Lynn
0 Kudos
Message 2 of 5
(3,377 Views)
Thanks for the fast response!

My signal ranges from 1 to 10 Hz over long periods of time (minutes), but is fairly constant
at a specific frequency for a few seconds. The signal has a white noise superimposing it, ranging up to 3kHz and with about 10 times the signal amplitude. For an easy approach I've reduced the noise to the same amplitude as the signal.

If I measure the filter delay, will it be the same for the whole spectrum? In LabView I saw that the filters have phase responses that depend on freqencies.

I'm measuring at 10kHz with 1k aquired samples at a time. The finally calculated angle has to be correct at about +/- 5°. I'm not sure on how to calculate this to the required phase precision...

Curve fitting sounds good, especially since I know quite for sure what frequency the sine/cosine currently has...
I'll try this and after that some filtering!

I probably should have included some more details in the first place Smiley Happy. Do you have some more suggestions or ideas for me?

Thanks again for the help
0 Kudos
Message 3 of 5
(3,372 Views)
A signal to noise ratio of less than 1 and only a few cycles of signal to work with (before the frequency changes) is going to be tough. The curve fitting routines (Lev-Mar) work pretty well with a fraction of a cycle. If you have an accurate frequency reference and only need to fit phase and amplitude, you may be able to use curve fitting. I have started an investigation along those lines but have had to set it aside for higer priority work.

Can you filter the signal before digitizing it? Something like a 25-30 Hz low pass filter would reduce your noise bandwidth by a factor of ten.

Different filter types have different phase or delay versus frequency responses. A special filter called an all pass filter or phase equalization filter has a constant amplitude response and a variable delay response. One of these can be used after a low pass or bandpass filter to create and overall constant phase or delay response over the pass band. You will probably need to consult a filter handbook or expert for details.

Lynn
0 Kudos
Message 4 of 5
(3,368 Views)
Curve fitting seems to be working quite good, but with a higher noise I'll probably end up with unusable results anyway.

I have looked into FIR-filtering which seem to have a group delay simply based upon the number of taps used. Does this mean if I use a FIR of defined tap-length will I then be able to calculate the delay undisturbed by frequency-changes?

I also took a look at the corss-correlation function which seems to be suitable as well. Assumed that I do know the signal frequency is it possible to simulate a clear sine signal and cross-correlate this to my noisy signals? Can the result of the cross-correlation be used to calculate the actual angle (being the initial question in my first posting)?

As for different filter types: The Bessel filter is said to be of linear phase response like the aforementioned FIR filter. I assume that the amplitude response is therefor very slow?

I fear that I cannot filter the signal before digitizing it, as I directly receive raw data. Nevertheless: Wouldn't filtering before digitizing also result in a phase error?

Hope, you still got some advice for me, despite all the problematic details...


0 Kudos
Message 5 of 5
(3,351 Views)