06-06-2012 07:45 PM
I need to generate an 8-bit word and a strobe pulse in Matlab through a usb-6009. How do I do that? Any help is appreciated!
Solved! Go to Solution.
06-07-2012 05:29 PM - edited 06-07-2012 05:31 PM
Roland,
Please make sure that you have the latest version of DAQmx installed.
DAQmx link
http://joule.ni.com/nidu/cds/view/p/id/2933/lang/en
Please test that the device functions properly using Measurement and Automation Explorer and the test panels.
The usb-6009 is supported in the Data Acquisition Toolbox.
It looks like they have quite a few demos available on their website to help with code development in MATLAB. There appears to be a few demos that involve signal generation.
http://www.mathworks.com/products/daq/demos.html
The MathWorks, Inc. MATLAB ® software
06-07-2012 08:22 PM - edited 06-07-2012 08:25 PM
To answer my own question:
Connect wires to digital pins p0.0-0.7 (each represents one bit) and an additional one to p1.0 (the strobe bit).
Matlab code:
dio = digitalio('nidaq', 'Dev1');
addline(dio, 0:7, 0, 'Out');%8 lines on port 0
addline(dio, 0, 1, 'Out');%strobe on port 1
sendthisvalue=23;
binvec = [dec2binvec(sendthisvalue,8), 0];%the 8bit word plus the strobe bit first set to 0
putvalue(dio,binvec);
binvec(9) = 1;%set strobe bit to 1
putvalue(dio,binvec);
Initially I used two separate 'putvalue' statements, one setting up the 8bit word and then another for the strobe bit, but the strobe was not received. What does seem to work is if I include both the 8bit word and the strobe bit value in each 'putvalue' statement, as in the code above.