02-07-2017 08:31 AM
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
02-08-2017
11:29 AM
- last edited on
11-27-2024
04:37 PM
by
Content Cleaner
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
02-23-2017 03:59 PM
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
02-24-2017 04:49 PM
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.