Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Express VI in a loop only functions on the first iteration

First, sorry if this has been answered.  I didn't see it when I searched the board.

I have a PCI-6259 DAQ board and I've boiled my problem down to the attached code.  The express VI just sends a TTL pulse on ctr0.  The while loop was automatically created after the express vi was made.  If I put that in another loop -- as shown -- the pulses go out fine on the first iteration of the for loop, but any subsequent times through the outer loop do nothing.  Using the highlight execution mode and such shows that the code is processing as it should, and no errors are raised, but no actual signal is sent out.  I've also tried putting the while loop into a sequence with a wait in a second frame in case that was problematic, but it still didn't work.  I also tried a 'reset device' block in the sequence too, resetting my dev1 (my daq board).

0 Kudos
Message 1 of 4
(2,932 Views)

Hi Ryan,

I couldn't really tell much from the picture that you posted. Are you just trying to output a single pulse or do you want to output a pulse train? I recommend taking a look at some of the example in the LabVIEW Example Finder. You can find these in Help >> Find Examples >> Hardware Input and Output >> DAQmx >> Generating Digital Pulses. Hope this helps.

Regards,
Hal L.

0 Kudos
Message 2 of 4
(2,914 Views)
I needed the weekend to look at this fresh:  I guess what the problem is all the "first call" nodes in the express vi.  It seems they're used so that the vi can be written to do a single pulse but when called in a loop it doesn't release the resources until the loop is done (the 'stop' boolean is read by the vi) allowing repeated calls without sucking up processing time re-initializing the configuration.  I believe it is the 'first call' bits that don't allow the express vi to be re-called as if new in a new loop (the outer for loop) as it would in other languages:

for{
    create_task()
    while(not done){
       generate_pulse()
    }
    if(task){
       clear_task()
    }
}

but the express vi, using 'first call' stuff is more like:

create_task()
for{
    while(not done){
       generate_pulse()
    }
    if(task){
       clear_task()
    }
}

None of the initialization code gets called, including creating the task, when using the first call stuff.

I've already written something using the daqmx task stuff that works to my liking, but ran into something that might be a bug.

When using the CO Pulse Time create channel vi and implicit timing, it would seem the task considers itself done (via daqmx wait until done vi) as soon as the high time is up, not after the whole high time + low time.  This causes anything wired after the wait until done to start as soon as the high part of the pulse is done.  Shouldn't it wait until the entire wave period is finished?  Wiring 2 into samples per channel on the timing node causes a full period, but shouldn't a 1 be a single full period?  I've been using equal high and low times.
0 Kudos
Message 3 of 4
(2,893 Views)

Hello Ryan,

What you are seeing is expected behavior. With a single pulse, only one counter is needed to generate the pulse so the second half (the low time) is not counted. With multiple pulses 2 counters are used, one to count and one to gate the counter so the wait until done must wait on both counters.

 

Hope this helps,

Andrew

0 Kudos
Message 4 of 4
(2,866 Views)