How to detect and send digital I/O using matlab? (not simulink)
Show older comments
How to use matlab to detect and generate digital input output form a NiDAQ using matlab?
I do not want to use simulink. Is that even possible? I have a sensor and a LED light. When I put my figure near the sensor the LED turn on, when I let go the LED will go off. IS that even possible in Matlab? I believe matlab don't run things continuously.
e.g while (true) If detect digital signal iniput from port 0 line 0 (Sensor) pause(.1) send digital signal output to port 0 line 1 (LED) pause(.1) send the inverse siganl to port 0 line 1 (turn off LED) end
end
Answers (2)
Walter Roberson
on 5 Dec 2013
0 votes
You already asked that three times before. Search the documentation for DIO
16 Comments
Kelly
on 6 Dec 2013
Walter Roberson
on 6 Dec 2013
Once you have configured the object as sending digital I/O then you just use the regular commands to send data to the port; there is no specific "send digital I/O" command.
Kelly
on 8 Dec 2013
Walter Roberson
on 8 Dec 2013
Session based interface or Legacy interface?
Walter Roberson
on 9 Dec 2013
Edited: Walter Roberson
on 9 Dec 2013
That is legacy code you have there.
The DAQ6202-AQC appears to be an IC rather than a board. It is for NI's "M-Series" hardware. In order to determine whether you need session or legacy, I will need the board name including the interface (e.g., PCI, PCI-express, and so on.) Also, I will need to know which MATLAB version you are using.
Instead of setting the direction out using set(), you can create it as out in the first place, using
addline(dio,0:3,{'out', 'in', 'in', 'in');
Once you have that, you can send a value to the port using putvalue(). It took me a bit of reading to figure out to use putvalue() instead of putsample() or putdata(): putvalue() is for digital lines and the other two are analog.
putvalue(dio.Line(1), 1)
Walter Roberson
on 9 Dec 2013
PCI-6025 System Timing Controller?
PCI-1407 N114 ?
PCI-8212 GPIB N114 Ethernet ?
Kelly
on 10 Dec 2013
Walter Roberson
on 10 Dec 2013
Edited: Walter Roberson
on 10 Dec 2013
1417 ? I am not finding that one. I am finding IMAQ PCI-1407 which is a monochrome image acquisition board. It has three BNC connectors on it, one of which can be driven high/low or as a TTL level line.
Kelly
on 10 Dec 2013
Walter Roberson
on 10 Dec 2013
I am going to need to do more reading, and I do not know if I am going to be able to solve this. I will be out this evening.
Kelly
on 11 Dec 2013
Walter Roberson
on 11 Dec 2013
Legacy interface instead of Session-based interface should be fine. You will need at least R2011b for the session-based interface for that device, and I see noted some bugs for support of the device before R2011b (but I did not cross-check which interface that was for.)
Beyond that I will need to research more.
Kelly
on 12 Dec 2013
Kelly
on 6 Dec 2013
0 votes
Categories
Find more on Hardware Discovery and Setup in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!