Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How to output a voltage in an analog output channel by DAQmx C

The demo "Volt Update" in DAQmx is executed.  It is effective in the first time. The output voltage of ao channel coincides with the value I set. However, errors occurred since the second time, and the error is "LINK : fatal error LNK1104:cannot open file D:\... project.exe " unless restarting the computer. The program can be compiled successfully. How to solve this problem? 

 

 

 

The code is copied as follow:

#include <stdio.h>
#include "NIDAQmx.h"
#pragma comment(lib,"NIDAQmx.lib")
#define DAQmxErrChk(functionCall) if( DAQmxFailed(error=(functionCall)) ) goto Error; else

int main(void)
{
int error = 0;
TaskHandle taskHandle=0;
char errBuff[2048]={'\0'};
float64 data[1] = {1};

/*********************************************/
// DAQmx Configure Code
/*********************************************/
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"Dev5/ao0","",-10.0,10.0,DAQmx_Val_Volts,""));

/*********************************************/
// DAQmx Start Code
/*********************************************/
DAQmxErrChk (DAQmxStartTask(taskHandle));

/*********************************************/
// DAQmx Write Code
/*********************************************/
DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle,1,1,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL));
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);

Error:
if( DAQmxFailed(error) )
DAQmxGetExtendedErrorInfo(errBuff,2048);
if( taskHandle!=0 ) {
/*********************************************/
// DAQmx Stop Code
/*********************************************/
DAQmxStopTask(taskHandle);
DAQmxClearTask(taskHandle);
}
if( DAQmxFailed(error) )
printf("DAQmx Error: %s\n",errBuff);
printf("End of program, press Enter key to quit\n");
getchar();
return 0;
}

0 Kudos
Message 1 of 2
(676 Views)

Dear WYF0614,

 

Have you tried putting breakpoints in your code and seeing where exactly it goes wrong?

0 Kudos
Message 2 of 2
(528 Views)