Data Acquisition Toolbox read and write are not syncrhonized when "readwrite" command is used
Show older comments
Hello,
I am using Data Acquisition Toolbox with NI 6115 PCIe card on Matlab 2020a. I am trying to send and receive data using readwrite. However, sent and received signals have some phase shift. You can see this phase shift in the graph below. However, this does not happen if I use an external trigger to activate both read and write operations. Is this intentional? i.e. "readwrite" does not properly trigger read and write operations at the same time internally, read is triggered a bit late. Or is this a bug?

Code I use is as follows:
Fs = 2e6;
f_d = 12.1e3;
Fs = Fs-mod(Fs, f_d);
time = 1.33;
t = 0:1/Fs:time-1/Fs;
f = -Fs/2:1/time:Fs/2-1/time;
amp = 3;
sig = sin(2*pi*f_d*t).*tukeywin(Fs*time, 0.25)';
sig = sig./max(abs(sig));
sig = amp*sig;
sigL = length(sig);
divs = divisors(sigL);
divs = divs(divs > Fs/10);
d = daq('ni');
d.Rate = Fs;
LNAin = addinput(d, 'Dev1', 'ai0', 'Voltage'); % input channel 1
LNAout = addoutput(d, 'Dev1', 'ao0', 'Voltage'); % output channel 1 (signal output)
[data, timestamps, triggertime] = readwrite(d, sig', 'OutputFormat', 'Matrix');
1 Comment
gujax
on 17 Jun 2024
Yes I agree with Arsian. In fact the phase shift appears to change if I change the d.Rate.
Why inscan and outscan are asynchronous?
Answers (0)
Categories
Find more on Simultaneous and Synchronized Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!