Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI 6254 DAQmxBase Error: -200495

Hi,

 

I just got a NI 6254 and I'm trying to use it with daqmxbase under linux.

It needs to correlated input from digital port 0 and analogue inputs 0-7.

All seems well at first but I keep getting this error:

 

Task started, waiting for trigger...

DAQmxBase Error: -200495 - An intermediate acquisition buffer has overflowed.  The driver was unable to read samples from the intermediate buffer fast enough to prevent the buffer from overflowing.

End of program, press Enter key to quit

 

I'm at a loss to understand why.  I've tried switching computers and switching from redhat el5 to el4.

The problem persists.

 

I'm sure this is just me being dumb, but I'd appreciate some advice.

Code below.

 

Thanks,

 

Matt.

 

#include <stdio.h>

#include "NIDAQmxBase.h"

 

#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }

 

int main(void)

{

 

  const int32 nsamples = 12000;

  const int32 nchannels  = 8;

  const int32 npretrig = 2000;

 

  int32       error=0;

  TaskHandle  taskHandleDig=0;

  TaskHandle  taskHandleAna=0;

  int32       numReadDig=0;

  int32      numReadAna=0;

  uInt8       dataDig[nsamples];

  float64     dataAna[nsamples*nchannels];

  float64     rate = 10000;

  float64     timeout = 86400;

  char        errBuff[2048] = {'\0'};

 

  /*********************************************/

  /*/ DAQmxBase Configure Code

  /*********************************************/

 

  DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandleDig));

  DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandleAna));

  

  DAQmxErrChk (DAQmxBaseCreateAIVoltageChan (taskHandleAna, "Dev1/ai0, Dev1/ai1, Dev1/ai2, Dev1/ai3, Dev1/ai4, Dev1/ai5, Dev1/ai6, Dev1/ai7","", DAQmx_Val_Diff, -10, 10, DAQmx_Val_Volts, ""));

  DAQmxErrChk (DAQmxBaseCreateDIChan (taskHandleDig, "Dev1/port0", "", DAQmx_Val_ChanForAllLines));

 

  DAQmxErrChk (DAQmxBaseCfgSampClkTiming (taskHandleAna, "OnboardClock", rate, DAQmx_Val_Rising, DAQmx_Val_FiniteSamps, nsamples));

  DAQmxErrChk (DAQmxBaseCfgSampClkTiming (taskHandleDig, "/Dev1/ai/SampleClock", rate,DAQmx_Val_Rising, DAQmx_Val_ContSamps, nsamples));

  DAQmxErrChk (DAQmxBaseCfgDigEdgeRefTrig(taskHandleAna,"/Dev1/PFI0",DAQmx_Val_Rising, npretrig));

  //DAQmxErrChk (DAQmxBaseCfgDigEdgeStartTrig(taskHandleAna,"/Dev1/PFI0",DAQmx_Val_Rising));

 

  /*********************************************/

  /*/ DAQmxBase Start Code

  /*********************************************/

  DAQmxErrChk (DAQmxBaseStartTask(taskHandleDig));

  DAQmxErrChk (DAQmxBaseStartTask(taskHandleAna));

 

  printf("Task started, waiting for trigger...\n");

 

  /*********************************************/

  /*/ DAQmxBase Read Code

  /*********************************************/

  DAQmxErrChk (DAQmxBaseReadAnalogF64 (taskHandleAna, nsamples, timeout,DAQmx_Val_GroupByChannel, dataAna, nsamples*nchannels, &numReadAna, NULL));

  DAQmxErrChk (DAQmxBaseReadDigitalU8 (taskHandleDig, nsamples, timeout,DAQmx_Val_GroupByChannel, dataDig, nsamples, &numReadDig, NULL));

 

  printf("Acquired %d analog samples\n",numReadAna);

  printf("Acquired %d digital samples\n",numReadDig);

 

 Error:

  if( DAQmxFailed(error) )

    DAQmxBaseGetExtendedErrorInfo(errBuff,2048);

  if( taskHandleDig!=0 && taskHandleAna!=0 ) {

    /*********************************************/

    /*/ DAQmxBase Stop Code

    /*********************************************/

    DAQmxBaseStopTask(taskHandleDig);

    DAQmxBaseStopTask(taskHandleAna);

  }

  if( DAQmxFailed(error) )

    printf("DAQmxBase Error: %d - %s\n",error, errBuff);

  printf("End of program, press Enter key to quit\n");

  getchar();

  if( taskHandleDig!=0 && taskHandleAna!=0 ) {

    DAQmxBaseClearTask(taskHandleDig);

    DAQmxBaseClearTask(taskHandleAna);

  }

  return 0;

}

 

0 Kudos
Message 1 of 3
(2,979 Views)

Hi unbeliever,

 

The first thing that would strike me from your code is that your digital sampling is on continous not finite but there is no looping in your program.  I think this could be the origin of your error.  I am also not sure how your digital channel will react to the reference trigger either as this does not affect the ai clock.  The start trigger works accross both because the ai clock does not fire any pulses until that point however the reference trigger does not affect the ai clock and so the digital channel will not be aware of this triggering taking place.  I will test this to verify this but I believe this is the case.

 

Hope this helps,

James Mc
========
Ask me about Rust & NI Hardware
My writings are at https://www.wiresmithtech.com/devs/
0 Kudos
Message 2 of 3
(2,950 Views)

Hi folks,

I'd like to underline what James said: the reference trigger will cause the analog sample clock to start once the call to DAQmxBaseStartTask is made. If you were after synchronization, you will lose it since the digital task will be acquiring samples while the analog task is waiting for the reference trigger.

One clarification I'd like to make is the supported sample modes for digital tasks: Base doesn't support finite digital acquisitions, only continuous and software-timed reads. The only way to use the same sample mode for both analog and digital acquisitions in this program is to switch the analog task to continuous.

Finally, the error you're seeing looks to be related to the digital task. I've been able to reproduce it, and from what I've seen so far, it's related to how data is transfered from the device to the computer: analog and counter measurements have DMA transfers, but digital measurements do not. They use polling instead. The added delay in the digital read appears to be affecting the analog task as well.

 

The full DAQmx driver for Linux (version 8.0) may be a better fit for your specific needs. While the driver only supports slightly older Linux distributions, it uses DMA transfers for digital reads and allows the full extent of the board to be used more easily.

Joe Friedchicken
NI Configuration Based Software
Get with your fellow OS users
[ Linux ] [ macOS ]
Principal Software Engineer :: Configuration Based Software
Senior Software Engineer :: Multifunction Instruments Applications Group (until May 2018)
Software Engineer :: Measurements RLP Group (until Mar 2014)
Applications Engineer :: High Speed Product Group (until Sep 2008)
0 Kudos
Message 3 of 3
(2,827 Views)