LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Waveform averaging to remove noise

Solved!
Go to solution

Hi,

Right now i am creating a VI that reads in a Waveform DBL trough the DAQ.mx. I have succeeded in this. however my signal is quite noisy. To help smoothen this waveform i want to create a loop where in every iteration of the loop, the waveform adds up to itself, and in the end divides that added up waveform by the amount of times it got looped.

I have created something that should do the job (see picture below) however when i try to see the averaged out waveform, it doesnt show anything in the waveform graph.

 

I think my problem lies within the interaction of the addition and division operators and my data type (waveform dbl).

 

Thank you in advance for your time and effort

 

See below:

- a screenshot of the loop in question

- a screenshot of the whole VI

- the VI

- an example of the noisy data

0 Kudos
Message 1 of 7
(1,578 Views)

I don't have LabVIEW 2020 running on this PC, but I think I can diagnose your problem.  You are collecting your individual samples as Waveforms, a LabVIEW structure that is nicely designed for sampled data.  A Waveform is a LabVIEW Cluster (I assume you know about Clusters, right?), consisting of t0, a TimeStamp when the acquisition started; dt, the time between samples (1/sampling frequency); and Y, the array of sampled data.  I'm uncertain what would happen if you averaged Waveforms, though I could easily write a little LabVIEW Program and test what happens (that's a nice Feature of LabVIEW -- it encourages you to write little programs and learn how LabVIEW does things).

 

But here's what you can do -- look at the first function on the Waveform Palette, get Waveform Components.  Use it to pull out the Y (data) component of each of your Waveforms (you can do this by passing the Array of Waveforms into a For Loop, which gives you each Waveform individually, extract its Y component, and bring the Y components out through an Indexing Tunnel), giving you a 2D Array of your data that you are now ready to average.  If you want to create an "Average" Waveform, simply copy your first Waveform (which has a reasonable t0 and the correct dt) and replace it's Y component with your new Average.

 

Bob Schor

Message 2 of 7
(1,528 Views)
Solution
Accepted by topic author Ulas

Hi Ulas,

 


@Ulas wrote:

I think my problem lies within the interaction of the addition and division operators and my data type (waveform dbl).


Your problem lies in the shift register and its missing initialization. And it lies in your non-existing error handling…

 

Try to understand what this code does:

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 3 of 7
(1,507 Views)

 Hi GerdW,

 

Thank you for your reply.

 

That was indeed the problem. I do understand what your code does. It picks 0th iteration and uses that to initialize the shift register.

 

I did have a question

Is he reason why you pulled the "samples to read" out of the for loop, memory reasons?

 

When i change the samplerate i get this error:

Ulas_0-1615367579964.png

 

I am guessing that this is due to the cycle still remembering the old value. I dont understand how though. When i start the VI it should start at iteration 0, so it shouldn't have this problem. Do you by any chance know how to avoid this?

 

Thank you for your help.

 

Ulas

0 Kudos
Message 4 of 7
(1,482 Views)

Hi Bob,

 

Thank you for your extensively written out response.

 

I did what GerdW suggested. As far as I understand both of your replies are a solution to the same problem. My initial value was a waveform that did not match the t0, dt and the amount of samples. This caused a problem when trying to add the two waveforms up. Your reply helped me understand this.

Thank you.

 

Ulas

0 Kudos
Message 5 of 7
(1,479 Views)

Hi GerdW,

 

I'm sorry for asking so many questions. But im noticing a phase change in the resulting averaged wave. see pictures.

 

when going from 100 to 1000 u see that the phase of the wave is changing by approximately 0.2pi.

 

I do not understand why. The waveform should be triggered, by the TTL/CMOS output of the function generator. When having only 1 iteration the wave was perfectly triggered.

 

Thank you in advance,

 

Ulas

Download All
0 Kudos
Message 6 of 7
(1,473 Views)

Hi Ulas,

 

are you sure you are reading exactly one period of your signal for all 500/1000 iterations?

 

I moved the "samples to read" out of the loop because it makes absolutely NO SENSE to change that value inside the loop while it is iterating.

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 7 of 7
(1,471 Views)