LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Sampling and averaging

Here's what I want to do.

I am acquiring a signal from potentiometer via DAQ card.

However that FFT of that signal reveals unexpected peaks that cant be explained.

It appears  that it is picking up some random values.

 

What I propose to do :

the unexpected peak occurs at 350 Hz.

I will avearge the samples. as in i choose my sampling frequency as 700Hz. then take which means i take 700 samples in a second.

However, i take 7000 samples in a second, average out every 10 samples so that i am left with effective rate of 700 Hz.

How can i do that?

Kindly help 

.

Very urgent

0 Kudos
Message 1 of 13
(3,499 Views)

Hi Bgmnt,

 

use a loop to average each 10 samples into an average value:

FOR i:=0 to arraysize/10
  ArraySubset(start:=i*10, size:=10)
  mean(arraysubset)
NEXT

How do you want to detect peaks at 350Hz when you sample with just 700Hz?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 13
(3,483 Views)

There are many ways to do this. Attached is a very basic and of course poor way of doing it! If you feed an aray of 7000 elements into this VI, it will return an array of 700 elements which are average of sets of 10 elements from the input array. However, please note that:

 

1- This VI is not flexible; what if you want to sample every 5 elements?

2- This VI will waste memory since it keeps resizing two arrays.

 

A better more advanced solution would be able to resolve both these problems, but I'm not sure if you are an advanced enough user to go there. I'd recomment using this as a starting point and if you run into memory issues or decided to grow your application, we can work on better solutions.

Certified LabVIEW Architect (CLA), LabVIEW 2015.
0 Kudos
Message 3 of 13
(3,480 Views)

I am using Lab VIEW 10, could you send it in my version ?

 

0 Kudos
Message 4 of 13
(3,472 Views)

No problem, I saved another version for LabVIEW 10.

 

 

Certified LabVIEW Architect (CLA), LabVIEW 2015.
0 Kudos
Message 5 of 13
(3,468 Views)

i am also facing another problem , while storing my dynamic data to array it shows and error that data types dont match.

it says that sink is double precision and input is array. how do i change that?

 

0 Kudos
Message 6 of 13
(3,464 Views)

It looks like you are trying to feed a numeric data (single measurement) into this VI. But this VI accepts an array of numeric values to post-process your raw data. You need to create an array from the acquired values and feed that array into this VI. You'll be able to figure that part out if you take LabVIEW Core 1. It will teach you how to do simple array operations and you can apply it to your application. You can visit www.ni.com/self-paced-training for LabVIEW Core 1.

Certified LabVIEW Architect (CLA), LabVIEW 2015.
0 Kudos
Message 7 of 13
(3,459 Views)

Just helping to diagnose your data error here.  You are sampling at 700Hz.  Therefore 350Hz is your maximum frequency you can read (well, actually not quite 350Hz).  So my guess is that you have some aliasing happening (higher frequencies show up as lower frequencies).  I would try changing your sampling rate to something more like 1 or 2 kHz.  If you still have unexpected noise at 350Hz, then the noise is real.

 

As far as the averaging, just read 10 samples and use Mean.vi to do the average.


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
0 Kudos
Message 8 of 13
(3,445 Views)

@DTV_AVE

The actual sampling frequency of the acquired signal is 2kHz . Even the the poteiometer signal shows a peak at around 200Hz. But what i fail to understand is that why this frequency is obbserved even though THERE IS NO MOVEMENT IN THE POTENTIOMETER. It is still and rests at a support.

Then why is this frequency coming?

0 Kudos
Message 9 of 13
(3,395 Views)

I guess, this last message was meant for Crossrulz. What I can add to Cross' comment is that you need to make sure your sampling rate is higher than the highest frequency component of your signal multiplied by 2 (Nyquist Theorem). Otherwise you will run into aliasing issues. One solution could be filtering your input data to prevent higher frequencies from getting in and causing aliasing. For example, if you want to sample at 1 KHz, having a 500Hz (preferably lower) LPF can prevent aliasing.

Certified LabVIEW Architect (CLA), LabVIEW 2015.
0 Kudos
Message 10 of 13
(3,388 Views)