How can I read data in backgorung from my NI hardware?
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I would like to run "read" function once in background to collect data in one-second intervals, and foreground to collect data in 0.03 s intervals simultaneously. Unfortunately I can't do it. Matlab return message "Use of function cd is not supported on a thread-based worker." Can you plaese advise me some solution for my problem?
d = daqlist;
d(1, :)
d{1, "DeviceInfo"}
dq = daq("ni")
dq.Rate = 51200;
ch1 = addinput(dq,"Dev1", "ai0","Voltage");
ch2 = addinput(dq,"Dev1", "ai1","Voltage");
F = parfeval(backgroundPool,@background_FFT,2,t_fft);
%%first data acquisition for 0.03 seconds
for i=1:inf
data = read(dq, seconds(0.03));
end
function [FFT,fr]=background_FFT(t_fft)
dq = daq("ni")
dq.Rate = 51200;
ch3 = addinput(dq,"Dev1", "ai3","IEPE");
%second data acquisition for 1 second
for i=1:100000
data = read(dq, seconds(t_fft));
ch3=data.Dev1_ai3;
[FFT,fr]=widmofft(ch3,dq.Rate,t_fft,1);
plot(fr,FFT)
end
Thank you.
0 comentarios
Respuestas (1)
Jeffrey Clark
el 15 de Sept. de 2022
@Jan Tomaszewski, try moving the device setup into your main program and pass that dq (and maybe ch3) as a parameters to the worker to use. Others have seen this issue with using files (opening) in workers and it seems likely that external devices could fall into that category see. But after the connection is made perhaps it would work. See:
0 comentarios
Ver también
Categorías
Más información sobre Analog Devices ADALM1000 Support from Data Acquisition Toolbox en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!