Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Why do I get -200474 when doing continuous (non-triggered) data acquisition?

I'm using a C program on Mac OS X with a PCIe-6251 card acquire data continuously without any trigger. Typically, I may collect 1024 samples with a rate of 40 usec per sample. I call DAQmxBaseDisableStartTrig before starting the task. Then I have a loop which essentially calls DAQmxBaseReadBinaryI16 repeatedly. It's not exactly clear to me how this could ever timeout. Shouldn't it just be returning whatever has been collected by the internal buffer on the card?

0 Kudos
Message 1 of 7
(3,932 Views)

Mauricev,

 

 

Just so you are clear we generally specify our read rate in samples per second.  What are you putting into the parameters for the read?  How long does it take the program to get this error?  If you are only acquiring 1024 samples according to my calculations you acquisition should only need to go about 41mseconds. 

 

Yes it should simply return what is in the buffer.  We also want to make sure that you are not continuously repeating the task.  Without seeing your code however I can only guess.  Everything you have said should work.  I am not exactly sure what you are or are not doing with this trigger.

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 2 of 7
(3,917 Views)

I believe I'm passing 25,000 to DAQmxBaseCfgSampClkTiming as the sampling rate. Then I start the task just once.

 

DAQmxBaseReadBinaryI16 is called as follows:

 

theError = DAQmxBaseReadBinaryI16(gTaskHandle,gIncomingTAData.pointsPerTrace,kNIDAQTimeOut,(unsigned long)DAQmx_Val_GroupByChannel,(short*)gTriggeredReceiveBuffer,(unsigned long)thePointsToRead,&theSamplesRead,0);

 

where gIncomingTAData.pointsPerTrace is 1024, kNIDAQTimeOut is 5, thePointsToRead is also 1024.

 

After DAQmxBaseReadBinaryI16 returns, the gTriggeredReceiveBuffer is copied into the buffer of another program and cleared with zeroes, then the loop starts over, calling DAQmxBaseReadBinaryI16 again. I believe the error occurs right away, either on the first or second call.

0 Kudos
Message 3 of 7
(3,912 Views)

mauricev,

 

I would recommend that you post your code so we can better help you.  If this is not an option:

 

1) I would follow as closely as possible the DAQmxBase Example: contAcquireNChan.c this will be a very good guide for programming this.

2) You might try making your buffer bigger (double in the above program) than the samples you are bringing in.

3) You might also try running the example mentioned above.

Sincerely,
Jason Daming
Applications Engineer
National Instruments
http://www.ni.com/support
0 Kudos
Message 4 of 7
(3,900 Views)

Why are they doubling the buffer?

 

Anyway,  doing that and preallocating the internal buffer makes no difference. The error still occurs. 

 

So here's my code...

 

PrepareCollection(); while(gIncomingTAData.doCollect && (!theQuitCollect)) { CollectChannels(); } void PrepareCollection() { gTriggeredReceiveBuffer = (UInt16 *)NewPtrClear(ReturnDataSizeinBytes()); const char *theChannelSelection; switch(gIncomingTAData.numInputChannels) { case 1: theChannelSelection = &k1Channel[0]; break; case 2: theChannelSelection = &k2Channels[0]; break; case 3: theChannelSelection = &k3Channels[0]; break; case 4: theChannelSelection = &k4Channels[0]; break; } gTaskHandle = nil; SInt32 theError = DAQmxBaseCreateTask(kMemoryLeakBusterString,&gTaskHandle); theError = DAQmxBaseCreateAIVoltageChan(gTaskHandle,theChannelSelection,"",DAQmx_Val_Cfg_Default,0,10,DAQmx_Val_Volts,NULL); double theSamplingRate = kSamplingRateFactor/(gSamplingRate * kSamplingRateFactor); theError = DAQmxBaseCfgSampClkTiming(gTaskHandle,kClockSource,theSamplingRate,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,gIncomingTAData.pointsPerTrace); theError = DAQmxBaseDisableStartTrig(gTaskHandle); SInt32 theError = DAQmxBaseStartTask(gTaskHandle); } void CollectChannels() { SInt32 theError; SInt32 thePointsToRead = gIncomingTAData.pointsPerTrace * gIncomingTAData.numInputChannels; long theSamplesRead = 0; theError = DAQmxBaseReadBinaryI16(gTaskHandle,gIncomingTAData.pointsPerTrace,kNIDAQTimeOut,(unsigned long)DAQmx_Val_GroupByChannel,(short*)gTriggeredReceiveBuffer,(unsigned long)thePointsToRead,&theSamplesRead,0); if (theError == 0) { SendDataToMainThread((short *)gTriggeredReceiveBuffer); } ClearIntBuffer(gTriggeredReceiveBuffer, (ReturnDataSizeinBytes() / 2)); }

 

 

0 Kudos
Message 5 of 7
(3,881 Views)

Hey,

Try intitalizing timeout as -1, which will set DAQ card timeout to infinity.

 

Thanks

lab

0 Kudos
Message 6 of 7
(3,828 Views)

If you think about it, the timeout value is irrelevant. Once the command is called, it should just return whatever data is present continuously.

 

Anyway, I figured it out. The problem is with DAQmx_Val_FiniteSamps being passed to DAQmxBaseCfgSampClkTiming. It should be DAQmx_Val_ContSamps. With that, it works fine!

0 Kudos
Message 7 of 7
(3,794 Views)