Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to abort DAQmxReadAnalogF64 and other questions

Hi,
 
1. I would like to sample data up to 30 seconds at a sampling rate of 100K, so I used the  DAQmx_Val_FiniteSamps mode. But I would like to be able to abort the samping when it is not finised by pressing a button. How could I realize it?
 
2. If I use DAQmx_Val_ContSamps to realize the tast by monitoring the total number of samples (30s * 100K = 3M), I am supposed to use DAQmxGetReadAvailSampPerChan() to check how many data is available and then use DAQmxReadAnalogF64() to read them. Is the code something like the below?

 while( totalRead<3000000 )
 {
    DAQmxErrChk(DAQmxGetReadAvailSampPerChan(taskHandle, read));
    if(read>=1000)
    {
        DAQmxErrChk(DAQmxErrChk (DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByScanNumber,data,bufferSize,read,NULL)));
        if( read>0 ) totalRead += read;
    }
 }

3. If the analog input from one channel is slow and the sampling rate need not be as high as 100K, how can I simultineously sample several channels with different sampling frequencies for each of them? I referred to this post http://forums.ni.com/ni/board/message?board.id=250&message.id=16434&query.id=23366#M16434 but it only samples channels one by one, not simultineously.

Your help will be appreciated!

David 

Message Edited by RedGrouper on 06-15-2006 03:59 AM

0 Kudos
Message 1 of 5
(3,446 Views)

Hi,all,

Some sample code would be greatly apprecated!

David

0 Kudos
Message 2 of 5
(3,441 Views)
Hi David,

  1. You can do a finite task (DAQmx_Val_FiniteSamps), but then do a DAQmxReadAnalogF64 for N (where N is less than the total number of samples and allows an update rate in the range of what you would like) number of samples within a While Loop that stops when DAQmxGet ReadAvailSampPerChan = 0 or when the user presses the stop button.
  2. If you wanted to read a finite number of samples in continuous mode, then you need to read something like 100kSamples for 30 times (or some other ratio that you deem worthy).  This method is not as good as method 1 though, but effectively does the same thing.
  3. Honestly the best way to read different channels at different rates is to read all channels at the max rate, and then decimate the data from the channels that needed slower rates.  The only other options are like you linked where you can do one at one rate, the second at a different, etc.  OR you could get multiple boards and easily obtain different rates for the different boards.
Regards,
0 Kudos
Message 3 of 5
(3,420 Views)

Hi,

If I follow the first method, do I need to set up the Read Relative To and Offset properties? Is there sample code that realized similar functions?

Thank you very much!

David

0 Kudos
Message 4 of 5
(3,354 Views)

Hi David,

I do not see any reason for you to set the Read Relative To or Offset properties. By default each subsequent read will start where the previous read left off.  It is kind of like a bookmark. You read to a particular point in the buffer and then the bookmark shows where you stopped.  So long as you do not stop or clear your task, the bookmark will remain in place and your next read will start in the appropriate location.

Once the user has pressed the button to stop, then you can stop and clear your task.

Regards,

Jennifer O.
Applications Engineer
National Instruments

 

 

0 Kudos
Message 5 of 5
(3,335 Views)