How do I write clocked digital data using the Data Acquisition Toolbox?
2 views (last 30 days)
Show older comments
MathWorks Support Team
on 13 Mar 2025
Answered: MathWorks Support Team
on 14 Mar 2025
I am using an NI DAQ 9174. If I follow the instructions to generate pulse data on a counter channel for R2023b, I can send a PWN signal to the DAQ that oscillates between 'on' and 'off':
This signal oscillates as follows: 0101010101, and so on.
How do send square wave with different peaks (i.e., a digital signal), such as 000101001111, to my DAQ?
Accepted Answer
MathWorks Support Team
on 14 Mar 2025
You can do this using a digital channel and a clock. To create the digital channel, use the following code:
d = daq('ni');
d.addoutput(<DEVICE ID>, <CHANNEL ID>, "Digital");
d.Rate = // Desired data rate here.
Then, you need to add a clock, the specifics of which which will depend on your goal. The easiest way to accomplish this is to add any analog input/output, which will automatically assign a clock for you. Please know that if you manually assign a clock the clock frequency will need to match the above rate.
d.addinput(<DEVICE ID>, <CHANNEL ID>, "Voltage");
Lastly, 'preload' your desired data and start the DAQ:
preload(d,[0 0 0 1 0 1 0 0 1 1 1 1]');
start(d);
0 Comments
More Answers (0)
See Also
Categories
Find more on Analog Input and Output 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!