How to adress channels independently in data acquisition toolbox session based interface
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hi,
I'm using data acquisition toolbox with the session based interface.
Is it possible, when using inpuntsinglescan and outputsinglescan, to adress lines independently? I'm scanning several sensors at the same time, and I want to perform a given action when a specific sensor displays a value independently of the other sensors values. When I use inputsinglescan I always get the values of all the channels I initialized, so for what I want to do I would have to define a if condition with the desired value in the channel i'm interested combined with all the other possibilities of values for the other channels.
Is there a better way to implement this?
Thank you in advance.
0 Kommentare
Akzeptierte Antwort
Wael Hemdan
am 26 Apr. 2013
Hi,
To access data on a per channel basis you need to index into the data array. For example, to look at the second channel's data you would do the following:
s = daq.createSession('ni')
s.addDigitalChannel('dev2', 'port0/line0:3', 'InputOnly')
s.addDigitalChannel('dev2', 'port0/line4:7', 'OutputOnly')
myOutputData = [0 0 0 0];
myInputData = s.inputSingleScan;
if myInputData(2) == 1
myOutputData = [1 1 1 1];
end
s.outputSingleScan(myOutputData);
Similarly, if you want to change only one output line based on the result from an input line, you can do the following:
if myInputData(1) == 1
myOutputData(3) = 0;
end
s.outputSingleScan(myOutputData)
- Wael Hemdan
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Data Acquisition Toolbox Supported Hardware finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!