Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxBase Acquiring at high frequency

Hi everyone,

 

Part of my job is to acquire continously on multiple channels using NIDAQmxBase.

 

As I faced problems in my application I decide to work with the provided examples but I doesn't succeed to make them work.

 

Here are my needs :

12 Channels

48000 Hertz

 

Here is my code (contAcquireNChan.c with a few modifications):

 

#include "NIDAQmxBase.h"
#include <stdio.h>
#include <time.h>

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


int main(int argc, char *argv[])
{
    // Task parameters
    int32       error = 0;
    TaskHandle  taskHandle = 0;
    char        errBuff[2048]={'\0'};
    int32       i,j;
    time_t      startTime;
    bool32      done=0;

    // Channel parameters
//    char        chan[] = "Dev1/ai0, Dev1/ai1";
    char        chan[] = "Dev1/ai0, Dev1/ai1, Dev1/ai2, Dev1/ai3, Dev1/ai4, Dev1/ai5, Dev1/ai6, Dev1/ai7, Dev1/ai8, Dev1/ai9, Dev1/ai10, Dev1/ai11";
    float64     min = -10.0;
    float64     max = 10.0;

    // Timing parameters
    char        clockSource[] = "OnboardClock";
    uInt64      samplesPerChan = 1000;
    float64     sampleRate = 48000.0;

    // Data read parameters
    #define     bufferSize (uInt32)1000
    float64     data[bufferSize * 12];
    int32       pointsToRead = bufferSize;
    int32       pointsRead;
    float64     timeout = 10.0;
    int32       totalRead = 0;


    printf("Press Ctrl-C to exit\n");
    DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
    DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
    DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,samplesPerChan));
    DAQmxErrChk (DAQmxBaseCfgInputBuffer(taskHandle,144000));

    DAQmxErrChk (DAQmxBaseStartTask(taskHandle));

    // The loop will quit after 10 seconds
    printf ("Acquisition starting\n");

    startTime = time(NULL);
    while( time(NULL)<startTime+50 ) {
        DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByScanNumber,data,bufferSize*12,&pointsRead,NULL));
        totalRead += pointsRead;
        printf("Acquired %d samples. Total %d\n",pointsRead,totalRead);
        // Just print out the first 10 points of the last data read
        for (i = 0; i < 10; ++i)
            printf ("data0[%d] = %f\tdata1[%d] = %f\n",i,data[2*i],i,data[2*i+1]);

    }
    printf("\nAcquired %d total samples.\n",totalRead);

Error:
    if( DAQmxFailed(error) )
        DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
    if(taskHandle != 0) {
        DAQmxBaseStopTask (taskHandle);
        DAQmxBaseClearTask (taskHandle);
    }
    if( DAQmxFailed(error) )
        printf("DAQmxBase Error: %s\n",errBuff);
    return 0;
}

 

 

With my  values (12 channels, 48000Hz) it doesn't seems to work; I get the following message when readingAnalogF64 :

 

DAQmxBase Error: RLP Invoke Node <err>There is <b>not enough data</b> in the DMA buffer to fill the VI's read buffer.  Either request less data, or wait until there is additional data in the DMA buffer.

With smallers values (10 channels or 30000Hz) it works better, even if sometimes I still get this error message.

 

 

After a few investigation it seem's that this not an error but just a warning (code 42), but I don't know if the values are correctly acquired.

 

As someone still faced this problem and have more information.

 

Thank in advance

 

Sylvain 

 

 

 

 

0 Kudos
Message 1 of 21
(5,102 Views)

A few more informations (forgotten) :

 

I run on linux (RHEL4 and RHEL5)

I tried on two differents machines (PentiumD 2.8Ghz, 1Go RAM  and C2D 3GHz, 2Go RAM)

 

The approximately same code works with NIDAQmx (but this last isn't supported on RHEL5 that's the reason why I try NIDAQmxBase)

0 Kudos
Message 2 of 21
(5,101 Views)

Hi Sylvain.

 

Could you send us a screen of the error message?

Thanks in advance.

Regards.

Romain D.
National Instruments France

