# LabVIEW

cancel
Showing results for
Did you mean:

## Average Output

Hello,

I'm trying to find the average output of the amplitude over a period of time. So the formula is the (Sum of amplitude/ΔT). Where for each time interval, the average amplitude is shown on the graph. I tried using the add array elements and dividing by the time, but from the waveform, this does not look correct. Would the MeanPtByPt vi work? Or is there any other way I could go about this? The amplitude should be around 5V. Thank you.

Message 1 of 6
(736 Views)

## Re: Average Output

I think that you have your formula wrong. To get an average you take the sum of the array elements divided by the number of elements in the array (assuming that the array only contains data over the period of time of interest). Even better is to use the Mean primitive from the Math/Probability and Statistics palette.

Message 2 of 6
(731 Views)

## Re: Average Output

Is the data spit out at a set rate?  If so, then remove the wait from your loop and hardcode the number of bytes to read.  Then you can just use the Mean.vi on the data and write that directly to your chart.  I say to remove the wait because the VISA Read will wait for the number of bytes you told it to wait for, up to the timeout.  Also, make sure the Termination Character is OFF during this transaction otherwise, if a byte just happens to match the termination character, you will not get all of the data you expected.

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 3 of 6
(722 Views)

## Re: Average Output

I would use "Mean ptbypt" and just reset after each time interval (or set a fixed length if that works).

Message 4 of 6
(710 Views)

## Re: Average Output

@DailonDonley wrote:

Hello,

I'm trying to find the average output of the amplitude over a period of time. So the formula is the (Sum of amplitude/ΔT). Where for each time interval, the average amplitude is shown on the graph. I tried using the add array elements and dividing by the time, but from the waveform, this does not look correct. Would the MeanPtByPt vi work? Or is there any other way I could go about this? The amplitude should be around 5V. Thank you

Average or Sigma per Delta Tau?

Despite the oddest typecast string to array of int16 I've seen lately and the completely superfluous build Array you have implemented the latter ALMOST! since the number of readings seams inconsistent for each second interval.

crossrulz is exactly right! Remove the bytes at port an simply read a reasonable even number of bytes.  The to from flattened strings could likely be replaced with a typecast. (You didn't show the received data format).  And we really don't know what the device measurement timing is.

With that information we can by more helpful to you.

"Should be" isn't "Is" -Jay
Message 5 of 6
(692 Views)

## Re: Average Output

@JÞB wrote:

Despite the oddest typecast string to array of int16 I've seen lately..

The only odd part about it is the first Flatten To String.  You already have a binary string, so you do not need to "flatten" it.  But the Unflatten From String to convert to I16 or U16 is fine.  Notice the "Little Endian" option is being used.  So if you used Type Cast instead, you would need to add a "Swap Bytes".

There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Message 6 of 6
(683 Views)