Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with continuous sampling and niDAQmx C API

I don't seem to be able to get continuous sampling to work. I am guessing that I do something wrong with the steps that I take (out of order or I might be missing one). Here is the code, simplified by taking out all the error checking (the program runs without issuing any errors, i.e. DAQmxFailed(error) is always 0, and data is not NULL).
The problem is that nSamplesRead is always 0, and data is always full of 0s as well. If I use the same program and replace the line error = DAQmxCfgSampClkTiming(...,DAQmx_Val_ContSamps,N_SAMPLES); by error = DAQmxCfgSampClkTiming(...,DAQmx_Val_FiniteSamps,10); for example, and do not issue the DAQmxStopTask, I am able to read 20 samples from the DAQ card (DAQcard-6024E). I al
so tried to add DAQmxDisableStartTrig before starting the task, but it didn't help. I tried not stopping the task, but that didn't help either.

Any help would greatly be appreciated.

Thanks!

Laurent
0 Kudos
Message 1 of 2
(3,070 Views)
Well, I'll answer my own question since I managed to solve the problem.

The problem was with error = DAQmxCfgSampClkTiming(...,DAQmx_Val_ContSamps,N_SA MPLES); which will apparently prevent the reading of any values before N_SAMPLES samples have been read.

This is incorrectly documented in the October 2003 edition of NI-DAQmx C reference where it states that this parameter is only used if sampleMode is DAQmx_Val_FiniteSamps.

Changing the above line to error = DAQmxCfgSampClkTiming(...,DAQmx_Val_ContSamps,2); and moving the DAQmxStopTask command after DAQmxReadAnalogF64 solved my problems.
0 Kudos
Message 2 of 2
(3,070 Views)