Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

how to set DAQMx multichannel sampling use Sample Clk function

      I am writing an application to output analog square waves using single DAQmx with multichannel. Attached is my simplified code. I create two channels and set the sampling parameters for the two channels to the same. In do-while loop, I use two square-wave generators to generate two different waveforms and write to two channels. The sampling information of the generators is kept same as DAQMx channels. However, when I ran the program, it always gave the error “Specified resource is reserved…”

The  problem seems at DAQMx Sampling clock function. If I remove them, the error was gone, but I asssume the sampling configurations between signal generator and DAQMx  will not be consistent.

If the application only has single output  channel, I can use DAQMx sampling clk function without problem. I wonder if anybody here give me the advice how to use DAQMx sampling clk function to set multichannles on the same card.

 

    Thanks

 

Guang

0 Kudos
Message 1 of 3
(3,935 Views)
You get the error 'Resource Reserved' because you cannot use the same resource for multiple tasks. For an analog out task, you can specify multiple channels. You have to use a single task because the analog output has a single convert clock. Select multiple channels with the DAQmx Physical Channel control. For a DAQmx Write, use N channel N samples. When outputing a waveform, it does not make any sense to use 1 sample mode.
0 Kudos
Message 2 of 3
(3,929 Views)

Hi wxc1204,

Dennis is correct. The error you are seeing is caused because you are trying to create two analog output tasks at the same time. Instead of having two separate tasks you can add both channels to one task. The Knowledge Base article Causes of NI-DAQmx Error 50103 "The Specified Resource is Reserved" explains what causes this error in more detail. I was able to find this article by searching the NI website for “specified resource is reserved”.

An easy way to select multiple channels when using a DAQmx Physical Channel control is to select the first channel you want to output on and then add a : and the second channel number. If you are trying to output on Dev1 channels 0 and 1 the text in the DAQmx Physical Channel control would look like this “Dev1/ao0:1”.  To output your waveforms combine them together using a Build Array block. This will combine them into a 1D waveform array. Then wire your waveform array to a DAQmx write set to multiple channels, multiple samples, and 1D waveform.

If you have any additional questions about DAQmx I would recommend taking a look at the Deveoloper Zone article Getting Started with NI-DAQmx

Regards,

Nathan

Nathan
NI Chief Hardware Engineer
0 Kudos
Message 3 of 3
(3,905 Views)