Why is the session interface no longer recommended? I have code that uses it and works, but can be slow. Will changing to the Data Acquisition interface speed up my code?

2 views (last 30 days)
Here is the part of my code that can be really slow:
valve1 = addDigitalChannel(session,'Dev1','port0/line0','OutputOnly');
valve2 = addDigitalChannel(session,'Dev1','port0/line1','OutputOnly');
valve3 = addDigitalChannel(session,'Dev1','port0/line2','OutputOnly');
valve4 = addDigitalChannel(session,'Dev1','port0/line3','OutputOnly');
trig1 = addDigitalChannel(session,'Dev1','port0/line6','OutputOnly');
trgi2 = addDigitalChannel(session,'Dev1','port0/line9','OutputOnly');
trig3 = addDigitalChannel(session,'Dev1','port0/line8','OutputOnly');
valve5 = addDigitalChannel(session,'Dev1','port0/line5','OutputOnly');
valve6 = addDigitalChannel(session,'Dev1','port0/line4','OutputOnly');
trig4 = addDigitalChannel(session,'Dev1','port0/line7','OutputOnly');
trig5 = addDigitalChannel(session,'Dev1','port0/line11','OutputOnly');
trig6 = addDigitalChannel(session,'Dev1','port0/line10','OutputOnly');
queueOutputData(session,actuators);
Everything works fine and is triggered on time, but it can be annoying to wait 30 seconds to initialize everything. Will swtiching over to the data acquisition interface be faster?

Answers (1)

Vidip
Vidip on 28 Mar 2024 at 4:46
Your current code using the session interface might work, it's generally recommended to migrate to the Data Acquisition Toolbox for several reasons. The toolbox offers better performance, more features, and future-proofs your code against potential compatibility issues in future MATLAB releases.
To get more information regarding advantages and capabilities of the new interface, you can refer to the below release note link:

Community Treasure Hunt

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

Start Hunting!