From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Failing to make repeated trigger pulses using 1Channel NSamples

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.

Download All
0 Kudos
Message 1 of 3
(984 Views)

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.

0 Kudos
Message 2 of 3
(963 Views)

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

CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 3 of 3
(888 Views)