11-29-2011 10:55 AM
Hello,
can any body help me? I would like to acquire voltage signal every 100ms, but I don't know how to set rate sample and number of samples. In the attached VI, the reading of voltage is much lower than 100ms and when there is some voltage variation, the response is very slow. I don't understand how to improve it.
Regards
11-29-2011 01:09 PM - edited 11-29-2011 01:10 PM
Hello,
I think it's probably working fine and your problem is your graph. Have you put a probe or a temporary indicator on the output from your DAQmx Read N Chan N Samples to see what the DAQmx Read function is actually outputting? For some reason, you are converting your DAQmx Read output from a 2D array to dynamic data, then back to a single point. Why are you doing that? If you are relying on your graph output to tell you how many points you're acquiring and how the voltage is changing, I guarantee you it's not telling you the truth. How could it? It's only plotting a single point per acquisition, and you're acquiring 100 per channel!
As a temporary measure, index out one row of the output of DAQmx Read and wire it directly to your graph. Do NOT convert it to dynamic data. Just wire it to your graph indicator. My guess is it'll look pretty different.
Also, if you're going to explicitly set the buffer size, then there is no need to wire a value to the "number of samples" input when you configure your clock source.
A couple of other odds and ends: you don't need the sequence structure. The error wire by itself will dictate dataflow and reset the graph before your loop starts. Also, you don't need the "wait for next msec multiple" in this case. The DAQ function will set the loop timing based on the number of samples you tell it to acquire.
So: try looking directly at the output of your DAQmx Read function, and get rid of all that dynamic data nonsense. I'm really curious as to why you're converting the array to dynamic data and then back to a single point!
11-29-2011 02:06 PM
I agree that the scalar chart emanating from a 2D/Multiple samples doesn't make sense. Especially since you are only looking at one channel. I would change it to Single Channel, Multiple Samples, then average the samples and display to chart.
Regarding the timing: "every 100mS" is a sample rate of 10 Samples per Second. Change the "rate" at the sample clock to 10. Change the Read VI as described above. Use the DAQ Read Property Node to look at the Status: Total Samples Per Channel Acquired to troubleshoot your timing.
11-30-2011 02:07 AM
Hello,
thanks. I did as you suggested. I changed to single point the output of DAQ read, but I don't know how to average the samples and display to chart. I mean, I would like to acquire sampels every 100ms and then showing the average value every 500ms.
Moreover, I use a Read Property Node and it seems that DAQ acquisition go much faster than my while loop iteration. Even if I reduce the sample rate, nothing changes. How is it possible? How timing my acquisition to the rate I would like?
11-30-2011 03:04 AM
Hello,
straight away, what is your sampling rate? I saw that as 10 and also you are reading 10 samples per iteration. If I am right, Each while iteration produce at the rate you specified i.e.. 10 samples. If you want to read only for 100ms, then try using timing options inside the while loop. You can get timing functions in Programming palette.
Coming to the average, The read daqmx function out as an array,, So, try using array length function from array functions under programming pallet and use Summation function as well to find the summation for coming values.
Hope this helps you.
11-30-2011 01:02 PM - edited 11-30-2011 01:05 PM
You're getting closer, but you missed a few things.
You do need something to time your loop, which means that you need to wire an input to "number of samples" on your DAQmx Read function. Right now you are just grabbing samples as they become available, as quickly as possible. (shukhjeter, where did you get the impression that he was reading 10 samples per loop iteration? I see a 10sec timeout, but "# samples" isn't wired.)
You have your sample rate set to 10Hz. Therefore, if you wire a "10" to the number of samples to read, your loop will iterate every 1000msec, because it takes 1000msec to read 10 samples (i.e. 10 samples/second). Each sample will be read at 100msec intervals, hardware-timed so it's pretty precise.
If you wire a "5" to the number of samples to read, your loop will iterate every 500msec (5 samples at a rate of 10samples/sec will take 500msec to read).
If you wire a "1" to the number of samples to read, your loop will iterate every 100msec.
Is that helpful?
To average your samples, use the "Mean" function. (Mathematics...Probability and Statistics...Mean)
Keep at it, you'll get there!