Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQ callback with Microsoft Visual C++ and LabVIEW

Hello!
I'm developing an application with two parts, a LabVIEW program and a DLL using Microsoft Visual C++.
The program has to acquire data and save it to HDD, so the labVIEW program configures the DAQ (PCI-6111) and starts the DLL. In the DLL I have a callback function to handle the DAQ message of N scans (with the Config_DAQ_Event_Message c function), and then I start the analog output and input from the LabVIEW program.
The DLL should pick up the message of N scans done, and I am getting the callback function called, but somehow it doesn't correspond with the frequency I set for the AI clock.
Does anybody knows if I can configure the AI in a LabVIEW program and wait for the message of N scans in a DLL? Or do I
need to configure the AI in the DLL as well to have them synchronised?
I mean, can I configure and start the AI in one program and handle the occurrences from the DAQ in a different program?
Thank you very much!!!
0 Kudos
Message 1 of 5
(3,328 Views)
Hello;

The problem you are facing is due probably to the fact that the NI-DAQ driver is not multithreaded. Then, if you have more than one thread accessing the driver at the same time, you will have a delay in one of the programs, since the driver will deal with the first request, and after it is done with that, it will deal with the second one. The requests will not be handled at the same time, as a multithread system.
Hope this helps.
Filipe
0 Kudos
Message 2 of 5
(3,328 Views)
Thanks for your answer!
But I am not sure if that is the problem, because both programs (LabVIEW and the DLL) are not accessing the DAQ at the same time, first LabVIEW configures the card, and once this is done, the DLL starts a thread and handles the callback from the DAQ for N acquisitions done.
I don't know what the problem could be, but is driving me mad!
Thanks a lot anyway!
0 Kudos
Message 3 of 5
(3,328 Views)
You are probably going to have to initialize and start the DAQ in the DLL. The C API and the LabVIEW API for DAQ are done through different interfaces into the DLL. I haven't been able to verify for sure that what you are doing won't work, but they are very different APIs so that is probably the problem. Write your initialization and acquisition in the NI-DAQ C API in the DLL and it will probably fix the problem.

Best Regards,

Chris Matthews
National Instruments
0 Kudos
Message 4 of 5
(3,328 Views)
I use the NI-Daq drivers in a multithreaded application all the time. I run up to 5 identical boards at the same time at high speed in an application where each board has two threads along with another 7 threads that do not access the NI-DAQ driver. I never see any latency that prevents continuous acquisition.
0 Kudos
Message 5 of 5
(3,328 Views)