LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Analog output to the DAQ that changes when controls on the front panel change

I'm using the PCI-6024E, and trying to output an analog waveform that can change when one of the two controls on the front panel change. It outputs fine setting it to continuous output and using a simple while loop around the "Is Task Done" VI, but if I put the "Write" VI in the while loop, it doesn't output steadily. I then tried to use an event structure, so that I'd only have to write every time something on the front panel changes, but for some reason it was writing finite samples, even though I set the Timing VI to continuous. I looked around the NI site, and found an article about this with an example. I tried to change it around to use my waveform, but whenever I run it, I get a memory underflow error. Has anyone needed to do this before? Thanks in advance.

-- Josh Matloff
0 Kudos
Message 1 of 5
(3,122 Views)
Whoops, I forgot to attach my code.
0 Kudos
Message 2 of 5
(3,118 Views)
Hi Josh-

It looks like you forgot to post the code still, but I'll take a stab at the problem anyway. It sounds like you're looking for a way to update a continuous waveform at runtime.

You will need to stop the task in order to replace the write buffer information, but this will only be a small gap in operation. I have attached a modified LabVIEW shipping example that shows how to use value change events for any of the pertinent waveform parameters to either programmatically stop the task, replace the buffer, set timing and restart or to just pass the task information straight through. This will lead to continuous operation with no breaks at the output.

Please let us know if this clears up your questions.

Thanks-
Tom W
National Instruments
0 Kudos
Message 3 of 5
(3,098 Views)
It's funny you bring this up, it's a problem I solved quite a while ago and then re-solved.

With an E-series board, I first configured the AO buffer outside of a while loop. Then, I placed my input parameters in a bundle in the while loop, and added a shift register in the while loop for the bundle. I compared the old values of the bundle with the current values (is the bundle coming out of the shift register equal to the one going in?), and if true, I just sent the task ID to an "AO Write" statement inside the while loop but outside of the for loop, and into a shift register in the while loop. If these were not equal, I wrote my signal to buffer via AO write and then used AO start (set to "continuous") to start the output. Again, the task ID went to the write statement. This changes wave parameters "on the fly" without gaps. I'll attach the code for this, and, if you remove the analog input stuff, it may have what you want.

Good luck,
Joe
0 Kudos
Message 4 of 5
(3,096 Views)
Hi Joe-

Your suggestion will also work- thanks for the tip.

One thing I would suggest though is that you look into event-driven programming. It removes the need to compare the values each time and actually leads to increased performance. You can see in the example that I posted that a "Value Change" event on any of the pertinent controls will execute a Stop-Write Buffer-Start sequence rather than a comparison on each loop iteration as in your example.

Regardless, as with any programming problem there are multiple solutions and yours is also quite useful.

Thanks again!
Tom W
National Instruments
0 Kudos
Message 5 of 5
(3,079 Views)