Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NI USB6212 sample rate issue

Hi!

We have a problem once we use different sample rates for input and output with an NI DAQ. The NI USB 6212 supports an analog output sample rate up to 250kS/s and input sample rate up to 400kS/s. In our application in Matlab with 1 DAQ, we want to use a different sample rate for input and output (twice the rate). To accomplish this, we initiated 2 sessions and assigned the sample rates: 

 

Fsample = 2^17;

mydaq_in = daq.createSession('ni');

mydaq_in.Rate = 2*Fsample;

mydaq_out = daq.createSession('ni');

mydaq_out.Rate = Fsample;

 

and synchronized the two sessions via triggers: 
mydaq_in.addTriggerConnection('Dev5/PFI1','External','StartTrigger'); %Dev 5 is our DAQ
mydaq_out.addTriggerConnection('External','Dev5/PFI2','StartTrigger');

 

and start the measurement:
mydaq_out.queueOutputData(tx'); % tx is random data we send
mydaq_out.startBackground; % Start the session that receives start trigger first
[data,timeStamps,~] = mydaq_in.startForeground;

 

However, we get a syncrhonization error between analog output and input over an ideal channel, which we don't have if we take the same sample rate for input and output. Should we also syncrhonize the clock? But I would expect that the same clock would be used for input and output? 

 

Regards,
Jona

0 Kudos
Message 1 of 4
(3,512 Views)

Hello Jona,

 

What is the specific error or message that you are seeing?

I'm assuming you are using the NI-DAQmx Support from Data Acquisition Toolbox?

 

You will need to set the same clock source for both the analog input and analog output tasks. You can set the clock source for the analog input task to use the same clock as the default clock for the analog output task. 

 

While I don't have an example using the Mathworks Data Acquisition Toolbox API, there is a document below that gives an example of Analog Input and Output using the LabVIEW API and I verified that it works with the USB-6212.

 

Timing and Synchronization Features of NI-DAQmx

 

Matt G.
Product Manager
National Instruments
0 Kudos
Message 2 of 4
(3,451 Views)

Hi Matt G., 

Thank you for your reply and excuse me for my late reply! We don't get a real error message. We just see that the time difference between the sent symbols and received symbols diverges as the time index increases. This is not the case if we use 1 session with analog input and analog output at the same sample rate. 

 

Setting the same clock source does not work. Is it maybe because only a discrete sample frequencies are allowed? Although I could not find this in the data sheets... 

 

Best,
Jona

0 Kudos
Message 3 of 4
(3,409 Views)

I attached code that I think does want you want in LabVIEW 2016. For third party tool-kits you may want to contact them about specific implementation in their API.

 

Notice that for both tasks the sample clock is pointing to the Dev1 AO Sample Clock.

Matt G.
Product Manager
National Instruments
0 Kudos
Message 4 of 4
(3,392 Views)