LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Reconfiguring DAQ VI to support multiple real-time updating analog output channels

In order to generate multiple analog waveforms through an NI-9263, I am using this VI to produce waveforms that can be edited at runtime. However, the waveforms take ~30 seconds to update regardless of the buffer size, frequency of signals, or the number of channels in use. I have found a new VI which allows me to instantaneously update my waveform output, but it only does this on one channel of my DAQ. Is there a way to modify the new VI such that I can output multiple channels of analog waveforms while keeping the ability to update these waveforms in real-time?

0 Kudos
Message 1 of 16
(3,530 Views)

Hi Zach_Phys_Research,

 

In response to your immediate question, you can modifiy the new VI to output to multiple channels; I've included an example of doing so below.

 

Modified Code.PNG

 

1) Initialize an array corresponding to the number of channels desired to output, with an waveform constant as the element.

2) Replace the elements of the array with the generated waveform. We optimize memory by pre-allocating the array and replacing the elements, rather than creating an array each time.

3) Change the DAQmx write task to multiple channels

 

 

Now, I want to step back to discuss your question in general about updating multiple channels in real time. Even modifying the new VI with the edits above, as you add more channels to the task, the update time is going to increase.


The reason is that when you call the write VI, the waveform data is copied to a temporary memory location, called a buffer, before being transferred to the device. The more channels that you are attempting to write to, the more data that is stored in the buffer that will need to be transferred to the device. How fast or slow that will happen is dependent upon your device's specifications. Here's a few resources providing some further information about buffers:

 

If it is critcal to have interactive control of a waveform output to multiple channels for your application, I would suggest looking at using a function generator instead.


Regards,

Regards,

Michael Whitten
Senior RF Applications Engineer
Message 2 of 16
(3,470 Views)

Also, just as another note, I just realized that this was posted in the LabVIEW forums; in order to receive more views and responses, I'd suggest you post issues of this nature in the MultifunctionDAQ forum in the future.

 

Happy Friday!

Regards,

Michael Whitten
Senior RF Applications Engineer
Message 3 of 16
(3,453 Views)

Thank you for your suggestion, would you be able to post the VI you modified in a response? I'm trying to modify my VI in the way you suggested, but I keep getting errors.

0 Kudos
Message 4 of 16
(3,408 Views)

Hi Zach,

 

What errors are you seeing? Did you make sure to connect the output of the array to the other shift register?

Regards,

Michael Whitten
Senior RF Applications Engineer
Message 5 of 16
(3,386 Views)

I tried to create the waveform constant in such a way that it would reference the waveform characteristics described within the while loop but was unable to. I also tried connecting the output of the array to the shift register, but it kept deleting the block structure inside of the while loop. Also, I could only enter information for the first waveform, even after I had gotten the block structure inside the loop to stop disappearing. Is there any way you could walk me through this, if you cannot post the file?

Thanks,

Zach

0 Kudos
Message 6 of 16
(3,344 Views)

Hi Zach,

 

I don't really understand what you mean. You don't need to reference the waveform characteristics in the while loop. Your waveform constant doesn't need to be anything other than a default waveform constant.

 

I also don't really understand what you mean about the block structure disappearing. I’ll just describe the steps I performed in further detail below to see if this helps:

 

  1. Use the “Initialize Array” VI to create the initial waveform array. The size is set to two, or however many channels you want to output. Use a default waveform constant as the value.
  2. Connect the output “Initialize Array” to the edge of the while loop. Right-click on the newly created terminal and select “Replace with Shift Register”
  3. Inside of the case structure inside of the while loop, add the “Replace Array Subset” VI. Drag the bottom of the VI down to add inputs to match the number of channels you are trying to output.
  4. Connect the array shift register created in step 2 to the “n-dimension array” input of the “Replace Array Subset” VI.
  5. Connect the output of the generated waveform to each of the “new element/subarray” inputs; no need to wire the index terminal.
  6. Change the DAQmx Write task to Analog 1D Waveform, Multiple Samples, Multiple Channels
  7. Connect the output of the “Replace Array Subset” VI to the input of the “DAQmx Write” VI
  8. Connect the output of the “Replace Array Subset” VI to the shift register on the right edge of the while loop, which was created in Step 2

Let me know if that clarified the steps. See the picture in my earlier post as a reference. Have a good one!

 

Regards,

Regards,

Michael Whitten
Senior RF Applications Engineer
Message 7 of 16
(3,321 Views)

Thank you so much for your detailed help! I followed your instructions, and was able to successfully run my VI. However, I still can only change the waveform characteristics of one waveform (there are no toggles on the front panel to change the signal properties of the 2nd waveform, as far as I can tell). Is there a way for me to add a waveform property array that allows me to change characteristics of waveforms, going from channel 0->n?Front Panel Screenshot 1.png

 

Front Panel Screenshot 2.png

I have attached screenshots of what I have so far, and please let me know if you think I'm making an obvious mistake somewhere.

Thanks again for your instructions,

Zach

0 Kudos
Message 8 of 16
(3,268 Views)

Zach,

     Please do not attach "screen shots" of pieces of (or entire) Block Diagrams.  They are hard to see, impossible to edit, and impossible to test unless we do the laborious work of trying to duplicate your code, warts and all.  Instead, attach your VI, or, even better, if you are using LabVIEW Project to encapsulate all your VIs and they are all in the same folder, compress the folder (right-click folder, choose Send To and use Compress from the drop-down), and attach the resulting .ZIP file.  It's a single file, has all the TypeDefs and sub-VIs we might need, and, if necessary, we can actually try to run your code.

 

Bob Schor

Message 9 of 16
(3,257 Views)

Hi Bob,

Thanks for letting me know about attaching screenshots. During some testing of the VI I attached in my previous response, I found that an error consistently appeared when I tried to test my VI with my physical mDAQ. Error Screenshot.pngThis error only appears when I test the physical DAQ unit that my lab owns, but when I test a simulated DAQ created in NI MAX (which is the same NI9181 unit), I get no error. Do you have any idea why this error might be occuring, and if so, do you have any ideas about how to fix it? 

 

Thanks,

Zach

0 Kudos
Message 10 of 16
(3,224 Views)