0 Kudos
Message 3 of 21
(5,077 Views)

Of course I can,

 

You can find enclosed a screen shot of my console.

 

I have tried many combination with no more results.

 

I'm thinking about a lack of optimisation in NIDAQmBase cause it works well with NIDAQmx.

 

Thanks for any help 

0 Kudos
Message 4 of 21
(5,054 Views)

Hello Atos.

 

Did you solve your problem?

Could you tell me the version of DaqmxBase did you use?

Thanks.

 

Regards. 

Romain D.
National Instruments France

0 Kudos
Message 5 of 21
(5,012 Views)

Well, I didn't solve the problem cause it's currently impossible to do this with DaqmxBase.

 

NI support, reproduce the problem with their example given below.

They also confirm that today the DAQmxBase layer is unable to acquire at the samplerate given in the hardware specification.

It seems to be a problem with the DMA writing/reading at high rates.

 

For me it's not very straight that NI sell a card with hight hardware specifications and linux support, althought they do not provide the software that enable to achieve this.

A bit incomprehensible ... 

0 Kudos
Message 6 of 21
(4,988 Views)

Hi Sylvain-

 

Which version of NI-DAQmx Base are you using?  Which PCI/PXI hardware device are you using? 

 

The error you are seeing is an internal software error that should not appear to the user in most cases.  Some enhancements were made in NI-DAQmx Base 3.2 to help avoid this error, so I'm curious if you might be using an older version.

 

Thanks-

Tom W
National Instruments
0 Kudos
Message 7 of 21
(4,979 Views)

Hi Tom,

Thanks for replying.

 

Actually I've tried with 2 configurations

    + RHEL4, DAQmxBase 3.2 and 6259PCI Card

    + RHEL5, DAQmxBase 3.2 and 6254PCI Card

 

I've got the same problem. It seems that I try to acquire at too high rates.

 

Moreover there's not many configuration's functions provided with the DAQmxBase C API, so I can't try many configuration's combinations.

 

If someone can tell me more ...

0 Kudos
Message 8 of 21
(4,974 Views)
Hi Atos,

One option you may want to evaluate is using the full NI-DAQmx driver on Linux. Both your 6254 and 6259 cards are supported and shouldn't experience the DMA problems you've been observing. The trade-off, however, is supported Linux versions. The only release of DAQmx for Linux is version 8.0 [1], and so it supports slightly older distributions. The latest RedHat release that DAQmx 8.0 works with is Enterprise WS 3 [2].

As Tom mentioned, the problems you're seeing shouldn't be happening in Base 3.2. We're looking into the cause and fixes, but I don't know when they will be added to the driver. The fastest resolution for you may be using DAQmx 8.0 and not Base 3.2

[1] DAQmx 8.0 for Linux
http://joule.ni.com/nidu/cds/view/p/id/374/lang/en

[2] DAQmx 8.0 for Linux Readme
http://ftp.ni.com/support/softlib/multifunction_daq/nidaqmx/8.0/Linux/Mandriva/readme.txt
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 9 of 21
(4,862 Views)

Hi Jo,

 

Thanks for your answer,

Sorry for my being late on replying, I was a few day on holydays...

 

Actually when I start working on this project, I've began with NIDAQmx on RHEL4.

At that time, I was given instructions, drivers and the NI card and I didn't know that NIDAQmx doesn't support RHEL4.

Almost every things worked well  ...

 

But today we have upgrade on RHEL5 (we've got new computers unsupported on the previous versions of RedHat). 

That's the reason why we try NIDAQmxBase (Only this driver, supports the last versions of RedHat)

We faced the above problems ...

 

But as I have just said, every things run well with NIDAQmx on RHEL4/5 ... even thought it's not supported.

Does someone know in which circumstances the kernel stack overflow happens ?

This could help us make more test on the reliability of our application ...

Actually it's quite simple, it can be summarized as an infinite acquiring task.

 

Thans for any help,  

 

 Sylvain

 

 

 

 

Message Edité par Atos le 09-22-2008 07:57 AM
0 Kudos
Message 10 of 21
(4,805 Views)