LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

daqmx read.vi dt=0

Hello,
I am quite new in Labview so probably this question is very silly from my side...
I am trying to read three analog input channels of a USB 6009. I am using the block diagram attached.
The reading worked fine but when I tried to make some FFT of the data I realised that the dt given by DAQmx Read, Analog, Multiple Channels, 1 or N samples, was zero. I have been searching around and trying to find an answer in the forums, but no success, probably because it is too easy to post it... but I am blocked.
Could you tell me any workaround? Using MAX you can change the frequency sampling but how you do it in LABVIEW?
Many thanks.
cheers,
I.
0 Kudos
Message 1 of 6
(3,731 Views)
You set the sample rate with the DAQmx Timing function. You don't have one so I believe you are in on-demand or software timed mode. You only get a single sample from each channel with each DAQms Read even though you have a DAQmx Read of multiple samples. You can confirm that by looking at the chart. If you only get a single point on the chart with each iteration, you're in single sample mode. A dt is zero with a single sample. Even if you did have a dt, your FFT wouldn't work in this fram because you only have a single element in the y array. Is that the purpose of your for loop and the local variable? To build an array of single readings? That part is confusing to me.
0 Kudos
Message 2 of 6
(3,721 Views)

Thanks a lot for your reply Dennis.

In fact, I am sorry 'cause to simplify things I have not included a while-loop which surround all the vi, so I repeat the read a certain number of iterations chosen by a control.

In fact, in the chart the three signals look ok.

The for/loop is the best way I've found to make a readout in the pannel control by a three component array of the real-time values of the signal for each channel, with that loop I write the values read by DAQmx continuously. That also works fine...

So, how should I proceed to get the right dt? I am sorry if you already told me and I have misunderstood you, I am quite new in these business.

Thanks!

 

0 Kudos
Message 3 of 6
(3,711 Views)

You have to add a DAQmx timing function to select a sample rate and actually get more than one sample at each DAQmx Read. If you leave it in single sample mode, you would write you own value to the dt based on how fast your loop iterates.

I understand the chart looks correct, what I was asking was whether you got just a single sample written to the chart with each iteration.

Message 4 of 6
(3,707 Views)

Thanks a lot, sorry for my mistake.

I will try with the timing function (I am not in the lab now).

The thing is that before I was working in single mode in the Read vi and with a timing while-loop of 1 ms, and dt it was equal to 0 as well. Is that normal? I was expecting, as you said, that dt was more or less equal to the while-loop wait constant. I think that could be a problem for the power spectrum vi if, though I included a sample rate using timing functions, once it goes to the next iteration it writes a dt=0.

But, don't worry, I should try before anticipating what will happen and in last term I will bother you all again with this.

Thanks!

 

0 Kudos
Message 5 of 6
(3,701 Views)

I'll try to explain a little better. In single point mode, you only have a single element in the y array of the waveform data type. With a single element, dt doesn't apply (you can't have a time between samples if you only have one sample) and the DAQmx driver writes a zero to dt. You can however, modify the dt after you've acquired the data. You can convert the loop rate in msec and write it to a waveform. Maybe the attachment will make it a bit clearer. There's a while loop that is doing single point acquisition. Each channel is indexed and then each y array is indexed to get the single value. I only show the steps for one channel but the while loop auto-indexes the single value out into an array when the while loop completes. You then have an array of all acquired values. To pass it to another function that requires a waveform data type, you use the build waveform function to specify the dt.

Please be aware that if you stick with single point acquisition, the dt is not very accurate. The timing is based on windows running your loop at some interval and that interval can change dramatically , depending on what windows decides to do. You may have a 1 msec wait in there but it could up to a couple orders of magnitude in actual wait time. That is why you never want to do software timed acquistion for such things as an FFT. Your results are going to be pretty meaningless unless you move to a real-time OS.

Message Edited by Dennis Knutson on 02-16-2007 01:52 PM

0 Kudos
Message 6 of 6
(3,694 Views)