04-09-2010 01:42 PM
I am trying to access a NI ENET-9163/9205 using the VC++ examples that came with the installation of the DAQ software. Specifically, I am using the "Cont Acq-Int Clk" example code from Visual Studio 2008 Professional Edition. The problem is with the function DAQmxCfgSampClkTiming (I think), and, aside from specfic voltage ranges, terminalConfig, etc., I'm using the example code exactly as it is with the following changes and corresponding results:
CASE I:
------
DAQmxCreateAIVoltageChan:
physicalChannel: "ENET-149618B/ai0"
DAQmxCfgSampClkTiming:
rate: 1000
sampleMode: DAQmx_Val_ContSamps
sampsPerChanToAcquire: 1000
DAQmxRegisterEveryNSamplesEvent:
everyNsamplesEventType: DAQmx_Val_Acquired_Into_Buffer
nSamples: 1000
==> RESULT: I get my data at a rate of 1000S/s every 1 second. That's good, I'm getting my data as I expect I should.
CASE II
-------
DAQmxCreateAIVoltageChan:
physicalChannel: "ENET-149618B/ai0,ENET-149618B/ai1"
DAQmxCfgSampClkTiming:
rate: 1000
sampleMode: DAQmx_Val_ContSamps
sampsPerChanToAcquire: 1000
DAQmxRegisterEveryNSamplesEvent:
everyNsamplesEventType: DAQmx_Val_Acquired_Into_Buffer
nSamples: 1000
==> RESULT: Generates the following output/error:
Acquiring samples continuously. Press Enter to interrupt
DAQmx Error: Buffer is too small to fit read data.
Buffer Length: 1000
Required Buffer Size in Samples: 2000
In fact, no matter what I put in for rate, sampsPerChanToAcquire and/or nSamples, it generates the same error message. I read through the NI-DAQmx C Reference Help pages and I'd expect the buffer length to actually be 10,000kS. So something is not right, most likely it's my lack of understanding that's the issue. I searched the discussion forums but did not find anything related to what I'm seeing. Any help would be greatly appreciated.
My setup information:
Hardware: NI ENET-9163/9205
NI-DAQmx 9.0 (Just purchased)
Windows version: XP
Language: VisualStudio VC++
04-12-2010 02:50 PM
Hi JohnC,
It seems to me that this error is the result of providing a shorter buffer than required by your read operation. As I can tell from the information you posted, you want to read 1000 samples from two channels (namely ENET-149618B/ai0 and ENET-149618B/ai1). This read operation requires you to provide a buffer with enough space for 2000 samples (1000 samples for each channel), but you are providing a buffer that can only allocate 1000 samples.
To solve this you could provide a buffer for 2000 samples. In order to do this in the example you mentioned, modify data's declaration within EveryNCallback function to be 2000 float64s long instead of 1000.
Please, let me know if this approach does not fix this behaviour.
Anzurio Parra
National Instruments