08-04-2017 09:14 AM
I am using MATLAB to change the values of my NIDAQ's digital outputs. The outputs are sent to the digital input of another device where they are recorded. Whenever the value of one of the output lines changes, the output lines defined in another fuction reset to 0.
I add 2 lines for a trigger using a function that contains the following code:
dio = digitalio('nidaq', 'Dev1');
trigger = addline(dio,13,0,'out'); % Port 0, Line 13
putvalue(trigger,0); % Reset trigger to start with
triggerAuto = addline(dio,4,0,'out'); % Port 0, Line 4
putvalue(triggerAuto,0); % Reset trigger to start with
Another function adds a line for an output that will send TTL pulses to a pump:
vr.dio = digitalio('nidaq','dev1');
vr.pump = addline(vr.dio,1,0,'out'); % port 0. line1
start(vr.dio);
putvalue(vr.pump,1); %
For example, if later the value of trigger is set to 1 ( putvalue(trigger,1); ) then the output signal of vr.pump will reset to zero. The MATLAB variable of vr.pump still shows "1" however my recording device shows that the output went down to zero.
Liekwise, if the value of vr.pump is changed using the putvalue function, then the output of trigger and triggerAuto will reset to zero (if they were not already at zero).
How can I change the value of one output line without resetting the output values of other output lines?
Thanks. Let me know if you want me to clarify anything further.
Solved! Go to Solution.
08-07-2017 09:16 AM
The command digitalio('nidaq', 'Dev1') creates a new digital I/O object. The documentation for this function says: "You can create multiple digital I/O objects that are associated with a single digital I/O subsystem. However, you can typically execute only one of them at a time." http://radio.feld.cvut.cz/matlab/toolbox/daq/digitalio.html
So I would expect that the problem is because you are trying to execute two of these objects at the same time. Is it possible to instead add the two lines to the same object?
08-07-2017 12:53 PM
Thanks for that info Hope!
These two functions are located in two different MATLAB files. One file contains a script that creates our experiment environment while the other MATLAB file is one specific test that takes place in that environment. Both files were created to send different sets of signals from different lines in our NiDAQ. It may be possible to add all the lines to the same object, however it may not be the most intuitive or efficient solution.
I will look into it.
08-08-2017 09:02 AM
Unfortunately I can't give you much more advice on the best/most efficient architecture for your third party code, since I'm not really an expert on that. But it seems like adding all lines to the same object is how you need to do it. Sorry I can't say how exactly you should do that.
08-08-2017 01:30 PM
No worries. Your solution is sufficient. Thanks.