Acquire Continuous and Background Data Using NI Devices

3 visualizaciones (últimos 30 días)
Vitali Walter
Vitali Walter el 13 de Ag. de 2017
Comentada: Shashank el 16 de Ag. de 2017
s = daq.createSession('ni');
addAnalogInputChannel(s,'myDAQ1', 0, 'Voltage'); %%OUT2, X-Achse
addAnalogInputChannel(s,'myDAQ1', 1, 'Voltage'); %%OUT1, Y-Achse
s.Rate = 100000
s.DurationInSeconds = 0.001
while 1
[data, time] = s.startForeground;
plot(data(:,1)-2.5,data(:,2)-2.5,'*')
axis([-2.5 2.5 -2.5 2.5])
end
Hello. I´m working on a project with an melexis hallsensorjoistick and an NI myDAQ device. I wants to a quire the valtage and give it back as a dot on a white screen. The code which you see above worked out. But I´ve tryed it befor with Continuous and Background Data and it didnt worked out. I wrote also a code to get data of the 2 outputs with continuous and Background Data, but can´t figure it out how to combine them.
clear all
close all
clc
s = daq.createSession('ni');
addAnalogInputChannel(s,'myDAQ1', 0, 'Voltage');
addAnalogInputChannel(s,'myDAQ1', 1, 'Voltage');
s.Rate = 10000;
s.IsContinuous = true;
lh = addlistener(s,'DataAvailable', @(src,event) plot(event.TimeStamps, event.Data));
s.startBackground();
[data, time] = startForeground(s);
plot(data(:,1)-2.5,data(:,2)-2.5,'*')
axis([-2.5 2.5 -2.5 2.5])
My goal is now to create an GUI with only 2 buttons, start and stop. If I try to combine the codes in one script, I get error messeges like "Error using qwert (line 19) This command can not be used while the Session is running." How can I make this working? Thx
  1 comentario
Shashank
Shashank el 16 de Ag. de 2017
Please post your combined script and the line 19 specifically where it throws this error

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by