I have a program which I am acquiring samples from NI9201 and output as analog dbl. I want to also calculate an average value over 10 samples and output that as well. After setting up the code and running, there is no difference in the calculated "Average" values and the raw reading as displayed by the two separate waveform. Could anyone shed a light on this?
Solved! Go to Solution.
The waveform charts looks the same because they are the same! Your for loop is simply adding a number to itself 10 times and then dividing by 10, so no averaging is occurring. Try the Mean PtByPt VI with a sample length of 10.
Thanks for the reply! Yes I noticed that as well right after I posted this.
I will try your suggestions. Although I am curious as to why it wouldnt work for this application, Could you please explain? I actually tried with a random number generator in a while loop with this for loop and it did take the average since each time the value enters the for loop is different. My speculation was each time it will acquire a different value and store into the for loop for N times then executes the average calculation.
LabVIEW relies on dataflow for the order of execution, meaning that anything that relies on data coming from upstream, has to wait until the subVIs, structures, or other nodes that provide that data are finished executing. So having a for loop in the middle of the diagram means: execute code to the left -> execute for loop N times -> execute code to the right.
(Left and right are general terms and usually how good looking code is laid out, but data can flow in any direction that you can draw a wire).