LabVIEW

cancel
Showing results forĀ 
Search instead forĀ 
Did you mean:Ā 

Using Acquire N Scans.vi

Hi, can anyone help?

I'm using Acquire N Scans.vi and would like to calculate the mean value for the N scans. The AI Read output is of the 'waveform' data type but may be changed to 'scaled array', 'binary array' or 'scaled & binary array' by right clicking on the icon. Is it necessary to change the data type? I notice that if I change the type to scaled array, then I get a broken wire when I try to connect it to the mean.vi. Iļæ½ve also noticed that if I select waveform for the data type then the mean (displayed in an indicator) is different (lower) from the mean of the values appearing in the 1D waveform data array on the front panel of the VI. Can you explain this?

My other question is if I press run, how can I display t
he mean value versus time in an XY graph so that by pressing the start/run button repeatedly I can monitor how the voltage is changing with time (in real-time)? At the moment I've got the mean.vi X input wired to the waveform data terminal and the mean output wired to a cluster bundle (with two elements). The other element of the cluster bundle is the 'Get/Date Time in Seconds' function. The output from the cluster is wired to a build array and this in turn wired to a XY graph. I would be very grateful for any help.

Thanks,

Adrian
0 Kudos
Message 1 of 3
(2,761 Views)
I think the problem you are having is that the output from the AI Read.VI is actually a 1-D array of waveforms. If you were scanning multiple channels at one time, each channel would have its own waveform. So scanning two channels would result in a 1-D array of waveforms with 2 elements in it. However, even if you only scan one channel, the VI will still out put an array. So to get a single waveform, you can index the array. Incidentally, if you change the output to a scaled array, you'll notice that the output is a 2-D array of SGL, so you would still have to index it to get a 1-D array. It really does not matter whether or not you use a scaled array or waveform types unless you want to keep the time data included in the waveform. When you wire a wavefor
m type to the Mean.VI it will coerse it into a 1-D array. The reason you were getting strange results out of the Mean.VI before is that LabVIEW will allow you to wire a 1-D array of waveforms to a 1-D numeric array, but it does not coerse it the way you would expect. LabVIEW will coerse it by taking the last value in each waveform of the array and make it an element in the numeric array. So if you wired an array of waveforms that only had one element and coersed it into a 1-D numeric array at the Mean.VI, your average would end up being the last value in your waveform. Hope that all makes sense, I know its a little confusing. Just index the array after the AI Read and I'm sure things will work for you.

If you just want to monitor the mean value versus time, you might have an easier time using a waveform chart. A chart will keep a history of values so that you can wire one value to it at a time inside of a loop.
Message 2 of 3
(2,761 Views)
Aaron, thanks - indexing the array did the trick. The mean I obtained was much closer to the one I calculated. However before assuming everything is alright, could I please confirm with you that I should wire the waveform data from AI Read to the input array terminal of Index Array, a constant of zero to the index terminal of Index Array and the mean.vi to the element/subarray terminal of the same function? I've never used the Index Array function before.

Thanks for your help.

Adrian
0 Kudos
Message 3 of 3
(2,761 Views)