Linux Users

cancel
Showing results for 
Search instead for 
Did you mean: 

real time processing with nidaqmxbase

Hi

I am running Fedora 9 and using nidaqmxbase ANSI C to program a USB 6009. I need to sample continuously for long periods of time and want to be able to view and analyze the data after it has been sampled. I am having trouble figuring out how to program the device in order to access individual samples.

Since I need to analyze the data in real time I would like to be able to access the sampled data before my recording is completely done. But the functions defined in the nidaqmxbase header files seem to finish the task before I can access the data.

Are there any functions provided by nidaqmxbase that will allow me to do this?

Ideally I would like to acquire data and then analyze using a frame base method and not with individual samples but any insight would help.

Thanks

cannonball.

0 Kudos
Message 1 of 8
(6,230 Views)

Before getting into very much detail, I'd like to understand what you mean when you say 'real time processing'. DAQmx Base does not have determinism, and even if it did, the USB communication would then break its determinism. 'Real time' tends to apply more to control scenarios, where operations that must happen happen within a certain amount of time or timeout errors are handled. 'Real time' does not mean 'real fast' but 'real predictable'. DAQmx Base and more so, USB, are not predictable and cannot be used in a real time application (at least with any amount of confidence ;-).

However, DAQmx Base does not prevent you from accessing and analyzing the analog data from a 6009 while the task is running. All you need to do is set up a continuous acquisition and process your data in the while loop that reads from the device. There are many different ways to architect how the data is processed (eg in the loop, or via workqueue, or another process altogether), but that data can be read and processed while the task is running nonetheless.

Modifying examples/ai/contAcquireNChan.c, a very simple way to get to your data would be:

    // The loop will quit after 10 seconds

    startTime = time(NULL);
    while( time(NULL)<startTime+10 ) {
        DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByScanNumber,data,bufferSize*2,&pointsRead,NULL));
        totalRead += pointsRead;
        printf("Acquired %d samples. Total %d\n",pointsRead,totalRead);
       
    // Process the data
    result = myDataProcessor(data, buffersize*2);

    }

where myDataProcessor is a function that takes buffersize samples and returns some result after doing something to them. Data will be read and then sent to this processing function until the while loop exits, and you will be processing your data as it comes in, buffersize samples at a time.

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 2 of 8
(4,191 Views)

Hi Joe,

Thanks for your help. When I said real time I meant processing while the said program was still acquiring data. I didn't want to have to acquire all of the data and then analyze the data after acquisition was complete. I'm sorry if I used the term incorrectly. I will try out what you suggested but I believe this is what I need.

Thanks for your help

cannonball

0 Kudos
Message 3 of 8
(4,191 Views)

Hi all,

I will get my DAQ PCI-6110 soon and I will use it for real time processing (acquisition and processing at the same time).

I am using a Mandriva 2008-32 bit. So first of all I must install the driver NIDAQmxBase3.2.0 ?

can I install this driver before getting my PCI card ?

and to program my application, can I use netbeans or eclipse instead of LabView (because I can't find Labview for Linux !!)?

Thank you in advance.

Pedro

0 Kudos
Message 4 of 8
(4,191 Views)

Hi Pedro-

If you are using Mandriva 2008 and a PCI device, you should use NI-DAQmx 8.0.1 instead.  In addition to the LabVIEW APIs, an ANSI C API is provided.  You may be able to use the ANSI C API from your programming environments by calling the .so directly.

BTW, you can find LabVIEW for Linux right here.

-TomW

Tom W
National Instruments
0 Kudos
Message 5 of 8
(4,191 Views)

thank you TomW for answering me so soon,

I found in this link http://digital.ni.com/public.nsf/websearch/35D2B5E483A001A18625716B005BE464?OpenDocument that NI-DAQmx 8.0.1 is not the most recommended driver for Mandriva 2008 !

and for the link of LabView that you gave me, do I have to buy it ? can I evaluate it with the 30 day evaluation software ? because that link is just about buying it or evaluating LabView for Microsoft.

Thank you.

Pedro

0 Kudos
Message 6 of 8
(4,191 Views)

Hi Pedro-

The document that you linked to is out-of-date.  NI-DAQmx 8.0.1 is the most current and recommended driver for vanilla installations of Mandriva 2008.

I do not believe there is an official evaluation version of LabVIEW for Linux.  If you want to evaluate LabVIEW, you can try it on a Windows machine or contact your local National Instruments sales engineer for other options to evaluate on Linux.

Hopefully this helps-

Tom W
National Instruments
0 Kudos
Message 7 of 8
(4,191 Views)

Hi TomW,

Ok. Thank you very much for your help.
I will contact an engineer for that.

Thank you again.

Pedro

0 Kudos
Message 8 of 8
(4,191 Views)