Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I pause and resume analog output using DAQmx?

Solved!
Go to solution

I'm using a DAQ device to output an analog waveform.  I'd like to simply pause the output of the waveform, and then resume where it left off.  I'm using LabVIEW 2011 and DAQmx.

 

I've seen the examples which use a digital or analog pause trigger, but I'd like to do the pausing in software only.  How can I do this?

 

-Joe

0 Kudos
Message 1 of 17
(8,126 Views)

Hi Joe!

 

Thanks for using the NI forums!

As you have already found, the most effective way to do this will be with a pause trigger in hardware.


Can I ask you what VIs you are using to generate the analog waveform? Also, are you wanting to pause the generation through a user control?

 

This is possible by generating the waveform and constantly putting the data in a Queue and then writing the data from the front of the Queue to the DAQ card. In this case, using a case structure to stop the DAQmx Write from happening will essentially be 'pausing' the generation. However, depending on how long this runs/how long you pause for, this may cause your PC memory to fill up quickly.

Peter E
Applications Engineer
National Instruments
0 Kudos
Message 2 of 17
(8,092 Views)

Thanks for the reply, Peter.

 

Yes, I'd like to pause the generation through a user control.  I've created a simplified VI that demonstrates what I'd like to do: The attached VI (also see the snippet below) plays a WAV file out an analog output.  I'd like to place some code in the FOR loop (see the comment) to pause the output (when the pause button is pressed) before the output is complete.

 

I understand your suggestion of constantly writing the data in chunks, but my application is already fairly complex, and I was hoping for a simpler way. 🙂

Software triggers are used elsewhere, is there a reason a software trigger is not available for the pause trigger?

 

-Joe

 

Pause analog output.png

0 Kudos
Message 3 of 17
(8,082 Views)
Solution
Accepted by topic author JoeDG

Hi Joe!

 

I spent some time thinking about this and I realized you can technically use a basic Analog Output task like you have written previously that is running continuously. However, the output samples generated are controlled by the pulses of the sample clock and we can manipulate that to fit our "pausing" needs.

 

To do this, we will need another counter task that generates a pulse train (See our shipping examples under Hardware Input and Output>>DAQmx>>Generating Digital Pulses>>Generate Dig Pulse Train-Continuous.vi) that will stop and start at the user's choosing. This can be in a separate VI altogether or controlled by software. We will use this as our output task's sample clock.

 

Then, on the AO task, wire a constant to the sample clock source and select "DevX/CtrXInternalOutput" based on the counter you have specified in the Counter task. You may need to right click the constant and select "I/O Name Filtering" and check the box that says "Include Advanced Terminals". See the attached image as a reference. That way, the AO task is constantly running, but it only actually outputs any data when the counter task running.

 

Pause DAQmx Output.png

 

Let me know if you have any questions!

 

Have a great day!

Peter E
Applications Engineer
National Instruments
Message 4 of 17
(8,062 Views)

Peter,

 

Great idea!  I didn't know you could do that with a counter.  I whipped up this VI that seems like it should do what you described, but when I run it, it only outputs data for a fraction of a second, and then the task stops.

 

In the VI I am setting up the two tasks, start them both (the output should start), and then when the pause button is pressed, I stop the counter task, and then when pause is pressed again, start up the task again.  In both tasks, I set the clock frequency to 44100, the sample rate of a WAV file.  Seems like it should work.  

 

In the interest of full disclosure, I am having similar issues with this output device not outputting all the samples of a waveform (see this thread) so maybe this VI works fine, and it's just a problem with my hardware.  But it would be great if you could confirm that this should/does work.

 

-Joe

Pause analog output - using counter.png

0 Kudos
Message 5 of 17
(8,059 Views)

Just an update:  I tried this on different hardware (a USB-6259) and got the same results.  So it doesn't look like the hardware issue I mentioned is the problem.  There still  must be an issue with the code I posted.  Any ideas?

 

-Joe

0 Kudos
Message 6 of 17
(8,053 Views)

Problem solved!  The output was stopping because I didn't wire the number of samples in the Timing VI (The default was 1000 samples, which was what was being output).  Attached is the working code.

 

Thanks a lot, Peter!

 

-Joe

 

Pause analog output - using counter.png

0 Kudos
Message 7 of 17
(8,050 Views)

Peter,

 

I have tried using this method you have posted with a digital output instead of an analog output, but I have not been having much luck. Is this something that would be possible with a digital output?

 

Thank you.

0 Kudos
Message 8 of 17
(7,904 Views)

Hello Katho,

 

What is the behavior you’re getting when doing this?

 

Best Regards,

0 Kudos
Message 9 of 17
(7,894 Views)

I am getting no output signal whatsoever. When I disconnect the digital line and replace it with an analog output, I can see the counter's signal, but that is the only instance where I am able to see any evidence of an output.

0 Kudos
Message 10 of 17
(7,888 Views)