01-04-2017 10:05 PM
Hello everyone,
I use Data Queue PtByPt VI to get a set of incoming data with the specific length for calculation. We can set the sample length in the input terminal, and there is a output terminal named "current length", I though it will return 1, 2, 3, ..., n, n, n,..., n, where n is the sample length. However, it keeps returning n, n, n,....
I don't know what is this terminal for. I hope the output is as the above, such as 1, 2, 3, ..., n, n, n....
Can you help me please? Thank you very much.
Qun
Solved! Go to Solution.
01-05-2017 01:53 AM - edited 01-05-2017 02:02 AM
Hi chalkwu,
I though it will return 1, 2, 3, ..., n, n, n,..., n, where n is the sample length. However, it keeps returning n, n, n,....
Let's read the LabVIEW help together:
current length is the size of the current queue.
Data Queue PtByPt Details: The data queue begins as a set of zeros that matches the size of sample length.
So you get what the LabVIEW help says you will get!
Can you help me please?
Help with what?
When you want to know the number of "real" data in your queue you could get the minimum of sample length and loop iteration count…
01-05-2017 04:22 PM
I recommned looking at a lossy queue if you do not want to start with an array of 0's. The queue size will increase everytime you add a new element up to the size of the queue. Then they will drop off the end as new items are added.
01-06-2017 03:30 PM
@chalkwu wrote:
Some general suggestions about comments about your coding style:
01-08-2017 11:17 AM
I can get your sense of humor. Thank you.
01-08-2017 11:33 AM
Hello,
Thanks for your reply.
I thought to use "build array" to store history data. However, it seems I need to intial the array and I don't know how to intial the array with an empty array. I can only do something like this, please see the attached vi.
Thanks for introducing me "mean ptbypt". There are plenty of useful functions I could use in the future. But my problem here is that the difference have to be divided by increasing number, such as 1, 2, 3,.... until n, and n is the maximum length if I use "Lossy enqueue element". I think I can not use the "mean ptbypt" directly.
Next time, whenever I start a post here I will attach actual vi. I did not post real vi because I thought you can not run the code without some device in my lab. Now I realized that you guys do not need to run the code, If someone are willing to help me, they only need to read the code. Sorry for before.
Qun
01-08-2017 11:43 AM - edited 01-08-2017 12:13 PM
01-09-2017 10:58 AM
See the attached LLB which implements a rolling average using a lossy queue. It may give you some ideas. Top level VI is "Using Rolling Average.vi"