Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

wrapper c++ class problem with DAQmxReadAnalogF64

Hi,

I'm very new to this group and NI-DAQmx. I started using provided ansi-c header and library to write applications for my PCI-6221. I was writing a wrapper class and program halts. Debug takes me to nidmxfu.dll and points:

_RELIABILITY_CONTRACT
void  __CLRCALL_PURE_OR_CDECL _Mtxlock(_Rmtx *_Mtx)
    {    /* lock mutex */
#ifdef _M_CEE
    System::Threading::Thread::BeginThreadAffinity();
#endif
    EnterCriticalSection(_Mtx);
    }

in xmtx.c

My class is very simple including <iostream> and "NIDAQmx.h". All variables are private and DAQmxReadAnalogF64 is wrapped as :

void VoltageRead::readDAQ(void)
{
    DAQmxReadAnalogF64(taskHandle,1000,10.0,DAQmx_Val_GroupByChannel,data,1000,&read,NULL);
}

I'm using VS 2005. Thanks for your help in advance.
emrah
0 Kudos
Message 1 of 9
(4,592 Views)
Hi Emrah,

When installing NI-DAQmx 8.0, you need to choose to install support for the 1.1 Framework. You need to use the 1.1 Framework (not the 2.0 framework) in Visual Studio 2005. Let us know if that resolves the issue. I also recommend that you take a look at the examples located at C:\Program Files\National Instruments\NI-DAQ\Examples\VisualC
--
Michael P
National Instruments
0 Kudos
Message 2 of 9
(4,577 Views)
Michael,

I installed 1.1 framework during the DAQmx installation, I couldn't find a way to switch between 1.1 and 2.0 in visual studio 2005 if there is could you assist me on that. Also under "C:\Program Files\National Instruments\NI-DAQ\Examples\" I only have "DAQmx ANSI C" and "Visual Basic 6.0" directories.

Thanks,
emrah
0 Kudos
Message 3 of 9
(4,573 Views)
You should be able to download and install the 1.1 Framework from Microsoft's website. Nevermind the examples I mentioned before. Instead, take a look at C:\Program Files\National Instruments\MeasurementStudioVS2003\VCNET\Examples\DAQmx
If you do not have this directory on your machine, run the DAQmx installer again and be sure to include support for it.
--
Michael P
National Instruments
0 Kudos
Message 4 of 9
(4,571 Views)
Hi,

I installed framework 1.1 and still I'm having the same problem only this time debugger points a different file. Also how can I switch between the framework versions is it always the latest installed one activated?

I checked C:\Program Files\National Instruments\MeasurementStudioVS2003\VCNET\Examples\DAQmx\ but during the compilation it returns an error:
Cannot open include file: 'NiCommonComponent.h': No such file or directory

I assume I need to purchase measurement studio for this.

thanks,
emrah
0 Kudos
Message 5 of 9
(4,570 Views)
My mistake; I didn't realize you didn't have Measurement Studio. Have you tried using a DAQmx ANSI C example (C:\Program Files\National Instruments\NI-DAQ\Examples\DAQmx ANSI C)?
--
Michael P
National Instruments
0 Kudos
Message 6 of 9
(4,564 Views)
That's where the problem is, the analog-in voltage read example under ansi-c works in VS 2005 but when I write a class around it program halts (which is the original posting). Also I don't know if it's a bug but I tried to install measurement studio 7.0 evaluation which didn't go through since I have VS 2005 but I installed the components one by one then re-installed the measurement studio support files with DAQmx 8.0.1. Now I have the "NiCommonComponent.h" etc. but again I had problems due to (http://msdn2.microsoft.com/en-us/library/ms177253(vs.80).aspx).

Thanks,
emrah kostem
0 Kudos
Message 7 of 9
(4,560 Views)
OK! The mystery is solved... This is what's going on, If I put the DAQmxReadAnalogF64 in a class and use cout before it any time either in the class or in the main it generates the error. Wrapping a class around the ansi-c code works if I don't use cout before reading, but without a class like the example c file given with a single main function there is no problem. Anybody know why this would happen? I assume DAQmxReadAnalogF64,taskHandle, and input output buffers are some related, shall I close the task after reading etc...??

Thanks,
emrah kostem
0 Kudos
Message 8 of 9
(4,544 Views)
Emrah,

Make sure that you are stopping and clearing the task when you are finished using it. Try to reproduce what you are seeing by modifying example code by adding a cout. If you continue to run into this error, please post your code (the smallest amount that reproduces the problem) and the error information.
--
Michael P
National Instruments
0 Kudos
Message 9 of 9
(4,520 Views)