How do I write clocked digital data using the Data Acquisition Toolbox?
5 次查看(过去 30 天)
显示 更早的评论
MathWorks Support Team
2025-3-13
回答: MathWorks Support Team
2025-3-14
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?
采纳的回答
MathWorks Support Team
2025-3-14
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Analog Input and Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!