12-08-2008 12:09 PM
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.
---------------------
So my questions are, which should be Faster, which one better Memory Management ?
Thanks!
Solved! Go to Solution.
12-08-2008 12:32 PM
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
12-10-2008 02:16 PM
12-10-2008 03:21 PM
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
12-15-2008 01:35 PM - edited 12-15-2008 01:44 PM
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!