06-11-2010 05:36 AM
Hi,
I'm new on
Measurement Studio for VC + + and I need your help.
I have a PCI-6703
with a box-CBS 68.
I installed the drivers necessary for NI-DAQmx
Measurement & Automotive with the Explorer.
I installed the
software Measurement Studio 2009 (trial version pending the validation that my
project manager buys the full version).
I work under
Visual Studio 2008 and in VC++ (I can not use LabView (if not it was
easier) to synchronize the codes for the whole project).
I want to
generate analog voltages (10V) to the output of the PCI-6703 for CBS-68
box. This
will send signals to an electronic card to turn on/off the LEDs.
I
tried these lines of code but it does not work (I'm inspired by the
codes I found on the forum) :
#include <cvirte.h>
#include "windows.h"
#include <NIDAQmx.h>
int main (int argc, char *argv[])
{
TaskHandle daqmxhandle;
if (InitCVIRTE (0, argv, 0) == 0)
return -1; /* out of memory */
DAQmxCreateTask ("", &daqmxhandle);
DAQmxCreateAOVoltageChan (daqmxhandle, "Dev1/ao0", "", -10.0, 10.0,
DAQmx_Val_Volts, "");
for(int i=0; i<10;i++)
{
DAQmxWriteAnalogScalarF64 (daqmxhandle, 1, 10.0, 10, 0);
Sleep(3000);
DAQmxWriteAnalogScalarF64 (daqmxhandle, 1, 10.0, 0, 0);
Sleep(3000);
}
DAQmxClearTask (daqmxhandle);
return 0;
}
-----------------------------------------------Error----------------------------------------------------------
1>------ Rebuild All started: Project: test1, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'test1', configuration 'Debug|Win32'
1>Compiling...
1>test1.cpp
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7256) : warning C4005: 'THREAD_BASE_PRIORITY_MIN' : macro redefinition
1> c:\program files\national instruments\measurementstudiovs2008\vcnet\include\cvidef.h(140) : see previous definition of 'THREAD_BASE_PRIORITY_MIN'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7257) : warning C4005: 'THREAD_BASE_PRIORITY_IDLE' : macro redefinition
1> c:\program files\national instruments\measurementstudiovs2008\vcnet\include\cvidef.h(143) : see previous definition of 'THREAD_BASE_PRIORITY_IDLE'
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Linking...
1>test1.obj : error LNK2019: unresolved external symbol _DAQmxClearTask@4 referenced in function _main
1>test1.obj : error LNK2019: unresolved external symbol _DAQmxWriteAnalogScalarF64@28 referenced in function _main
1>test1.obj : error LNK2019: unresolved external symbol _DAQmxCreateAOVoltageChan@36 referenced in function _main
1>test1.obj : error LNK2019: unresolved external symbol _DAQmxCreateTask@8 referenced in function _main
1>test1.obj : error LNK2019: unresolved external symbol _InitCVIRTEEx@12 referenced in function _main
1>C:\Documents and Settings\Default\Mes documents\Visual Studio 2008\Projects\test1\Debug\test1.exe : fatal error LNK1120: 5 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Default\Mes documents\Visual Studio 2008\Projects\test1\test1\Debug\BuildLog.htm"
1>test1 - 6 error(s), 2 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Solved! Go to Solution.
06-14-2010 02:14 AM
Hi AndriRavo,
Did you add DAQmx.lib file to your project ?
Thanks for posting on National Instruments forums.
Regards,
06-14-2010 04:05 AM
Hi Maxime MULLER,
Thank you for your reply. I have added
the file "NIDAQmx.lib" in my project.
I still
get error messages. I searched on internet forums
and I see that I miss CVI libraries. I looked on
my computer files as "cvirt.lib cvisupp.lib cviwmain.lib" but I have not
found. I believe we must also install LabWindows /
CVI (?).
Does he have other ways to
program it without going through these libraries CVI? Using only Measurement Studio.
------------------------------ Error ----------------------------------
1>------ Rebuild All started: Project: test1, Configuration: Debug Win32 ------
1>Deleting intermediate and output files for project 'test1', configuration 'Debug|Win32'
1>Compiling...
1>test1.cpp
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7256) : warning C4005: 'THREAD_BASE_PRIORITY_MIN' : macro redefinition
1> c:\program files\national instruments\measurementstudiovs2008\vcnet\include\cvidef.h(140) : see previous definition of 'THREAD_BASE_PRIORITY_MIN'
1>c:\program files\microsoft sdks\windows\v6.0a\include\winnt.h(7257) : warning C4005: 'THREAD_BASE_PRIORITY_IDLE' : macro redefinition
1> c:\program files\national instruments\measurementstudiovs2008\vcnet\include\cvidef.h(143) : see previous definition of 'THREAD_BASE_PRIORITY_IDLE'
1>Compiling manifest to resources...
1>Microsoft (R) Windows (R) Resource Compiler Version 6.1.6723.1
1>Copyright (C) Microsoft Corporation. All rights reserved.
1>Linking...
1>test1.obj : error LNK2019: unresolved external symbol _InitCVIRTEEx@12 referenced in function _main
1>C:\Documents and Settings\Default\Mes documents\Visual Studio 2008\Projects\test1\Debug\test1.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\Default\Mes documents\Visual Studio 2008\Projects\test1\test1\Debug\BuildLog.htm"
1>test1 - 2 error(s), 2 warning(s)
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
06-14-2010 04:18 AM - edited 06-14-2010 04:19 AM
Hi AndriRavo,
I didn't see that you had the library cvirte.
You can't use it with Visual Studio ! This library and functions like InitCVIRTE are used when you are programming with CVI !
Just use the DAQmx functions but remove all the CVI functions from the example you have found.
#include "windows.h"
#include
<NIDAQmx.h>
int main (int argc, char *argv[])
{
TaskHandle daqmxhandle;
DAQmxCreateTask ("", &daqmxhandle);
DAQmxCreateAOVoltageChan
(daqmxhandle, "Dev1/ao0", "", -10.0, 10.0,
DAQmx_Val_Volts, "");
for(int i=0; i<10;i++)
{
DAQmxWriteAnalogScalarF64 (daqmxhandle, 1, 10.0, 10, 0);
Sleep(3000);
DAQmxWriteAnalogScalarF64
(daqmxhandle, 1, 10.0, 0, 0);
Sleep(3000);
}
DAQmxClearTask (daqmxhandle);
return 0;
}
Regards,