How do I write clocked digital data using the Data Acquisition Toolbox?
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 13 Mar 2025
Réponse apportée : MathWorks Support Team
le 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?
Réponse acceptée
MathWorks Support Team
le 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Analog Input and Output dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!