From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simultaneous Analog Input and Output using myDAQ

Hello All!

Question I hope some of you may help guide me in. I am fairly new to LabVIEW and currently working on a project. I am using an analog waveform as an input and outputting that same analog output to display on a controller. For learning and practical purposes, I wish to have the analog input and analog output pretty much on top of one another displayed on the oscilloscope. I have successfully displayed both input and output on the oscilloscope, but there is a significant delay between the two. Can anyone provide any guidelines as to how to fine tune my number of samples and sampling frequency to gain optimal results? Also, my output signal is flashing on and off, am I doing something wrong? I apologize for the newbie questions, new here. Besides the Nyquist theorem, is there any other guidelines that must be followed? I plan on enrolling in a DSP Course next semester to learn all these nifty tricks.

 

Thanks all!

vjfids.JPG

0 Kudos
Message 1 of 14
(7,437 Views)

Hi alexponce!

 

First tip i can give you is ditch the Express-VIs. Instead try to work with the basic DAQ-functions.

The delay between your Signals might result from the serial execution of your VI. You first read the signal, then process it and then write to your DAQ. You might want to look up the Producer-Consumer Architecture, which allows parralel execution of read/write operations. That might get rid of your delay.

On sampling rate and frequency: Those parameters depend heavily on the application. I believe the myDAQ can sample at a rate of 200kHz, which should be fine. As far as number of samples go, i'd say you will have to play around with that. Using a Producer-Consumer Design you might get away with less points because you can read more often.

Thats only my five cents on the topic, maybe someone else has another idea.

 

Sq

Message 2 of 14
(7,397 Views)

So you are reading data, analyzing them, filtering them, and then want to start generating at the same time as data have been read? 

You need to invent a time machine first...

Option 1: read 10 samples - that will be your minimum time delay you can achieve. Use point by point functions to analyze data (they will take into account old data, not only current chunk). This sounds more like a task for real-time/FPGA system.

Option 2: Generate original data on the second analog output channel. They will shift in time relative to original, but will be in sync with output

Message 3 of 14
(7,382 Views)

"I am using an analog waveform as an input and outputting that same analog output to display on a controller"

As far as i understood his problem, he wants to "throughput" a signal and simultaneously analyze it. No time machine needed for that. At 200kSa/s a modern computer won't break a sweat Smiley Wink

With regard to your answer i have some questions:

"Option 1: read 10 samples - that will be your minimum time delay you can achieve."

Is there any reason behind the 10 samples? If so, why will that be the minimum time delay?

 

"Option 2: Generate original data on the second analog output channel. They will shift in time relative to original, but will be in sync with output"

Generating, or rather RE-generatng, the original data will, as you pointed out, timeshift the signal, so how can it be in sync?

 

I think we need more detailed information about the problem to find a solution.

 

Sq

Message 4 of 14
(7,361 Views)

I will be performing the FFT of a periodic, but non-sinusoidal waveform. Within my program, I wish to output all but the fundamental frequency component (just harmonic content) because I will be using that analog output waveform to drive a controller I am designing. I understand that there will always exist that time delay between the input and output, but I wish to eliminate the delay as much as I possibly can. I've spend most of my time designing the controller that I did not put much thought in the actual data acquisition / signal processing

0 Kudos
Message 5 of 14
(7,359 Views)

On the LabVIEW side, one thing to help keep up the loop rate is get any element with a GUI outside of the processing loop. Each call to the GUI thread to read or update elements requires time to complete that must be done before or after the processing can happen. A produce consumer structure with an event structure to handle the user operations.

 

I use a similar set of analysis techniques for peristaltic pump pressure data. The initial loops had a couple of graphs and a number of indicators. Removing the graphs took the data from about 60% real-time, to 150% real-time when bench-marked with prerecorded data. 

Message 6 of 14
(7,341 Views)

PC does not allow to throughput a signal with simultaneous analyze - it is not analog filter. It aquires a batch of data, processes them, outputs result. In Windows I would not rely on acquisition-processing-generation loop more frequent than 1 kHz. This gives you at least 1 ms delay between original data and filtered output. 1 ms is good case, 10ms is more reliable, it is not real-time system

Yes, "10" samples was an arbitrary number, I do not know acquisition frequency, required window, etc. Something PC will be able to process in 1 ms.


"Option 2: Generate original data on the second analog output channel. They will shift in time relative to original, but will be in sync with output"

Generating, or rather RE-generatng, the original data will, as you pointed out, timeshift the signal, so how can it be in sync?


Filtered output and re-generated output will not have shift, but will both be shifted relative to original data by loop period.

 

 

Option 1 allows minimum time delay between original signal and output. But it requires point by point functions to process data and more work than a couple express VIs.

Option 2 will show no delay between filtered output and regenerated input, but if you a using original signal somewhere else, then delay will be larger = window for FFT filter.

To proceed to advise on program structure we need timing parameters of the system, daq board you are using and option you choose.

But in first case I would definitely not separate generation-acquisition into producer-consumer. Something like loop below can be producer for UI loop - consumer and controller. Data will be generated on next iteration in parallel with new acquisition via shift register - I believe, the fastest transfer. 

read-write.png

 

Message 7 of 14
(7,305 Views)

Nevermind, bad idea

Message 8 of 14
(7,295 Views)

Hello Alexander!

 

Currently have this setup and I am getting some errors. Not really sure on how to handle them. I am using a square wave as my test signal. I believe my main problem is setting the analog output. I am not sure if I am doing it correctly. Would you mind taking a look at it and letting me know if there any ways I can improve it? Any help is greatly appreciated.

0 Kudos
Message 9 of 14
(7,265 Views)

Hello Squidee!

 

I have come up with this block diagram and keep getting error 201435, saying no samples provided to DAQmx Write to initialize buffered generation. I assumed I did have data connected. I am unsure of what to do at this point. Any help would be greatly appreciated.

0 Kudos
Message 10 of 14
(7,241 Views)