can anyone help me with real time data plot using ni 9234

s = daq.createSession('ni');
s.addAnalogInputChannel('cDAQ2Mod1', 0, 'Voltage');
s.addAnalogInputChannel('cDAQ2Mod1', 1, 'Voltage');
s.Rate = 2000
s.DurationInSeconds = 20;
s
[data5,time] = s.startForeground;
plot(time,data5);
xlabel('Time (secs)');
ylabel('Voltage')

7 Comments

What difficulty are you observing?
i'm able to get data but i want real time plot can u help me with sample code??
Where is your callback for when data is ready?
function nidaq9234
global data
s = daq.createSession('ni');
s.addAnalogInputChannel('cDAQ2Mod1',0,'voltage')
s.addAnalogInputChannel('cDAQ2Mod1', 1, 'Voltage');
s.Rate = 2000
s.DurationInSeconds = 20
lh = s.addlistener('DataAvailable',@plotData);
s.startBackground();
% Do something
while(~s.IsDone)
end
close(gcf);
plot(data); % plot global data
function plotData(src,event)
persistent tempData;
global data
if(isempty(tempData))
tempData = [];
end
plot(event.TimeStamps, event.Data)
tempData = [tempData;event.Data];
data = tempData;
Is your plotData callback being called? If you put a disp() statement in it does the string get displayed ?

Answers (0)

This question is closed.

Tags

Asked:

on 2 Nov 2013

Closed:

on 11 Feb 2023

Community Treasure Hunt

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

Start Hunting!