Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

Use DAQmxCreateAOVoltageChan() to create multiple output channels in VS2017

Hi, all:

I want to use c++ to control NI-USB-9263. 

First, when I create a single output channel as: 

DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"cDAQ1Mod1/ao0","",0.0000,5.0000,DAQmx_Val_Volts,NULL));

There is no problem.

But when I want to create two output channels as:

for(;i<4000;i++)
data[i] = 5.0*(double)i/4000.0;
DAQmxErrChk (DAQmxCreateTask("",&taskHandle));
DAQmxErrChk (DAQmxCreateAOVoltageChan(taskHandle,"cDAQ1Mod1/ao0","",0.0000,5.0000,DAQmx_Val_Volts,NULL));
DAQmxErrChk(DAQmxCreateAOVoltageChan(taskHandle, "cDAQ1Mod1/ao1", "", 0.0000, 5.0000, DAQmx_Val_Volts, NULL));
DAQmxErrChk (DAQmxCfgSampClkTiming(taskHandle,"",4000.0,DAQmx_Val_Rising,DAQmx_Val_FiniteSamps,4000));
DAQmxErrChk (DAQmxWriteAnalogF64(taskHandle,4000,0,10.0,DAQmx_Val_GroupByChannel,data,&written,NULL));

......

an error occurs: attemped writing data that is too large or too small.

error code: -200561.

 

I am sure the voltage range is not beyond the limitation.

Could someone help to solve this question? Thank you so much.

 

Regards

Xiaoran

0 Kudos
Message 1 of 2
(2,548 Views)

Hi

 

This is Elmunzir from National Instruments Application Engineering.

 

Since the error says the data is too large or too small, I suggest looking at the values written to the USB-9263. If at any point the data is out of the

0 to 5V range you specified, the error appears and it means somewhere in the code the values are going out of range. Please let me know of the outcome.

 

Best Regards

Elmunzir Elnaiem

NI Applications Engineer
0 Kudos
Message 2 of 2
(2,522 Views)