LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Queue vs. Array question

Solved!
Go to solution

I had a recent application where I wanted to take 100 samples of something then get the RMS of the dara. This happens in a loop and until program ends. Very basic stuff.

 

  • QUEUE Method: 
  • Obtain Queue with 100 elements max.
  • Enqueue data (data arrives about every 50mS).
  • Get Queue Status, when Number of Elements is 100....
  • ... Flush Queue and get all elements (that'll be an aray of course) and use RMS funtion.
  • Repeat

 

---------------------

  •  ARRAY Method:
  • Initialize Array with 100 elements of the DBL 9999.99 (that's a value that can't occur in the data)
  • Insert data into the array by using Replace Array Subset
  • When index 100 is not 9999.99, then....
  • ... Put array in the RMS function, then re-initialize array full of 9999.99
  • Repeat

 

So my questions are, which should be Faster, which one better Memory Management ?

 

 Thanks!

 

0 Kudos
Message 1 of 5
(4,877 Views)

LV_Addict wrote:

I had a recent application where I wanted to take 100 samples of something then get the RMS of the dara. This happens in a loop and until program ends. Very basic stuff.

 

  • QUEUE Method: 
  • Obtain Queue with 100 elements max.
  • Enqueue data (data arrives about every 50mS).
  • Get Queue Status, when Number of Elements is 100....
  • ... Flush Queue and get all elements (that'll be an aray of course) and use RMS funtion.
  • Repeat

 

---------------------

  •  ARRAY Method:
  • Initialize Array with 100 elements of the DBL 9999.99 (that's a value that can't occur in the data)
  • Insert data into the array by using Replace Array Subset
  • When index 100 is not 9999.99, then....
  • ... Put array in the RMS function, then re-initialize array full of 9999.99
  • Repeat

 

So my questions are, which should be Faster, which one better Memory Management ?

 

 Thanks!

 


 

Queues can pass data "inplace" by just moving the pointer to the data buffer to who ever want to read the queue.

 

The array method you outlined requires repeatedly peeking in at the data buffer to decide what you need to do plus you have to over-write the buffer with you special "code".

 

Ben

 

 

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 2 of 5
(4,864 Views)
So which of the two methods would you use? Is the array method to cheesy? I have not implemented it, just the Queue, and it's running fine, but it seems that the queue functions would be more overhead than one array + insert into + a shift register.
0 Kudos
Message 3 of 5
(4,817 Views)
Solution
Accepted by topic author LV_Addict

Why not just use the RMS PtByPt VI. That way, you don't need to store data at all? This may require marginally more computation, but will require less memory.

 

If you insist on the buffer, I'd probably go with the array for simplicity. I think you can simplify your scheme to determine when to process though. No reason to have all those 9999.99's in there.

 

Chris

Message 4 of 5
(4,806 Views)

Sorry for not geeting back faster Chris. Thanks for the idea. RMS PtByPt was perfect. I didn't even know it existed, because it's in a completely different pallete than the other RMS VI. There should at least be a sub-pallette off of the math for PtByPt, but it's under signals.

Thanks!

 

Message Edited by LV_Addict on 12-15-2008 01:35 PM
Message Edited by LV_Addict on 12-15-2008 01:44 PM
0 Kudos
Message 5 of 5
(4,754 Views)