Change properties of more than one channel for a session-based DAQ object

1 Ansicht (letzte 30 Tage)
C R
C R am 25 Feb. 2014
Beantwortet: Shyam Sangaraju am 23 Jul. 2014
Concerning the session-based DAQ control:
s = daq.createSession('ni');
s.addAnalogInputChannel('cDAQ1Mod6',[0 1 2 3],'Thermocouple');
When there are multiple channels, how to I assign similar properties. For example:
s.Channels.Thermocoupletype = 'J';
This does not work when there is more than one channel assigned on the left hand side, and only one on the right (It seems there is no overloaded function to distribute the 'J' to all channels...).
Also, and I feel like the solution, shown with 3 channels:
s.Channels(1).Thermocoupletype = 'J';
s.Channels(2).Thermocoupletype = 'J';
s.Channels(3).Thermocoupletype = 'J';
Is poor at best, and very cumbersome - if you have 15 channels and 3 properties, that is 45 lines of code!!! For loops seem like a bad idea also, thou I am sure they work.
How can I change Channel properties for multiple channels at one time?
Many fine details for session-based DAQ work are difficult to find in the help documentation. Please guide me.
Thanks for any advice.

Antworten (1)

Shyam Sangaraju
Shyam Sangaraju am 23 Jul. 2014
“set” function can be used to assign similar properties to multiple channels. Following sample code demonstrates how to use “set” function:
>> s = daq.createSession('ni');
>> h = s.addAnalogInputChannel('Dev1',[0 1 2 3],'Voltage');
>> set(h,'Name','HWDigital');
Where ‘Name’ is PropertyName (in your case it could be ‘Thermocoupletype’).
HWDigitalis PropertyValue (in your case it could be ‘J’).
his vector of handles.
“set” function sets the named properties to the specified values on the object(s) identified by H. H can be a vector of handles, in which case set sets the properties' values for all the objects.

Kategorien

Mehr zu Simultaneous and Synchronized Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by