LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Array Data Manipulation

Hi,

 

I have a very basic data acquisition program. The program reads a sine wave for 1 second and stores the read values as an array containing 102400 elements.

The frequency of the wave is 50 Hz so 1 cycle is contained within 2048 elements. I want to write a program that evaluates the average value over 1 second or 50 cycles. Any idea how to do that?

I tried using for loop but it's now working for me. can any one help me out?

 

Best Regards,

Mubeen Haadi.

Download All
0 Kudos
Message 1 of 7
(3,603 Views)

The problem comes when you are summing the arrays.  Look at the very first sum, and ask yourself what two things are being added.

 

LabVIEW is very particular about how it handles arrays.  If I add an array of size 5 to an array of size 10, how big do you thing the resulting sum will be?  If you are not sure, write a little LabVIEW program that does exactly that.  Once you see the answer to this second question, you can probably figure out why your sum is not working, and maybe even how to fix it.

 

Note -- I am deliberately not telling you the (relatively simple) fix.  Since you are trying to learn LabVIEW, finding and fixing the problem yourself will be much better for you in terms of learning.  However, if you are still having trouble, and especially if you did the simple "Add two arrays of known and different sizes" exercise, come back and explain what puzzles you ...

 

Bob Schor

0 Kudos
Message 2 of 7
(3,585 Views)

You might want to rethink the average, and replace with RMS. The average of a sine wave will be zero or whatever its offset is, the RMS value is probably more enlightening.

 

mcduff

0 Kudos
Message 3 of 7
(3,583 Views)

I figured it out. needed to initialize the shift register with first.

0 Kudos
Message 4 of 7
(3,555 Views)

@mcduff

 

I was not interested in finding average of on cycle. that is obviously zero. I wanted to add the 50 cycles up and than find average such that at the end I have one cycle left.

0 Kudos
Message 5 of 7
(3,549 Views)

Yep.  By not specifying an input, you effectively used the "default" value, which is an empty array.  As you've discovered, adding two arrays of different lengths gives you a "sum array" whose length is the shorter of the two addends.  If one is an empty array, then the sum will also be an empty (length 0) array.

 

Bob Schor

0 Kudos
Message 6 of 7
(3,545 Views)

That makes more sense. Sorry I misunderstood.

 

Here's another way, shift registers not required.

 

mcduff

 

Snip.png

 

Message 7 of 7
(3,489 Views)