LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Number of samples for Statistics VI

Hi,

 

I'm trying to write both the amplitude and statistics to a csv file. I'm using both the Statistics VI and point to point VI and even if I change the number of samples in the point to point VI the value is always calculated after 100 samples are taken. Is there a reason for this?

 

Thank you.

0 Kudos
Message 1 of 12
(3,558 Views)

Your Simulate Signal is creating a dynamic data type consisting of 100 samples.  Then you go and wire that directly into the mean point by point.  Blue dynamic wires are bad because they hide what is the underlying data.  There is a coercion dot for that wire going into the mean pt by pt.  That means the data is being coerced to something else.  What is happening is that either the first or the last data point is being used, and the other 99 are being thrown away in the mean calculations.

0 Kudos
Message 2 of 12
(3,554 Views)

How exactly could I fix that?

0 Kudos
Message 3 of 12
(3,544 Views)

Simulate the signals with regular LabVIEW primitives and subVI's rather than the Express VI's.

 

Or you could convert the blue wire to another datatype such as a waveform or an array using the From DDT express VI.  That Express VI gives you several different ways of converting the data.

0 Kudos
Message 4 of 12
(3,540 Views)

Is there anything i can read up to understand why this isn't working? I convert it to a waveform but its still every 100 values.

0 Kudos
Message 5 of 12
(3,534 Views)

You still have a coercion dot because it is taking a waveform of 100 samples and converting to a scalar value because that is what pt. by pt. is expecting.  If you want the average of all 100 samples, along with future waveform segments of 100 samples, I would convert the blue wire to an array.  Wrap the Mean pt. by pt with a For loop and feed it the array so that the array is autoindexed on the tunnel. Now the Mean VI will loop as many times as there are points in the array.  Then hold tha value and do it some more when the next batch of 100 samples comes in.

Message 6 of 12
(3,530 Views)

How do i wait for the samples to be collected? Thanks for you help by the way.

0 Kudos
Message 7 of 12
(3,520 Views)

I don't understand your question.  If you have a DAQ device, the VI will automatically wait for the 100 samples to be acquired.  For a simulate signal express VI, it will wait if you have it set to simulate timing.

0 Kudos
Message 8 of 12
(3,509 Views)

Hello again, I'm back from working on other projects and i've rewritten my VI to use DAQmx tasks. I am not sure what is wrong with my VI as i'm pretty sure the point by point mean should eventually go to zero as the sine wave (generated in NI MAX) is just oscillating around 0. From my understanding it should loop through 100 times and then take the mean of the collected samples. Is this correct?

0 Kudos
Message 9 of 12
(3,430 Views)

What is the frequency of the sine wave you are generating?

 

How fast is your while loop actually running?

 

Your samples to read is -1, which means all available samples.  If the while loop is running pretty fast, you may not be collecting that many samples.  (Conversely, if it is running slow, which I doubt, you'd be collecting a lot of samples.)

 

Then you run the For Loop the number of times for the samples you collect.  So if you only got 10 samples, the loop runs 10 times, and you'd output the mean of the last 100 pts after every 10 samples.  If you got 10,000 samples (that would be a very slow loop), you'd output the mean of the last 100 points after every 10,000 samples.  You have no real correlation of how frequently the average is being calculated.

 

If the frequency of the sine wave is low, such as 1 Hz, (and you are collecting frequently enough that you the 100 point window isn't losing data), then you will only collect 1/10 of a sine wave since your sampling frequency is 1000 Hz.  The average of 1/10 of a sine wave is going to look like a sine wave.  If you are averaging more than one period of a sine wave, but not an integral number of periods, lets say your sinewave frequency is 10.1 Hz, then the average of 1/10 of that will be 1.01 periods, and will look like a pretty low amplitude sinewave itself as that odd point flows up and down depending on where the 100 pt window is relative to that sine wave.

Message 10 of 12
(3,403 Views)