Multiple channel Data Acquistion - NI USB-6251 & BNC-2090
4 views (last 30 days)
Show older comments
Hello, I'm trying to write an m-file using only a couple of channels (triggering off 1 channel) on the NI hardware captioned above to collect voltage. However, after I add channels, specify which channel is the trigger and other parameters, run the program and get data, my plots only reflect data from the trigger channel. I've tried pulling only certain columns out to see the individual channels, but it didn't work. What am I doing wrong or not including in my script?
Also, any advice on the best way to trigger using this hardware configuration would be appreciated.
2 Comments
Answers (1)
Chirag Gupta
on 22 Aug 2011
Greg from your code, it seems that:
ai = analoginput ('nidaq','Dev1');
chan = addchannel (ai,0:1);
%Set DAQ Parameters (property values)
set(ai,'SampleRate', 500000); %Value in Hz
set(ai,'SamplesPerTrigger', 2.5e6); %No. of Samples
set(ai,'TriggerChannel',chan(1)); %Choose trigger channel
set(ai,'TriggerType','software'); %Choose trigger type
set(ai,'TriggerCondition','rising'); %Select how trigger initiates
set(ai,'TriggerConditionValue',0.01);%Choose voltage value for trigger to initiate
set(ai,'Timeout',5); %Time in sec for program to wait for trigger start
%Start Data Acq, plot, stop.
start (ai);
wait(ai,6)
[data,time] = getdata(ai);
trigger = data(:,2);
vout = data(:,1);
You have assigned ai channel 0 as the trigger channel. Even though the NI channels start from zero, MATLAB index is 1 based. So I think, the code should be:
set(ai,'TriggerChannel',chan(2)); % Corresponds to ai channel 1
0 Comments
See Also
Categories
Find more on Simultaneous and Synchronized Operations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!