LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Mean of 5 data at a time

Hi, 

 

I have a while loop where I collect data each seconds from a data acquisition system who is connected to my instrument. 

 

I would like to show in the front panel a means of 5 data which is the rate of shearing.

 

Each time 5 more data are collected, I would like it to discard the 5 previous data and do a new means with those 5 new data. 

 

I thought about wait function but I already have one in the while loop so I am able to acquire data each second. 

 

Thanks!

 

0 Kudos
Message 1 of 12
(1,709 Views)

Store the number of time data is collected.  When it reaches 5, do the average and then whatever you want with it.  We would need a little more context (such as the code you already have) to give any better advice.


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 2 of 12
(1,694 Views)

Given your system involving shear rate, I wonder if you might want to consider a 5-sample "sliding window" average instead.  This is what the "Mean (PtByPt)" function is made to do, so the implementation is easy and the behavior might be preferable.

 

It depends on whether you really *want* to reduce your data down from 1 sample per sec to 1 average per 5 sec, or whether you'd rather be able to calculate a new 5-sample average with every new sample (thus 1 per sec).

 

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 3 of 12
(1,686 Views)

Maybe you can discuss this with your classmates who posted here.

 

(It is also not clear why you posted in the Counter/Timer forum. Can you explain what the problem has to do with it?)

0 Kudos
Message 4 of 12
(1,679 Views)

Hi Kevin, 

 

I think the Mean (PtByPT) would work. Unfortunately, I couldn't find it in my labVIEW so I looked on internet and realized it need the full developpement system which I don't have. Is there another way to do the same thing but manually ? 

 

For your other point, I don't really care about reducing my data down since it is only for showing information on the front panel during a test. I will still record my data each second in my file. 

 

I already calculate a mean of the shear rate with all the data. But I want the technician to be able to tell in the last 5 second if the shear rate is correct or if it need to be adjusted.

 

I joined a screenshot of my VI but I don't think it will be that helpful since it is pretty big and you might need more context to understand how I collect data. 

 

Thanks ! 

Download All
0 Kudos
Message 5 of 12
(1,664 Views)

@anickt wrote:

I think the Mean (PtByPT) would work. Unfortunately, I couldn't find it in my labVIEW so I looked on internet and realized it need the full developpement system which I don't have. Is there another way to do the same thing but manually?


See if this gives you some ideas...


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
Download All
Message 6 of 12
(1,658 Views)

@anickt wrote:

I joined a screenshot of my VI but I don't think it will be that helpful since it is pretty big ...


That's an understatement. While it's pretty big, it is even uglier than big. Does not look maintainable. 😞

 

Mean prbypt will give you the average of the last N points after each point, so that's probably better than having it only update every five seconds. There are plenty of ways to implement it from scratch in LabVIEW base, and you have all the tools. I always recommend a solution that scales well with history size so you don't need to reinvent the wheel if you suddenly need the average of the last 1 million points. For some fun, have a look at slide 12-14 (of part II) of our 2016 NI Week talk that compares how different approaches to running averages scale with history size.

 

(I still don't understand what all this has to do with the "counter/timer" forum. Do you want me to move this thread to the LabVIEW forum where it belongs?)

 

 

 

0 Kudos
Message 7 of 12
(1,644 Views)

Hi altenbach, 

 

Well I had to start with a code that was done by the company who made my data acquisition system for acquiring the data. There was a case structure and a for loop but I had to do calculation only in the while loop(outside the other structure) from data in some of the for case structure. I had some error while trying to acces those data so I decided to delete the case structure and for loop and now it work. There might be other ways to do it but I am not familiar enough with labview to do it (it is my first time using it). So, it's not pretty but I understand it and it works.

 

Thank you for the talk I will look into it.

 

Yes, you can move it where it belong. I didn't really know where to put it and I tought my issue for mean each 5 second was related with counter/timer. 

0 Kudos
Message 8 of 12
(1,636 Views)

@anickt wrote:

Yes, you can move it where it belong. I didn't really know where to put it and I tought my issue for mean each 5 second was related with counter/timer. 


I am sorry you have to deal with that code!

 

Yes, a counter/timer is a hardware device (that's why it's forum is under "Most active hardware boards"). This is a pure programming question about running averages with a fixed N. Doing a 5 second average for any random irregular sampling rate is another can of worms. I'll move the thread.

0 Kudos
Message 9 of 12
(1,629 Views)

@anickt wrote:

 

Well I had to start with a code that was done by the company who made my data acquisition system for acquiring the data.  


This is just the tip of the iceberg!

 

altenbach_0-1652975145504.png

 

0 Kudos
Message 10 of 12
(1,618 Views)