Use addoutput
to add a channel that generates pulses on a counter/timer subsystem. You can
generate on one channel or on multiple channels on the same device.
This example shows how to generate pulse data on an NI 9402
with device ID cDAQ1Mod5
.
Step 1. Create a DataAcquisition object assigned to the variable
d
:
d = daq("ni");
Step 2. Add a counter output channel for pulse generation:
ch = addoutput(d,"cDAQ1Mod5",0,"PulseGeneration")
Index Type Device Channel Measurement Type Range Name _____ ____ ___________ _______ _________________ _____ ________________ 1 "co" "cDAQ1Mod5" "ctr0" "PulseGeneration" "n/a" "cDAQ1Mod5_ctr0"
Step 3. Configure the output counter channel properties for signal frequency and duty cycle.
ch.Frequency = 50000; ch.DutyCycle = 0.25;
Step 4. Generate pulses in the background while MATLAB® continues:
start(d,"Continuous")
Step 5. When finished, stop the DataAcquisition output.
stop(d)