07-07-2021 05:50 PM
I want to trigger a camera with a 5 V pulse sent to analog output 0. The code I wrote should let me change the duration of the pulse and how frequently the pulses happen. I thought that the best way to do this would be to use 1Channel NSamples version of Write. I would write a 5, then write a 0, and the line would stay at 0 until the next time the loop happened.
In version 1, I tell the timing VI to do "Continuous samples." But when I look at the analog output with an oscilloscope I see that it's going 5,0,5,0,5,0,... forever, even before the next iteration of the while loop happens.
In version 2, I tell the timing VI to do "Finite samples", and to do 2 of them. But when I look at the oscilloscope I see that only one 5 V pulse happens. A second pulse doesn't happen on the next iteration of the loop.
What's the correct way to achieve what I'm trying to do? I tried putting the timing VI in the while loop and that didn't fix it.
07-07-2021 06:57 PM
By the way, I based my program on something I saw in the forums. TroyK posted code here. One way he made a pulse was with Write - 1Channel NSamples, just like I did, but with a digital output line rather than an analog, and with a waveform rather than an array of 1D Doubles.
07-11-2021 03:12 PM
1. A better way to do this would be with a counter output task. Pulse outputs are a core function of counters.
2. Meanwhile, one problem with your finite sampling AO approach is that your 2 samples only define 1 cycle of the pulse. You'd need 4 samples to define 2 cycles.
You should also make some other changes to do this via AO. Do the DAQmx Write before the loop. Then inside the loop, chain together a DAQmx Start, a DAQmx Wait Until Done, and a DAQmx Stop.
-Kevin P