LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Moving Average Filter w/ continuous data acquisition

Solved!
Go to solution

I'm looking to filter multiple noisey signals. I'm currently using a NI9203 w/ a cDAQ-9174 sampling at 1000Hz. I use DAQmx vi's to start the task and aquire the signal. I've tried using smoothing filter coefficients.vi paired with IIR filter.vi (Moving Avg.png) this seems to work for simulated signals and for logged data. However, when I try to use this setup for real time averaging it simply cuts all signals to zero.  I've looked into using shift registers but to get the result needed it seems I would have to use hundreds of elements.

 

Ultimately I'm trying to filter the signal to obtain a more constant reading for the user. For example during operation the user needs to review the current status of values in real time. This is difficult currently when the noise shows values +/- 100 changing every 100ms.

 

Any help or suggestions would be appreciated, thanks in advance.

0 Kudos
Message 1 of 9
(11,901 Views)

Without attaching your VI, you don't give anyone enough information to help you.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 2 of 9
(11,898 Views)

Since you are trying to perfrom a filter while continuously gathering data, you might want to look into the Point-To-Point filter VIs.  You will need to put your waveform data into a FOR loop to process it, but it can run real-time for you.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 9
(11,893 Views)

I have attached a slightly simplified version of my vi. I'm not sure how I would implement a for loop with out disrupting the consumer loop. From my understanding if I inserted a For Loop the while loop would stop functioning and therefore not log data until the for loop had completed, this "pause" of the while loop would happen each interation of the while loop giving inconsistent data.

 

0 Kudos
Message 4 of 9
(11,879 Views)

You have not attached your VI, but a picture of one point in time of your VI's execution, there are states not shown, there is no visible connection to the case selector for the state you are showing, "Boolean 3" is apparently just out in the middle of nowhere, and the whole picture has no connection with the filtering that you said you were trying to do in the original post.

 

One thing that occurs to me, however, is that IMHO you are trying to do way too much in the producer loop. Have you searched sine.NI.com for writeups on this architecture?  You might want to do that and soak up several good explanations and examples of P-C programs, then see where yours are qualitatively different.

 

Anyway, without sending a VI relevant to your question (and some data/pictures of the results for those of us who do not have your exact equipment), that's about as far as I can go here. Others might be able to give you a better guess on what's going on, but it will still be just a guess.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
0 Kudos
Message 5 of 9
(11,863 Views)

My apologizes for the image instead of the actual vi I'm not sure if I should upload the main and all the sub vi's or what the accepted method is for these forums. Boolean 3 was accidentally left over from my quick simplification, the case selector is in the top right corner and basically functions to reset the while loop in between testing sets. The filtering is not on this vi due to the fact that this is the current functioning vi, i.e.. It is fully capable of logging all the data that is require for testing and post processing which is continuing daily. If I add in the filtering and it sets all signals to zero this will defeat the purpose of logging. I was hoping that someone with a better knowledge of labview could lend some advice to filtering signals during continuous sampling and the general architecture of P-C programs. I will look into P-C papers to adjust what  I have done incorrectly. 

0 Kudos
Message 6 of 9
(11,845 Views)

I'm not trying to give you a lecture on forum etiquette, just pointing out the information that would make it easier for you to get help from the good folks here (maybe even I can help you). If you can pare your program down to the part you are having problems with, that will help. Even if you are using DAQ stuff to take data and someone doesn't have the same equipment, many times the structure of the VI is recognizable enough that they can help. If you can enclose a "typical" input data file/stream that results in bad output, it also helps.

 

As for your VI, I would probably split it up into three loops, the first just to take the data, second to log to a file, and third to filter for the user's benefit. As crossrulz said, you can use a point-to-point filter in a FOR loop inside the filtering loop, then you won't lose any data because it doesn't affect that function.

 

Cameron

 

To err is human, but to really foul it up requires a computer.
The optimist believes we are in the best of all possible worlds - the pessimist fears this is true.
Profanity is the one language all programmers know best.
An expert is someone who has made all the possible mistakes.

To learn something about LabVIEW at no extra cost, work the online LabVIEW tutorial(s):

LabVIEW Unit 1 - Getting Started</ a>
Learn to Use LabVIEW with MyDAQ</ a>
Message 7 of 9
(11,819 Views)

Digging some more, there is a VI in the Signal Processing->Waveform Conditioning called Digital IIR Filter.vi.  It does the filter on your waveform and it keeps memory.  Just use that VI to do a filter.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 8 of 9
(11,803 Views)
Solution
Accepted by topic author LukeTEI

Thank you all for the assistance and the tips. I have attached the vi I used to solve the issue, one of my major problems was not using DAQmx timing. Attached in both 2012 and 2013.

Download All
0 Kudos
Message 9 of 9
(11,782 Views)