Digital I/O

cancel
Showing results for 
Search instead for 
Did you mean: 

Digital Output - Unwanted Reset on Lines

Solved!
Go to solution

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.

 

 

 

 

0 Kudos
Message 1 of 5
(2,927 Views)
Solution
Accepted by topic author Mattty

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?

Message 2 of 5
(2,874 Views)

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.

0 Kudos
Message 3 of 5
(2,854 Views)

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.

0 Kudos
Message 4 of 5
(2,830 Views)

No worries.  Your solution is sufficient.  Thanks.

0 Kudos
Message 5 of 5
(2,825 Views)