LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Handle Large Data Generation and DAQmx Analog Output

Solved!
Go to solution

Hi all,

 

I’m running into trouble with a LabVIEW project that involves handling a lot of data for analog output. I’d appreciate any advice on these two points:

 

1. **Generating Large Waveform Data:**  

   I need to create a long, complex waveform (for example, a sine sweep from 18 Hz to 30 kHz over 2 minutes). Because of the high sampling rate and long time, this results in a huge amount of data, and I’m running into memory issues when trying to generate the whole signal at once.

 

2. **Sending Data to DAQmx Analog Output:**  

   After generating the data, I need to send it out through DAQmx analog output. I’m not sure how to do this efficiently without running into memory problems, since sending all the data at once isn’t working.

 

Has anyone dealt with similar issues or found good strategies for generating and outputting large signals like this? Tips on chunking, streaming, or any other best practices would be really helpful!

 

Thanks in advance!

0 Kudos
Message 1 of 10
(236 Views)
  1. Generate and save the data to a file; save it in chunks so you don't run out of memory.
  2. Read the file in, once again, in chunks, for the DAQ output. I have done this in the past with large files that needed to be output.
0 Kudos
Message 2 of 10
(195 Views)

Thanks for the suggestion!

Could you share the best way to write data in chunks to DAQmx for analog output so that the output remains smooth and free of glitches when moving from one chunk to the next?

0 Kudos
Message 3 of 10
(179 Views)

Don't have LabVIEW available, so try to explain, ... Load about 10s of waveform, then in 8 or 9s, load the next 10s, etc. You can use a loop with a Wait or stall Data flow to accomplish this. 

0 Kudos
Message 4 of 10
(161 Views)

Try this Sound and Vibration Toolkit Example:
Audio Measurements\Discrete Swept-Sine Measurements (DAQmx).vi

dsbNI_0-1747545541305.png

dsbNI_1-1747545666713.png

 

The example computes and generates the output signal in chunks. At each discrete frequency, the example also processes the acquired input signals.

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 5 of 10
(137 Views)

Can anyone help me understand how to write a long waveform to a DAQmx analog output (AO) in chunks? I was able to do this, but I get glitches between chunks because there is a waiting time to write to the buffer+processing time. 

0 Kudos
Message 6 of 10
(71 Views)
Solution
Accepted by topic author luisdclopes2

Here is an example that writes (gap-free) to DAQmx AO in chunks:

DAQmx AO in Chunks.png

 

2020 version attached.

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
Message 7 of 10
(58 Views)

Fantastic. I see you use continuous samples, while I was using finite samples. The wait inside the while loop is really necessary?

0 Kudos
Message 8 of 10
(50 Views)

The Wait inside the while loop is only necessary on certain types of hardware (such as ethernet cDAQ) where the driver allows additional data to be written to the buffer faster than the hardware pulls from the buffer.

Doug
Enthusiast for LabVIEW, DAQmx, and Sound and Vibration
0 Kudos
Message 9 of 10
(41 Views)

@luisdclopes2 wrote:

Hi all,

 

I’m running into trouble with a LabVIEW project that involves handling a lot of data for analog output. I’d appreciate any advice on these two points:

 

1. **Generating Large Waveform Data:**  

   I need to create a long, complex waveform (for example, a sine sweep from 18 Hz to 30 kHz over 2 minutes). Because of the high sampling rate and long time, this results in a huge amount of data, and I’m running into memory issues when trying to generate the whole signal at once.

 

2. **Sending Data to DAQmx Analog Output:**  

   After generating the data, I need to send it out through DAQmx analog output. I’m not sure how to do this efficiently without running into memory problems, since sending all the data at once isn’t working.

 

Has anyone dealt with similar issues or found good strategies for generating and outputting large signals like this? Tips on chunking, streaming, or any other best practices would be really helpful!

 

Thanks in advance!


The following might be useful in case you want to output a frequency sweep and want to measure signals coming back from your setup / experiment through a single USB DAQmx-device:

 

Sample rates in the example given above are rather low (51200 samples / s).  If you need much higher sample rates for generating (outputing) and simultaneously reading signals you can also use several (shorter lasting) sweeps.  Depending on hardware***, each sweep can be done glitchles at several 100kHz sample rates through USB, simultaneously, on a single device.

 

[***we are using the USB-6351]

 

The secret is that you only do minimal uploading to generate your (Output) sweeps so your full focus can be on reading the various (Input) signals coming back from the DAQ-device.  This is assuming the signal to output has a fixed pattern, like a sine wave or similar.

 

Failing clear documentation by NI you might have discovered that uploading a fixed set of samples into the output-buffer of your DAQ only allows for rather crude frequency increments during a frequency sweep.  This is caused by NI using an internal clock as a base.  All your samples will be output with precise integer defined delays between each sample based on that clock.  There is no internal sine signal generator or any interpolation system to gradualy change the outputed frequency based on your fixed set of samples.  (At least none that I have discovered.)

 

By chosing some convenient sample sets for your sweeps (like a 500, 501, 504, and 496 sample representation of a single sine-wave) you can upload a set and than use those samples for a sweep.  Combining the results of all those sweeps could then give a reasonable set of measurements at various frequencies. (the specific case needed a sweep from around 750Hz to 1kHz)

 

The frequencies you can do with "fixed sample set" sweeps are based on the internal NI clock (in my case 100MHz) and using various integer "delays between samples".  You just continuously output the fixed samples and vary the "SampClk.Rate" when you want to change the frequency.  If you keep the changes to "SampClk.Rate" small the signal transition will be relatively smooth (without glitches).  By using less output-samples in your fixed sample sets the frequency steps per sweep become smaller.

 

To create such a solution yourself is a lot of work.  But with some care the USB-6351 can then flawlessly read several (in my case 3) inputs at 250kHz continuously, during a few dozen seconds.

0 Kudos
Message 10 of 10
(11 Views)