From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Returning the mean of a continuous signal every x time

Hello,

I have an input at 10 Hz, continuous datas from a sensor via the DAQ assistant

 

I want to make a loop where every second the mean of the 10 last values is returned

 

By example :

1st second : 1 2 1 2 2 1 2 1 1 2

2 is returned

2nd second : 1 2 1 2 3 2 3 3 3 3

3 is returned

 

etc

 

is it doable ? Any idea of an existing .vi ?

0 Kudos
Message 1 of 9
(1,481 Views)

Why do you put the tedious limitation of the DAQ assistant as a requirement? Use DAQmx and read 10 values every iteration of the loop. Average these 10 values. Perhaps there is a way with DAQ assistant, but I don't use DAQ assistant so I'm not sure.

0 Kudos
Message 2 of 9
(1,476 Views)

To be clear : I don't want to do that IN the DAQ but working on the output

0 Kudos
Message 3 of 9
(1,463 Views)

@Oxbow88 wrote:

To be clear : I don't want to do that IN the DAQ but working on the output


Yes.  The suggestion was to have the DAQ assistant give you the X samples in a single call and then you just average the data you were given.


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 4 of 9
(1,459 Views)

@Oxbow88 wrote:

By example :

1st second : 1 2 1 2 2 1 2 1 1 2

2 is returned

2nd second : 1 2 1 2 3 2 3 3 3 3

3 is returned


Just to be clear, in your example you are returning the MODE of the data set (value that occurs the most), not the MEAN (average of the values). So what exactly is it that you want returned?

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 5 of 9
(1,434 Views)

It was the mean but rounded to the nearest integer

 

So, any idea of a code or function to do that ?
Like I said I cannot use the DAQ assistant for some reasons

 

that would be awesome

0 Kudos
Message 6 of 9
(1,405 Views)

Hi Oxbow,

 

read 10 samples using DAQmx functions, then apply the Mean function on those samples…

 

What have you tried? Where did you fail?

Mind to attach your VI?

Best regards,
GerdW


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

@Oxbow88 wrote:

It was the mean but rounded to the nearest integer

 

So, any idea of a code or function to do that ?
Like I said I cannot use the DAQ assistant for some reasons

 

that would be awesome


I took a look at the DAQ Assistant and you should be able to do it with that (though I highly advise converting to DAQmx functions and getting away from that dreadful dynamic data wire). Post some code and you're likely to get more help on showing you where you've gone wrong.

0 Kudos
Message 8 of 9
(1,341 Views)
0 Kudos
Message 9 of 9
(1,320 Views)