06-25-2020 03:08 PM
Hi Folks!
I was wondering of anyone could help me with my issue (i hope matlab related questions are allowed).
I am running a code with the intent on testing all of the channels of each card on my pxi chassis (4464, and 2 4461's) and to do this, I am generating a general sine wave in MATLAB and outputting it through one of the 4461's into the 4464. One problem I ran into was that the recording started about 0.1 seconds after the transmission, resulting on the captured data to be 0.1 seconds out of phase (late) of the outputted data.
Below is the code I am using: Notice how the foreground start is right after the data queue? Is this problem caused by that data queue command taking up 0.1 seconds, delaying the recording while the output runs? And should I look into using startBackground instead of startForeground?
Any advice or information is much appreciated! Thanks
v = daq.getVendors()
d = daq.getDevices()
deviceInfo = d(1)
get(deviceInfo)
get(deviceInfo.Subsystems(1))
%record + plot
s = daq.createSession('ni')
addAnalogInputChannel(s,'PXI1Slot2','ai3','Voltage');
addAnalogOutputChannel(s,'PXI1Slot5','ao0','Voltage')
%create sine wave output
output_data = sin(linspace(0,2*pi,1000)');
queueOutputData(s,output_data);
[input_data,time] = s.startForeground(); %try starting background before queing data
%
%plot output data
figure();
plot(time,output_data);
ylabel('Voltage');
xlabel('Time');
title('Output Data Queued')
%plot capture
figure();
plot(time,input_data);
ylabel('Voltage');
xlabel('Time');
title('Acquired Signal');
%set variable names:
dev1_chan3_capture = input_data;
dev2_chan0_output = output_data;
06-28-2020 03:31 PM
The delay you would observe may be due to Filter delay on the instruments (due to the delta-sigma architecture of both DAC and ADC, filtering is required)
Based on the sampling rate, you can calculate the sample delay expected. Below snippet is for 4461 AO.
Example calculation, Sample rate = 51.2 kS/s, Filter delay = 43.2 samples ~ 843.75us
06-29-2020 09:04 AM
That is very helpful! Thank you!
I was wondering if you could send me a link to where you found that table (is it in the manual for the 4461?), and also is there some kind of equation I can use to calculate the delay?
These tests I am running are sampled at 1KS/s, however, the device I am using has a sampling rate of 204.8KS/s
Thanks again!
-Alex
06-29-2020 03:46 PM
These filter delays are specified in the datasheet/specification sheet for each DSA instrument (both AI and AO).
sampling rate = samples / time
rearranging them (time here can be considered as the delay time)
delay time = samples / sampling rate.
Please note that this delay is applicable to both AO and AI.
Total delay = AO delay + AI delay (assuming there is no delay in the loopback)