05-18-2022 03:01 PM
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!
05-18-2022 04:19 PM - edited 05-18-2022 04:20 PM
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.
05-18-2022 05:05 PM
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
05-18-2022 09:19 PM - edited 05-18-2022 09:22 PM
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?)
05-19-2022 07:02 AM
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 !
05-19-2022 07:23 AM - edited 05-19-2022 07:23 AM
@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...
05-19-2022 10:17 AM
@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?)
05-19-2022 10:29 AM
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.
05-19-2022 10:36 AM
@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.
05-19-2022 10:46 AM
@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!