Real time plot for multiple channels qith National Instruments
1 view (last 30 days)
Show older comments
Hi, I apologize in advance for my bad english, hope you understand. I am currently attempting to acquire two signals from a NI USB6009 in order to plot both of them in real time, but I can't manage to plot the channel 'ai1', actually, it plots the same graphic of the 'ai0'. The code that I already have is this:
clc
clear all
s = daq.createSession('ni');
addAnalogInputChannel(s,'Dev1', 0:1, 'Voltage');
s.Rate = 1000;
tc1 = s.Channels(1);
set(tc1);
tc1.Range = [-5 5];
tc1.TerminalConfig = 'SingleEnded';
tc2 = s.Channels(2);
set(tc2);
tc2.Range = [-5 5];
tc2.TerminalConfig = 'SingleEnded';
s.DurationInSeconds = 3;
figure
subplot(2,1,1)
h1=animatedline;
ylim([0 6])
grid on
lh1 = addlistener(s,'DataAvailable', @(src,event) addpoints(h1,event.TimeStamps(1), event.Data(1)));
drawnow
s.NotifyWhenDataAvailableExceeds = 100;
s.startBackground();
hold on
subplot(2,1,2)
h2=animatedline;
xlim([0 30])
ylim([0 6])
lh2 = addlistener(s,'DataAvailable', @(src,event) addpoints(h2,event.TimeStamps(2), event.Data(2)));
drawnow
s.wait()
0 Comments
Answers (0)
See Also
Categories
Find more on Waveform Generation 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!