How do I write clocked digital data using the Data Acquisition Toolbox?

5 visualizaciones (últimos 30 días)
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?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 14 de Mzo. de 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);

Más respuestas (0)

Categorías

Más información sobre Analog Input and Output en Help Center y File Exchange.

Productos


Versión

R2023b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by