File Exchange

image thumbnail

MATLAB Code Example- 24 bit Digital Output using NI USB-6501

Controlling Digital Output from MATLAB


Updated 01 Sep 2016

View License

MATLAB supports digital input/output devices with the Data Acquisition Toolbox.
This MATLAB code example shows you how to set the output voltages of a data acquisition device capable of digital output.
This example was tested on National Instruments™ USB-6255 device. The example also applies to NI USB-6501 and other devices. This example assumes that the vendor board driver (NI-DAQmx ) is installed.

For a complete list of supported boards:

Learn more about using the Data Acquistion Toolbox:

Cite As

MathWorks Data Acquisition Toolbox Team (2020). MATLAB Code Example- 24 bit Digital Output using NI USB-6501 (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (1)

aplha zeta

I Am Using NI-USB6501.

I am trying to get an output pulse of 100Hz and 5V form USB-6501.
The maximum I am getting is 10Hz.

I changed the output of a pin in a continuous for loop from 0 to 5v (without any delays) and the maximum freq I get is 10Hz.

I tried precise timming by using the timer function and I toggeled the output pin after every 0.001 sec and still the output was 10Hz. Even if I decrease the time period for the timer fcn still I dont get above 10.5Hz.

the code is:

dio=digitalio('nidaq', 'Dev1');
addline(dio, 0:23, 'out');

for i=0:500
putvalue(dio.Line(9:16), [1 1 1 1 1 1 1 0])
putvalue(dio.Line(9:16), [1 1 1 1 1 1 1 1])

and by using other method i.e timers

t = timer('TimerFcn',{@abctimer, dio}, 'Period', 0.001,'TasksToExecute', 500,'ExecutionMode', 'fixedRate');

and I toggle the pin in abctimer fcn.
its the same...doesn't go above 10Hz..
I tried both fixedrate and fixeddelay...but no change


Updated license

Updated description.

MATLAB Release Compatibility
Created with R2009b
Compatible with any release
Platform Compatibility
Windows macOS Linux