LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxWriteAnalogF64() - array & number of samples

I plan to use DAQmxWriteAnalogF64() to output AO to my device.  This is part of the code that generate the AO:

 

    // DAQmx Configure Code
    DAQmxErrChk (DAQmxCreateTask            ("",&taskHandle)                                                    );
    DAQmxErrChk (DAQmxCreateAOVoltageChan   (taskHandle,"Dev1/ao0","",-10.0,10.0,DAQmx_Val_Volts,NULL)          );
    DAQmxErrChk (DAQmxCfgSampClkTiming      (taskHandle,"",1000.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,1000)    );
    DAQmxErrChk (DAQmxRegisterDoneEvent     (taskHandle,0,DoneCallback,NULL)                                    );

    // DAQmx Write Code
    DAQmxErrChk (DAQmxWriteAnalogF64        (taskHandle,1000,0,10.0,DAQmx_Val_GroupByChannel,data,NULL,NULL)    );

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

 

Questions:

1. DAQmxCfgSampClkTiming() specifies a number of 1000 samples with a rate of 1000 samples/second.  dataLayout is DAQmx_Val_ContSamps, which is generate samples until task is stopped.  Does this mean that the input array that I pass into DAQmxWriteAnalogF64() must have a size of 1000?  This is single channel.

 

2. Say if I use a total of 4 channels, each has 1000 samples, then my input array must have a size of 4000, while my sampling rate remains at 1000 samples/second, correct?

 

0 Kudos
Message 1 of 2
(5,856 Views)

Hello hn_sofec,

 

In regards to your doubt:

 

No,  the input array that you pass into DAQmxWriteAnalogF64() does not necesarily have to have the same value than the number of the sample rate. The number of samples is just the number of samples that compose the waveform that you want to generate. Then, the sample rate, will determine how fast will you transfer to the output buffer those samples. For example, for an array of 100 samples (lets say that those 100 samples represents a complete period of a sine wave), and configuring a sample rate of 1000 S/s, it would take 0.1 s to generate the first complete period of the sinewave (array of 100 samples). After1 second you would have generated 10 complete periods of the sinewave.

 

I suggest you to review more examples in order to understand better how the functions work. I share you one here:

 

"NI-DAQmx: Continuous Multi-Channel Analog Output Example in CVI"
http://www.ni.com/example/25867/en/

 

Hope this helps. Best regards!

 

Daniel C.

0 Kudos
Message 2 of 2
(5,782 Views)