From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Anyone knows how to get the thermocouple temperature with the SCXI 1102 device?

I know the method with using AI, but when I put it in a worker thread, I get runtime error. So I intend to do it with lower level language, anyone know how? An example will be much appreciated. Thanks!
0 Kudos
Message 1 of 3
(2,743 Views)
naturom,
The CWAI controls you are working with are ActiveX controls. If you use them in a multihreaded application,
you need to call CoInitialize(NULL) in any thread where you wish to use ActiveX or any other COM components. From the MSDN Library definition for CoInitialize(LPVOID pvReserved //Reserved; must be NULL);:

"Initializes the COM library on the current apartment and identifies the concurrency model as single-thread apartment (STA). Applications must initialize the COM library before they can call COM library functions other than CoGetMalloc and memory allocation functions."

Also, if you used AppWizard to generate your application and did not enable ActiveX control support, you will have to add this support manually using AfxEnableControlContainer().



Do the following in InitInstance of your DLL


CoInitialize(NULL);

AfxEnableControlContainer();


In ExitInstance, you must do a CoUninitialize() if the above call to CoInitialize() returns S_OK



All that said, please reference:

http://digital.ni.com/public.nsf/3efedde4322fef19862567740067f3cc/9c8e7d6858f40c7186256b520081d0ed?OpenDocument

For examples reading thermocouples from 1102. The examples are in CVI, but the code is ANSI C and will work in C++. Using the DAQ function calls would be the preferable method since you are programming in VC++.

Hope this all helps.

Kevin R
Applications Engineer
National Instruments.
0 Kudos
Message 2 of 3
(2,743 Views)
Thanks for ur help, I have followed the example, but I get the following error:

Linking...
ThermocoupleMod.obj : error LNK2001: unresolved external symbol "int __cdecl Thermocouple_Buf_Convert(int,double,int,unsigned long,double * const,double * const)" (?Thermocouple_Buf_Convert@@YAHHNHKQAN0@Z)
Debug/RCT.exe : fatal error LNK1120: 1 unresolved externals
Error executing link.exe.

RCT.exe - 2 error(s), 0 warning(s)


Its the convert.h cannot be included into my program, I can't figure out the solution, I don't know wat lib to add too, thanks for helping again...
0 Kudos
Message 3 of 3
(2,743 Views)