LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to configure a continuous pulse generation that doesn't end after the VI exits with DAQmx?

Hi,

I'm just learning the DAQmx and I have run into a problem.

With the legacy DAQ API I could configure a counter to create continuous pulses and
when I needed change the freq or duty cycle, I would just call the the configuration function
again. The pulses were generated even after I closed LV, so it was all in the hardware.

Now, with DAQmx api, it seems that this is not possible. I read a forum post saying that
LV will end the pulse generation after the VI exits. Is there a workaround for this?
I could ofcourse create a LV thread for this, but I liked the old one better
It was simpler and I didn't need to worry about threads so much.

All LV operations are going to be inside a DLL that is called from outside of LV, so I can't
use LV threads in a simple way, e.g. putting things inside a while loop. Just that you'll
know why I wan't to avoid using the threads.

Thanks.
0 Kudos
Message 1 of 5
(3,301 Views)

You could create a task in MAX, and run it directly from there instead of LV...

I am not sure if you can run a VI and have it continue after exiting LV, because LV cleans up and closes all open tasks when you exit...so running from MAX may be the only/best option, but maybe someone else has a different way of doing it.

________________________________________________________

Use the rating system, otherwise its useless; and please don't forget to tip your waiters!
using LV 2010 SP 1, Windows 7
________________________________________________________
0 Kudos
Message 2 of 5
(3,279 Views)
Thank you for your reply TWGomez.

I'll add some more information on what I'm trying to achieve.

I'm creating a DLL with LV that is called from VC++. In the DLL I wan't
to have a VI that sets a counter to pulse generation, and then the VI exits
and the program control goes back to VC++ code.

I don't think that I can run the task from MAX in this case. With the old API
this was possible directly, but with the new one, it seems that I need to
create a LV thread for this. Unless, someone knows a workaround for this.
0 Kudos
Message 3 of 5
(3,270 Views)
It is possible to achieve this behavior using the DAQmx API by using the DAQmx Create Task VI to explicitly create the task (rather than relying on DAQmx Create Channel to do it implicitly) and setting the AutoCleanup attribute to False.  This method prevents LabVIEW from automatically clearing the task when your VI (or the function you'll be exporting to your C .dll) finishes executing.  The disadvantage is that you might accidentally "leak" a task if you're not careful.  In order to stop the pulse generation on command, you can either reset the device or somehow store the task name you created and come back later to call DAQmx Stop and/or Clear Task.
 
Here's how you would start the generation:
 
 
 
...and how you could come back and stop it later, using the task name you created:
 
 
Hopefully this helps-


Message Edited by Tom W [DE] on 11-16-2007 07:54 AM
Tom W
National Instruments
Download All
Message 4 of 5
(3,262 Views)
Thanks Tom for the reply.

I didn't have much time to play around with the example, but it seems to be
what I'm looking. Now, it's time to leave the office, so I'll get back on this
next week if I have more questions.
0 Kudos
Message 5 of 5
(3,256 Views)